diff --git a/lib/encryption/cms.ex b/lib/encryption/cms.ex index 9988504..ab799b3 100644 --- a/lib/encryption/cms.ex +++ b/lib/encryption/cms.ex @@ -257,7 +257,7 @@ defmodule CA.CMS do end def parseContentInfo({:ContentInfo, oid, content}, false) do - case CA.AT.oid(oid) do + case CA.AT.code(oid) do :data -> parseData(content) :signedData -> parseData(content) :envelopedData -> parseEnvelopedData(content) @@ -265,7 +265,7 @@ defmodule CA.CMS do end end def parseContentInfo({:ContentInfo, oid, content}, true) do - case CA.AT.oid(oid) do + case CA.AT.code(oid) do :data -> parseDataBin(content) :signedData -> parseDataBin(content) :envelopedData -> parseEnvelopedDataBin(content) diff --git a/lib/oid/at.ex b/lib/oid/at.ex index 14c1344..2d30e72 100644 --- a/lib/oid/at.ex +++ b/lib/oid/at.ex @@ -1,11 +1,7 @@ defmodule CA.AT do @moduledoc "CA CSR Attributes OIDs." - def oid(x) do - case :lists.keyfind(x, 1, algorithms()) do - {_,val} -> val - false -> CA.ALG.oid(x) - end - end + def oid(x) do case :lists.keyfind(x, 1, algorithms()) do {_,val} -> val ; false -> CA.ALG.oid(x) end end + def code(x) do case :lists.keyfind(x, 2, algorithms()) do {code,_} -> code ; false -> CA.ALG.lookup(x) end end # https://zakon.rada.gov.ua/laws/show/z0423-17