Line 0
Link Here
|
|
|
1 |
--- src/engine/openssl/ossl_bc.cpp.orig 2018-10-15 00:16:53 UTC |
2 |
+++ src/engine/openssl/ossl_bc.cpp |
3 |
@@ -40,7 +40,7 @@ class EVP_BlockCipher : public BlockCipher |
4 |
size_t block_sz; |
5 |
Key_Length_Specification cipher_key_spec; |
6 |
std::string cipher_name; |
7 |
- mutable EVP_CIPHER_CTX encrypt, decrypt; |
8 |
+ mutable EVP_CIPHER_CTX *encrypt, *decrypt; |
9 |
}; |
10 |
|
11 |
/* |
12 |
@@ -55,14 +55,14 @@ EVP_BlockCipher::EVP_BlockCipher(const EVP_CIPHER* alg |
13 |
if(EVP_CIPHER_mode(algo) != EVP_CIPH_ECB_MODE) |
14 |
throw Invalid_Argument("EVP_BlockCipher: Non-ECB EVP was passed in"); |
15 |
|
16 |
- EVP_CIPHER_CTX_init(&encrypt); |
17 |
- EVP_CIPHER_CTX_init(&decrypt); |
18 |
+ EVP_CIPHER_CTX_init(encrypt); |
19 |
+ EVP_CIPHER_CTX_init(decrypt); |
20 |
|
21 |
- EVP_EncryptInit_ex(&encrypt, algo, 0, 0, 0); |
22 |
- EVP_DecryptInit_ex(&decrypt, algo, 0, 0, 0); |
23 |
+ EVP_EncryptInit_ex(encrypt, algo, 0, 0, 0); |
24 |
+ EVP_DecryptInit_ex(decrypt, algo, 0, 0, 0); |
25 |
|
26 |
- EVP_CIPHER_CTX_set_padding(&encrypt, 0); |
27 |
- EVP_CIPHER_CTX_set_padding(&decrypt, 0); |
28 |
+ EVP_CIPHER_CTX_set_padding(encrypt, 0); |
29 |
+ EVP_CIPHER_CTX_set_padding(decrypt, 0); |
30 |
} |
31 |
|
32 |
/* |
33 |
@@ -79,14 +79,14 @@ EVP_BlockCipher::EVP_BlockCipher(const EVP_CIPHER* alg |
34 |
if(EVP_CIPHER_mode(algo) != EVP_CIPH_ECB_MODE) |
35 |
throw Invalid_Argument("EVP_BlockCipher: Non-ECB EVP was passed in"); |
36 |
|
37 |
- EVP_CIPHER_CTX_init(&encrypt); |
38 |
- EVP_CIPHER_CTX_init(&decrypt); |
39 |
+ EVP_CIPHER_CTX_init(encrypt); |
40 |
+ EVP_CIPHER_CTX_init(decrypt); |
41 |
|
42 |
- EVP_EncryptInit_ex(&encrypt, algo, 0, 0, 0); |
43 |
- EVP_DecryptInit_ex(&decrypt, algo, 0, 0, 0); |
44 |
+ EVP_EncryptInit_ex(encrypt, algo, 0, 0, 0); |
45 |
+ EVP_DecryptInit_ex(decrypt, algo, 0, 0, 0); |
46 |
|
47 |
- EVP_CIPHER_CTX_set_padding(&encrypt, 0); |
48 |
- EVP_CIPHER_CTX_set_padding(&decrypt, 0); |
49 |
+ EVP_CIPHER_CTX_set_padding(encrypt, 0); |
50 |
+ EVP_CIPHER_CTX_set_padding(decrypt, 0); |
51 |
} |
52 |
|
53 |
/* |
54 |
@@ -94,8 +94,8 @@ EVP_BlockCipher::EVP_BlockCipher(const EVP_CIPHER* alg |
55 |
*/ |
56 |
EVP_BlockCipher::~EVP_BlockCipher() |
57 |
{ |
58 |
- EVP_CIPHER_CTX_cleanup(&encrypt); |
59 |
- EVP_CIPHER_CTX_cleanup(&decrypt); |
60 |
+ EVP_CIPHER_CTX_cleanup(encrypt); |
61 |
+ EVP_CIPHER_CTX_cleanup(decrypt); |
62 |
} |
63 |
|
64 |
/* |
65 |
@@ -105,7 +105,7 @@ void EVP_BlockCipher::encrypt_n(const byte in[], byte |
66 |
size_t blocks) const |
67 |
{ |
68 |
int out_len = 0; |
69 |
- EVP_EncryptUpdate(&encrypt, out, &out_len, in, blocks * block_sz); |
70 |
+ EVP_EncryptUpdate(encrypt, out, &out_len, in, blocks * block_sz); |
71 |
} |
72 |
|
73 |
/* |
74 |
@@ -115,7 +115,7 @@ void EVP_BlockCipher::decrypt_n(const byte in[], byte |
75 |
size_t blocks) const |
76 |
{ |
77 |
int out_len = 0; |
78 |
- EVP_DecryptUpdate(&decrypt, out, &out_len, in, blocks * block_sz); |
79 |
+ EVP_DecryptUpdate(decrypt, out, &out_len, in, blocks * block_sz); |
80 |
} |
81 |
|
82 |
/* |
83 |
@@ -130,19 +130,19 @@ void EVP_BlockCipher::key_schedule(const byte key[], s |
84 |
full_key += std::make_pair(key, 8); |
85 |
} |
86 |
else |
87 |
- if(EVP_CIPHER_CTX_set_key_length(&encrypt, length) == 0 || |
88 |
- EVP_CIPHER_CTX_set_key_length(&decrypt, length) == 0) |
89 |
+ if(EVP_CIPHER_CTX_set_key_length(encrypt, length) == 0 || |
90 |
+ EVP_CIPHER_CTX_set_key_length(decrypt, length) == 0) |
91 |
throw Invalid_Argument("EVP_BlockCipher: Bad key length for " + |
92 |
cipher_name); |
93 |
|
94 |
if(cipher_name == "RC2") |
95 |
{ |
96 |
- EVP_CIPHER_CTX_ctrl(&encrypt, EVP_CTRL_SET_RC2_KEY_BITS, length*8, 0); |
97 |
- EVP_CIPHER_CTX_ctrl(&decrypt, EVP_CTRL_SET_RC2_KEY_BITS, length*8, 0); |
98 |
+ EVP_CIPHER_CTX_ctrl(encrypt, EVP_CTRL_SET_RC2_KEY_BITS, length*8, 0); |
99 |
+ EVP_CIPHER_CTX_ctrl(decrypt, EVP_CTRL_SET_RC2_KEY_BITS, length*8, 0); |
100 |
} |
101 |
|
102 |
- EVP_EncryptInit_ex(&encrypt, 0, 0, full_key.begin(), 0); |
103 |
- EVP_DecryptInit_ex(&decrypt, 0, 0, full_key.begin(), 0); |
104 |
+ EVP_EncryptInit_ex(encrypt, 0, 0, full_key.begin(), 0); |
105 |
+ EVP_DecryptInit_ex(decrypt, 0, 0, full_key.begin(), 0); |
106 |
} |
107 |
|
108 |
/* |
109 |
@@ -150,7 +150,7 @@ void EVP_BlockCipher::key_schedule(const byte key[], s |
110 |
*/ |
111 |
BlockCipher* EVP_BlockCipher::clone() const |
112 |
{ |
113 |
- return new EVP_BlockCipher(EVP_CIPHER_CTX_cipher(&encrypt), |
114 |
+ return new EVP_BlockCipher(EVP_CIPHER_CTX_cipher(encrypt), |
115 |
cipher_name, |
116 |
cipher_key_spec.minimum_keylength(), |
117 |
cipher_key_spec.maximum_keylength(), |
118 |
@@ -162,16 +162,16 @@ BlockCipher* EVP_BlockCipher::clone() const |
119 |
*/ |
120 |
void EVP_BlockCipher::clear() |
121 |
{ |
122 |
- const EVP_CIPHER* algo = EVP_CIPHER_CTX_cipher(&encrypt); |
123 |
+ const EVP_CIPHER* algo = EVP_CIPHER_CTX_cipher(encrypt); |
124 |
|
125 |
- EVP_CIPHER_CTX_cleanup(&encrypt); |
126 |
- EVP_CIPHER_CTX_cleanup(&decrypt); |
127 |
- EVP_CIPHER_CTX_init(&encrypt); |
128 |
- EVP_CIPHER_CTX_init(&decrypt); |
129 |
- EVP_EncryptInit_ex(&encrypt, algo, 0, 0, 0); |
130 |
- EVP_DecryptInit_ex(&decrypt, algo, 0, 0, 0); |
131 |
- EVP_CIPHER_CTX_set_padding(&encrypt, 0); |
132 |
- EVP_CIPHER_CTX_set_padding(&decrypt, 0); |
133 |
+ EVP_CIPHER_CTX_cleanup(encrypt); |
134 |
+ EVP_CIPHER_CTX_cleanup(decrypt); |
135 |
+ EVP_CIPHER_CTX_init(encrypt); |
136 |
+ EVP_CIPHER_CTX_init(decrypt); |
137 |
+ EVP_EncryptInit_ex(encrypt, algo, 0, 0, 0); |
138 |
+ EVP_DecryptInit_ex(decrypt, algo, 0, 0, 0); |
139 |
+ EVP_CIPHER_CTX_set_padding(encrypt, 0); |
140 |
+ EVP_CIPHER_CTX_set_padding(decrypt, 0); |
141 |
} |
142 |
|
143 |
} |