| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2003-2007, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: bsettop_cipher.h $ |
|---|
| 11 | * $brcm_Revision: 2 $ |
|---|
| 12 | * $brcm_Date: 2/1/07 6:29p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: ioctl interface for driver |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /BSEAV/api/include/bsettop_cipher.h $ |
|---|
| 19 | * |
|---|
| 20 | * 2 2/1/07 6:29p vsilyaev |
|---|
| 21 | * PR 27399: Fixed typo and updated comments |
|---|
| 22 | * |
|---|
| 23 | * 1 2/7/05 7:04p dlwin |
|---|
| 24 | * Merge down for release 2005_REFSW_MERGETOMAIN: |
|---|
| 25 | * |
|---|
| 26 | * Irvine_BSEAVSW_Devel/8 6/23/04 3:21p erickson |
|---|
| 27 | * PR11135: fixed comment |
|---|
| 28 | * |
|---|
| 29 | * Irvine_BSEAVSW_Devel/7 11/18/03 1:54p erickson |
|---|
| 30 | * PR8356: got venom2 working and added scrambling_control support |
|---|
| 31 | * |
|---|
| 32 | * Irvine_BSEAVSW_Devel/6 11/7/03 4:28p erickson |
|---|
| 33 | * PR8583: removing, fixing or implementing TODO's |
|---|
| 34 | * |
|---|
| 35 | * Irvine_BSEAVSW_Devel/5 11/4/03 2:42p erickson |
|---|
| 36 | * documentation changes |
|---|
| 37 | * |
|---|
| 38 | * Irvine_BSEAVSW_Devel/4 10/31/03 11:58a erickson |
|---|
| 39 | * settop api changes after internal review |
|---|
| 40 | * |
|---|
| 41 | * Irvine_BSEAVSW_Devel/3 10/28/03 11:28a erickson |
|---|
| 42 | * settop api reworks after internal design view |
|---|
| 43 | * |
|---|
| 44 | * Irvine_BSEAVSW_Devel/2 9/30/03 12:19a erickson |
|---|
| 45 | * added standard header stuff like cplusplus |
|---|
| 46 | * |
|---|
| 47 | * Irvine_BSEAVSW_Devel/1 9/25/03 1:28p erickson |
|---|
| 48 | * added cpu-based encryption to settop api and util |
|---|
| 49 | * |
|---|
| 50 | *************************************************************************/ |
|---|
| 51 | #ifndef BSETTOP_CIPHER_H__ |
|---|
| 52 | #define BSETTOP_CIPHER_H__ |
|---|
| 53 | |
|---|
| 54 | #ifdef __cplusplus |
|---|
| 55 | extern "C" { |
|---|
| 56 | #endif |
|---|
| 57 | |
|---|
| 58 | /*=****************************** |
|---|
| 59 | The cipher module provides access to the PVR DES/3DES encryption |
|---|
| 60 | and decryption engine. You can decrypt or encrypt MPEG2 transport data |
|---|
| 61 | off-line, or you can also encrypt or decrypt any raw data for your own purposes. |
|---|
| 62 | |
|---|
| 63 | This is not the interface for controlling playback or record encryption or live conditional access. |
|---|
| 64 | PVR encryption is handled through the bstream_mpeg.encryption structure passed in to |
|---|
| 65 | bplayback_start. |
|---|
| 66 | |
|---|
| 67 | Live conditional access for Magnum platforms is supported via bstream_set_encryption. |
|---|
| 68 | Live conditional access for legacy platforms is not yet supported. |
|---|
| 69 | |
|---|
| 70 | The cipher module is not intended for use with Magnum platforms. General cryptographic functionality |
|---|
| 71 | for Magnum boards is provided via the bcrypto interface. |
|---|
| 72 | *********************************/ |
|---|
| 73 | |
|---|
| 74 | /* |
|---|
| 75 | Summary: |
|---|
| 76 | Handle for cipher engine. |
|---|
| 77 | */ |
|---|
| 78 | typedef struct bcipher *bcipher_t; |
|---|
| 79 | |
|---|
| 80 | /* |
|---|
| 81 | Summary: |
|---|
| 82 | Open a cipher handle. |
|---|
| 83 | */ |
|---|
| 84 | bcipher_t bcipher_open( |
|---|
| 85 | bobject_t id |
|---|
| 86 | ); |
|---|
| 87 | |
|---|
| 88 | /* |
|---|
| 89 | Summary: |
|---|
| 90 | Close a cipher handle. |
|---|
| 91 | */ |
|---|
| 92 | void bcipher_close(bcipher_t encrypt); |
|---|
| 93 | |
|---|
| 94 | /* |
|---|
| 95 | Summary: |
|---|
| 96 | Mode used when processing data. |
|---|
| 97 | Description: |
|---|
| 98 | 3DES is not symmetric, therefore you must chose encrypt or decrypt mode. |
|---|
| 99 | This doesn't matter for DES. |
|---|
| 100 | */ |
|---|
| 101 | typedef enum bcipher_mode { |
|---|
| 102 | bcipher_mode_encrypt, |
|---|
| 103 | bcipher_mode_decrypt |
|---|
| 104 | } bcipher_mode; |
|---|
| 105 | |
|---|
| 106 | /* |
|---|
| 107 | Summary: |
|---|
| 108 | Special data format (e.g. MPEG2 Transport) to be processed by the cipher engine. |
|---|
| 109 | */ |
|---|
| 110 | typedef enum bcipher_data_format { |
|---|
| 111 | bcipher_data_format_raw, /* Process all data */ |
|---|
| 112 | bcipher_data_format_ts /* Data will be processed in 188 byte packets, |
|---|
| 113 | skipping the transport headers and verifying the sync byte. */ |
|---|
| 114 | } bcipher_data_format; |
|---|
| 115 | |
|---|
| 116 | /* |
|---|
| 117 | Summary: |
|---|
| 118 | Settings structure passed into bcipher_convert_data to control |
|---|
| 119 | the type of encryption or decryption performed. |
|---|
| 120 | */ |
|---|
| 121 | typedef struct bcipher_settings { |
|---|
| 122 | bencryption_params encryption; /* Encryption type and key */ |
|---|
| 123 | bcipher_mode mode; |
|---|
| 124 | bcipher_data_format data_format; /* Special data format processing */ |
|---|
| 125 | bool scrambling_control; /* If true, then the cipher algorithm will set and |
|---|
| 126 | clear the MPEG2 transport scrambling control field. This is necessary |
|---|
| 127 | to support Broadcom trick modes with pvr encrypted streams. */ |
|---|
| 128 | } bcipher_settings; |
|---|
| 129 | |
|---|
| 130 | /* |
|---|
| 131 | Summary: |
|---|
| 132 | Required to initialize bcipher_settings. |
|---|
| 133 | */ |
|---|
| 134 | void bcipher_settings_init( |
|---|
| 135 | bcipher_settings *settings, /* [out] structure to be initialized */ |
|---|
| 136 | bcipher_t cipher /* Cipher handle if there are resource-specific defaults */ |
|---|
| 137 | ); |
|---|
| 138 | |
|---|
| 139 | /* |
|---|
| 140 | Summary: |
|---|
| 141 | Encrypt or decrypt a buffer of data using the PVR encryption block. |
|---|
| 142 | */ |
|---|
| 143 | bresult |
|---|
| 144 | bcipher_convert_data( |
|---|
| 145 | bcipher_t handle, /* handle returned by bcipher_open() */ |
|---|
| 146 | void *dest, /* [out,size_is(datalen)] data to be converted */ |
|---|
| 147 | const void *source, /* [size_is(datalen)] data to be converted */ |
|---|
| 148 | size_t datalen, /* length of data in bytes to be converted */ |
|---|
| 149 | const bcipher_settings *settings /* settings which control the type of encryption |
|---|
| 150 | or decryption. */ |
|---|
| 151 | ); |
|---|
| 152 | |
|---|
| 153 | #ifdef __cplusplus |
|---|
| 154 | } |
|---|
| 155 | #endif |
|---|
| 156 | |
|---|
| 157 | #endif /* BSETTOP_CIPHER_H__ */ |
|---|
| 158 | |
|---|