2013-03-27 3 views
4

얼랭의 GPG 공개 키를 "pem_entry_decode"할 수 없습니다. OpenSSL을 통해 생성 된 공개 키는 정상적으로 작동합니다. Erlang - Importing GPG Public Key에서 제안한대로 GPG 키를 수정했습니다.Erlang의 PGP 키 디코딩

#!/usr/local/bin/escript 

main(_) -> 
    [application:start(X) || X <- [crypto, public_key, ssl]], 
    Msg = list_to_binary("Hello World!"), 
    %{ok, FileContents} = file:read_file("public_openssl.pem"), 
    {ok, FileContents} = file:read_file("public_gpg.asc"), 
    show(FileContents), 
    [Entry] = public_key:pem_decode(FileContents), 
    show(Entry), 
    Key = public_key:pem_entry_decode(Entry), 
    show(Key), 
    EM = public_key:encrypt_public(Msg, Key), 
    show(EM). 

show(Something) -> 
    io:format("~p~n", [Something]). 

오류 :에서

escript: exception error: no match of right hand side value 
       {error, 
        {asn1, 
         {wrong_tag, 
          {{expected,16},{got,131097,{131097,<<"\r">>}}}}}} 
    in function public_key:der_decode/2 (public_key.erl, line 170) 
    in call from erl_eval:do_apply/6 (erl_eval.erl, line 572) 
    in call from erl_eval:expr/5 (erl_eval.erl, line 367) 
    in call from escript:eval_exprs/5 (escript.erl, line 850) 
    in call from erl_eval:local_func/5 (erl_eval.erl, line 470) 
    in call from escript:interpret/4 (escript.erl, line 768) 
    in call from escript:start/1 (escript.erl, line 277) 
    in call from init:start_it/1 
+0

소스 코드가 오류 스택과 일치합니까? 오류 스택에는 public_key : der_decode에 대한 언급이 있지만 소스 코드에는 public_key : pem_decode가 포함되어 있습니다 ... – user803422

+0

public_key.erl을 체크인했습니다. 'der_decode'는'pem_entry_decode'에 의해 호출됩니다. 왜 전체 스택을 표시하지 않는지 확실하지 않습니다. – ram

+1

R16B의 새로운 Erlang 릴리스에서이 문제를 재현 해보는 것이 좋습니다. 이제 DER로 인코딩 된 다양한 DER에 약간 친숙 함을 느낀다는 소식이 있습니다. – Keynslug

답변

0

:

{ok, FileContents} = file:read_file("public_gpg.asc") 

FileContents, 처음 16 개 문자를 선택합니다.