Initial commit

This commit is contained in:
Andrey Mayorov 2017-03-01 23:02:32 +03:00
commit 6a39173d1e
5 changed files with 36 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
_build

1
rebar.config Normal file
View File

@ -0,0 +1 @@
{escript_emu_args, "%%! +sbtu +A0 -noshell -boot start_clean\n"}.

1
rebar.lock Normal file
View File

@ -0,0 +1 @@
[].

17
src/genecpubkey.app.src Normal file
View File

@ -0,0 +1,17 @@
{application, genecpubkey, [
{description, "Generate PEM file with EC Public key from EC Private key"},
{vsn, "0"},
{registered, []},
{applications, [
kernel,
stdlib,
public_key
]},
{env, []},
{modules, []},
{maintainers, [
"Andrew Mayorov <a.mayorov@rbkmoney.com>"
]},
{licenses, []},
{links, []}
]}.

16
src/genecpubkey.erl Normal file
View File

@ -0,0 +1,16 @@
-module(genecpubkey).
-export([main/1]).
-spec main([string()]) -> no_return().
main([PrivKeyPEMFilename, PubKeyPEMFilename]) ->
{ok, PrivKeyPEMBin} = file:read_file(PrivKeyPEMFilename),
[PrivKeyPEMEntry] = public_key:pem_decode(PrivKeyPEMBin),
[PrivKeyPEMEntry] = public_key:pem_decode(PrivKeyPEMBin),
PrivKey = public_key:pem_entry_decode(PrivKeyPEMEntry),
{'ECPrivateKey', 1, _, ECParams, PublicKey} = PrivKey,
PubKey = {{'ECPoint', PublicKey}, ECParams},
PubKeyPEMEntry = public_key:pem_entry_encode('SubjectPublicKeyInfo', PubKey),
PubKeyPEMBin = public_key:pem_encode([PubKeyPEMEntry]),
ok = file:write_file(PubKeyPEMFilename, PubKeyPEMBin).