Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
5HT committed Jul 31, 2023
2 parents 6e01398 + b52f1ed commit 2bc5eb2
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/cmp.ex
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ defmodule CA.CMP do
def mac(bin, salt, iter) do
base_key = :lists.foldl(fn x, acc ->

Check warning on line 40 in lib/cmp.ex

View workflow job for this annotation

GitHub Actions / build

variable "x" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 40 in lib/cmp.ex

View workflow job for this annotation

GitHub Actions / build

variable "base_key" is unused (if the variable is not meant to be used, prefix it with an underscore)
:crypto.hash(:sha256, acc) end, bin <> salt, :lists.seq(1,iter))
:binary.part(base_key, 0, 32)
# :binary.part(base_key, 0, 32)
end

def message(socket, header, {:ir, req} = body, code) do

Check warning on line 45 in lib/cmp.ex

View workflow job for this annotation

GitHub Actions / build

variable "body" is unused (if the variable is not meant to be used, prefix it with an underscore)

Check warning on line 45 in lib/cmp.ex

View workflow job for this annotation

GitHub Actions / build

variable "code" is unused (if the variable is not meant to be used, prefix it with an underscore)
Expand Down Expand Up @@ -84,8 +84,8 @@ defmodule CA.CMP do

incomingProtection = CA."ProtectedPart"(header: header, body: body)
{:ok, bin} = :"PKIXCMP-2009".encode(:'ProtectedPart', incomingProtection)
verifyKey = mac("0000", salt, counter)
verifyKey2 = :crypto.pbkdf2_hmac(:sha256, "0000", salt, counter, 32)
verifyKey = mac("ThisIsClassified", salt, counter)
verifyKey2 = :crypto.pbkdf2_hmac(:sha256, "ThisIsClassified", salt, counter, 20)
verify = :crypto.mac(:hmac, :sha256, verifyKey, bin)
verify2 = :crypto.mac(:hmac, :sha256, verifyKey2, bin)

Expand Down Expand Up @@ -119,9 +119,11 @@ defmodule CA.CMP do
outgoingProtection = CA."ProtectedPart"(header: pkiheader, body: pkibody)

{:ok, out} = :"PKIXCMP-2009".encode(:'ProtectedPart', outgoingProtection)
kdf = :crypto.pbkdf2_hmac(:sha256, out, salt, counter, 20)
# kdf = mac(out, salt, counter)
:io.format 'protection: ~p~n', [kdf]
overifyKey = mac("ThisIsClassified", salt, counter)
overifyKey2 = :crypto.pbkdf2_hmac(:sha256, "ThisIsClassified", salt, counter, 32)
overify = :crypto.mac(:hmac, :sha256, overifyKey, out)
overify2 = :crypto.mac(:hmac, :sha256, overifyKey2, out)
:io.format 'protection: ~p~n', [overify]

answer(socket, pkiheader, pkibody, :asn1_NOVALUE)
end
Expand Down

0 comments on commit 2bc5eb2

Please sign in to comment.