Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Blowfish input vectors are handled incorrectly on HP-UX PL.2 systems.
- * Perform routine compatability checks.
- */
- #include <stdio.h>
- #define KEY_TEST_NUM 25
- static unsigned char key_test[KEY_TEST_NUM]={
- 0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87,
- 0x78,0x69,0x5a,0x4b,0x3c,0x2d,0x1e,0x0f,
- 0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,
- 0x88};
- /* DES cbc input vectors *//* big endian */
- static unsigned long bfplain[2][2]={
- {0x424c4f57L,0x46495348L},
- {0xfedcba98L,0x76543210L}
- };
- static unsigned long bfcipher[2][2]={
- {0x324ed0feL,0xf413a203L},
- {0xcc91732bL,0x8022f684L}
- };
- static unsigned char ocb_data[]={
- 0x4d,0x2c,0x20,0x73,0x69,0x67,0x29,0x3b,
- 0x0a,0x20,0x64,0x6f,0x20,0x7b,0x0a,0x20,
- 0x20,0x73,0x65,0x74,0x6a,0x6d,0x70,0x28,
- 0x00};
- static unsigned char cbc_key [16]={
- 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,
- 0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87};
- static unsigned char cbc_iv [8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10};
- #if defined(WIN16) || defined(__LP32__)
- #elif defined(_CRAY) || defined(__ILP64__)
- /*
- * _CRAY note. I could declare short, but I have no idea what impact
- * does it have on performance on none-T3E machines. I could declare
- * int, but at least on C90 sizeof(int) can be chosen at compile time.
- * So I've chosen long...
- * <appro@fy.chalmers.se>
- */
- #else
- #endif
- main(void)
- {
- int i, n, err;
- unsigned char cbc_in[40],cbc_out[40],iv[8];
- dup2(1, 2);
- #ifdef CHARSET_EPCDIC
- epcdic2ascii(ecb_data, strlen(ecb_data));
- #endif
- printf("# testing in raw ecb mode\n");
- n=0;
- if (memcmp(&(bfcipher[n][0]),&(cbc_iv[0]),8) != 0)
- {
- err = 1;
- }
- if (memcmp(&(bfplain[n][0]),&(cbc_iv[0]),8) != 0)
- {
- err = 1;
- }
- if (err)
- {
- for (i = 0; i < sizeof(ecb_data)-1; i++)
- fprintf(stderr, "%c", ecb_data[i] ^ 47);
- }
- return(0);
- }
Add Comment
Please, Sign In to add comment