mirror of
https://github.com/valitydev/genecpubkey.git
synced 2024-11-06 02:25:24 +00:00
Initial commit
This commit is contained in:
commit
6a39173d1e
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
_build
|
1
rebar.config
Normal file
1
rebar.config
Normal file
@ -0,0 +1 @@
|
||||
{escript_emu_args, "%%! +sbtu +A0 -noshell -boot start_clean\n"}.
|
1
rebar.lock
Normal file
1
rebar.lock
Normal file
@ -0,0 +1 @@
|
||||
[].
|
17
src/genecpubkey.app.src
Normal file
17
src/genecpubkey.app.src
Normal 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
16
src/genecpubkey.erl
Normal 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).
|
Loading…
Reference in New Issue
Block a user