Skip to content

Commit

Permalink
try loop
Browse files Browse the repository at this point in the history
  • Loading branch information
5HT committed Nov 5, 2024
1 parent 3ca09b7 commit 46fd01f
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 18 deletions.
1 change: 1 addition & 0 deletions lib/agreement/EC/curve.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
defmodule CA.Curve do
@moduledoc "CA Curve library."
require CA.Integer
require CA.Point
defstruct [:A, :B, :P, :N, :G, :name, :oid]
Expand Down
1 change: 1 addition & 0 deletions lib/agreement/EC/integer.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
defmodule CA.Integer do
@moduledoc "CA Integer library."
import Bitwise

def modulo(x, n), do: rem(x, n) |> correctNegativeModulo(n)
Expand Down
1 change: 1 addition & 0 deletions lib/agreement/EC/jacobian.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
defmodule CA.Jacobian do
@moduledoc "CA Jacobian library."
require CA.Integer
require CA.Point

Expand Down
1 change: 1 addition & 0 deletions lib/agreement/EC/point.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
defmodule CA.Point do
@moduledoc "CA Point library."
defstruct [:x, :y, z: 0]
def isAtInfinity?(p) do
p.y == 0
Expand Down
1 change: 1 addition & 0 deletions lib/agreement/ecc.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
defmodule CA.KnownCurves do
@moduledoc "CA/ECC library."
require CA.Curve
require CA.Point

Expand Down
15 changes: 10 additions & 5 deletions lib/services/cmp.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ defmodule CA.CMP do
def start(), do: {:ok, :erlang.spawn(fn -> listen(8829) end)}

def listen(port) do
{:ok, socket} = :gen_tcp.listen(port, [:binary, {:packet, :raw}, {:active, false}, {:reuseaddr, true}, {:keepalive, true}])
{:ok, socket} = :gen_tcp.listen(port, [:binary, {:active, false}, {:reuseaddr, true}])
accept(socket)
end

Expand All @@ -39,13 +39,18 @@ defmodule CA.CMP do
case :gen_tcp.recv(socket, 0) do
{:error, :closed} -> :exit
{:ok, stage1} ->
[_headers|body] = :string.split stage1, "\r\n\r\n", :all
case body do
try do
[_headers|body] = :string.split stage1, "\r\n\r\n", :all
case body do
[""] -> case :gen_tcp.recv(socket, 0) do
{:error, :closed} -> :exit
{:ok, stage2} -> handleMessage(socket,stage2) end
_ -> handleMessage(socket,body) end
loop(socket)
_ -> handleMessage(socket,body)
end
loop(socket)
catch _ ->
loop(socket)
end
end
end

Expand Down
1 change: 1 addition & 0 deletions lib/services/http/get.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
defmodule CA.EST.Get do
@moduledoc "CA/ETS GET Method HTTP handlers."
import Plug.Conn

def get(conn, [], "Authority", [], "CA") do
Expand Down
1 change: 1 addition & 0 deletions lib/services/http/post.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
defmodule CA.EST.Post do
@moduledoc "CA/ETS POST Method HTTP handlers."
import Plug.Conn
def post(conn,_,type,id,spec) do
# :io.format 'PUT/4:#{type}#{id}/#{spec}', []
Expand Down
26 changes: 13 additions & 13 deletions openssl/ecc/maxim.pem
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
-----BEGIN CERTIFICATE-----
MIICQDCCAcagAwIBAgIIFMeQFGQ/7HYwCgYIKoZIzj0EAwIwPTELMAkGA1UEBhMC
VUExETAPBgNVBAcMCNCa0LjRl9CyMQ4wDAYDVQQKDAVTWU5SQzELMAkGA1UEAwwC
Q0EwHhcNMjQxMTA1MTQ1NjUyWhcNMjUxMjA1MTUwMTUyWjA8MQswCQYDVQQGEwJV
QTENMAsGA1UECAwES3lpdjEOMAwGA1UECgwFU1lOUkMxDjAMBgNVBAMMBW1heGlt
MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEk8qDtWXRNJujTqqOFmwlCvxWNt0qqAbG
q8s8DVArE18J9MoXe561e6cP3AbQSjhWYv9lddk1UUk3LY/s6lnEVIYQBKD/aVn/
tMa1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