|
31 | 31 | import java.math.BigInteger;
|
32 | 32 |
|
33 | 33 | import java.security.GeneralSecurityException;
|
| 34 | +import java.security.MessageDigest; |
34 | 35 |
|
35 | 36 | import org.bouncycastle.asn1.*;
|
36 | 37 | import org.bouncycastle.asn1.x500.X500Name;
|
@@ -430,7 +431,7 @@ private byte[] publicKeyIdentifier(final ThreadContext context) {
|
430 | 431 | der = ASN1.decode(context, ASN1._ASN1(runtime), pkey.callMethod(context, "to_der"));
|
431 | 432 | der = der.callMethod(context, "value").callMethod(context, "[]", runtime.newFixnum(1)).callMethod(context, "value");
|
432 | 433 | }
|
433 |
| - return getSHA1Digest(runtime, der.asString().getBytes()); |
| 434 | + return getSHA1Digest(runtime, der.asString().getByteList()); |
434 | 435 | }
|
435 | 436 |
|
436 | 437 | private IRubyObject getPublicKey(final ThreadContext context) {
|
@@ -466,9 +467,11 @@ private BigInteger getIssuerSerialNumber(final ThreadContext context) {
|
466 | 467 | return serial.isNil() ? null : ((BN) serial).getValue();
|
467 | 468 | }
|
468 | 469 |
|
469 |
| - private static byte[] getSHA1Digest(Ruby runtime, byte[] bytes) { |
| 470 | + private static byte[] getSHA1Digest(Ruby runtime, ByteList bytes) { |
470 | 471 | try {
|
471 |
| - return SecurityHelper.getMessageDigest("SHA-1").digest(bytes); |
| 472 | + MessageDigest sha1 = SecurityHelper.getMessageDigest("SHA-1"); |
| 473 | + sha1.update(bytes.unsafeBytes(), bytes.getBegin(), bytes.getRealSize()); |
| 474 | + return sha1.digest(); |
472 | 475 | }
|
473 | 476 | catch (GeneralSecurityException e) {
|
474 | 477 | throw newExtensionError(runtime, e.getMessage());
|
|
0 commit comments