status update, probably last commit
[rofl0r-kripto.git] / test / block / speck32.c
blob4139484413c17865487874d9f4e77ca23abde53c
1 /*
2 * Written in 2013 by Gregor Pintar <grpintar@gmail.com>
4 * To the extent possible under law, the author(s) have dedicated
5 * all copyright and related and neighboring rights to this software
6 * to the public domain worldwide.
7 *
8 * This software is distributed without any warranty.
10 * You should have received a copy of the CC0 Public Domain Dedication.
11 * If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
14 #include <stdint.h>
15 #include <stdio.h>
17 #include <kripto/block/speck32.h>
19 int main(void)
21 kripto_block *s;
22 unsigned int i;
23 uint8_t t[4];
24 const uint8_t k[8] =
26 0x19, 0x18, 0x11, 0x10, 0x09, 0x08, 0x01, 0x00
28 const uint8_t pt[4] = {0x65, 0x74, 0x69, 0x4C};
29 const uint8_t ct[4] = {0xA8, 0x68, 0x42, 0xF2};
31 puts("kripto_block_speck32");
33 /* 64-bit key */
34 s = kripto_block_create(kripto_block_speck32, 0, k, 8);
35 if(!s) puts("error");
37 kripto_block_encrypt(s, pt, t);
38 for(i = 0; i < 4; i++) if(t[i] != ct[i])
40 puts("64-bit key encrypt: FAIL");
41 break;
43 if(i == 4) puts("64-bit key encrypt: OK");
45 kripto_block_decrypt(s, ct, t);
46 for(i = 0; i < 4; i++) if(t[i] != pt[i])
48 puts("64-bit key decrypt: FAIL");
49 break;
51 if(i == 4) puts("64-bit key decrypt: OK");
53 kripto_block_destroy(s);
55 return 0;