Debian Codegraph @

debian/patches/1002_remove_unused_oaes_code.patch

raw
1 Origin: upstream, 0f9a5c1020bb5edff999f65e9e496c0d793968be
2 From: jeffro256 <[email protected]>
3 Date: Sun, 6 Oct 2024 16:08:52 -0500
4 Subject: crypto: remove unused OAES code
5
6 @SyntheticBird45 reported that the OpenBSD compiler gives warnings about string functions used in `oaes_sprintf`,
7 as well as use of `rand()` in `oaes_key_gen`. Neither of these functions are used in the codebase. Removing the
8 unused OAES functions silences these warnings.
9 ---
10 --- a/src/crypto/oaes_lib.c
11 +++ b/src/crypto/oaes_lib.c
12 @@ -54,35 +54,12 @@
13 #include <unistd.h>
14 #endif
15
16 -#ifdef _MSC_VER
17 -#define GETPID() _getpid()
18 -#else
19 -#define GETPID() getpid()
20 -#endif
21 -
22 -#include "oaes_config.h"
23 #include "oaes_lib.h"
24
25 -#ifdef OAES_HAVE_ISAAC
26 -#include "rand.h"
27 -#endif // OAES_HAVE_ISAAC
28 -
29 #define OAES_RKEY_LEN 4
30 #define OAES_COL_LEN 4
31 #define OAES_ROUND_BASE 7
32
33 -// the block is padded
34 -#define OAES_FLAG_PAD 0x01
35 -
36 -#ifndef min
37 -# define min(a,b) (((a)<(b)) ? (a) : (b))
38 -#endif /* min */
39 -
40 -// "OAES<8-bit header version><8-bit type><16-bit options><8-bit flags><56-bit reserved>"
41 -static uint8_t oaes_header[OAES_BLOCK_SIZE] = {
42 - // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f,
43 - /*0*/ 0x4f, 0x41, 0x45, 0x53, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44 -};
45 static uint8_t oaes_gf_8[] = {
46 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36 };
47
48 @@ -106,146 +83,6 @@ static uint8_t oaes_sub_byte_value[16][16] = {
49 /*f*/ { 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 },
50 };
51
52 -static uint8_t oaes_inv_sub_byte_value[16][16] = {
53 - // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f,
54 - /*0*/ { 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb },
55 - /*1*/ { 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb },
56 - /*2*/ { 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e },
57 - /*3*/ { 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25 },
58 - /*4*/ { 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92 },
59 - /*5*/ { 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84 },
60 - /*6*/ { 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06 },
61 - /*7*/ { 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b },
62 - /*8*/ { 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73 },
63 - /*9*/ { 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e },
64 - /*a*/ { 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b },
65 - /*b*/ { 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4 },
66 - /*c*/ { 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f },
67 - /*d*/ { 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef },
68 - /*e*/ { 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61 },
69 - /*f*/ { 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d },
70 -};
71 -
72 -static uint8_t oaes_gf_mul_2[16][16] = {
73 - // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f,
74 - /*0*/ { 0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e },
75 - /*1*/ { 0x20, 0x22, 0x24, 0x26, 0x28, 0x2a, 0x2c, 0x2e, 0x30, 0x32, 0x34, 0x36, 0x38, 0x3a, 0x3c, 0x3e },
76 - /*2*/ { 0x40, 0x42, 0x44, 0x46, 0x48, 0x4a, 0x4c, 0x4e, 0x50, 0x52, 0x54, 0x56, 0x58, 0x5a, 0x5c, 0x5e },
77 - /*3*/ { 0x60, 0x62, 0x64, 0x66, 0x68, 0x6a, 0x6c, 0x6e, 0x70, 0x72, 0x74, 0x76, 0x78, 0x7a, 0x7c, 0x7e },
78 - /*4*/ { 0x80, 0x82, 0x84, 0x86, 0x88, 0x8a, 0x8c, 0x8e, 0x90, 0x92, 0x94, 0x96, 0x98, 0x9a, 0x9c, 0x9e },
79 - /*5*/ { 0xa0, 0xa2, 0xa4, 0xa6, 0xa8, 0xaa, 0xac, 0xae, 0xb0, 0xb2, 0xb4, 0xb6, 0xb8, 0xba, 0xbc, 0xbe },
80 - /*6*/ { 0xc0, 0xc2, 0xc4, 0xc6, 0xc8, 0xca, 0xcc, 0xce, 0xd0, 0xd2, 0xd4, 0xd6, 0xd8, 0xda, 0xdc, 0xde },
81 - /*7*/ { 0xe0, 0xe2, 0xe4, 0xe6, 0xe8, 0xea, 0xec, 0xee, 0xf0, 0xf2, 0xf4, 0xf6, 0xf8, 0xfa, 0xfc, 0xfe },
82 - /*8*/ { 0x1b, 0x19, 0x1f, 0x1d, 0x13, 0x11, 0x17, 0x15, 0x0b, 0x09, 0x0f, 0x0d, 0x03, 0x01, 0x07, 0x05 },
83 - /*9*/ { 0x3b, 0x39, 0x3f, 0x3d, 0x33, 0x31, 0x37, 0x35, 0x2b, 0x29, 0x2f, 0x2d, 0x23, 0x21, 0x27, 0x25 },
84 - /*a*/ { 0x5b, 0x59, 0x5f, 0x5d, 0x53, 0x51, 0x57, 0x55, 0x4b, 0x49, 0x4f, 0x4d, 0x43, 0x41, 0x47, 0x45 },
85 - /*b*/ { 0x7b, 0x79, 0x7f, 0x7d, 0x73, 0x71, 0x77, 0x75, 0x6b, 0x69, 0x6f, 0x6d, 0x63, 0x61, 0x67, 0x65 },
86 - /*c*/ { 0x9b, 0x99, 0x9f, 0x9d, 0x93, 0x91, 0x97, 0x95, 0x8b, 0x89, 0x8f, 0x8d, 0x83, 0x81, 0x87, 0x85 },
87 - /*d*/ { 0xbb, 0xb9, 0xbf, 0xbd, 0xb3, 0xb1, 0xb7, 0xb5, 0xab, 0xa9, 0xaf, 0xad, 0xa3, 0xa1, 0xa7, 0xa5 },
88 - /*e*/ { 0xdb, 0xd9, 0xdf, 0xdd, 0xd3, 0xd1, 0xd7, 0xd5, 0xcb, 0xc9, 0xcf, 0xcd, 0xc3, 0xc1, 0xc7, 0xc5 },
89 - /*f*/ { 0xfb, 0xf9, 0xff, 0xfd, 0xf3, 0xf1, 0xf7, 0xf5, 0xeb, 0xe9, 0xef, 0xed, 0xe3, 0xe1, 0xe7, 0xe5 },
90 -};
91 -
92 -static uint8_t oaes_gf_mul_3[16][16] = {
93 - // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f,
94 - /*0*/ { 0x00, 0x03, 0x06, 0x05, 0x0c, 0x0f, 0x0a, 0x09, 0x18, 0x1b, 0x1e, 0x1d, 0x14, 0x17, 0x12, 0x11 },
95 - /*1*/ { 0x30, 0x33, 0x36, 0x35, 0x3c, 0x3f, 0x3a, 0x39, 0x28, 0x2b, 0x2e, 0x2d, 0x24, 0x27, 0x22, 0x21 },
96 - /*2*/ { 0x60, 0x63, 0x66, 0x65, 0x6c, 0x6f, 0x6a, 0x69, 0x78, 0x7b, 0x7e, 0x7d, 0x74, 0x77, 0x72, 0x71 },
97 - /*3*/ { 0x50, 0x53, 0x56, 0x55, 0x5c, 0x5f, 0x5a, 0x59, 0x48, 0x4b, 0x4e, 0x4d, 0x44, 0x47, 0x42, 0x41 },
98 - /*4*/ { 0xc0, 0xc3, 0xc6, 0xc5, 0xcc, 0xcf, 0xca, 0xc9, 0xd8, 0xdb, 0xde, 0xdd, 0xd4, 0xd7, 0xd2, 0xd1 },
99 - /*5*/ { 0xf0, 0xf3, 0xf6, 0xf5, 0xfc, 0xff, 0xfa, 0xf9, 0xe8, 0xeb, 0xee, 0xed, 0xe4, 0xe7, 0xe2, 0xe1 },
100 - /*6*/ { 0xa0, 0xa3, 0xa6, 0xa5, 0xac, 0xaf, 0xaa, 0xa9, 0xb8, 0xbb, 0xbe, 0xbd, 0xb4, 0xb7, 0xb2, 0xb1 },
101 - /*7*/ { 0x90, 0x93, 0x96, 0x95, 0x9c, 0x9f, 0x9a, 0x99, 0x88, 0x8b, 0x8e, 0x8d, 0x84, 0x87, 0x82, 0x81 },
102 - /*8*/ { 0x9b, 0x98, 0x9d, 0x9e, 0x97, 0x94, 0x91, 0x92, 0x83, 0x80, 0x85, 0x86, 0x8f, 0x8c, 0x89, 0x8a },
103 - /*9*/ { 0xab, 0xa8, 0xad, 0xae, 0xa7, 0xa4, 0xa1, 0xa2, 0xb3, 0xb0, 0xb5, 0xb6, 0xbf, 0xbc, 0xb9, 0xba },
104 - /*a*/ { 0xfb, 0xf8, 0xfd, 0xfe, 0xf7, 0xf4, 0xf1, 0xf2, 0xe3, 0xe0, 0xe5, 0xe6, 0xef, 0xec, 0xe9, 0xea },
105 - /*b*/ { 0xcb, 0xc8, 0xcd, 0xce, 0xc7, 0xc4, 0xc1, 0xc2, 0xd3, 0xd0, 0xd5, 0xd6, 0xdf, 0xdc, 0xd9, 0xda },
106 - /*c*/ { 0x5b, 0x58, 0x5d, 0x5e, 0x57, 0x54, 0x51, 0x52, 0x43, 0x40, 0x45, 0x46, 0x4f, 0x4c, 0x49, 0x4a },
107 - /*d*/ { 0x6b, 0x68, 0x6d, 0x6e, 0x67, 0x64, 0x61, 0x62, 0x73, 0x70, 0x75, 0x76, 0x7f, 0x7c, 0x79, 0x7a },
108 - /*e*/ { 0x3b, 0x38, 0x3d, 0x3e, 0x37, 0x34, 0x31, 0x32, 0x23, 0x20, 0x25, 0x26, 0x2f, 0x2c, 0x29, 0x2a },
109 - /*f*/ { 0x0b, 0x08, 0x0d, 0x0e, 0x07, 0x04, 0x01, 0x02, 0x13, 0x10, 0x15, 0x16, 0x1f, 0x1c, 0x19, 0x1a },
110 -};
111 -
112 -static uint8_t oaes_gf_mul_9[16][16] = {
113 - // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f,
114 - /*0*/ { 0x00, 0x09, 0x12, 0x1b, 0x24, 0x2d, 0x36, 0x3f, 0x48, 0x41, 0x5a, 0x53, 0x6c, 0x65, 0x7e, 0x77 },
115 - /*1*/ { 0x90, 0x99, 0x82, 0x8b, 0xb4, 0xbd, 0xa6, 0xaf, 0xd8, 0xd1, 0xca, 0xc3, 0xfc, 0xf5, 0xee, 0xe7 },
116 - /*2*/ { 0x3b, 0x32, 0x29, 0x20, 0x1f, 0x16, 0x0d, 0x04, 0x73, 0x7a, 0x61, 0x68, 0x57, 0x5e, 0x45, 0x4c },
117 - /*3*/ { 0xab, 0xa2, 0xb9, 0xb0, 0x8f, 0x86, 0x9d, 0x94, 0xe3, 0xea, 0xf1, 0xf8, 0xc7, 0xce, 0xd5, 0xdc },
118 - /*4*/ { 0x76, 0x7f, 0x64, 0x6d, 0x52, 0x5b, 0x40, 0x49, 0x3e, 0x37, 0x2c, 0x25, 0x1a, 0x13, 0x08, 0x01 },
119 - /*5*/ { 0xe6, 0xef, 0xf4, 0xfd, 0xc2, 0xcb, 0xd0, 0xd9, 0xae, 0xa7, 0xbc, 0xb5, 0x8a, 0x83, 0x98, 0x91 },
120 - /*6*/ { 0x4d, 0x44, 0x5f, 0x56, 0x69, 0x60, 0x7b, 0x72, 0x05, 0x0c, 0x17, 0x1e, 0x21, 0x28, 0x33, 0x3a },
121 - /*7*/ { 0xdd, 0xd4, 0xcf, 0xc6, 0xf9, 0xf0, 0xeb, 0xe2, 0x95, 0x9c, 0x87, 0x8e, 0xb1, 0xb8, 0xa3, 0xaa },
122 - /*8*/ { 0xec, 0xe5, 0xfe, 0xf7, 0xc8, 0xc1, 0xda, 0xd3, 0xa4, 0xad, 0xb6, 0xbf, 0x80, 0x89, 0x92, 0x9b },
123 - /*9*/ { 0x7c, 0x75, 0x6e, 0x67, 0x58, 0x51, 0x4a, 0x43, 0x34, 0x3d, 0x26, 0x2f, 0x10, 0x19, 0x02, 0x0b },
124 - /*a*/ { 0xd7, 0xde, 0xc5, 0xcc, 0xf3, 0xfa, 0xe1, 0xe8, 0x9f, 0x96, 0x8d, 0x84, 0xbb, 0xb2, 0xa9, 0xa0 },
125 - /*b*/ { 0x47, 0x4e, 0x55, 0x5c, 0x63, 0x6a, 0x71, 0x78, 0x0f, 0x06, 0x1d, 0x14, 0x2b, 0x22, 0x39, 0x30 },
126 - /*c*/ { 0x9a, 0x93, 0x88, 0x81, 0xbe, 0xb7, 0xac, 0xa5, 0xd2, 0xdb, 0xc0, 0xc9, 0xf6, 0xff, 0xe4, 0xed },
127 - /*d*/ { 0x0a, 0x03, 0x18, 0x11, 0x2e, 0x27, 0x3c, 0x35, 0x42, 0x4b, 0x50, 0x59, 0x66, 0x6f, 0x74, 0x7d },
128 - /*e*/ { 0xa1, 0xa8, 0xb3, 0xba, 0x85, 0x8c, 0x97, 0x9e, 0xe9, 0xe0, 0xfb, 0xf2, 0xcd, 0xc4, 0xdf, 0xd6 },
129 - /*f*/ { 0x31, 0x38, 0x23, 0x2a, 0x15, 0x1c, 0x07, 0x0e, 0x79, 0x70, 0x6b, 0x62, 0x5d, 0x54, 0x4f, 0x46 },
130 -};
131 -
132 -static uint8_t oaes_gf_mul_b[16][16] = {
133 - // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f,
134 - /*0*/ { 0x00, 0x0b, 0x16, 0x1d, 0x2c, 0x27, 0x3a, 0x31, 0x58, 0x53, 0x4e, 0x45, 0x74, 0x7f, 0x62, 0x69 },
135 - /*1*/ { 0xb0, 0xbb, 0xa6, 0xad, 0x9c, 0x97, 0x8a, 0x81, 0xe8, 0xe3, 0xfe, 0xf5, 0xc4, 0xcf, 0xd2, 0xd9 },
136 - /*2*/ { 0x7b, 0x70, 0x6d, 0x66, 0x57, 0x5c, 0x41, 0x4a, 0x23, 0x28, 0x35, 0x3e, 0x0f, 0x04, 0x19, 0x12 },
137 - /*3*/ { 0xcb, 0xc0, 0xdd, 0xd6, 0xe7, 0xec, 0xf1, 0xfa, 0x93, 0x98, 0x85, 0x8e, 0xbf, 0xb4, 0xa9, 0xa2 },
138 - /*4*/ { 0xf6, 0xfd, 0xe0, 0xeb, 0xda, 0xd1, 0xcc, 0xc7, 0xae, 0xa5, 0xb8, 0xb3, 0x82, 0x89, 0x94, 0x9f },
139 - /*5*/ { 0x46, 0x4d, 0x50, 0x5b, 0x6a, 0x61, 0x7c, 0x77, 0x1e, 0x15, 0x08, 0x03, 0x32, 0x39, 0x24, 0x2f },
140 - /*6*/ { 0x8d, 0x86, 0x9b, 0x90, 0xa1, 0xaa, 0xb7, 0xbc, 0xd5, 0xde, 0xc3, 0xc8, 0xf9, 0xf2, 0xef, 0xe4 },
141 - /*7*/ { 0x3d, 0x36, 0x2b, 0x20, 0x11, 0x1a, 0x07, 0x0c, 0x65, 0x6e, 0x73, 0x78, 0x49, 0x42, 0x5f, 0x54 },
142 - /*8*/ { 0xf7, 0xfc, 0xe1, 0xea, 0xdb, 0xd0, 0xcd, 0xc6, 0xaf, 0xa4, 0xb9, 0xb2, 0x83, 0x88, 0x95, 0x9e },
143 - /*9*/ { 0x47, 0x4c, 0x51, 0x5a, 0x6b, 0x60, 0x7d, 0x76, 0x1f, 0x14, 0x09, 0x02, 0x33, 0x38, 0x25, 0x2e },
144 - /*a*/ { 0x8c, 0x87, 0x9a, 0x91, 0xa0, 0xab, 0xb6, 0xbd, 0xd4, 0xdf, 0xc2, 0xc9, 0xf8, 0xf3, 0xee, 0xe5 },
145 - /*b*/ { 0x3c, 0x37, 0x2a, 0x21, 0x10, 0x1b, 0x06, 0x0d, 0x64, 0x6f, 0x72, 0x79, 0x48, 0x43, 0x5e, 0x55 },
146 - /*c*/ { 0x01, 0x0a, 0x17, 0x1c, 0x2d, 0x26, 0x3b, 0x30, 0x59, 0x52, 0x4f, 0x44, 0x75, 0x7e, 0x63, 0x68 },
147 - /*d*/ { 0xb1, 0xba, 0xa7, 0xac, 0x9d, 0x96, 0x8b, 0x80, 0xe9, 0xe2, 0xff, 0xf4, 0xc5, 0xce, 0xd3, 0xd8 },
148 - /*e*/ { 0x7a, 0x71, 0x6c, 0x67, 0x56, 0x5d, 0x40, 0x4b, 0x22, 0x29, 0x34, 0x3f, 0x0e, 0x05, 0x18, 0x13 },
149 - /*f*/ { 0xca, 0xc1, 0xdc, 0xd7, 0xe6, 0xed, 0xf0, 0xfb, 0x92, 0x99, 0x84, 0x8f, 0xbe, 0xb5, 0xa8, 0xa3 },
150 -};
151 -
152 -static uint8_t oaes_gf_mul_d[16][16] = {
153 - // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f,
154 - /*0*/ { 0x00, 0x0d, 0x1a, 0x17, 0x34, 0x39, 0x2e, 0x23, 0x68, 0x65, 0x72, 0x7f, 0x5c, 0x51, 0x46, 0x4b },
155 - /*1*/ { 0xd0, 0xdd, 0xca, 0xc7, 0xe4, 0xe9, 0xfe, 0xf3, 0xb8, 0xb5, 0xa2, 0xaf, 0x8c, 0x81, 0x96, 0x9b },
156 - /*2*/ { 0xbb, 0xb6, 0xa1, 0xac, 0x8f, 0x82, 0x95, 0x98, 0xd3, 0xde, 0xc9, 0xc4, 0xe7, 0xea, 0xfd, 0xf0 },
157 - /*3*/ { 0x6b, 0x66, 0x71, 0x7c, 0x5f, 0x52, 0x45, 0x48, 0x03, 0x0e, 0x19, 0x14, 0x37, 0x3a, 0x2d, 0x20 },
158 - /*4*/ { 0x6d, 0x60, 0x77, 0x7a, 0x59, 0x54, 0x43, 0x4e, 0x05, 0x08, 0x1f, 0x12, 0x31, 0x3c, 0x2b, 0x26 },
159 - /*5*/ { 0xbd, 0xb0, 0xa7, 0xaa, 0x89, 0x84, 0x93, 0x9e, 0xd5, 0xd8, 0xcf, 0xc2, 0xe1, 0xec, 0xfb, 0xf6 },
160 - /*6*/ { 0xd6, 0xdb, 0xcc, 0xc1, 0xe2, 0xef, 0xf8, 0xf5, 0xbe, 0xb3, 0xa4, 0xa9, 0x8a, 0x87, 0x90, 0x9d },
161 - /*7*/ { 0x06, 0x0b, 0x1c, 0x11, 0x32, 0x3f, 0x28, 0x25, 0x6e, 0x63, 0x74, 0x79, 0x5a, 0x57, 0x40, 0x4d },
162 - /*8*/ { 0xda, 0xd7, 0xc0, 0xcd, 0xee, 0xe3, 0xf4, 0xf9, 0xb2, 0xbf, 0xa8, 0xa5, 0x86, 0x8b, 0x9c, 0x91 },
163 - /*9*/ { 0x0a, 0x07, 0x10, 0x1d, 0x3e, 0x33, 0x24, 0x29, 0x62, 0x6f, 0x78, 0x75, 0x56, 0x5b, 0x4c, 0x41 },
164 - /*a*/ { 0x61, 0x6c, 0x7b, 0x76, 0x55, 0x58, 0x4f, 0x42, 0x09, 0x04, 0x13, 0x1e, 0x3d, 0x30, 0x27, 0x2a },
165 - /*b*/ { 0xb1, 0xbc, 0xab, 0xa6, 0x85, 0x88, 0x9f, 0x92, 0xd9, 0xd4, 0xc3, 0xce, 0xed, 0xe0, 0xf7, 0xfa },
166 - /*c*/ { 0xb7, 0xba, 0xad, 0xa0, 0x83, 0x8e, 0x99, 0x94, 0xdf, 0xd2, 0xc5, 0xc8, 0xeb, 0xe6, 0xf1, 0xfc },
167 - /*d*/ { 0x67, 0x6a, 0x7d, 0x70, 0x53, 0x5e, 0x49, 0x44, 0x0f, 0x02, 0x15, 0x18, 0x3b, 0x36, 0x21, 0x2c },
168 - /*e*/ { 0x0c, 0x01, 0x16, 0x1b, 0x38, 0x35, 0x22, 0x2f, 0x64, 0x69, 0x7e, 0x73, 0x50, 0x5d, 0x4a, 0x47 },
169 - /*f*/ { 0xdc, 0xd1, 0xc6, 0xcb, 0xe8, 0xe5, 0xf2, 0xff, 0xb4, 0xb9, 0xae, 0xa3, 0x80, 0x8d, 0x9a, 0x97 },
170 -};
171 -
172 -static uint8_t oaes_gf_mul_e[16][16] = {
173 - // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f,
174 - /*0*/ { 0x00, 0x0e, 0x1c, 0x12, 0x38, 0x36, 0x24, 0x2a, 0x70, 0x7e, 0x6c, 0x62, 0x48, 0x46, 0x54, 0x5a },
175 - /*1*/ { 0xe0, 0xee, 0xfc, 0xf2, 0xd8, 0xd6, 0xc4, 0xca, 0x90, 0x9e, 0x8c, 0x82, 0xa8, 0xa6, 0xb4, 0xba },
176 - /*2*/ { 0xdb, 0xd5, 0xc7, 0xc9, 0xe3, 0xed, 0xff, 0xf1, 0xab, 0xa5, 0xb7, 0xb9, 0x93, 0x9d, 0x8f, 0x81 },
177 - /*3*/ { 0x3b, 0x35, 0x27, 0x29, 0x03, 0x0d, 0x1f, 0x11, 0x4b, 0x45, 0x57, 0x59, 0x73, 0x7d, 0x6f, 0x61 },
178 - /*4*/ { 0xad, 0xa3, 0xb1, 0xbf, 0x95, 0x9b, 0x89, 0x87, 0xdd, 0xd3, 0xc1, 0xcf, 0xe5, 0xeb, 0xf9, 0xf7 },
179 - /*5*/ { 0x4d, 0x43, 0x51, 0x5f, 0x75, 0x7b, 0x69, 0x67, 0x3d, 0x33, 0x21, 0x2f, 0x05, 0x0b, 0x19, 0x17 },
180 - /*6*/ { 0x76, 0x78, 0x6a, 0x64, 0x4e, 0x40, 0x52, 0x5c, 0x06, 0x08, 0x1a, 0x14, 0x3e, 0x30, 0x22, 0x2c },
181 - /*7*/ { 0x96, 0x98, 0x8a, 0x84, 0xae, 0xa0, 0xb2, 0xbc, 0xe6, 0xe8, 0xfa, 0xf4, 0xde, 0xd0, 0xc2, 0xcc },
182 - /*8*/ { 0x41, 0x4f, 0x5d, 0x53, 0x79, 0x77, 0x65, 0x6b, 0x31, 0x3f, 0x2d, 0x23, 0x09, 0x07, 0x15, 0x1b },
183 - /*9*/ { 0xa1, 0xaf, 0xbd, 0xb3, 0x99, 0x97, 0x85, 0x8b, 0xd1, 0xdf, 0xcd, 0xc3, 0xe9, 0xe7, 0xf5, 0xfb },
184 - /*a*/ { 0x9a, 0x94, 0x86, 0x88, 0xa2, 0xac, 0xbe, 0xb0, 0xea, 0xe4, 0xf6, 0xf8, 0xd2, 0xdc, 0xce, 0xc0 },
185 - /*b*/ { 0x7a, 0x74, 0x66, 0x68, 0x42, 0x4c, 0x5e, 0x50, 0x0a, 0x04, 0x16, 0x18, 0x32, 0x3c, 0x2e, 0x20 },
186 - /*c*/ { 0xec, 0xe2, 0xf0, 0xfe, 0xd4, 0xda, 0xc8, 0xc6, 0x9c, 0x92, 0x80, 0x8e, 0xa4, 0xaa, 0xb8, 0xb6 },
187 - /*d*/ { 0x0c, 0x02, 0x10, 0x1e, 0x34, 0x3a, 0x28, 0x26, 0x7c, 0x72, 0x60, 0x6e, 0x44, 0x4a, 0x58, 0x56 },
188 - /*e*/ { 0x37, 0x39, 0x2b, 0x25, 0x0f, 0x01, 0x13, 0x1d, 0x47, 0x49, 0x5b, 0x55, 0x7f, 0x71, 0x63, 0x6d },
189 - /*f*/ { 0xd7, 0xd9, 0xcb, 0xc5, 0xef, 0xe1, 0xf3, 0xfd, 0xa7, 0xa9, 0xbb, 0xb5, 0x9f, 0x91, 0x83, 0x8d },
190 -};
191 -
192 static OAES_RET oaes_sub_byte( uint8_t * byte )
193 {
194 size_t _x, _y;
195 @@ -262,36 +99,6 @@ static OAES_RET oaes_sub_byte( uint8_t * byte )
196 return OAES_RET_SUCCESS;
197 }
198
199 -static OAES_RET oaes_inv_sub_byte( uint8_t * byte )
200 -{
201 - size_t _x, _y;
202 -
203 - if( NULL == byte )
204 - return OAES_RET_ARG1;
205 -
206 - _x = _y = *byte;
207 - _x &= 0x0f;
208 - _y &= 0xf0;
209 - _y >>= 4;
210 - *byte = oaes_inv_sub_byte_value[_y][_x];
211 -
212 - return OAES_RET_SUCCESS;
213 -}
214 -/*
215 -static OAES_RET oaes_word_rot_right( uint8_t word[OAES_COL_LEN] )
216 -{
217 - uint8_t _temp[OAES_COL_LEN];
218 -
219 - if( NULL == word )
220 - return OAES_RET_ARG1;
221 -
222 - memcpy( _temp + 1, word, OAES_COL_LEN - 1 );
223 - _temp[0] = word[OAES_COL_LEN - 1];
224 - memcpy( word, _temp, OAES_COL_LEN );
225 -
226 - return OAES_RET_SUCCESS;
227 -}
228 -*/
229 static OAES_RET oaes_word_rot_left( uint8_t word[OAES_COL_LEN] )
230 {
231 uint8_t _temp[OAES_COL_LEN];
232 @@ -306,239 +113,6 @@ static OAES_RET oaes_word_rot_left( uint8_t word[OAES_COL_LEN] )
233 return OAES_RET_SUCCESS;
234 }
235
236 -static OAES_RET oaes_shift_rows( uint8_t block[OAES_BLOCK_SIZE] )
237 -{
238 - uint8_t _temp[OAES_BLOCK_SIZE];
239 -
240 - if( NULL == block )
241 - return OAES_RET_ARG1;
242 -
243 - _temp[0x00] = block[0x00];
244 - _temp[0x01] = block[0x05];
245 - _temp[0x02] = block[0x0a];
246 - _temp[0x03] = block[0x0f];
247 - _temp[0x04] = block[0x04];
248 - _temp[0x05] = block[0x09];
249 - _temp[0x06] = block[0x0e];
250 - _temp[0x07] = block[0x03];
251 - _temp[0x08] = block[0x08];
252 - _temp[0x09] = block[0x0d];
253 - _temp[0x0a] = block[0x02];
254 - _temp[0x0b] = block[0x07];
255 - _temp[0x0c] = block[0x0c];
256 - _temp[0x0d] = block[0x01];
257 - _temp[0x0e] = block[0x06];
258 - _temp[0x0f] = block[0x0b];
259 - memcpy( block, _temp, OAES_BLOCK_SIZE );
260 -
261 - return OAES_RET_SUCCESS;
262 -}
263 -
264 -static OAES_RET oaes_inv_shift_rows( uint8_t block[OAES_BLOCK_SIZE] )
265 -{
266 - uint8_t _temp[OAES_BLOCK_SIZE];
267 -
268 - if( NULL == block )
269 - return OAES_RET_ARG1;
270 -
271 - _temp[0x00] = block[0x00];
272 - _temp[0x01] = block[0x0d];
273 - _temp[0x02] = block[0x0a];
274 - _temp[0x03] = block[0x07];
275 - _temp[0x04] = block[0x04];
276 - _temp[0x05] = block[0x01];
277 - _temp[0x06] = block[0x0e];
278 - _temp[0x07] = block[0x0b];
279 - _temp[0x08] = block[0x08];
280 - _temp[0x09] = block[0x05];
281 - _temp[0x0a] = block[0x02];
282 - _temp[0x0b] = block[0x0f];
283 - _temp[0x0c] = block[0x0c];
284 - _temp[0x0d] = block[0x09];
285 - _temp[0x0e] = block[0x06];
286 - _temp[0x0f] = block[0x03];
287 - memcpy( block, _temp, OAES_BLOCK_SIZE );
288 -
289 - return OAES_RET_SUCCESS;
290 -}
291 -
292 -static uint8_t oaes_gf_mul(uint8_t left, uint8_t right)
293 -{
294 - size_t _x, _y;
295 -
296 - _x = _y = left;
297 - _x &= 0x0f;
298 - _y &= 0xf0;
299 - _y >>= 4;
300 -
301 - switch( right )
302 - {
303 - case 0x02:
304 - return oaes_gf_mul_2[_y][_x];
305 - break;
306 - case 0x03:
307 - return oaes_gf_mul_3[_y][_x];
308 - break;
309 - case 0x09:
310 - return oaes_gf_mul_9[_y][_x];
311 - break;
312 - case 0x0b:
313 - return oaes_gf_mul_b[_y][_x];
314 - break;
315 - case 0x0d:
316 - return oaes_gf_mul_d[_y][_x];
317 - break;
318 - case 0x0e:
319 - return oaes_gf_mul_e[_y][_x];
320 - break;
321 - default:
322 - return left;
323 - break;
324 - }
325 -}
326 -
327 -static OAES_RET oaes_mix_cols( uint8_t word[OAES_COL_LEN] )
328 -{
329 - uint8_t _temp[OAES_COL_LEN];
330 -
331 - if( NULL == word )
332 - return OAES_RET_ARG1;
333 -
334 - _temp[0] = oaes_gf_mul(word[0], 0x02) ^ oaes_gf_mul( word[1], 0x03 ) ^
335 - word[2] ^ word[3];
336 - _temp[1] = word[0] ^ oaes_gf_mul( word[1], 0x02 ) ^
337 - oaes_gf_mul( word[2], 0x03 ) ^ word[3];
338 - _temp[2] = word[0] ^ word[1] ^
339 - oaes_gf_mul( word[2], 0x02 ) ^ oaes_gf_mul( word[3], 0x03 );
340 - _temp[3] = oaes_gf_mul( word[0], 0x03 ) ^ word[1] ^
341 - word[2] ^ oaes_gf_mul( word[3], 0x02 );
342 - memcpy( word, _temp, OAES_COL_LEN );
343 -
344 - return OAES_RET_SUCCESS;
345 -}
346 -
347 -static OAES_RET oaes_inv_mix_cols( uint8_t word[OAES_COL_LEN] )
348 -{
349 - uint8_t _temp[OAES_COL_LEN];
350 -
351 - if( NULL == word )
352 - return OAES_RET_ARG1;
353 -
354 - _temp[0] = oaes_gf_mul( word[0], 0x0e ) ^ oaes_gf_mul( word[1], 0x0b ) ^
355 - oaes_gf_mul( word[2], 0x0d ) ^ oaes_gf_mul( word[3], 0x09 );
356 - _temp[1] = oaes_gf_mul( word[0], 0x09 ) ^ oaes_gf_mul( word[1], 0x0e ) ^
357 - oaes_gf_mul( word[2], 0x0b ) ^ oaes_gf_mul( word[3], 0x0d );
358 - _temp[2] = oaes_gf_mul( word[0], 0x0d ) ^ oaes_gf_mul( word[1], 0x09 ) ^
359 - oaes_gf_mul( word[2], 0x0e ) ^ oaes_gf_mul( word[3], 0x0b );
360 - _temp[3] = oaes_gf_mul( word[0], 0x0b ) ^ oaes_gf_mul( word[1], 0x0d ) ^
361 - oaes_gf_mul( word[2], 0x09 ) ^ oaes_gf_mul( word[3], 0x0e );
362 - memcpy( word, _temp, OAES_COL_LEN );
363 -
364 - return OAES_RET_SUCCESS;
365 -}
366 -
367 -OAES_RET oaes_sprintf(
368 - char * buf, size_t * buf_len, const uint8_t * data, size_t data_len )
369 -{
370 - size_t _i, _buf_len_in;
371 - char _temp[4];
372 -
373 - if( NULL == buf_len )
374 - return OAES_RET_ARG2;
375 -
376 - _buf_len_in = *buf_len;
377 - *buf_len = data_len * 3 + data_len / OAES_BLOCK_SIZE + 1;
378 -
379 - if( NULL == buf )
380 - return OAES_RET_SUCCESS;
381 -
382 - if( *buf_len > _buf_len_in )
383 - return OAES_RET_BUF;
384 -
385 - if( NULL == data )
386 - return OAES_RET_ARG3;
387 -
388 - strcpy( buf, "" );
389 -
390 - for( _i = 0; _i < data_len; _i++ )
391 - {
392 - sprintf( _temp, "%02x ", data[_i] );
393 - strcat( buf, _temp );
394 - if( _i && 0 == ( _i + 1 ) % OAES_BLOCK_SIZE )
395 - strcat( buf, "\n" );
396 - }
397 -
398 - return OAES_RET_SUCCESS;
399 -}
400 -
401 -#ifdef OAES_HAVE_ISAAC
402 -static void oaes_get_seed( char buf[RANDSIZ + 1] )
403 -{
404 - #if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__)
405 - struct timeb timer;
406 - struct tm *gmTimer;
407 - char * _test = NULL;
408 -
409 - ftime (&timer);
410 - gmTimer = gmtime( &timer.time );
411 - _test = (char *) calloc( sizeof( char ), timer.millitm );
412 - sprintf( buf, "%04d%02d%02d%02d%02d%02d%03d%p%d",
413 - gmTimer->tm_year + 1900, gmTimer->tm_mon + 1, gmTimer->tm_mday,
414 - gmTimer->tm_hour, gmTimer->tm_min, gmTimer->tm_sec, timer.millitm,
415 - _test + timer.millitm, GETPID() );
416 - #else
417 - struct timeval timer;
418 - struct tm *gmTimer;
419 - char * _test = NULL;
420 -
421 - gettimeofday(&timer, NULL);
422 - gmTimer = gmtime( &timer.tv_sec );
423 - _test = (char *) calloc( sizeof( char ), timer.tv_usec/1000 );
424 - sprintf( buf, "%04d%02d%02d%02d%02d%02d%03d%p%d",
425 - gmTimer->tm_year + 1900, gmTimer->tm_mon + 1, gmTimer->tm_mday,
426 - gmTimer->tm_hour, gmTimer->tm_min, gmTimer->tm_sec, timer.tv_usec/1000,
427 - _test + timer.tv_usec/1000, GETPID() );
428 - #endif
429 -
430 - if( _test )
431 - free( _test );
432 -}
433 -#else
434 -static uint32_t oaes_get_seed(void)
435 -{
436 - #if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__ANDROID__) && !defined(__NetBSD__)
437 - struct timeb timer;
438 - struct tm *gmTimer;
439 - char * _test = NULL;
440 - uint32_t _ret = 0;
441 -
442 - ftime (&timer);
443 - gmTimer = gmtime( &timer.time );
444 - _test = (char *) calloc( sizeof( char ), timer.millitm );
445 - _ret = gmTimer->tm_year + 1900 + gmTimer->tm_mon + 1 + gmTimer->tm_mday +
446 - gmTimer->tm_hour + gmTimer->tm_min + gmTimer->tm_sec + timer.millitm +
447 - (uintptr_t) ( _test + timer.millitm ) + GETPID();
448 - #else
449 - struct timeval timer;
450 - struct tm *gmTimer;
451 - char * _test = NULL;
452 - uint32_t _ret = 0;
453 -
454 - gettimeofday(&timer, NULL);
455 - gmTimer = gmtime( &timer.tv_sec );
456 - _test = (char *) calloc( sizeof( char ), timer.tv_usec/1000 );
457 - _ret = gmTimer->tm_year + 1900 + gmTimer->tm_mon + 1 + gmTimer->tm_mday +
458 - gmTimer->tm_hour + gmTimer->tm_min + gmTimer->tm_sec + timer.tv_usec/1000 +
459 - (uintptr_t) ( _test + timer.tv_usec/1000 ) + GETPID();
460 - #endif
461 -
462 - if( _test )
463 - free( _test );
464 -
465 - return _ret;
466 -}
467 -#endif // OAES_HAVE_ISAAC
468 -
469 static OAES_RET oaes_key_destroy( oaes_key ** key )
470 {
471 if( NULL == *key )
472 @@ -625,220 +199,6 @@ static OAES_RET oaes_key_expand( OAES_CTX * ctx )
473 return OAES_RET_SUCCESS;
474 }
475
476 -static OAES_RET oaes_key_gen( OAES_CTX * ctx, size_t key_size )
477 -{
478 - size_t _i;
479 - oaes_key * _key = NULL;
480 - oaes_ctx * _ctx = (oaes_ctx *) ctx;
481 - OAES_RET _rc = OAES_RET_SUCCESS;
482 -
483 - if( NULL == _ctx )
484 - return OAES_RET_ARG1;
485 -
486 - _key = (oaes_key *) calloc( sizeof( oaes_key ), 1 );
487 -
488 - if( NULL == _key )
489 - return OAES_RET_MEM;
490 -
491 - if( _ctx->key )
492 - oaes_key_destroy( &(_ctx->key) );
493 -
494 - _key->data_len = key_size;
495 - _key->data = (uint8_t *) calloc( key_size, sizeof( uint8_t ));
496 -
497 - if( NULL == _key->data )
498 - {
499 - free( _key );
500 - return OAES_RET_MEM;
501 - }
502 -
503 - for( _i = 0; _i < key_size; _i++ )
504 -#ifdef OAES_HAVE_ISAAC
505 - _key->data[_i] = (uint8_t) rand( _ctx->rctx );
506 -#else
507 - _key->data[_i] = (uint8_t) rand();
508 -#endif // OAES_HAVE_ISAAC
509 -
510 - _ctx->key = _key;
511 - _rc = _rc || oaes_key_expand( ctx );
512 -
513 - if( _rc != OAES_RET_SUCCESS )
514 - {
515 - oaes_key_destroy( &(_ctx->key) );
516 - return _rc;
517 - }
518 -
519 - return OAES_RET_SUCCESS;
520 -}
521 -
522 -OAES_RET oaes_key_gen_128( OAES_CTX * ctx )
523 -{
524 - return oaes_key_gen( ctx, 16 );
525 -}
526 -
527 -OAES_RET oaes_key_gen_192( OAES_CTX * ctx )
528 -{
529 - return oaes_key_gen( ctx, 24 );
530 -}
531 -
532 -OAES_RET oaes_key_gen_256( OAES_CTX * ctx )
533 -{
534 - return oaes_key_gen( ctx, 32 );
535 -}
536 -
537 -OAES_RET oaes_key_export( OAES_CTX * ctx,
538 - uint8_t * data, size_t * data_len )
539 -{
540 - size_t _data_len_in;
541 - oaes_ctx * _ctx = (oaes_ctx *) ctx;
542 -
543 - if( NULL == _ctx )
544 - return OAES_RET_ARG1;
545 -
546 - if( NULL == _ctx->key )
547 - return OAES_RET_NOKEY;
548 -
549 - if( NULL == data_len )
550 - return OAES_RET_ARG3;
551 -
552 - _data_len_in = *data_len;
553 - // data + header
554 - *data_len = _ctx->key->data_len + OAES_BLOCK_SIZE;
555 -
556 - if( NULL == data )
557 - return OAES_RET_SUCCESS;
558 -
559 - if( _data_len_in < *data_len )
560 - return OAES_RET_BUF;
561 -
562 - // header
563 - memcpy( data, oaes_header, OAES_BLOCK_SIZE );
564 - data[5] = 0x01;
565 - data[7] = _ctx->key->data_len;
566 - memcpy( data + OAES_BLOCK_SIZE, _ctx->key->data, _ctx->key->data_len );
567 -
568 - return OAES_RET_SUCCESS;
569 -}
570 -
571 -OAES_RET oaes_key_export_data( OAES_CTX * ctx,
572 - uint8_t * data, size_t * data_len )
573 -{
574 - size_t _data_len_in;
575 - oaes_ctx * _ctx = (oaes_ctx *) ctx;
576 -
577 - if( NULL == _ctx )
578 - return OAES_RET_ARG1;
579 -
580 - if( NULL == _ctx->key )
581 - return OAES_RET_NOKEY;
582 -
583 - if( NULL == data_len )
584 - return OAES_RET_ARG3;
585 -
586 - _data_len_in = *data_len;
587 - *data_len = _ctx->key->data_len;
588 -
589 - if( NULL == data )
590 - return OAES_RET_SUCCESS;
591 -
592 - if( _data_len_in < *data_len )
593 - return OAES_RET_BUF;
594 -
595 - memcpy( data, _ctx->key->data, *data_len );
596 -
597 - return OAES_RET_SUCCESS;
598 -}
599 -
600 -OAES_RET oaes_key_import( OAES_CTX * ctx,
601 - const uint8_t * data, size_t data_len )
602 -{
603 - oaes_ctx * _ctx = (oaes_ctx *) ctx;
604 - OAES_RET _rc = OAES_RET_SUCCESS;
605 - int _key_length;
606 -
607 - if( NULL == _ctx )
608 - return OAES_RET_ARG1;
609 -
610 - if( NULL == data )
611 - return OAES_RET_ARG2;
612 -
613 - switch( data_len )
614 - {
615 - case 16 + OAES_BLOCK_SIZE:
616 - case 24 + OAES_BLOCK_SIZE:
617 - case 32 + OAES_BLOCK_SIZE:
618 - break;
619 - default:
620 - return OAES_RET_ARG3;
621 - }
622 -
623 - // header
624 - if( 0 != memcmp( data, oaes_header, 4 ) )
625 - return OAES_RET_HEADER;
626 -
627 - // header version
628 - switch( data[4] )
629 - {
630 - case 0x01:
631 - break;
632 - default:
633 - return OAES_RET_HEADER;
634 - }
635 -
636 - // header type
637 - switch( data[5] )
638 - {
639 - case 0x01:
640 - break;
641 - default:
642 - return OAES_RET_HEADER;
643 - }
644 -
645 - // options
646 - _key_length = data[7];
647 - switch( _key_length )
648 - {
649 - case 16:
650 - case 24:
651 - case 32:
652 - break;
653 - default:
654 - return OAES_RET_HEADER;
655 - }
656 -
657 - if( (int)data_len != _key_length + OAES_BLOCK_SIZE )
658 - return OAES_RET_ARG3;
659 -
660 - if( _ctx->key )
661 - oaes_key_destroy( &(_ctx->key) );
662 -
663 - _ctx->key = (oaes_key *) calloc( sizeof( oaes_key ), 1 );
664 -
665 - if( NULL == _ctx->key )
666 - return OAES_RET_MEM;
667 -
668 - _ctx->key->data_len = _key_length;
669 - _ctx->key->data = (uint8_t *)
670 - calloc( _key_length, sizeof( uint8_t ));
671 -
672 - if( NULL == _ctx->key->data )
673 - {
674 - oaes_key_destroy( &(_ctx->key) );
675 - return OAES_RET_MEM;
676 - }
677 -
678 - memcpy( _ctx->key->data, data + OAES_BLOCK_SIZE, _key_length );
679 - _rc = _rc || oaes_key_expand( ctx );
680 -
681 - if( _rc != OAES_RET_SUCCESS )
682 - {
683 - oaes_key_destroy( &(_ctx->key) );
684 - return _rc;
685 - }
686 -
687 - return OAES_RET_SUCCESS;
688 -}
689 -
690 OAES_RET oaes_key_import_data( OAES_CTX * ctx,
691 const uint8_t * data, size_t data_len )
692 {
693 @@ -898,35 +258,7 @@ OAES_CTX * oaes_alloc(void)
694 if( NULL == _ctx )
695 return NULL;
696
697 -#ifdef OAES_HAVE_ISAAC
698 - {
699 - ub4 _i = 0;
700 - char _seed[RANDSIZ + 1];
701 -
702 - _ctx->rctx = (randctx *) calloc( sizeof( randctx ), 1 );
703 -
704 - if( NULL == _ctx->rctx )
705 - {
706 - free( _ctx );
707 - return NULL;
708 - }
709 -
710 - oaes_get_seed( _seed );
711 - memset( _ctx->rctx->randrsl, 0, RANDSIZ );
712 - memcpy( _ctx->rctx->randrsl, _seed, RANDSIZ );
713 - randinit( _ctx->rctx, TRUE);
714 - }
715 -#else
716 - srand( oaes_get_seed() );
717 -#endif // OAES_HAVE_ISAAC
718 -
719 _ctx->key = NULL;
720 - oaes_set_option( _ctx, OAES_OPTION_CBC, NULL );
721 -
722 -#ifdef OAES_DEBUG
723 - _ctx->step_cb = NULL;
724 - oaes_set_option( _ctx, OAES_OPTION_STEP_OFF, NULL );
725 -#endif // OAES_DEBUG
726
727 return (OAES_CTX *) _ctx;
728 }
729 @@ -944,564 +276,8 @@ OAES_RET oaes_free( OAES_CTX ** ctx )
730 if( (*_ctx)->key )
731 oaes_key_destroy( &((*_ctx)->key) );
732
733 -#ifdef OAES_HAVE_ISAAC
734 - if( (*_ctx)->rctx )
735 - {
736 - free( (*_ctx)->rctx );
737 - (*_ctx)->rctx = NULL;
738 - }
739 -#endif // OAES_HAVE_ISAAC
740 -
741 free( *_ctx );
742 *_ctx = NULL;
743
744 return OAES_RET_SUCCESS;
745 }
746 -
747 -OAES_RET oaes_set_option( OAES_CTX * ctx,
748 - OAES_OPTION option, const void * value )
749 -{
750 - size_t _i;
751 - oaes_ctx * _ctx = (oaes_ctx *) ctx;
752 -
753 - if( NULL == _ctx )
754 - return OAES_RET_ARG1;
755 -
756 - switch( option )
757 - {
758 - case OAES_OPTION_ECB:
759 - _ctx->options &= ~OAES_OPTION_CBC;
760 - memset( _ctx->iv, 0, OAES_BLOCK_SIZE );
761 - break;
762 -
763 - case OAES_OPTION_CBC:
764 - _ctx->options &= ~OAES_OPTION_ECB;
765 - if( value )
766 - memcpy( _ctx->iv, value, OAES_BLOCK_SIZE );
767 - else
768 - {
769 - for( _i = 0; _i < OAES_BLOCK_SIZE; _i++ )
770 -#ifdef OAES_HAVE_ISAAC
771 - _ctx->iv[_i] = (uint8_t) rand( _ctx->rctx );
772 -#else
773 - _ctx->iv[_i] = (uint8_t) rand();
774 -#endif // OAES_HAVE_ISAAC
775 - }
776 - break;
777 -
778 -#ifdef OAES_DEBUG
779 -
780 - case OAES_OPTION_STEP_ON:
781 - if( value )
782 - {
783 - _ctx->options &= ~OAES_OPTION_STEP_OFF;
784 - _ctx->step_cb = value;
785 - }
786 - else
787 - {
788 - _ctx->options &= ~OAES_OPTION_STEP_ON;
789 - _ctx->options |= OAES_OPTION_STEP_OFF;
790 - _ctx->step_cb = NULL;
791 - return OAES_RET_ARG3;
792 - }
793 - break;
794 -
795 - case OAES_OPTION_STEP_OFF:
796 - _ctx->options &= ~OAES_OPTION_STEP_ON;
797 - _ctx->step_cb = NULL;
798 - break;
799 -
800 -#endif // OAES_DEBUG
801 -
802 - default:
803 - return OAES_RET_ARG2;
804 - }
805 -
806 - _ctx->options |= option;
807 -
808 - return OAES_RET_SUCCESS;
809 -}
810 -
811 -static OAES_RET oaes_encrypt_block(
812 - OAES_CTX * ctx, uint8_t * c, size_t c_len )
813 -{
814 - size_t _i, _j;
815 - oaes_ctx * _ctx = (oaes_ctx *) ctx;
816 -
817 - if( NULL == _ctx )
818 - return OAES_RET_ARG1;
819 -
820 - if( NULL == c )
821 - return OAES_RET_ARG2;
822 -
823 - if( c_len != OAES_BLOCK_SIZE )
824 - return OAES_RET_ARG3;
825 -
826 - if( NULL == _ctx->key )
827 - return OAES_RET_NOKEY;
828 -
829 -#ifdef OAES_DEBUG
830 - if( _ctx->step_cb )
831 - _ctx->step_cb( c, "input", 1, NULL );
832 -#endif // OAES_DEBUG
833 -
834 - // AddRoundKey(State, K0)
835 - for( _i = 0; _i < c_len; _i++ )
836 - c[_i] = c[_i] ^ _ctx->key->exp_data[_i];
837 -
838 -#ifdef OAES_DEBUG
839 - if( _ctx->step_cb )
840 - {
841 - _ctx->step_cb( _ctx->key->exp_data, "k_sch", 1, NULL );
842 - _ctx->step_cb( c, "k_add", 1, NULL );
843 - }
844 -#endif // OAES_DEBUG
845 -
846 - // for round = 1 step 1 to Nr–1
847 - for( _i = 1; _i < _ctx->key->num_keys - 1; _i++ )
848 - {
849 - // SubBytes(state)
850 - for( _j = 0; _j < c_len; _j++ )
851 - oaes_sub_byte( c + _j );
852 -
853 -#ifdef OAES_DEBUG
854 - if( _ctx->step_cb )
855 - _ctx->step_cb( c, "s_box", _i, NULL );
856 -#endif // OAES_DEBUG
857 -
858 - // ShiftRows(state)
859 - oaes_shift_rows( c );
860 -
861 -#ifdef OAES_DEBUG
862 - if( _ctx->step_cb )
863 - _ctx->step_cb( c, "s_row", _i, NULL );
864 -#endif // OAES_DEBUG
865 -
866 - // MixColumns(state)
867 - oaes_mix_cols( c );
868 - oaes_mix_cols( c + 4 );
869 - oaes_mix_cols( c + 8 );
870 - oaes_mix_cols( c + 12 );
871 -
872 -#ifdef OAES_DEBUG
873 - if( _ctx->step_cb )
874 - _ctx->step_cb( c, "m_col", _i, NULL );
875 -#endif // OAES_DEBUG
876 -
877 - // AddRoundKey(state, w[round*Nb, (round+1)*Nb-1])
878 - for( _j = 0; _j < c_len; _j++ )
879 - c[_j] = c[_j] ^
880 - _ctx->key->exp_data[_i * OAES_RKEY_LEN * OAES_COL_LEN + _j];
881 -
882 -#ifdef OAES_DEBUG
883 - if( _ctx->step_cb )
884 - {
885 - _ctx->step_cb( _ctx->key->exp_data + _i * OAES_RKEY_LEN * OAES_COL_LEN,
886 - "k_sch", _i, NULL );
887 - _ctx->step_cb( c, "k_add", _i, NULL );
888 - }
889 -#endif // OAES_DEBUG
890 -
891 - }
892 -
893 - // SubBytes(state)
894 - for( _i = 0; _i < c_len; _i++ )
895 - oaes_sub_byte( c + _i );
896 -
897 -#ifdef OAES_DEBUG
898 - if( _ctx->step_cb )
899 - _ctx->step_cb( c, "s_box", _ctx->key->num_keys - 1, NULL );
900 -#endif // OAES_DEBUG
901 -
902 - // ShiftRows(state)
903 - oaes_shift_rows( c );
904 -
905 -#ifdef OAES_DEBUG
906 - if( _ctx->step_cb )
907 - _ctx->step_cb( c, "s_row", _ctx->key->num_keys - 1, NULL );
908 -#endif // OAES_DEBUG
909 -
910 - // AddRoundKey(state, w[Nr*Nb, (Nr+1)*Nb-1])
911 - for( _i = 0; _i < c_len; _i++ )
912 - c[_i] = c[_i] ^ _ctx->key->exp_data[
913 - ( _ctx->key->num_keys - 1 ) * OAES_RKEY_LEN * OAES_COL_LEN + _i ];
914 -
915 -#ifdef OAES_DEBUG
916 - if( _ctx->step_cb )
917 - {
918 - _ctx->step_cb( _ctx->key->exp_data +
919 - ( _ctx->key->num_keys - 1 ) * OAES_RKEY_LEN * OAES_COL_LEN,
920 - "k_sch", _ctx->key->num_keys - 1, NULL );
921 - _ctx->step_cb( c, "output", _ctx->key->num_keys - 1, NULL );
922 - }
923 -#endif // OAES_DEBUG
924 -
925 - return OAES_RET_SUCCESS;
926 -}
927 -
928 -static OAES_RET oaes_decrypt_block(
929 - OAES_CTX * ctx, uint8_t * c, size_t c_len )
930 -{
931 - size_t _i, _j;
932 - oaes_ctx * _ctx = (oaes_ctx *) ctx;
933 -
934 - if( NULL == _ctx )
935 - return OAES_RET_ARG1;
936 -
937 - if( NULL == c )
938 - return OAES_RET_ARG2;
939 -
940 - if( c_len != OAES_BLOCK_SIZE )
941 - return OAES_RET_ARG3;
942 -
943 - if( NULL == _ctx->key )
944 - return OAES_RET_NOKEY;
945 -
946 -#ifdef OAES_DEBUG
947 - if( _ctx->step_cb )
948 - _ctx->step_cb( c, "iinput", _ctx->key->num_keys - 1, NULL );
949 -#endif // OAES_DEBUG
950 -
951 - // AddRoundKey(state, w[Nr*Nb, (Nr+1)*Nb-1])
952 - for( _i = 0; _i < c_len; _i++ )
953 - c[_i] = c[_i] ^ _ctx->key->exp_data[
954 - ( _ctx->key->num_keys - 1 ) * OAES_RKEY_LEN * OAES_COL_LEN + _i ];
955 -
956 -#ifdef OAES_DEBUG
957 - if( _ctx->step_cb )
958 - {
959 - _ctx->step_cb( _ctx->key->exp_data +
960 - ( _ctx->key->num_keys - 1 ) * OAES_RKEY_LEN * OAES_COL_LEN,
961 - "ik_sch", _ctx->key->num_keys - 1, NULL );
962 - _ctx->step_cb( c, "ik_add", _ctx->key->num_keys - 1, NULL );
963 - }
964 -#endif // OAES_DEBUG
965 -
966 - for( _i = _ctx->key->num_keys - 2; _i > 0; _i-- )
967 - {
968 - // InvShiftRows(state)
969 - oaes_inv_shift_rows( c );
970 -
971 -#ifdef OAES_DEBUG
972 - if( _ctx->step_cb )
973 - _ctx->step_cb( c, "is_row", _i, NULL );
974 -#endif // OAES_DEBUG
975 -
976 - // InvSubBytes(state)
977 - for( _j = 0; _j < c_len; _j++ )
978 - oaes_inv_sub_byte( c + _j );
979 -
980 -#ifdef OAES_DEBUG
981 - if( _ctx->step_cb )
982 - _ctx->step_cb( c, "is_box", _i, NULL );
983 -#endif // OAES_DEBUG
984 -
985 - // AddRoundKey(state, w[round*Nb, (round+1)*Nb-1])
986 - for( _j = 0; _j < c_len; _j++ )
987 - c[_j] = c[_j] ^
988 - _ctx->key->exp_data[_i * OAES_RKEY_LEN * OAES_COL_LEN + _j];
989 -
990 -#ifdef OAES_DEBUG
991 - if( _ctx->step_cb )
992 - {
993 - _ctx->step_cb( _ctx->key->exp_data + _i * OAES_RKEY_LEN * OAES_COL_LEN,
994 - "ik_sch", _i, NULL );
995 - _ctx->step_cb( c, "ik_add", _i, NULL );
996 - }
997 -#endif // OAES_DEBUG
998 -
999 - // InvMixColums(state)
1000 - oaes_inv_mix_cols( c );
1001 - oaes_inv_mix_cols( c + 4 );
1002 - oaes_inv_mix_cols( c + 8 );
1003 - oaes_inv_mix_cols( c + 12 );
1004 -
1005 -#ifdef OAES_DEBUG
1006 - if( _ctx->step_cb )
1007 - _ctx->step_cb( c, "im_col", _i, NULL );
1008 -#endif // OAES_DEBUG
1009 -
1010 - }
1011 -
1012 - // InvShiftRows(state)
1013 - oaes_inv_shift_rows( c );
1014 -
1015 -#ifdef OAES_DEBUG
1016 - if( _ctx->step_cb )
1017 - _ctx->step_cb( c, "is_row", 1, NULL );
1018 -#endif // OAES_DEBUG
1019 -
1020 - // InvSubBytes(state)
1021 - for( _i = 0; _i < c_len; _i++ )
1022 - oaes_inv_sub_byte( c + _i );
1023 -
1024 -#ifdef OAES_DEBUG
1025 - if( _ctx->step_cb )
1026 - _ctx->step_cb( c, "is_box", 1, NULL );
1027 -#endif // OAES_DEBUG
1028 -
1029 - // AddRoundKey(state, w[0, Nb-1])
1030 - for( _i = 0; _i < c_len; _i++ )
1031 - c[_i] = c[_i] ^ _ctx->key->exp_data[_i];
1032 -
1033 -#ifdef OAES_DEBUG
1034 - if( _ctx->step_cb )
1035 - {
1036 - _ctx->step_cb( _ctx->key->exp_data, "ik_sch", 1, NULL );
1037 - _ctx->step_cb( c, "ioutput", 1, NULL );
1038 - }
1039 -#endif // OAES_DEBUG
1040 -
1041 - return OAES_RET_SUCCESS;
1042 -}
1043 -
1044 -OAES_RET oaes_encrypt( OAES_CTX * ctx,
1045 - const uint8_t * m, size_t m_len, uint8_t * c, size_t * c_len )
1046 -{
1047 - size_t _i, _j, _c_len_in, _c_data_len;
1048 - size_t _pad_len = m_len % OAES_BLOCK_SIZE == 0 ?
1049 - 0 : OAES_BLOCK_SIZE - m_len % OAES_BLOCK_SIZE;
1050 - oaes_ctx * _ctx = (oaes_ctx *) ctx;
1051 - OAES_RET _rc = OAES_RET_SUCCESS;
1052 - uint8_t _flags = _pad_len ? OAES_FLAG_PAD : 0;
1053 -
1054 - if( NULL == _ctx )
1055 - return OAES_RET_ARG1;
1056 -
1057 - if( NULL == m )
1058 - return OAES_RET_ARG2;
1059 -
1060 - if( NULL == c_len )
1061 - return OAES_RET_ARG5;
1062 -
1063 - _c_len_in = *c_len;
1064 - // data + pad
1065 - _c_data_len = m_len + _pad_len;
1066 - // header + iv + data + pad
1067 - *c_len = 2 * OAES_BLOCK_SIZE + m_len + _pad_len;
1068 -
1069 - if( NULL == c )
1070 - return OAES_RET_SUCCESS;
1071 -
1072 - if( _c_len_in < *c_len )
1073 - return OAES_RET_BUF;
1074 -
1075 - if( NULL == _ctx->key )
1076 - return OAES_RET_NOKEY;
1077 -
1078 - // header
1079 - memcpy(c, oaes_header, OAES_BLOCK_SIZE );
1080 - memcpy(c + 6, &_ctx->options, sizeof(_ctx->options));
1081 - memcpy(c + 8, &_flags, sizeof(_flags));
1082 - // iv
1083 - memcpy(c + OAES_BLOCK_SIZE, _ctx->iv, OAES_BLOCK_SIZE );
1084 - // data
1085 - memcpy(c + 2 * OAES_BLOCK_SIZE, m, m_len );
1086 -
1087 - for( _i = 0; _i < _c_data_len; _i += OAES_BLOCK_SIZE )
1088 - {
1089 - uint8_t _block[OAES_BLOCK_SIZE];
1090 - size_t _block_size = min( m_len - _i, OAES_BLOCK_SIZE );
1091 -
1092 - memcpy( _block, c + 2 * OAES_BLOCK_SIZE + _i, _block_size );
1093 -
1094 - // insert pad
1095 - for( _j = 0; _j < OAES_BLOCK_SIZE - _block_size; _j++ )
1096 - _block[ _block_size + _j ] = _j + 1;
1097 -
1098 - // CBC
1099 - if( _ctx->options & OAES_OPTION_CBC )
1100 - {
1101 - for( _j = 0; _j < OAES_BLOCK_SIZE; _j++ )
1102 - _block[_j] = _block[_j] ^ _ctx->iv[_j];
1103 - }
1104 -
1105 - _rc = _rc ||
1106 - oaes_encrypt_block( ctx, _block, OAES_BLOCK_SIZE );
1107 - memcpy( c + 2 * OAES_BLOCK_SIZE + _i, _block, OAES_BLOCK_SIZE );
1108 -
1109 - if( _ctx->options & OAES_OPTION_CBC )
1110 - memcpy( _ctx->iv, _block, OAES_BLOCK_SIZE );
1111 - }
1112 -
1113 - return _rc;
1114 -}
1115 -
1116 -OAES_RET oaes_decrypt( OAES_CTX * ctx,
1117 - const uint8_t * c, size_t c_len, uint8_t * m, size_t * m_len )
1118 -{
1119 - size_t _i, _j, _m_len_in;
1120 - oaes_ctx * _ctx = (oaes_ctx *) ctx;
1121 - OAES_RET _rc = OAES_RET_SUCCESS;
1122 - uint8_t _iv[OAES_BLOCK_SIZE];
1123 - uint8_t _flags;
1124 - OAES_OPTION _options;
1125 -
1126 - if( NULL == ctx )
1127 - return OAES_RET_ARG1;
1128 -
1129 - if( NULL == c )
1130 - return OAES_RET_ARG2;
1131 -
1132 - if( c_len % OAES_BLOCK_SIZE )
1133 - return OAES_RET_ARG3;
1134 -
1135 - if( NULL == m_len )
1136 - return OAES_RET_ARG5;
1137 -
1138 - _m_len_in = *m_len;
1139 - *m_len = c_len - 2 * OAES_BLOCK_SIZE;
1140 -
1141 - if( NULL == m )
1142 - return OAES_RET_SUCCESS;
1143 -
1144 - if( _m_len_in < *m_len )
1145 - return OAES_RET_BUF;
1146 -
1147 - if( NULL == _ctx->key )
1148 - return OAES_RET_NOKEY;
1149 -
1150 - // header
1151 - if( 0 != memcmp( c, oaes_header, 4 ) )
1152 - return OAES_RET_HEADER;
1153 -
1154 - // header version
1155 - switch( c[4] )
1156 - {
1157 - case 0x01:
1158 - break;
1159 - default:
1160 - return OAES_RET_HEADER;
1161 - }
1162 -
1163 - // header type
1164 - switch( c[5] )
1165 - {
1166 - case 0x02:
1167 - break;
1168 - default:
1169 - return OAES_RET_HEADER;
1170 - }
1171 -
1172 - // options
1173 - memcpy(&_options, c + 6, sizeof(_options));
1174 - // validate that all options are valid
1175 - if( _options & ~(
1176 - OAES_OPTION_ECB
1177 - | OAES_OPTION_CBC
1178 -#ifdef OAES_DEBUG
1179 - | OAES_OPTION_STEP_ON
1180 - | OAES_OPTION_STEP_OFF
1181 -#endif // OAES_DEBUG
1182 - ) )
1183 - return OAES_RET_HEADER;
1184 - if( ( _options & OAES_OPTION_ECB ) &&
1185 - ( _options & OAES_OPTION_CBC ) )
1186 - return OAES_RET_HEADER;
1187 - if( _options == OAES_OPTION_NONE )
1188 - return OAES_RET_HEADER;
1189 -
1190 - // flags
1191 - memcpy(&_flags, c + 8, sizeof(_flags));
1192 - // validate that all flags are valid
1193 - if( _flags & ~(
1194 - OAES_FLAG_PAD
1195 - ) )
1196 - return OAES_RET_HEADER;
1197 -
1198 - // iv
1199 - memcpy( _iv, c + OAES_BLOCK_SIZE, OAES_BLOCK_SIZE);
1200 - // data + pad
1201 - memcpy( m, c + 2 * OAES_BLOCK_SIZE, *m_len );
1202 -
1203 - for( _i = 0; _i < *m_len; _i += OAES_BLOCK_SIZE )
1204 - {
1205 - if( ( _options & OAES_OPTION_CBC ) && _i > 0 )
1206 - memcpy( _iv, c + OAES_BLOCK_SIZE + _i, OAES_BLOCK_SIZE );
1207 -
1208 - _rc = _rc ||
1209 - oaes_decrypt_block( ctx, m + _i, min( *m_len - _i, OAES_BLOCK_SIZE ) );
1210 -
1211 - // CBC
1212 - if( _options & OAES_OPTION_CBC )
1213 - {
1214 - for( _j = 0; _j < OAES_BLOCK_SIZE; _j++ )
1215 - m[ _i + _j ] = m[ _i + _j ] ^ _iv[_j];
1216 - }
1217 - }
1218 -
1219 - // remove pad
1220 - if( _flags & OAES_FLAG_PAD )
1221 - {
1222 - int _is_pad = 1;
1223 - size_t _temp = (size_t) m[*m_len - 1];
1224 -
1225 - if( _temp <= 0x00 || _temp > 0x0f )
1226 - return OAES_RET_HEADER;
1227 - for( _i = 0; _i < _temp; _i++ )
1228 - if( m[*m_len - 1 - _i] != _temp - _i )
1229 - _is_pad = 0;
1230 - if( _is_pad )
1231 - {
1232 - memset( m + *m_len - _temp, 0, _temp );
1233 - *m_len -= _temp;
1234 - }
1235 - else
1236 - return OAES_RET_HEADER;
1237 - }
1238 -
1239 - return OAES_RET_SUCCESS;
1240 -}
1241 -
1242 -
1243 -OAES_API OAES_RET oaes_encryption_round( const uint8_t * key, uint8_t * c )
1244 -{
1245 - size_t _i;
1246 -
1247 - if( NULL == key )
1248 - return OAES_RET_ARG1;
1249 -
1250 - if( NULL == c )
1251 - return OAES_RET_ARG2;
1252 -
1253 - // SubBytes(state)
1254 - for( _i = 0; _i < OAES_BLOCK_SIZE; _i++ )
1255 - oaes_sub_byte( c + _i );
1256 -
1257 - // ShiftRows(state)
1258 - oaes_shift_rows( c );
1259 -
1260 - // MixColumns(state)
1261 - oaes_mix_cols( c );
1262 - oaes_mix_cols( c + 4 );
1263 - oaes_mix_cols( c + 8 );
1264 - oaes_mix_cols( c + 12 );
1265 -
1266 - // AddRoundKey(State, key)
1267 - for( _i = 0; _i < OAES_BLOCK_SIZE; _i++ )
1268 - c[_i] ^= key[_i];
1269 -
1270 - return OAES_RET_SUCCESS;
1271 -}
1272 -
1273 -OAES_API OAES_RET oaes_pseudo_encrypt_ecb( OAES_CTX * ctx, uint8_t * c )
1274 -{
1275 - size_t _i;
1276 - oaes_ctx * _ctx = (oaes_ctx *) ctx;
1277 -
1278 - if( NULL == _ctx )
1279 - return OAES_RET_ARG1;
1280 -
1281 - if( NULL == c )
1282 - return OAES_RET_ARG2;
1283 -
1284 - if( NULL == _ctx->key )
1285 - return OAES_RET_NOKEY;
1286 -
1287 - for ( _i = 0; _i < 10; ++_i )
1288 - {
1289 - oaes_encryption_round( &_ctx->key->exp_data[_i * OAES_RKEY_LEN * OAES_COL_LEN], c );
1290 - }
1291 -
1292 - return OAES_RET_SUCCESS;
1293 -}