diff options
-rw-r--r-- | src/plop.erl | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/plop.erl b/src/plop.erl index b0d9090..ccc32cf 100644 --- a/src/plop.erl +++ b/src/plop.erl @@ -81,10 +81,7 @@ init([PrivKeyfile, PubKeyfile]) -> %% LogID = crypto:hash(sha256, %% public_key:der_encode('RSAPublicKey', Public_key)), %% Read EC keypair. - {Private_key, Public_key} = read_keyfiles_ec(PrivKeyfile, PubKeyfile), - LogID = crypto:hash(sha256, public_key:der_encode( - 'ECPoint', - element(2, element(1, Public_key)))), % FIXME! + {Private_key, Public_key, LogID} = read_keyfiles_ec(PrivKeyfile, PubKeyfile), _Tree = ht:reset_tree([db:size() - 1]), {ok, #state{pubkey = Public_key, privkey = Private_key, @@ -278,6 +275,8 @@ read_keyfile_rsa(Filename, Passphrase) -> %% @doc Read two PEM files, one with a private EC key and one with the %% corresponding public EC key. +%% -spec read_keyfiles_ec(list(), list()) -> +%% {ec_private_key(), ec_public_key(), binary()}. read_keyfiles_ec(PrivkeyFile, Pubkeyfile) -> {ok, PemBinPriv} = file:read_file(PrivkeyFile), [OTPPubParamsPem, PrivkeyPem] = public_key:pem_decode(PemBinPriv), @@ -297,7 +296,9 @@ read_keyfiles_ec(PrivkeyFile, Pubkeyfile) -> Point = #'ECPoint'{point = Octets}, Publickey = {Point, Params}, - {Privatekey, Publickey}. + KeyID = crypto:hash(sha256, AlgoDer), + + {Privatekey, Publickey, KeyID}. decode_key(Entry) -> public_key:pem_entry_decode(Entry). |