If I generate a public RSA key into a PEM file and then base64-decode the
contents (this is in Emacs):

(string-to-unibyte (base64-decode-string 
"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAreGA/Qky9W3izQV0kzba
7wKl/wzwxkbbQxvcUqUT1krgAbO/n1tYFjXdJZoWwbMO/qv7NRoMDY4yPWGpsQfY
+PSIknAhTZVbgwXrm/wb37+hKRKax2UZ9A/Rx4vJZRYlkpvZ9LbBziseFNN7SMWW
qkjBO/NeT8/I9mURDa+4RoYfT6ZwjTvt808PH7uIghk+MHAx9EMBAfafF1Jn9TqW
y+Hgdqik9sZteMvCumvGK4grSwzdfPO5I05tt/0I7QVPxlXbHIk/bBsE7mpgOxur
P0DAkFKtYDM7oZPBwB6X778ba2EEFKPpVIyzw/jlDPd9PB6gE6dixmax3Hlg69RI
EwIDAQAB"))

I seem unable to load that as a public key (SCHARS macro == length,
SDATA macro == data):

struct rsa_public_key key;
rsa_public_key_init(&key);
rsa_keypair_from_der (&key, NULL, 0, SCHARS (public_key), SDATA (public_key))

It keeps failing.  From the docs and example it seems like that should
work.  Can you see what I'm doing wrong?  I've spent a few hours on
it and can't trace the problem.  If not I will start digging into the
key loading functions, but was hoping it's something obvious (and if you
have a working example that would be great).

As soon as I have this working I will publish my work for review; the
RSA signatures are the last piece missing.

Ted

_______________________________________________
nettle-bugs mailing list
[email protected]
http://lists.lysator.liu.se/mailman/listinfo/nettle-bugs

Reply via email to