Annotation of OpenXM/src/ox_ntl/crypt/blowfish/bftest.c, Revision 1.1
1.1 ! iwane 1: /* $OpenXM$ */
! 2:
! 3: /*
! 4: * BLOWFISH: Bruce Schneier
! 5: * http://www.schneier.com/blowfish.html
! 6: */
! 7:
! 8: #include <stdio.h>
! 9: #include <string.h>
! 10:
! 11: #include "blowfish.h"
! 12:
! 13:
! 14:
! 15: int
! 16: main()
! 17: {
! 18: blowfish_key key;
! 19: uint32_t er, el;
! 20: uint32_t dr, dl;
! 21:
! 22: int i;
! 23:
! 24: unsigned char *keystr[] = {
! 25: (unsigned char *)"abcdefghijklmnopqrstuvwxyz",
! 26: (unsigned char *)"Who is John Galt?"};
! 27: uint32_t plain[][2] = {
! 28: {0x424c4f57U, 0x46495348U},
! 29: {0xfedcba98U, 0x76543210U},
! 30: };
! 31: uint32_t chiper[][2] = {
! 32: {0x324ed0feU, 0xf413a203U},
! 33: {0xcc91732bU, 0x8022f684U},
! 34: };
! 35:
! 36: for (i = 0; i < 2; i++) {
! 37: blowfish_setkey(keystr[i], strlen((char *)keystr[i]), &key);
! 38:
! 39: blowfish_enc_i(&key, plain[i][0], plain[i][1], &el, &er);
! 40:
! 41: if (el == chiper[i][0] && er == chiper[i][1]) {
! 42: printf("test[1-%3d]. ok\n", i);
! 43: } else {
! 44: printf("test[1-%3d]. NG\n", i);
! 45: }
! 46:
! 47: blowfish_dec_i(&key, el, er, &dl, &dr);
! 48: if (dl == plain[i][0] && dr == plain[i][1]) {
! 49: printf("test[2-%3d]. ok\n", i);
! 50: } else {
! 51: printf("test[2-%3d]. NG\n", i);
! 52: printf("dec = %08x %08x\n", dl, dr);
! 53: printf("plain= %08x %08x\n", plain[i][0], plain[i][1]);
! 54: }
! 55:
! 56: }
! 57:
! 58: return (0);
! 59: }
! 60:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>