summaryrefslogtreecommitdiff
path: root/utils/imxtools/sbtools/crypto.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utils/imxtools/sbtools/crypto.cpp')
-rw-r--r--utils/imxtools/sbtools/crypto.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/utils/imxtools/sbtools/crypto.cpp b/utils/imxtools/sbtools/crypto.cpp
index d7ef04f098..5563fcfd3b 100644
--- a/utils/imxtools/sbtools/crypto.cpp
+++ b/utils/imxtools/sbtools/crypto.cpp
@@ -30,19 +30,19 @@ namespace
30{ 30{
31 31
32enum crypto_method_t g_cur_method = CRYPTO_NONE; 32enum crypto_method_t g_cur_method = CRYPTO_NONE;
33byte g_key[16]; 33uint8_t g_key[16];
34CBC_Mode<AES>::Encryption g_aes_enc; 34CBC_Mode<AES>::Encryption g_aes_enc;
35CBC_Mode<AES>::Decryption g_aes_dec; 35CBC_Mode<AES>::Decryption g_aes_dec;
36bool g_aes_enc_key_dirty; /* true of g_aes_enc key needs to be updated */ 36bool g_aes_enc_key_dirty; /* true of g_aes_enc key needs to be updated */
37bool g_aes_dec_key_dirty; /* same for g_aes_dec */ 37bool g_aes_dec_key_dirty; /* same for g_aes_dec */
38 38
39int cbc_mac2( 39int cbc_mac2(
40 const byte *in_data, /* Input data */ 40 const uint8_t *in_data, /* Input data */
41 byte *out_data, /* Output data (or NULL) */ 41 uint8_t *out_data, /* Output data (or NULL) */
42 int nr_blocks, /* Number of blocks to encrypt/decrypt (one block=16 bytes) */ 42 int nr_blocks, /* Number of blocks to encrypt/decrypt (one block=16 bytes) */
43 byte key[16], /* Key */ 43 uint8_t key[16], /* Key */
44 byte iv[16], /* Initialisation Vector */ 44 uint8_t iv[16], /* Initialisation Vector */
45 byte (*out_cbc_mac)[16], /* CBC-MAC of the result (or NULL) */ 45 uint8_t (*out_cbc_mac)[16], /* CBC-MAC of the result (or NULL) */
46 bool encrypt /* 1 to encrypt, 0 to decrypt */ 46 bool encrypt /* 1 to encrypt, 0 to decrypt */
47 ) 47 )
48{ 48{
@@ -58,10 +58,10 @@ int cbc_mac2(
58 g_aes_enc_key_dirty = false; 58 g_aes_enc_key_dirty = false;
59 } 59 }
60 g_aes_enc.Resynchronize(iv, 16); 60 g_aes_enc.Resynchronize(iv, 16);
61 byte tmp[16]; 61 uint8_t tmp[16];
62 /* we need some output buffer, either a temporary one if we are CBC-MACing 62 /* we need some output buffer, either a temporary one if we are CBC-MACing
63 * only, or use output buffer if available */ 63 * only, or use output buffer if available */
64 byte *out_ptr = (out_data == NULL) ? tmp : out_data; 64 uint8_t *out_ptr = (out_data == NULL) ? tmp : out_data;
65 while(nr_blocks-- > 0) 65 while(nr_blocks-- > 0)
66 { 66 {
67 g_aes_enc.ProcessData(out_ptr, in_data, 16); 67 g_aes_enc.ProcessData(out_ptr, in_data, 16);
@@ -113,11 +113,11 @@ int crypto_setup(struct crypto_key_t *key)
113} 113}
114 114
115int crypto_apply( 115int crypto_apply(
116 byte *in_data, /* Input data */ 116 uint8_t *in_data, /* Input data */
117 byte *out_data, /* Output data (or NULL) */ 117 uint8_t *out_data, /* Output data (or NULL) */
118 int nr_blocks, /* Number of blocks (one block=16 bytes) */ 118 int nr_blocks, /* Number of blocks (one block=16 bytes) */
119 byte iv[16], /* Key */ 119 uint8_t iv[16], /* Key */
120 byte (*out_cbc_mac)[16], /* CBC-MAC of the result (or NULL) */ 120 uint8_t (*out_cbc_mac)[16], /* CBC-MAC of the result (or NULL) */
121 bool encrypt) 121 bool encrypt)
122{ 122{
123 if(g_cur_method == CRYPTO_KEY) 123 if(g_cur_method == CRYPTO_KEY)
@@ -131,7 +131,7 @@ void sha_1_init(struct sha_1_params_t *params)
131 params->object = new SHA1; 131 params->object = new SHA1;
132} 132}
133 133
134void sha_1_update(struct sha_1_params_t *params, byte *buffer, int size) 134void sha_1_update(struct sha_1_params_t *params, uint8_t *buffer, int size)
135{ 135{
136 reinterpret_cast<SHA1 *>(params->object)->Update(buffer, size); 136 reinterpret_cast<SHA1 *>(params->object)->Update(buffer, size);
137} 137}
@@ -143,7 +143,7 @@ void sha_1_finish(struct sha_1_params_t *params)
143 delete obj; 143 delete obj;
144} 144}
145 145
146void sha_1_output(struct sha_1_params_t *params, byte *out) 146void sha_1_output(struct sha_1_params_t *params, uint8_t *out)
147{ 147{
148 memcpy(out, params->hash, 20); 148 memcpy(out, params->hash, 20);
149} 149}