Debian Codegraph @

cmp_ssleay/blowfish.c

raw symbols SCIP
1 #include <stdio.h>
2 #include "blowfish.h"
3
4
5 void print4(unsigned char *p) {
6 int x3,x2,x1,x0;
7 x3 = p[0] << 8 | p[1];
8 x2 = p[2] << 8 | p[3];
9 x1 = p[4] << 8 | p[5];
10 x0 = p[6] << 8 | p[7];
11
12 printf(" %d %d %d %d", x3, x2, x1, x0);
13 }
14
15
16
17
18 main () {
19 BF_KEY k;
20 unsigned char out8[8];
21 unsigned char out16[16];
22 unsigned char ivec[8];
23 int i, num;
24
25 BF_set_key(&k, 16, "abcdefghijklmnop");
26
27
28 /* ECB TEST */
29
30 BF_ecb_encrypt("12345678", out8, &k, 1);
31
32 printf("Result ECB:");
33 print4(out8);
34 printf("\n");
35
36
37 /* CBC TEST */
38
39
40 for (i=0; i<8; i++) ivec[i] = 0;
41 BF_cbc_encrypt("12345678abcdefgh", out16, 16, &k, ivec, 1);
42
43 printf("Result CBC:");
44 print4(out16);
45 print4(out16+8);
46 printf("\n");
47
48
49 /* CFB-64 TEST */
50
51 for (i=0; i<8; i++) ivec[i] = 0;
52 num = 0;
53 BF_cfb64_encrypt("12345678abcdefgh", out16, 16, &k, ivec, &num, 1);
54
55 printf("Result CFB-64:");
56 print4(out16);
57 print4(out16+8);
58 printf("\n");
59
60
61 /* OFB TEST */
62
63 for (i=0; i<8; i++) ivec[i] = 0;
64 num = 0;
65 BF_ofb64_encrypt("12345678abcdefgh", out16, 16, &k, ivec, &num);
66
67 printf("Result OFB:");
68 print4(out16);
69 print4(out16+8);
70 printf("\n");
71 }