@@ -201,7 +201,7 @@ def test_sign_verify_pss
201201
202202 def test_encrypt_decrypt
203203 rsapriv = Fixtures . pkey ( "rsa-1" )
204- rsapub = dup_public ( rsapriv )
204+ rsapub = OpenSSL :: PKey . read ( rsapriv . public_to_der )
205205
206206 # Defaults to PKCS #1 v1.5
207207 raw = "data"
@@ -216,7 +216,7 @@ def test_encrypt_decrypt
216216
217217 def test_encrypt_decrypt_legacy
218218 rsapriv = Fixtures . pkey ( "rsa-1" )
219- rsapub = dup_public ( rsapriv )
219+ rsapub = OpenSSL :: PKey . read ( rsapriv . public_to_der )
220220
221221 # Defaults to PKCS #1 v1.5
222222 raw = "data"
@@ -346,13 +346,15 @@ def test_RSAPrivateKey_encrypted
346346
347347 def test_RSAPublicKey
348348 rsa1024 = Fixtures . pkey ( "rsa1024" )
349+ rsa1024pub = OpenSSL ::PKey ::RSA . new ( rsa1024 . public_to_der )
350+
349351 asn1 = OpenSSL ::ASN1 ::Sequence ( [
350352 OpenSSL ::ASN1 ::Integer ( rsa1024 . n ) ,
351353 OpenSSL ::ASN1 ::Integer ( rsa1024 . e )
352354 ] )
353355 key = OpenSSL ::PKey ::RSA . new ( asn1 . to_der )
354356 assert_not_predicate key , :private?
355- assert_same_rsa dup_public ( rsa1024 ) , key
357+ assert_same_rsa rsa1024pub , key
356358
357359 pem = <<~EOF
358360 -----BEGIN RSA PUBLIC KEY-----
@@ -362,11 +364,13 @@ def test_RSAPublicKey
362364 -----END RSA PUBLIC KEY-----
363365 EOF
364366 key = OpenSSL ::PKey ::RSA . new ( pem )
365- assert_same_rsa dup_public ( rsa1024 ) , key
367+ assert_same_rsa rsa1024pub , key
366368 end
367369
368370 def test_PUBKEY
369371 rsa1024 = Fixtures . pkey ( "rsa1024" )
372+ rsa1024pub = OpenSSL ::PKey ::RSA . new ( rsa1024 . public_to_der )
373+
370374 asn1 = OpenSSL ::ASN1 ::Sequence ( [
371375 OpenSSL ::ASN1 ::Sequence ( [
372376 OpenSSL ::ASN1 ::ObjectId ( "rsaEncryption" ) ,
@@ -381,7 +385,7 @@ def test_PUBKEY
381385 ] )
382386 key = OpenSSL ::PKey ::RSA . new ( asn1 . to_der )
383387 assert_not_predicate key , :private?
384- assert_same_rsa dup_public ( rsa1024 ) , key
388+ assert_same_rsa rsa1024pub , key
385389
386390 pem = <<~EOF
387391 -----BEGIN PUBLIC KEY-----
@@ -392,10 +396,15 @@ def test_PUBKEY
392396 -----END PUBLIC KEY-----
393397 EOF
394398 key = OpenSSL ::PKey ::RSA . new ( pem )
395- assert_same_rsa dup_public ( rsa1024 ) , key
399+ assert_same_rsa rsa1024pub , key
400+
401+ assert_equal asn1 . to_der , key . to_der
402+ assert_equal pem , key . export
396403
397- assert_equal asn1 . to_der , dup_public ( rsa1024 ) . to_der
398- assert_equal pem , dup_public ( rsa1024 ) . export
404+ assert_equal asn1 . to_der , rsa1024 . public_to_der
405+ assert_equal asn1 . to_der , key . public_to_der
406+ assert_equal pem , rsa1024 . public_to_pem
407+ assert_equal pem , key . public_to_pem
399408 end
400409
401410 def test_pem_passwd
@@ -482,12 +491,6 @@ def test_private_encoding_encrypted
482491 assert_same_rsa rsa1024 , OpenSSL ::PKey . read ( pem , "abcdef" )
483492 end
484493
485- def test_public_encoding
486- rsa1024 = Fixtures . pkey ( "rsa1024" )
487- assert_equal dup_public ( rsa1024 ) . to_der , rsa1024 . public_to_der
488- assert_equal dup_public ( rsa1024 ) . to_pem , rsa1024 . public_to_pem
489- end
490-
491494 def test_dup
492495 key = Fixtures . pkey ( "rsa1024" )
493496 key2 = key . dup
0 commit comments