Commit e46d992
committed
cipher: remove Cipher#encrypt(password, iv) form
OpenSSL::Cipher#encrypt and #decrypt have long supported a hidden
feature to derive a key and an IV from the String argument, but in an
inappropriate way.
This feature is undocumented, untested, and has been deprecated since
commit ruby/ruby@0dc4321 on 2004-06-30,
which started printing a non-verbose warning. More than 20 years later,
it must be safe to remove it entirely.
The deprecated usage:
# `password` is a String, `iv` is either a String or nil
cipher = OpenSSL::Cipher.new("aes-256-cbc")
cipher.encrypt(password, iv)
p cipher.update("data") << cipher.final
was equivalent to:
cipher = OpenSSL::Cipher.new("aes-256-cbc")
cipher.encrypt
iv ||= "OpenSSL for Ruby rulez!"
key = ((cipher.key_len + 15) / 16).times.inject([""]) { |ary, _|
ary << OpenSSL::Digest.digest("MD5", ary.last + password + iv[0, 8].ljust(8, "\0"))
}.join
cipher.key = key[...cipher.key_len]
cipher.iv = iv[...cipher.iv_len].ljust(cipher.iv_len, "\0")
p cipher.update("data") << cipher.final1 parent 080b21d commit e46d992
1 file changed
+12
-43
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
201 | | - | |
| 201 | + | |
202 | 202 | | |
203 | 203 | | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
239 | 208 | | |
240 | 209 | | |
241 | | - | |
| 210 | + | |
242 | 211 | | |
243 | 212 | | |
244 | 213 | | |
| |||
256 | 225 | | |
257 | 226 | | |
258 | 227 | | |
259 | | - | |
| 228 | + | |
260 | 229 | | |
261 | | - | |
| 230 | + | |
262 | 231 | | |
263 | 232 | | |
264 | 233 | | |
| |||
274 | 243 | | |
275 | 244 | | |
276 | 245 | | |
277 | | - | |
| 246 | + | |
278 | 247 | | |
279 | | - | |
| 248 | + | |
280 | 249 | | |
281 | 250 | | |
282 | 251 | | |
| |||
1064 | 1033 | | |
1065 | 1034 | | |
1066 | 1035 | | |
1067 | | - | |
1068 | | - | |
| 1036 | + | |
| 1037 | + | |
1069 | 1038 | | |
1070 | 1039 | | |
1071 | 1040 | | |
| |||
0 commit comments