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

Ingela Andin <>
Mon Jan 24 22:59:44 CET 2011


Hi Seth,

2011/1/24 Seth Falcon <>:
> On Mon, Jan 24, 2011 at 2:51 AM, Ingela Andin <> wrote:
>> I think that the decoding of  'SubjectPublicKeyInfo',  from
>> pem_decode_public_key, should rather be handled in the
>> function pem_entry_decode. As I think the normal thing is that you
>> want the actual key and not a 'SubjectPublicKeyInfo', that would
>> mean just a little more decoding is done by pem_entry_decode. (You can
>> match on the 'SubjectPublicKeyInfo' in the function head to
>> create a clause for this.)


> Sure.  I agree that the common case is that you want the public key in
> a form that can be used for encrypt/decrypt as easily as possible.
> I'll try reworking things so that this happens inside pem_entry_decode
> -- and then remove the pem_decode_public_key function.
>
> Can you point me at docs on how to run the tests for the public_key
> module?

https://github.com/erlang/otp/wiki/Running-tests

I think this should still work, but we are in the process of  migrating from one
testfrontend to another. So maybe Lucas can point you eleswhere if needed.


>> It will not then be a 100 % symmetric with pem_entry_encode but I
>> think  that is ok, it could be mentioned in the documentation.
>> Another reason that this is a good idea is that it will not then be
>> sensitive to that the public_key is the only entry in the file.
>> PEM files may contain several entries which is not handled by your
>> function.
>
> Do you think it should be possible to reproduce the
> SubjectPublicKeyInfo-style PEM file given an 'RSAPublicKey' record
> type?  I think this has some value, aside from symmetry, because it is
> the default output of openssl.
>
> I admit that I haven't yet worked through the encoding cases in any
> detail, so perhaps I'm not clear on how this is supposed to work.
>

I thought some more about this and I feel the right way to go is have
several clauses in pem_entry_encode for the asn1-type  'SubjectPublicKeyInfo'
some thing along the lines

pem_entry_decode( 'SubjectPublicKeyInfo',  #'RSAPublicKey'{}) ->


More information about the erlang-questions mailing list