@@ -404,7 +404,7 @@ def test_add_signer_to_signed_and_enveloped_should_add_that_to_stack
404404 BIG_ONE = BigInteger ::ONE . to_java
405405
406406 def create_signer_info_with_algo ( algo )
407- md5 = AlgorithmIdentifier . new ( ASN1Registry . nid2obj ( 4 ) )
407+ md5 = algorithm_identifier ( 4 )
408408 org . jruby . ext . openssl . impl . SignerInfoWithPkey . new (
409409 org . bouncycastle . asn1 . ASN1Integer . new ( BIG_ONE ) ,
410410 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
421421 p7 . type = ASN1Registry ::NID_pkcs7_signed
422422
423423 # 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 )
426426
427427 si = create_signer_info_with_algo ( md5 )
428428 p7 . add_signer ( si )
@@ -450,8 +450,8 @@ def test_add_signer_to_signed_and_enveloped_with_new_algo_should_add_that_algo_t
450450 p7 . type = ASN1Registry ::NID_pkcs7_signedAndEnveloped
451451
452452 # 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 )
455455
456456 si = create_signer_info_with_algo ( md5 )
457457 p7 . add_signer ( si )
@@ -473,6 +473,13 @@ def test_add_signer_to_signed_and_enveloped_with_new_algo_should_add_that_algo_t
473473 assert p7 . get_signed_and_enveloped . md_algs . contains ( md5 )
474474 end
475475
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+
476483 def test_set_content_on_data_throws_exception
477484 p7 = PKCS7 . new
478485 p7 . type = ASN1Registry ::NID_pkcs7_data
0 commit comments