status update, probably last commit
[rofl0r-kripto.git] / test / block / rc5.c
bloba4f4c3ded8cc983ccf8088d1008f9a30480919bc
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>
16 #include <string.h>
18 #include <kripto/block/rc5.h>
20 int main(void)
22 kripto_block *s;
23 uint8_t t[8];
24 const uint8_t k[16] =
26 0x91, 0x5F, 0x46, 0x19, 0xBE, 0x41, 0xB2, 0x51,
27 0x63, 0x55, 0xA5, 0x01, 0x10, 0xA9, 0xCE, 0x91
29 const uint8_t pt[8] =
31 0x21, 0xA5, 0xDB, 0xEE, 0x15, 0x4B, 0x8F, 0x6D
33 const uint8_t ct[8] =
35 0xF7, 0xC0, 0x13, 0xAC, 0x5B, 0x2B, 0x89, 0x52
38 puts("kripto_block_rc5");
40 /* 128-bit key */
41 s = kripto_block_create(kripto_block_rc5, 0, k, 16);
42 if(!s) puts("error");
44 kripto_block_encrypt(s, pt, t);
45 if(memcmp(t, ct, 8)) puts("128-bit key encrypt: FAIL");
46 else puts("128-bit key encrypt: OK");
48 kripto_block_decrypt(s, ct, t);
49 if(memcmp(t, pt, 8)) puts("128-bit key decrypt: FAIL");
50 else puts("128-bit key decrypt: OK");
52 kripto_block_destroy(s);
54 return 0;