Wasabi ExpressPlay SDK for Embedded Systems
1.10
Main Page
Modules
Data Structures
Files
File List
Globals
Client
ThirdParty
Ts2
Source
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
+---------------------------------------------------------------------*/
37
typedef
struct
TS2_AesBlockCipher
TS2_AesBlockCipher
;
38
typedef
struct
TS2_Hmac
TS2_Hmac
;
39
typedef
struct
TS2_Digest
TS2_Digest
;
40
typedef
struct
TS2_AesCbcEncrypter
TS2_AesCbcEncrypter
;
41
typedef
struct
TS2_AesCbcDecrypter
TS2_AesCbcDecrypter
;
42
43
typedef
enum
{
44
TS2_CIPHER_DIRECTION_ENCRYPT
,
45
TS2_CIPHER_DIRECTION_DECRYPT
46
}
TS2_BlockCipherDirection
;
47
48
typedef
enum
{
49
TS2_DIGEST_SHA1
50
}
TS2_DigestAlgorithm
;
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
63
void
TS2_AesBlockCipher_Destroy
(
TS2_AesBlockCipher
*
self
);
64
65
ATX_Result
TS2_AesBlockCipher_ProcessBlock
(
TS2_AesBlockCipher
*
self
,
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
149
ATX_Result
TS2_AesCbcEncrypter_Encrypt
(
TS2_AesCbcEncrypter
*
self
,
150
const
ATX_Byte* data,
151
ATX_Size data_size,
152
ATX_Byte* enc_data);
153
154
155
void
TS2_AesCbcEncrypter_Destroy
(
TS2_AesCbcEncrypter
*
self
);
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
181
ATX_Result
TS2_AesCbcDecrypter_Decrypt
(
TS2_AesCbcDecrypter
*
self
,
182
const
ATX_Byte* enc_data,
183
ATX_Size data_size,
184
ATX_Byte* dec_data);
185
186
187
void
TS2_AesCbcDecrypter_Destroy
(
TS2_AesCbcDecrypter
*
self
);
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_ */