{"action":"opened","issue":{"url":"https://api.github.com/repos/Legrandin/pycryptodome/issues/82","repository_url":"https://api.github.com/repos/Legrandin/pycryptodome","labels_url":"https://api.github.com/repos/Legrandin/pycryptodome/issues/82/labels{/name}","comments_url":"https://api.github.com/repos/Legrandin/pycryptodome/issues/82/comments","events_url":"https://api.github.com/repos/Legrandin/pycryptodome/issues/82/events","html_url":"https://github.com/Legrandin/pycryptodome/issues/82","id":252906662,"number":82,"title":"Issue when creating RSA PEM format public key files?","user":{"login":"AJPoulter-Soton","id":28599916,"avatar_url":"https://avatars0.githubusercontent.com/u/28599916?v=4","gravatar_id":"","url":"https://api.github.com/users/AJPoulter-Soton","html_url":"https://github.com/AJPoulter-Soton","followers_url":"https://api.github.com/users/AJPoulter-Soton/followers","following_url":"https://api.github.com/users/AJPoulter-Soton/following{/other_user}","gists_url":"https://api.github.com/users/AJPoulter-Soton/gists{/gist_id}","starred_url":"https://api.github.com/users/AJPoulter-Soton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AJPoulter-Soton/subscriptions","organizations_url":"https://api.github.com/users/AJPoulter-Soton/orgs","repos_url":"https://api.github.com/users/AJPoulter-Soton/repos","events_url":"https://api.github.com/users/AJPoulter-Soton/events{/privacy}","received_events_url":"https://api.github.com/users/AJPoulter-Soton/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-08-25T13:49:32Z","updated_at":"2017-08-25T13:49:32Z","closed_at":null,"body":"Apologies if the error here is mine - but it looks like there's an issue when creating PEM format RSA public keys...\r\n\r\nIf I follow the documentation I can create the key as follows:\r\n\r\n```\r\nfrom Cryptodome.PublicKey import RSA\r\nkey = RSA.generate(2048)\r\npv_key_string = key.exportKey()\r\npb_key_string = key.publickey().exportKey()\r\n```\r\n\r\nAnd I can write these two keys to files very simply:\r\n\r\n```\r\nwith open (\"private.pem\", \"w\") as prv_file:\r\n    print(\"{}\".format(pv_key_string.decode()), file=prv_file)\r\n\r\n\r\n with open (\"public.pem\", \"w\") as pub_file:\r\n    print(\"{}\".format(pb_key_string.decode()), file=pub_file)\r\n```\r\n\r\nUsing OpenSSL the private key checks out okay...\r\n\r\n```\r\n$ openssl rsa -check -inform pem -noout -in private.pem \r\nRSA key ok\r\n```\r\n\r\nBut if I try to use the public key I get an error...\r\n\r\n ```\r\n$ openssl rsa -pubin -in ./public.pem                           \r\nunable to load Public Key\r\n62946:error:0906D06C:PEM routines:PEM_read_bio:no start line:/BuildRoot/Library/Caches/com.apple.xbs/Sources/OpenSSL098/OpenSSL098-64.50.6/src/crypto/pem/pem_lib.c:648:Expecting: PUBLIC KEY\r\n```\r\n\r\nHowever if I manually edit they key file and change the header and footer from \r\n-----BEGIN RSA PUBLIC KEY----- & -----END RSA PUBLIC KEY----- to -----BEGIN PUBLIC KEY----- & -----END PUBLIC KEY----- it works just fine.\r\n\r\nIs this a bug - or am I misunderstanding the differences between PKCS#1 & PKCS#8?\r\n"}}
{"actor":{"display_login":"AJPoulter-Soton"}}