Debian Codegraph @

cmp_ssleay/des.c

raw symbols SCIP
1 #include <stdio.h>
2 #include "des.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 des_key_schedule k;
20 unsigned char out8[8];
21 unsigned char out16[16];
22 unsigned char ivec[8];
23 int i, num;
24
25 des_set_key("abcdefgh",k);
26
27
28 /* ECB TEST */
29
30 des_ecb_encrypt("12345678", out8, k, 1);
31
32 printf("Result ECB:");
33 print4(out8);
34 printf("\n");
35
36
37 /* CBC TEST */
38
39 for (i=0; i<8; i++) ivec[i] = 0;
40 des_cbc_encrypt("12345678abcdefgh", out16, 16, k, ivec, 1);
41
42 printf("Result CBC:");
43 print4(out16);
44 print4(out16+8);
45 printf("\n");
46
47 /* CFB-64 TEST */
48
49 for (i=0; i<8; i++) ivec[i] = 0;
50 num = 0;
51 des_cfb64_encrypt("12345678abcdefgh", out16, 16, k, ivec, &num, 1);
52
53 printf("Result CFB-64:");
54 print4(out16);
55 print4(out16+8);
56 printf("\n");
57
58 /* OFB TEST */
59
60 for (i=0; i<8; i++) ivec[i] = 0;
61 num = 0;
62 des_ofb64_encrypt("12345678abcdefgh", out16, 16, k, ivec, &num);
63
64 printf("Result OFB:");
65 print4(out16);
66 print4(out16+8);
67 printf("\n");
68 }