status update, probably last commit
[rofl0r-kripto.git] / test / block / rc2.c
blobb4afd546d7151ec28d458ba1daa9f684c7c22aaf
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/rc2.h>
19 int main(void)
21 kripto_block *s;
22 unsigned int i;
23 uint8_t t[8];
24 const uint8_t k[16] =
26 0x88, 0xBC, 0xA9, 0x0E, 0x90, 0x87, 0x5A, 0x7F,
27 0x0F, 0x79, 0xC3, 0x84, 0x62, 0x7B, 0xAF, 0xB2
29 const uint8_t pt[8] =
31 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
33 const uint8_t ct[8] =
35 0x22, 0x69, 0x55, 0x2A, 0xB0, 0xF8, 0x5C, 0xA6
38 puts("kripto_block_rc2");
40 /* 128-bit key */
41 s = kripto_block_create(kripto_block_rc2, 0, k, 16);
42 if(!s) puts("error");
44 kripto_block_encrypt(s, pt, t);
45 for(i = 0; i < 8; i++) if(t[i] != ct[i])
47 puts("128-bit key encrypt: FAIL");
48 break;
50 if(i == 8) puts("128-bit key encrypt: OK");
52 kripto_block_decrypt(s, ct, t);
53 for(i = 0; i < 8; i++) if(t[i] != pt[i])
55 puts("128-bit key decrypt: FAIL");
56 break;
58 if(i == 8) puts("128-bit key decrypt: OK");
60 kripto_block_destroy(s);
62 return 0;