~increscent/aes-ccm

aes-ccm/lib.h -rw-r--r-- 3.2 KiB
6fdb84d8 — Robert Williams Found the issue: the msg_len parameter should be 16-bit, but it's 8-bit 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#ifndef _LIB_H_
#define _LIB_H_

//unsigned char PLAINTEXT[293] = {0xc4, 0xef, 0xbe, 0x01, 0x00, 0x01, 0x1a, 0x00, 0x08, 0x00, 0x00, 0xbf, 0x63, 0x6f, 0x66, 0x66, 0x00, 0x64, 0x64, 0x61, 0x74, 0x61, 0x59, 0x01, 0x00, 0x49, 0x4e, 0x46, 0x3a, 0x20, 0x0a, 0x0a, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x20, 0x54, 0x69, 0x6d, 0x65, 0x3a, 0x09, 0x4a, 0x75, 0x6c, 0x20, 0x32, 0x36, 0x20, 0x32, 0x30, 0x32, 0x32, 0x20, 0x31, 0x32, 0x3a, 0x30, 0x30, 0x3a, 0x30, 0x32, 0x0a, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x3a, 0x09, 0x73, 0x74, 0x65, 0x72, 0x6c, 0x69, 0x6e, 0x67, 0x40, 0x70, 0x61, 0x73, 0x73, 0x69, 0x76, 0x65, 0x6c, 0x6f, 0x67, 0x69, 0x63, 0x2e, 0x63, 0x6f, 0x6d, 0x0a, 0x48, 0x61, 0x73, 0x68, 0x3a, 0x09, 0x76, 0x30, 0x2e, 0x31, 0x2d, 0x31, 0x32, 0x39, 0x30, 0x2d, 0x67, 0x61, 0x61, 0x63, 0x30, 0x64, 0x30, 0x32, 0x65, 0x2d, 0x64, 0x69, 0x72, 0x74, 0x79, 0x0a, 0x44, 0x61, 0x74, 0x65, 0x3a, 0x09, 0x54, 0x75, 0x65, 0x20, 0x4a, 0x75, 0x6c, 0x20, 0x31, 0x39, 0x20, 0x31, 0x36, 0x3a, 0x31, 0x37, 0x3a, 0x35, 0x39, 0x20, 0x32, 0x30, 0x32, 0x32, 0x0a, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x72, 0x63, 0x00, 0x63, 0x6c, 0x65, 0x6e, 0x19, 0x01, 0x00, 0xff};
//unsigned char KEY[16] = {0xE3, 0xBB, 0x08, 0xF7, 0x9A, 0xCB, 0xF5, 0xEA, 0x14, 0x87, 0x98, 0x0D, 0xBE, 0xF7, 0x8D, 0x49};

char KEY_STR[] = "98B217B18E4AC60E57D52852C46280B9";
//char PLAINTEXT_STR[] = "0200EFBEFECABEBA0A00020000000301000002000010EFBEFECA";
char PLAINTEXT_STR[] = "c4efbe0100011a00080000bf636f6666006464617461590100494e463a200a0a4275696c642054696d653a094a756c20323620323032322031323a30303a30320a417574686f723a09737465726c696e6740706173736976656c6f6769632e636f6d0a486173683a0976302e312d313239302d6761616330643032652d64697274790a446174653a09547565204a756c2031392031363a31373a353920323032320a0a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000062726300636c656e190100ff";
char IV_STR[] = "0280000002003C000100000000";
char MIC_STR[] = "D188B56A94D354EC";
char CIPHERTEXT_STR[] = "50F569E06F2C5154ED0AEEEFEC2CEC84FB34566CA77E499512D0";

unsigned char KEY[sizeof(KEY_STR) / 2] = {0};
unsigned char PLAINTEXT[sizeof(PLAINTEXT_STR) / 2] = {0};
unsigned char IV[sizeof(IV_STR) / 2] = {0};
unsigned char MIC[sizeof(MIC_STR) / 2] = {0};
unsigned char CIPHERTEXT[sizeof(CIPHERTEXT_STR) / 2] = {0};

void init();
void handleErrors(const char *str);
void printHex(unsigned char *buf, int len);
int hexValue(char c);
void hexToBytes(char *str, int len, unsigned char *buf);

#endif//_LIB_H_