21
21
* implementation. This file assumes that there is an encryption
22
22
* function available with this signature:
23
23
*
24
- * extern "C" void aes_encrypt (u1_t *data, u1_t *key);
24
+ * extern "C" void lmic_aes_encrypt (u1_t *data, u1_t *key);
25
25
*
26
26
* That takes a single 16-byte buffer and encrypts it wit the given
27
27
* 16-byte key.
32
32
#if !defined(USE_ORIGINAL_AES )
33
33
34
34
// This should be defined elsewhere
35
- void aes_encrypt (u1_t * data , u1_t * key );
35
+ void lmic_aes_encrypt (u1_t * data , u1_t * key );
36
36
37
37
// global area for passing parameters (aux, key) and for storing round keys
38
38
u4_t AESAUX [16 /sizeof (u4_t )];
@@ -55,7 +55,7 @@ static void shift_left(xref2u1_t buf, u1_t len) {
55
55
// in any case. The CMAC result is returned in AESAUX as well.
56
56
static void os_aes_cmac (xref2u1_t buf , u2_t len , u1_t prepend_aux ) {
57
57
if (prepend_aux )
58
- aes_encrypt (AESaux , AESkey );
58
+ lmic_aes_encrypt (AESaux , AESkey );
59
59
else
60
60
memset (AESaux , 0 , 16 );
61
61
@@ -79,7 +79,7 @@ static void os_aes_cmac(xref2u1_t buf, u2_t len, u1_t prepend_aux) {
79
79
// shifts and xor on that.
80
80
u1_t final_key [16 ];
81
81
memset (final_key , 0 , sizeof (final_key ));
82
- aes_encrypt (final_key , AESkey );
82
+ lmic_aes_encrypt (final_key , AESkey );
83
83
84
84
// Calculate K1
85
85
u1_t msb = final_key [0 ] & 0x80 ;
@@ -100,7 +100,7 @@ static void os_aes_cmac(xref2u1_t buf, u2_t len, u1_t prepend_aux) {
100
100
AESaux [i ] ^= final_key [i ];
101
101
}
102
102
103
- aes_encrypt (AESaux , AESkey );
103
+ lmic_aes_encrypt (AESaux , AESkey );
104
104
}
105
105
}
106
106
@@ -112,7 +112,7 @@ static void os_aes_ctr (xref2u1_t buf, u2_t len) {
112
112
while (len ) {
113
113
// Encrypt the counter block with the selected key
114
114
memcpy (ctr , AESaux , sizeof (ctr ));
115
- aes_encrypt (ctr , AESkey );
115
+ lmic_aes_encrypt (ctr , AESkey );
116
116
117
117
// Xor the payload with the resulting ciphertext
118
118
for (u1_t i = 0 ; i < 16 && len > 0 ; i ++ , len -- , buf ++ )
@@ -132,7 +132,7 @@ u4_t os_aes (u1_t mode, xref2u1_t buf, u2_t len) {
132
132
case AES_ENC :
133
133
// TODO: Check / handle when len is not a multiple of 16
134
134
for (u1_t i = 0 ; i < len ; i += 16 )
135
- aes_encrypt (buf + i , AESkey );
135
+ lmic_aes_encrypt (buf + i , AESkey );
136
136
break ;
137
137
138
138
case AES_CTR :
0 commit comments