Changeset 988 for vendor/current/lib/crypto/aes.c
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/lib/crypto/aes.c
r740 r988 33 33 34 34 #include "replace.h" 35 #include "aes.h" 35 36 37 #ifdef SAMBA_RIJNDAEL 36 38 #include "rijndael-alg-fst.h" 37 #include "aes.h"38 39 39 40 int … … 66 67 rijndaelDecrypt(key->key, key->rounds, in, out); 67 68 } 69 #endif /* SAMBA_RIJNDAEL */ 68 70 71 #ifdef SAMBA_AES_CBC_ENCRYPT 69 72 void 70 73 AES_cbc_encrypt(const unsigned char *in, unsigned char *out, … … 113 116 } 114 117 } 118 #endif /* SAMBA_AES_CBC_ENCRYPT */ 115 119 116 void aes_cfb8_encrypt(const uint8_t *in, uint8_t *out, 117 size_t length, const AES_KEY *key, 118 uint8_t *iv, int forward) 120 #ifdef SAMBA_AES_CFB8_ENCRYPT 121 void 122 AES_cfb8_encrypt(const unsigned char *in, unsigned char *out, 123 unsigned long size, const AES_KEY *key, 124 unsigned char *iv, int forward_encrypt) 119 125 { 120 size_t i;126 int i; 121 127 122 for (i=0; i < length; i++) {123 uint8_t tiv[AES_BLOCK_SIZE*2];128 for (i = 0; i < size; i++) { 129 unsigned char tmp[AES_BLOCK_SIZE + 1]; 124 130 125 memcpy(tiv, iv, AES_BLOCK_SIZE);126 127 if (!forward) {128 tiv[AES_BLOCK_SIZE] = in[i];129 130 131 if (forward) {132 tiv[AES_BLOCK_SIZE] = out[i];133 134 memcpy(iv, tiv+1, AES_BLOCK_SIZE);135 131 memcpy(tmp, iv, AES_BLOCK_SIZE); 132 AES_encrypt(iv, iv, key); 133 if (!forward_encrypt) { 134 tmp[AES_BLOCK_SIZE] = in[i]; 135 } 136 out[i] = in[i] ^ iv[0]; 137 if (forward_encrypt) { 138 tmp[AES_BLOCK_SIZE] = out[i]; 139 } 140 memcpy(iv, &tmp[1], AES_BLOCK_SIZE); 141 } 136 142 } 143 #endif /* SAMBA_AES_CFB8_ENCRYPT */
Note:
See TracChangeset
for help on using the changeset viewer.