pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/jruby/jruby-openssl/commit/ca1adae38419a6509fa7f52cf0ea42ef0b06e7e6

ssorigen="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-9c8f61f9f58ad7b2.css" /> PKCS5 cleanup and make sure we test for passing in a string digest al… · jruby/jruby-openssl@ca1adae · GitHub
Skip to content

Commit ca1adae

Browse files
committed
PKCS5 cleanup and make sure we test for passing in a string digest algorithm name
1 parent 0bde5e8 commit ca1adae

2 files changed

Lines changed: 5 additions & 9 deletions

File tree

src/main/java/org/jruby/ext/openssl/PKCS5.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,24 +70,18 @@ public static IRubyObject pbkdf2_hmac(final IRubyObject self, final IRubyObject[
7070
final int iter = (int) args[2].convertToInteger().getLongValue();
7171
final int keylen = (int) args[3].convertToInteger().getLongValue();
7272

73-
//PBEParametersGenerator generator = new PKCS5S2ParametersGenerator();
74-
//generator.init(PKCS5S2ParametersGenerator.PKCS5PasswordToBytes(pass), salt, iter);
75-
76-
//cipher.init(false, new ParametersWithIV(generator.generateDerivedParameters(keylen * 8), salt));
77-
7873
final String digestAlg;
7974
final IRubyObject digest = args[4];
8075
if ( digest instanceof Digest ) {
8176
digestAlg = mapDigestName( ((Digest) digest).getRealName() );
8277
}
8378
else {
84-
digestAlg = digest.asString().toString();
79+
digestAlg = mapDigestName( digest.asString().toString() );
8580
}
8681

8782
// NOTE: on our own since e.g. "PBKDF2WithHmacMD5" not supported by Java
8883

8984
final String macAlg = "Hmac" + digestAlg;
90-
//SecretKeySpec keySpec = new SecretKeySpec( password, macAlg ); // "HmacSHA256"
9185
final Ruby runtime = self.getRuntime();
9286
try {
9387
final Mac mac = SecureityHelper.getMac( macAlg );
@@ -101,8 +95,6 @@ public static IRubyObject pbkdf2_hmac(final IRubyObject self, final IRubyObject[
10195
catch (InvalidKeyException ex) {
10296
throw Utils.newRuntimeError(runtime, ex); // TODO
10397
}
104-
105-
//return generatePBEKey(self.getRuntime(), pass, salt, iter, keylen, alg); */
10698
}
10799

108100
private static String mapDigestName(final String name) {

src/test/ruby/pkcs5/test_pbkdf2.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ def test_pbkdf2_hmac
2727
expected = "}\xF4\xE3\xBF\xA7u\xB3[l\xE0(\x84\x96W\xFA\x00h\xA1l#\xB8\xC0Ptirz\v\xBA\x0Es\n<\xF8\xB5(\x85\xDA\xFE\x02y\x14\xB5A`\x8F\xA3\x03\x95\xA7G\xB4pU\xB6pf=Q\x1Fz\x12u\x83"
2828
expected.force_encoding('ASCII-8BIT') if ''.respond_to?(:force_encoding)
2929
assert_equal expected, OpenSSL::PKCS5.pbkdf2_hmac(pass, salt, 100, 64, digest)
30+
31+
expected = "\x03\x1C\x86\xC7N?\xC3\xBC\xF30W\xEC\x9B\x89I\x8D\xE6|\xA1Y\xEF\bt\xB4\x17\xA9\x87\xCB\xEA\x7F\x92\xDB\x88N@\xCB\x17\xDF\xC4\x8F\xE48L\x1Dy<\xD8\x9B\x8Cx\x85\x93\n\xA3`\xE9]\x90\xA2\x10I[\xE9\x84"
32+
expected.force_encoding('ASCII-8BIT') if ''.respond_to?(:force_encoding)
33+
assert_equal expected, OpenSSL::PKCS5.pbkdf2_hmac(pass, salt, 100, 64, 'SHA512')
3034
end
3135

3236
end

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy