RSAPublicKey is backwards in order of modulus and exponent
See original GitHub issueOpenSSL doesn’t like the order you have the asn1crypto.keys.RSAPublicKey object. Simply switching the order around let’s things parse correctly. I overrode with my own class, like so:
`class MyRSAPublicKey(Sequence):
_fields = [
('public_exponent', Integer),
('modulus', Integer),
]`
Example parsing the RSAPublicKey with it currently:
openssl rsa -pubin -inform PEM -text -noout < test.pub Modulus (17 bit): 65537 (0x10001) Exponent: 00:c1:72:a6:ca:26:db:34:1e:8c:27:8d:d4:d6:0f: cd:05:16:55:95:a1:f0:a8:55:b4:a0:28:b1:db:bf: c5:df:f4:7b:b4:65:3f:31:5f:04:60:d8:d2:13:3a: 8a:58:93:78:68:a3:95:78:d8:72:0d:21:d5:f7:c3: a8:ae:7d:3a:ad:71:10:79:cf:8c:32:a3:95:16:92: 6d:63:1a:a3:55:e6:69:9a:37:0a:58:b6:44:dc:fe: be:39:12:d1:56:ef:15:99:8f:e4:ca:91:30:e8:e6: f5:fd:59:c5:17:61:53:b4:91:8d:df:53:8a:cc:b6: 4f:7b:c2:19:83:db:76:8b:44:55:85🇩🇪61:5e:f0: 6f:29:8b:8a:70:af:44:16:b3:2b:27:6b:d6:63:e6: 65:81:ed:19:5c:18:12:31:77:64:30:a0:26:6b:fe: d8:c4:0e:72:f1:26:b4:50:96:d0:e9:b3:8c:c0:bf: a5:67:d5:5f:fc💿be:15:b9:db:6f:4b:eb:f3:85: bc:5d:ef:82:3f:56:09:cf:e4:3a:e6:f6:97:2b:a6: 17:70:5e:3e:76:f4:89:f7:af:ee:9e:6f:89:f6:0c: 2b:b3:3e:97:af:4a:e7:31:f8:39:3f:14:df:62🇩🇪 01:6b:fa:80:14:9c:9e:da:5f:48:7f:e5:8f:b2:02: 01:bf
Example parsing with the order switched:
openssl rsa -pubin -inform PEM -text -noout < test.pub Modulus (2048 bit): 00:c1:72:a6:ca:26:db:34:1e:8c:27:8d:d4:d6:0f: cd:05:16:55:95:a1:f0:a8:55:b4:a0:28:b1:db:bf: c5:df:f4:7b:b4:65:3f:31:5f:04:60:d8:d2:13:3a: 8a:58:93:78:68:a3:95:78:d8:72:0d:21:d5:f7:c3: a8:ae:7d:3a:ad:71:10:79:cf:8c:32:a3:95:16:92: 6d:63:1a:a3:55:e6:69:9a:37:0a:58:b6:44:dc:fe: be:39:12:d1:56:ef:15:99:8f:e4:ca:91:30:e8:e6: f5:fd:59:c5:17:61:53:b4:91:8d:df:53:8a:cc:b6: 4f:7b:c2:19:83:db:76:8b:44:55:85🇩🇪61:5e:f0: 6f:29:8b:8a:70:af:44:16:b3:2b:27:6b:d6:63:e6: 65:81:ed:19:5c:18:12:31:77:64:30:a0:26:6b:fe: d8:c4:0e:72:f1:26:b4:50:96:d0:e9:b3:8c:c0:bf: a5:67:d5:5f:fc💿be:15:b9:db:6f:4b:eb:f3:85: bc:5d:ef:82:3f:56:09:cf:e4:3a:e6:f6:97:2b:a6: 17:70:5e:3e:76:f4:89:f7:af:ee:9e:6f:89:f6:0c: 2b:b3:3e:97:af:4a:e7:31:f8:39:3f:14:df:62🇩🇪 01:6b:fa:80:14:9c:9e:da:5f:48:7f:e5:8f:b2:02: 01:bf Exponent: 65537 (0x10001)
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (2 by maintainers)

Top Related StackOverflow Question
heh, that would be why they are backwards… wow, sorry about that. Can’t believe I missed that typo
You seem to be assigning the
pub_modtopublic_exponentandpub_exptomodulus.