[erlang-questions] Question about Patch: Add MD5 and SHA1 sign/verify functions

Daniel Kwiecinski <>
Tue Feb 5 11:40:09 CET 2008


I've applied the path from
http://article.gmane.org/gmane.comp.lang.erlang.patches/151 and
I did the following. Any help explaining cause of the error will be
very appreciated. Do I correct use MPints?

************* CODE *************************************************************
encode(String) when is_list(String) ->
  {ok,{'RSAPrivateKey', 'two-prime', N , E, _, _, _, _, _, _, _}} =
ssl_pkix:decode_rsa_keyfile("keys/private.pem", ""),
  io:format("N: ~p, E: ~p~n", [N, E]),
  LicEncoded = base64:encode(String),
  DataSize = size(StringEncoded),
  Data = list_to_binary([<<DataSize:32/integer>>, StringEncoded]),
  Key = [crypto:mpint(N), crypto:mpint(E)],
  Signed = crypto:rsa_sha_sign(Data, Key).


************* OUTPUT
************************************************************

1> N: 138445250593310927542773857214440421480303788023222788575718585027863611115049364971357691872676298545743250295800358402756549552994822827897856839673996350473620588754354369610803297438509920062322876055789528692164182842422276496510610413689066855989959284865235115518531216882699698497082235347230922628187,
E: 65537

ERROR erlang  code  crashed:
Reason: {badarg,[{erlang,port_control,
                         [#Port<0.726>,37,
                          [<<0,0,0,12,89,87,74,106,101,72,108,54,77,84,73,122>>,
                           [<<0,0,0,129,0,197,39,15,141,167,6,5,108,161,36,156,
                              232,98,38,254,39,218,195,218,129,86,197,124,175,
                              154,216,158,194,246,96,166,139,158,183,81,58,162,
                              18,64,198,190,247,160,66,39,71,212,124,232,153,
                              25,254,239,65,183,202,58,151,88,229,174,59,162,4,
                              230,41,233,100,28,179,130,16,216,89,163,179,59,
                              223,210,251,174,78,108,157,165,251,234,86,60,198,
                              244,158,230,64,250,137,86,85,7,55,61,26,94,207,
                              27,171,40,181,95,236,192,7,33,219,39,233,110,211,
                              132,47,236,69,170,167,6,171,220,91>>,
                            <<0,0,0,3,1,0,1>>]]]},
                 {crypto,control,2},
                 {crypto,rsa_sha_sign,2},

-- 
Kind Regards,
Daniel Kwiecinski



More information about the erlang-questions mailing list