Update test.c

This commit is contained in:
kokke 2014-07-12 02:16:45 +02:00
parent ce6f709a72
commit ba3271eaee

25
test.c
View File

@ -5,11 +5,13 @@
static void phex(uint8_t* str); static void phex(uint8_t* str);
static void test_ECB(void); static void test_ECB(void);
static void test_decrypt(void);
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
test_ECB(); test_ECB();
test_decrypt();
return 0; return 0;
} }
@ -54,7 +56,7 @@ static void test_ECB(void)
} }
// prints string as hex // prints string as hex
void phex(uint8_t* str) static void phex(uint8_t* str)
{ {
unsigned char i; unsigned char i;
for(i = 0; i < 16; ++i) for(i = 0; i < 16; ++i)
@ -63,3 +65,24 @@ void phex(uint8_t* str)
} }
static void test_decrypt(void)
{
uint8_t key[] = {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c};
uint8_t in[] = {0x3a, 0xd7, 0x7b, 0xb4, 0x0d, 0x7a, 0x36, 0x60, 0xa8, 0x9e, 0xca, 0xf3, 0x24, 0x66, 0xef, 0x97};
uint8_t out[] = {0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a};
uint8_t buffer[16];
AES128_ECB_decrypt(in, key, buffer);
printf("decrypt: ");
if(0 == strncmp(out, buffer, 16))
{
printf("SUCCESS!\n");
}
else
{
printf("FAILURE!\n");
}
}