You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
937 B

// test unit for twofish-256
// odzhan
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <ctype.h>
// 256-bit master key
uint8_t key[32]=
{0x24, 0x8a, 0x7f, 0x35, 0x28, 0xb1, 0x68, 0xac,
0xfd, 0xd1, 0x38, 0x6e, 0x3f, 0x51, 0xe3, 0x0c,
0x2e, 0x21, 0x58, 0xbc, 0x3e, 0x5f, 0xc7, 0x14,
0xc1, 0xee, 0xec, 0xa0, 0xea, 0x69, 0x6d, 0x48};
// 128-bit plain text
uint8_t plain[16]=
{0x43, 0x10, 0x58, 0xf4, 0xdb, 0xc7, 0xf7, 0x34,
0xda, 0x4f, 0x02, 0xf0, 0x4c, 0xc4, 0xf4, 0x59};
// 128-bit cipher text
uint8_t cipher[16]=
{0x37, 0xfe, 0x26, 0xff, 0x1c, 0xf6, 0x61, 0x75,
0xf5, 0xdd, 0xf4, 0xc3, 0x3b, 0x97, 0xa2, 0x05};
int main(void) {
uint8_t data[16];
int equ;
memcpy(data, plain, 16);
twofish(key, data);
equ = (memcmp(data, cipher, 16)==0);
printf("Twofish-256 test : %s\n", equ ? "OK" : "FAILED");
return 0;