Skip to content

Commit cc2d139

Browse files
committed
Fixed Mcrypt Deprecated functions and tests
1 parent c64f4e7 commit cc2d139

13 files changed

+205
-9
lines changed

ext/mcrypt/mcrypt.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,9 @@ ZEND_END_ARG_INFO()
239239

240240
const zend_function_entry mcrypt_functions[] = { /* {{{ */
241241
PHP_DEP_FE(mcrypt_ecb, arginfo_mcrypt_ecb)
242-
PHP_FE(mcrypt_cbc, arginfo_mcrypt_cbc)
243-
PHP_FE(mcrypt_cfb, arginfo_mcrypt_cfb)
244-
PHP_FE(mcrypt_ofb, arginfo_mcrypt_ofb)
242+
PHP_DEP_FE(mcrypt_cbc, arginfo_mcrypt_cbc)
243+
PHP_DEP_FE(mcrypt_cfb, arginfo_mcrypt_cfb)
244+
PHP_DEP_FE(mcrypt_ofb, arginfo_mcrypt_ofb)
245245
PHP_FE(mcrypt_get_key_size, arginfo_mcrypt_get_key_size)
246246
PHP_FE(mcrypt_get_block_size, arginfo_mcrypt_get_block_size)
247247
PHP_FE(mcrypt_get_cipher_name, arginfo_mcrypt_get_cipher_name)

ext/mcrypt/tests/mcrypt_cbc.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ echo trim(mcrypt_cbc($cipher, $key, $enc_data, MCRYPT_DECRYPT, $iv)) . "\n";
1818
mcrypt_cbc($cipher, $key, $enc_data, MCRYPT_DECRYPT);
1919

2020
--EXPECTF--
21+
22+
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
23+
24+
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
2125
PHP Testfest 2008
2226

27+
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
28+
2329
Warning: mcrypt_cbc(): Attempt to use an empty IV, which is NOT recommend in %s on line %d

ext/mcrypt/tests/mcrypt_cbc_3des_decrypt.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,31 +72,45 @@ function special_var_dump($str) {
7272
--- testing different key lengths
7373

7474
key length=8
75+
76+
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
7577
string(32) "736563726574206d6573736167650000"
7678

7779
key length=20
80+
81+
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
7882
string(32) "736563726574206d6573736167650000"
7983

8084
key length=24
85+
86+
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
8187
string(32) "736563726574206d6573736167650000"
8288

8389
key length=26
8490

91+
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
92+
8593
Warning: mcrypt_cbc(): Size of key is too large for this algorithm in %s on line %d
8694
string(32) "736563726574206d6573736167650000"
8795

8896
--- testing different iv lengths
8997

9098
iv length=4
9199

100+
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
101+
92102
Warning: mcrypt_cbc(): The IV parameter must be as long as the blocksize in %s on line %d
93103
string(32) "736563726574206d6573736167650000"
94104

95105
iv length=8
106+
107+
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
96108
string(32) "736563726574206d6573736167650000"
97109

98110
iv length=9
99111

112+
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
113+
100114
Warning: mcrypt_cbc(): The IV parameter must be as long as the blocksize in %s on line %d
101115
string(32) "736563726574206d6573736167650000"
102116
===DONE===

ext/mcrypt/tests/mcrypt_cbc_3des_encrypt.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,31 +55,45 @@ foreach ($ivs as $iv) {
5555
--- testing different key lengths
5656

5757
key length=8
58+
59+
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
5860
string(112) "082b437d039d09418e20dc9de1dafa7ed6da5c6335b78950968441da1faf40c1f886e04da8ca177b80b376811e138c1bf51cb48dae2e7939"
5961

6062
key length=20
63+
64+
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
6165
string(112) "0627351e0f8a082bf7981ae2c700a43fd3d44b270ac67b00fded1c5796eea935be0fef2a23da0b3f5e243929e62ac957bf0bf463aa90fc4f"
6266

6367
key length=24
68+
69+
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
6470
string(112) "b85e21072239d60c63a80e7c9ae493cb741a1cd407e52f451c5f43a0d103f55a7b62617eb2e44213c2d44462d388bc0b8f119384b12c84ac"
6571

6672
key length=26
6773

74+
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
75+
6876
Warning: mcrypt_cbc(): Size of key is too large for this algorithm in %s on line %d
6977
string(112) "b85e21072239d60c63a80e7c9ae493cb741a1cd407e52f451c5f43a0d103f55a7b62617eb2e44213c2d44462d388bc0b8f119384b12c84ac"
7078

7179
--- testing different iv lengths
7280

7381
iv length=4
7482

83+
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
84+
7585
Warning: mcrypt_cbc(): The IV parameter must be as long as the blocksize in %s on line %d
7686
string(112) "440a6f54601969b127aad3c217ce7583c7f7b29989693130645569301db0020b29a34a3dcd104b2d0e3ba19d6cbd8a33d352b9c27cc34ef1"
7787

7888
iv length=8
89+
90+
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
7991
string(112) "bac347506bf092c5557c4363c301745d78f047028e2953e84fd66b30aeb6005812dadbe8baa871b83278341599b0c448ddaaa52b5a378ce5"
8092

8193
iv length=9
8294

95+
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
96+
8397
Warning: mcrypt_cbc(): The IV parameter must be as long as the blocksize in %s on line %d
8498
string(112) "440a6f54601969b127aad3c217ce7583c7f7b29989693130645569301db0020b29a34a3dcd104b2d0e3ba19d6cbd8a33d352b9c27cc34ef1"
8599
===DONE===

ext/mcrypt/tests/mcrypt_cbc_error.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,15 @@ var_dump( mcrypt_cbc($cipher, $key, $data) );
4141

4242
-- Testing mcrypt_cbc() function with more than expected no. of arguments --
4343

44+
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
45+
4446
Warning: mcrypt_cbc() expects at most 5 parameters, 6 given in %s on line %d
4547
NULL
4648

4749
-- Testing mcrypt_cbc() function with less than expected no. of arguments --
4850

51+
Deprecated: Function mcrypt_cbc() is deprecated in %s on line %d
52+
4953
Warning: mcrypt_cbc() expects at least 4 parameters, 3 given in %s on line %d
5054
NULL
5155
===DONE===

ext/mcrypt/tests/mcrypt_cbc_variation1.phpt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,106 +124,132 @@ fclose($fp);
124124
*** Testing mcrypt_cbc() : usage variation ***
125125

126126
--int 0--
127+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
127128
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
128129
bool(false)
129130

130131
--int 1--
132+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
131133
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
132134
bool(false)
133135

134136
--int 12345--
137+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
135138
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
136139
bool(false)
137140

138141
--int -12345--
142+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
139143
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
140144
bool(false)
141145

142146
--float 10.5--
147+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
143148
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
144149
bool(false)
145150

146151
--float -10.5--
152+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
147153
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
148154
bool(false)
149155

150156
--float 12.3456789000e10--
157+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
151158
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
152159
bool(false)
153160

154161
--float -12.3456789000e10--
162+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
155163
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
156164
bool(false)
157165

158166
--float .5--
167+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
159168
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
160169
bool(false)
161170

162171
--empty array--
172+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
163173
Error: 2 - mcrypt_cbc() expects parameter 1 to be string, array given, %s(%d)
164174
NULL
165175

166176
--int indexed array--
177+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
167178
Error: 2 - mcrypt_cbc() expects parameter 1 to be string, array given, %s(%d)
168179
NULL
169180

170181
--associative array--
182+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
171183
Error: 2 - mcrypt_cbc() expects parameter 1 to be string, array given, %s(%d)
172184
NULL
173185

174186
--nested arrays--
187+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
175188
Error: 2 - mcrypt_cbc() expects parameter 1 to be string, array given, %s(%d)
176189
NULL
177190

178191
--uppercase NULL--
192+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
179193
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
180194
bool(false)
181195

182196
--lowercase null--
197+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
183198
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
184199
bool(false)
185200

186201
--lowercase true--
202+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
187203
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
188204
bool(false)
189205

190206
--lowercase false--
207+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
191208
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
192209
bool(false)
193210

194211
--uppercase TRUE--
212+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
195213
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
196214
bool(false)
197215

198216
--uppercase FALSE--
217+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
199218
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
200219
bool(false)
201220

202221
--empty string DQ--
222+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
203223
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
204224
bool(false)
205225

206226
--empty string SQ--
227+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
207228
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
208229
bool(false)
209230

210231
--instance of classWithToString--
232+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
211233
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
212234
bool(false)
213235

214236
--instance of classWithoutToString--
237+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
215238
Error: 2 - mcrypt_cbc() expects parameter 1 to be string, object given, %s(%d)
216239
NULL
217240

218241
--undefined var--
242+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
219243
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
220244
bool(false)
221245

222246
--unset var--
247+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
223248
Error: 2 - mcrypt_cbc(): Module initialization failed, %s(%d)
224249
bool(false)
225250

226251
--resource--
252+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
227253
Error: 2 - mcrypt_cbc() expects parameter 1 to be string, resource given, %s(%d)
228254
NULL
229255
===DONE===

ext/mcrypt/tests/mcrypt_cbc_variation2.phpt

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,87 +124,112 @@ fclose($fp);
124124
*** Testing mcrypt_cbc() : usage variation ***
125125

126126
--int 0--
127+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
127128
string(32) "bc27b3a4e33b531d5983fc7df693cd09"
128129

129130
--int 1--
131+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
130132
string(32) "bc27b3a4e33b531d5983fc7df693cd09"
131133

132134
--int 12345--
135+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
133136
string(32) "d109b7973383127002474ae731c4b3a8"
134137

135138
--int -12345--
139+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
136140
string(32) "3e82a931cedb03a38b91a637ff8c9f9e"
137141

138142
--float 10.5--
143+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
139144
string(32) "de71833586c1d7132a289960ebeeca7a"
140145

141146
--float -10.5--
147+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
142148
string(32) "7d0489dd2e99ae910ecc015573f3dd16"
143149

144150
--float 12.3456789000e10--
151+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
145152
string(32) "978055b42c0506a8947e3c3c8d994baf"
146153

147154
--float -12.3456789000e10--
155+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
148156
string(32) "4aa84ba400c2b8ef467d4d98372b4f4e"
149157

150158
--float .5--
159+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
151160
string(32) "e731dc5059b84e0c8774ac490f77d6e6"
152161

153162
--empty array--
163+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
154164
Error: 2 - mcrypt_cbc() expects parameter 2 to be string, array given, %s(%d)
155165
string(0) ""
156166

157167
--int indexed array--
168+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
158169
Error: 2 - mcrypt_cbc() expects parameter 2 to be string, array given, %s(%d)
159170
string(0) ""
160171

161172
--associative array--
173+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
162174
Error: 2 - mcrypt_cbc() expects parameter 2 to be string, array given, %s(%d)
163175
string(0) ""
164176

165177
--nested arrays--
178+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
166179
Error: 2 - mcrypt_cbc() expects parameter 2 to be string, array given, %s(%d)
167180
string(0) ""
168181

169182
--uppercase NULL--
183+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
170184
string(32) "be722a5ffc361d721fbcab1eacc6acf5"
171185

172186
--lowercase null--
187+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
173188
string(32) "be722a5ffc361d721fbcab1eacc6acf5"
174189

175190
--lowercase true--
191+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
176192
string(32) "bc27b3a4e33b531d5983fc7df693cd09"
177193

178194
--lowercase false--
195+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
179196
string(32) "be722a5ffc361d721fbcab1eacc6acf5"
180197

181198
--uppercase TRUE--
199+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
182200
string(32) "bc27b3a4e33b531d5983fc7df693cd09"
183201

184202
--uppercase FALSE--
203+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
185204
string(32) "be722a5ffc361d721fbcab1eacc6acf5"
186205

187206
--empty string DQ--
207+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
188208
string(32) "be722a5ffc361d721fbcab1eacc6acf5"
189209

190210
--empty string SQ--
211+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
191212
string(32) "be722a5ffc361d721fbcab1eacc6acf5"
192213

193214
--instance of classWithToString--
215+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
194216
string(32) "19420fa26f561ee82ed84abbcd2d284b"
195217

196218
--instance of classWithoutToString--
219+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
197220
Error: 2 - mcrypt_cbc() expects parameter 2 to be string, object given, %s(%d)
198221
string(0) ""
199222

200223
--undefined var--
224+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
201225
string(32) "be722a5ffc361d721fbcab1eacc6acf5"
202226

203227
--unset var--
228+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
204229
string(32) "be722a5ffc361d721fbcab1eacc6acf5"
205230

206231
--resource--
232+
Error: 8192 - Function mcrypt_cbc() is deprecated, %s(%d)
207233
Error: 2 - mcrypt_cbc() expects parameter 2 to be string, resource given, %s(%d)
208234
string(0) ""
209235
===DONE===
210-

0 commit comments

Comments
 (0)