Skip to content

Commit

Permalink
hash algs
Browse files Browse the repository at this point in the history
  • Loading branch information
5HT committed Jul 28, 2023
1 parent f5755e4 commit 949f6ae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
8 changes: 8 additions & 0 deletions lib/alg.ex
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ defmodule CA.ALG do
{:'id-aes256-GCM', {2,16,840,1,101,3,4,1,46}},
{:'id-aes256-CCM', {2,16,840,1,101,3,4,1,47}},
{:'id-aes256-wrap-pad', {2,16,840,1,101,3,4,1,48}},
{:sha256, {2,16,840,1,101,3,4,2,1}},
{:sha384, {2,16,840,1,101,3,4,2,2}},
{:sha512, {2,16,840,1,101,3,4,2,3}},
{:sha224, {2,16,840,1,101,3,4,2,4}},
{:'sha512-224', {2,16,840,1,101,3,4,2,5}},
{:'sha512-256', {2,16,840,1,101,3,4,2,6}},
{:shake128, {2,16,840,1,101,3,4,2,11}},
{:shake256, {2,16,840,1,101,3,4,2,12}},
{:'dsa-with-sha224', {2,16,840,1,101,3,4,3,1}},
{:'dsa-with-sha256', {2,16,840,1,101,3,4,3,2}},
{:'dhSinglePass-stdDH-hkdf-sha256-scheme', {1,2,840,113549,1,9,16,3,19}},
Expand Down
12 changes: 8 additions & 4 deletions lib/cmp.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@ defmodule CA.CMP do

# IETF 2510:2005 X.509 PKI CMP

# openssl cmp -cmd genm -server 127.0.0.1:829 \
# openssl cmp -cmd genm -server 127.0.0.1:1829 \
# -recipient "/CN=CMPserver" -ref 1234 -secret pass:0000

# openssl cmp -cmd ir -server 127.0.0.1:829 \
# openssl cmp -cmd ir -server 127.0.0.1:1829 \
# -path priv/certs -srvcert ca.pem -ref NewUser \
# -secret pass:0000 -certout maxim.pem -newkey maxim.key -subject "/CN=maxim/O=SYNRC/ST=Kyiv/C=UA"

# openssl cmp -cmd p10cr -server localhost:1829 \
# -path . -srvcert ca.pem -ref cmptestp10cr \
# -secret pass:0000 -certout $client.pem -csr $client.csr


def code(), do: :binary.encode_hex(:crypto.strong_rand_bytes(8))
def start(), do: :erlang.spawn(fn -> listen(1829) end)

Expand Down Expand Up @@ -93,12 +98,11 @@ defmodule CA.CMP do
def loop(socket) do
case :gen_tcp.recv(socket, 0) do
{:ok, data} ->
:io.format 'Data: ~p~n', [data]
{{_,headers},asn} = :asn1rt_nif.decode_ber_tlv(data)

Check warning on line 101 in lib/cmp.ex

View workflow job for this annotation

GitHub Actions / build

variable "headers" is unused (if the variable is not meant to be used, prefix it with an underscore)
[_,body] = :string.split asn, "\r\n\r\n", :all
{:ok,dec} = :'PKIXCMP-2009'.decode(:'PKIMessage', body)
{:PKIMessage, header, body, code, _} = dec
:logger.info 'PKIMessage:~n~p~n', [dec]
:io.format 'PKIMessage:~n~p~n', [dec]
message(socket, header, body, code)
loop(socket)
{:error, :closed} -> :exit
Expand Down

0 comments on commit 949f6ae

Please sign in to comment.