XCBC mac added
[rofl0r-kripto.git] / test / mac / xcbc.c
blob0fd6551f543a78dd6745c5dff621c6cde09cf187
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 <stdio.h>
15 #include <stdlib.h>
16 #include <stdint.h>
17 #include <string.h>
19 #include <kripto/mac.h>
20 #include <kripto/mac/xcbc.h>
21 #include <kripto/block/rijndael128.h>
23 static const uint8_t key[16] =
25 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
26 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
29 static const uint8_t msg[34] =
31 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
32 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
33 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
34 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
35 0x20, 0x21
38 static const uint8_t tag[16] =
40 0xBE, 0xCB, 0xB3, 0xBC, 0xCD, 0xB5, 0x18, 0xA3,
41 0x06, 0x77, 0xD5, 0x48, 0x1F, 0xB6, 0xB4, 0xD8
44 int main(void)
46 kripto_mac_desc *desc;
47 uint8_t t[16];
49 desc = kripto_mac_xcbc(kripto_block_rijndael128);
50 if(!desc) return -1;
52 kripto_mac_all(
53 desc, 0,
54 key, 16,
55 msg, 34,
56 t, 16
59 if(memcmp(tag, t, 16)) puts("xcbc rijndael128: FAIL");
60 else puts("xcbc rijndael128: OK");
62 free(desc);
64 return 0;