@@ -404,7 +404,7 @@ def test_add_signer_to_signed_and_enveloped_should_add_that_to_stack
404
404
BIG_ONE = BigInteger ::ONE . to_java
405
405
406
406
def create_signer_info_with_algo ( algo )
407
- md5 = AlgorithmIdentifier . new ( ASN1Registry . nid2obj ( 4 ) )
407
+ md5 = algorithm_identifier ( 4 )
408
408
org . jruby . ext . openssl . impl . SignerInfoWithPkey . new (
409
409
org . bouncycastle . asn1 . ASN1Integer . new ( BIG_ONE ) ,
410
410
org . bouncycastle . asn1 . pkcs . IssuerAndSerialNumber . new ( org . bouncycastle . asn1 . x500 . X500Name . new ( "C=SE" ) , BIG_ONE ) ,
@@ -421,8 +421,8 @@ def test_add_signer_to_signed_with_new_algo_should_add_that_algo_to_the_algo_lis
421
421
p7 . type = ASN1Registry ::NID_pkcs7_signed
422
422
423
423
# YES, these numbers are correct. Don't change them. They are OpenSSL internal NIDs
424
- md5 = AlgorithmIdentifier . new ( ASN1Registry . nid2obj ( 4 ) )
425
- md4 = AlgorithmIdentifier . new ( ASN1Registry . nid2obj ( 5 ) )
424
+ md5 = algorithm_identifier ( 4 )
425
+ md4 = algorithm_identifier ( 5 )
426
426
427
427
si = create_signer_info_with_algo ( md5 )
428
428
p7 . add_signer ( si )
@@ -450,8 +450,8 @@ def test_add_signer_to_signed_and_enveloped_with_new_algo_should_add_that_algo_t
450
450
p7 . type = ASN1Registry ::NID_pkcs7_signedAndEnveloped
451
451
452
452
# YES, these numbers are correct. Don't change them. They are OpenSSL internal NIDs
453
- md5 = AlgorithmIdentifier . new ( ASN1Registry . nid2obj ( 4 ) )
454
- md4 = AlgorithmIdentifier . new ( ASN1Registry . nid2obj ( 5 ) )
453
+ md5 = algorithm_identifier ( 4 )
454
+ md4 = algorithm_identifier ( 5 )
455
455
456
456
si = create_signer_info_with_algo ( md5 )
457
457
p7 . add_signer ( si )
@@ -473,6 +473,13 @@ def test_add_signer_to_signed_and_enveloped_with_new_algo_should_add_that_algo_t
473
473
assert p7 . get_signed_and_enveloped . md_algs . contains ( md5 )
474
474
end
475
475
476
+ def algorithm_identifier ( nid )
477
+ oid = ASN1Registry . nid2oid ( nid )
478
+ raise "oid for #{ nid . inspect } not found!" unless oid
479
+ AlgorithmIdentifier . new ( org . bouncycastle . asn1 . ASN1ObjectIdentifier . new ( oid ) )
480
+ end
481
+ private :algorithm_identifier
482
+
476
483
def test_set_content_on_data_throws_exception
477
484
p7 = PKCS7 . new
478
485
p7 . type = ASN1Registry ::NID_pkcs7_data
0 commit comments