Wasabi ExpressPlay SDK for Embedded Systems  1.23.0
Ts2Crypto.h
Go to the documentation of this file.
1 /*****************************************************************
2 |
3 | MPEG2 Transport Stream - Crypto
4 |
5 | $Id: Ts2Crypto.h 296 2014-06-25 11:20:09Z jebaseelir $
6 | Original author: Julien Boeuf
7 |
8 | This software is provided to you pursuant to your agreement
9 | with Intertrust Technologies Corporation ("Intertrust").
10 | This software may be used only in accordance with the terms
11 | of the agreement.
12 |
13 | Copyright (c) 2010-2014 by Intertrust. All rights reserved.
14 |
15 ****************************************************************/
16 
17 #ifndef _TS2_CRYPTO_H_
18 #define _TS2_CRYPTO_H_
19 
20 /*----------------------------------------------------------------------
21 | includes
22 +---------------------------------------------------------------------*/
23 #include "Atomix.h"
24 
25 /*----------------------------------------------------------------------
26 | constants
27 +---------------------------------------------------------------------*/
28 #define TS2_AES_BLOCK_SIZE 16
29 #define TS2_AES_KEY_LENGTH 16
30 #define TS2_AES_CBC_IV_SIZE 16
31 #define TS2_SHA1_DIGEST_SIZE 20
32 #define TS2_SHA1_BLOCK_SIZE 64
33 
34 /*----------------------------------------------------------------------
35 | types
36 +---------------------------------------------------------------------*/
38 typedef struct TS2_Hmac TS2_Hmac;
39 typedef struct TS2_Digest TS2_Digest;
42 
43 typedef enum {
47 
48 typedef enum {
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
56 /*----------------------------------------------------------------------
57 | TS2_AesBlockCipher functions
58 +---------------------------------------------------------------------*/
59 ATX_Result TS2_AesBlockCipher_Create(const ATX_Byte* key,
60  TS2_BlockCipherDirection direction,
61  TS2_AesBlockCipher** cipher);
62 
64 
66  const ATX_Byte* input,
67  ATX_Byte* output);
68 
69 /*----------------------------------------------------------------------
70 | TS2_Digest functions
71 +---------------------------------------------------------------------*/
72 ATX_Result TS2_Digest_Create(TS2_DigestAlgorithm algorithm,
73  TS2_Digest** digest);
74 
75 ATX_Result TS2_Digest_Update(TS2_Digest* self,
76  const ATX_Byte* data,
77  ATX_Size data_size);
78 
79 ATX_Size TS2_Digest_GetDigestSize(const TS2_Digest* self);
80 
81 ATX_Size TS2_Digest_GetBlockSize(const TS2_Digest* self);
82 
83 ATX_Result TS2_Digest_Final(TS2_Digest* self,
84  ATX_Byte* digest);
85 
86 void TS2_Digest_Destroy(TS2_Digest* self);
87 
89 ATX_Result TS2_ComputeDigest(TS2_DigestAlgorithm algorithm,
90  const ATX_Byte* data,
91  ATX_Size data_size,
92  ATX_Byte* digest);
93 
94 /*----------------------------------------------------------------------
95 | TS2_Hmac functions
96 +---------------------------------------------------------------------*/
97 ATX_Result TS2_Hmac_Create(TS2_DigestAlgorithm algorithm,
98  const ATX_Byte* key,
99  ATX_Size key_size,
100  TS2_Hmac** hmac);
101 
102 ATX_Result TS2_Hmac_Update(TS2_Hmac* self,
103  const ATX_Byte* data,
104  ATX_Size data_size);
105 
106 ATX_Size TS2_Hmac_GetMacSize(TS2_Hmac* self);
107 
108 ATX_Result TS2_Hmac_Final(TS2_Hmac* self,
109  ATX_Byte* mac);
110 
111 void TS2_Hmac_Destroy(TS2_Hmac* self);
112 
128 ATX_Result TS2_ComputeHmac(TS2_DigestAlgorithm algorithm,
129  const ATX_Byte* key,
130  ATX_Size key_size,
131  const ATX_Byte* data,
132  ATX_Size data_size,
133  ATX_Byte* mac);
134 
135 /*----------------------------------------------------------------------
136 | Prng functions
137 +---------------------------------------------------------------------*/
138 ATX_Result TS2_GeneratePseudoRandom(ATX_Byte* buffer, ATX_Size size);
139 
140 
141 /*----------------------------------------------------------------------
142 | TS2_AesCbcEncrypter functions
143 +---------------------------------------------------------------------*/
144 ATX_Result TS2_AesCbcEncrypter_Create(const ATX_Byte* key,
145  const ATX_Byte* iv,
146  TS2_AesCbcEncrypter** encrypter);
147 
148 
150  const ATX_Byte* data,
151  ATX_Size data_size,
152  ATX_Byte* enc_data);
153 
154 
156 
167 ATX_Result TS2_AesCbcEncrypt(const ATX_Byte* key,
168  const ATX_Byte* iv,
169  const ATX_Byte* data,
170  ATX_Size data_size,
171  ATX_Byte* enc_data);
172 
173 /*----------------------------------------------------------------------
174 | TS2_AesCbcDecrypter functions
175 +---------------------------------------------------------------------*/
176 ATX_Result TS2_AesCbcDecrypter_Create(const ATX_Byte* key,
177  const ATX_Byte* iv,
178  TS2_AesCbcDecrypter** decrypter);
179 
180 
182  const ATX_Byte* enc_data,
183  ATX_Size data_size,
184  ATX_Byte* dec_data);
185 
186 
188 
190 ATX_Result TS2_AesCbcDecrypt(const ATX_Byte* key,
191  const ATX_Byte* iv,
192  const ATX_Byte* enc_data,
193  ATX_Size data_size,
194  ATX_Byte* dec_data);
195 
196 
197 #ifdef __cplusplus
198 }
199 #endif
200 
201 
202 
203 #endif /* _TS2_CRYPTO_H_ */
ATX_Result TS2_AesCbcEncrypt(const ATX_Byte *key, const ATX_Byte *iv, const ATX_Byte *data, ATX_Size data_size, ATX_Byte *enc_data)
helper
void TS2_AesCbcDecrypter_Destroy(TS2_AesCbcDecrypter *self)
void TS2_AesCbcEncrypter_Destroy(TS2_AesCbcEncrypter *self)
ATX_Result TS2_Hmac_Final(TS2_Hmac *self, ATX_Byte *mac)
ATX_Result TS2_ComputeHmac(TS2_DigestAlgorithm algorithm, const ATX_Byte *key, ATX_Size key_size, const ATX_Byte *data, ATX_Size data_size, ATX_Byte *mac)
helper
void TS2_Hmac_Destroy(TS2_Hmac *self)
ATX_Result TS2_AesCbcEncrypter_Encrypt(TS2_AesCbcEncrypter *self, const ATX_Byte *data, ATX_Size data_size, ATX_Byte *enc_data)
ATX_Result TS2_GeneratePseudoRandom(ATX_Byte *buffer, ATX_Size size)
ATX_Result TS2_ComputeDigest(TS2_DigestAlgorithm algorithm, const ATX_Byte *data, ATX_Size data_size, ATX_Byte *digest)
helper
ATX_Size TS2_Digest_GetDigestSize(const TS2_Digest *self)
Definition: Ts2Crypto.h:49
void TS2_AesBlockCipher_Destroy(TS2_AesBlockCipher *self)
ATX_Result TS2_Digest_Update(TS2_Digest *self, const ATX_Byte *data, ATX_Size data_size)
ATX_Result TS2_Hmac_Create(TS2_DigestAlgorithm algorithm, const ATX_Byte *key, ATX_Size key_size, TS2_Hmac **hmac)
Definition: Ts2Crypto.h:45
ATX_Result TS2_Digest_Final(TS2_Digest *self, ATX_Byte *digest)
ATX_Result TS2_Digest_Create(TS2_DigestAlgorithm algorithm, TS2_Digest **digest)
ATX_Size TS2_Hmac_GetMacSize(TS2_Hmac *self)
void TS2_Digest_Destroy(TS2_Digest *self)
ATX_Result TS2_AesBlockCipher_ProcessBlock(TS2_AesBlockCipher *self, const ATX_Byte *input, ATX_Byte *output)
struct TS2_AesBlockCipher TS2_AesBlockCipher
Definition: Ts2Crypto.h:37
ATX_Size TS2_Digest_GetBlockSize(const TS2_Digest *self)
struct TS2_Hmac TS2_Hmac
Definition: Ts2Crypto.h:38
struct TS2_Digest TS2_Digest
Definition: Ts2Crypto.h:39
struct TS2_AesCbcEncrypter TS2_AesCbcEncrypter
Definition: Ts2Crypto.h:40
struct TS2_AesCbcDecrypter TS2_AesCbcDecrypter
Definition: Ts2Crypto.h:41
ATX_Result TS2_AesCbcDecrypt(const ATX_Byte *key, const ATX_Byte *iv, const ATX_Byte *enc_data, ATX_Size data_size, ATX_Byte *dec_data)
helper
ATX_Result TS2_AesCbcDecrypter_Decrypt(TS2_AesCbcDecrypter *self, const ATX_Byte *enc_data, ATX_Size data_size, ATX_Byte *dec_data)
Definition: Ts2Crypto.h:44
ATX_Result TS2_AesCbcDecrypter_Create(const ATX_Byte *key, const ATX_Byte *iv, TS2_AesCbcDecrypter **decrypter)
TS2_DigestAlgorithm
Definition: Ts2Crypto.h:48
ATX_Result TS2_AesBlockCipher_Create(const ATX_Byte *key, TS2_BlockCipherDirection direction, TS2_AesBlockCipher **cipher)
ATX_Result TS2_AesCbcEncrypter_Create(const ATX_Byte *key, const ATX_Byte *iv, TS2_AesCbcEncrypter **encrypter)
ATX_Result TS2_Hmac_Update(TS2_Hmac *self, const ATX_Byte *data, ATX_Size data_size)
TS2_BlockCipherDirection
Definition: Ts2Crypto.h:43