comparison aes.c @ 166:c7ea70dea191 libavutil

memleak
author michael
date Sun, 14 Jan 2007 09:25:52 +0000
parents d64f200afe17
children 6104bbdb757b
comparison
equal deleted inserted replaced
165:d64f200afe17 166:c7ea70dea191
103 } 103 }
104 } 104 }
105 105
106 // this is based on the reference AES code by Paulo Barreto and Vincent Rijmen 106 // this is based on the reference AES code by Paulo Barreto and Vincent Rijmen
107 AVAES *av_aes_init(uint8_t *key, int keyBits) { 107 AVAES *av_aes_init(uint8_t *key, int keyBits) {
108 AVAES *a= av_malloc(sizeof(AVAES)); 108 AVAES *a;
109 int i, j, t, rconpointer = 0; 109 int i, j, t, rconpointer = 0;
110 uint8_t tk[8][4]; 110 uint8_t tk[8][4];
111 int KC= keyBits/32; 111 int KC= keyBits/32;
112 int ROUNDS= KC + 6; 112 int ROUNDS= KC + 6;
113 113
129 sbox [i]= j; 129 sbox [i]= j;
130 // av_log(NULL, AV_LOG_ERROR, "%d, ", log8[i]); 130 // av_log(NULL, AV_LOG_ERROR, "%d, ", log8[i]);
131 } 131 }
132 } 132 }
133 133
134 a->rounds= ROUNDS;
135
136 if(keyBits!=128 && keyBits!=192 && keyBits!=256) 134 if(keyBits!=128 && keyBits!=192 && keyBits!=256)
137 return NULL; 135 return NULL;
136
137 a= av_malloc(sizeof(AVAES));
138 a->rounds= ROUNDS;
138 139
139 memcpy(tk, key, KC*4); 140 memcpy(tk, key, KC*4);
140 141
141 for(t= 0; t < (ROUNDS+1)*4; ) { 142 for(t= 0; t < (ROUNDS+1)*4; ) {
142 for(j = 0; (j < KC) && (t < (ROUNDS+1)*4); j++, t++) 143 for(j = 0; (j < KC) && (t < (ROUNDS+1)*4); j++, t++)