@@ -655,31 +655,31 @@ def tearDownClass(self):
655655 def test_export_pubkey (self ):
656656 """ export a public key and make sure the parameters are the right ones:
657657
658- since there's very little we can do to check rsa key parameters are right
659- we pre-exported the public key to an ssh key, which we can load with
660- cryptography for the sake of comparison """
658+ since there's very little we can do to check key parameters are right
659+ we pre-exported the public key to an x.509 SubjectPublicKeyInfo key,
660+ which we can load with cryptography for the sake of comparison """
661661
662662 # export our gpg key, using our functions
663663 key_data = export_pubkey (self .default_keyid , homedir = self .gnupg_home )
664664 our_exported_key = dsa_create_pubkey (key_data )
665665
666- # load the equivalent ssh key, and make sure that we get the same RSA key
667- # parameters
668- ssh_key_basename = "{}.ssh" .format (self .default_keyid )
669- ssh_key_path = os .path .join (self .gnupg_home , ssh_key_basename )
670- with open (ssh_key_path , "rb" ) as fp :
666+ # load same key, pre-exported with 3rd-party tooling
667+ pem_key_basename = "{}.pem" .format (self .default_keyid )
668+ pem_key_path = os .path .join (self .gnupg_home , pem_key_basename )
669+ with open (pem_key_path , "rb" ) as fp :
671670 keydata = fp .read ()
672671
673- ssh_key = serialization .load_ssh_public_key (keydata ,
672+ pem_key = serialization .load_pem_public_key (keydata ,
674673 backends .default_backend ())
675674
676- self .assertEqual (ssh_key .public_numbers ().y ,
675+ # make sure keys match
676+ self .assertEqual (pem_key .public_numbers ().y ,
677677 our_exported_key .public_numbers ().y )
678- self .assertEqual (ssh_key .public_numbers ().parameter_numbers .g ,
678+ self .assertEqual (pem_key .public_numbers ().parameter_numbers .g ,
679679 our_exported_key .public_numbers ().parameter_numbers .g )
680- self .assertEqual (ssh_key .public_numbers ().parameter_numbers .q ,
680+ self .assertEqual (pem_key .public_numbers ().parameter_numbers .q ,
681681 our_exported_key .public_numbers ().parameter_numbers .q )
682- self .assertEqual (ssh_key .public_numbers ().parameter_numbers .p ,
682+ self .assertEqual (pem_key .public_numbers ().parameter_numbers .p ,
683683 our_exported_key .public_numbers ().parameter_numbers .p )
684684
685685 def test_gpg_sign_and_verify_object_with_default_key (self ):
0 commit comments