[erlang-questions] public_key:pem_decode/1 and public_key:verify/4

Ingela Andin ingela.andin@REDACTED
Tue Feb 1 12:31:00 CET 2011


Hi!

We are getting there thank you for your good work, and with a few
more adjustments we will include it.

I would like you to change the function pem_entry_encode in the following way

pem_entry_encode('SubjectPublicKeyInfo', Entity=#'RSAPublicKey'{}) ->
%% The function clause that you implemented for RSA

pem_entry_encode('SubjectPublicKeyInfo', {DsaInt,
Params=#'Dss-Parms'{}}) when is_integer(DsaInt) ->
%% The function clause that you implemented for DSA

pem_entry_encode('RSAPublicKey', Entity=#'RSAPublicKey'{}) ->
%% This clause I think should not need to be special but should be
able to go as default
%% and create an "BEGIN RSA PUBLIC KEY"  entry.

And finally include  the trivial patch from Jocke.

RSA-keys does not have any parameters hence the value  NULL  value
"<<5,0>>" you could make a
constante for it calling it DER_NULL.

And also a test case for the "BEGIN RSA PUBLIC KEY" maybe you could
use Jokes example.

Regards Ingela Erlang/OTP team - Ericsson AB

2011/1/31 Seth Falcon <seth@REDACTED>:
> Hi Ingela,
>
> I've updated my patch:
>
>    https://github.com/seth/otp/tree/sf/rsa_pub_key
>
> it now includes basic tests for decoding and encoding both RSA and DSA
> public keys in the SubjectPublicKeyInfo format.  After moving all
> lib/FOO/test directories with references to wx, I was able to run the
> tests for public_key on my OS X laptop :-)
>
> Here's the summary of where I ended up:
>
>    {ok, RSAPubPem} = file:read_file(filename:join(Datadir, "rsa_pub.pem")),
>    [{'SubjectPublicKeyInfo', _, _} = PubEntry1] =
>        public_key:pem_decode(RSAPubPem),
>    RSAPubKey = public_key:pem_entry_decode(PubEntry1),
>    true = check_entry_type(RSAPubKey, 'RSAPublicKey'),
>    PubEntry1 = public_key:pem_entry_encode('RSAPublicKey', RSAPubKey),
>
> Notes:
>
> - I haven't merged in the trivial patch from Joakim to allow reading
>  RSA public keys in "unwrapped" form where the PEM header has "RSA
>  Public Key".
>
> - RSA public key records get encoded into the SubjectPublicKeyInfo
>  wrapper form.  So to create the form that Joakim is dealing with,
>  one would have to use der_encode directly I believe.
>
> - When encoding RSAPublic keys, there is a parameter spot where it
>  seems the right thing to put is <<5, 0>>, but I wanted to mention
>  this in case I'm wrong about this being the right value for all RSA
>  public keys in SPKI form.
>
> Let me know what else I can do to help get this patch into the
> public_key module :-)
>
> Best,
>
> + seth
>
> --
> Seth Falcon | @sfalcon | http://userprimary.net/
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>
>


More information about the erlang-questions mailing list