Skip to content

Commit 45930df

Browse files
committed
fix(s138): verify answers no trust when FIPS mode's provider refuses ML-DSA-87 with :error, never a crash
Signed-off-by: Ayla Croft <aylacroft@proton.me>
1 parent 5bd20ff commit 45930df

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎lib/trinity/n6/cose.ex‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,14 @@ defmodule Trinity.N6.COSE do
223223
e in ErlangError -> unavailable(e)
224224
end
225225

226-
# :crypto raises :notsup in FIPS mode on a provider that refuses ML-DSA-87, and badarg where
227-
# the linked library has no ML-DSA at all. Either way this runtime cannot judge.
228-
defp unavailable(%ErlangError{original: {reason, _, _}}) when reason in [:notsup, :badarg],
229-
do: {:error, :alg_unavailable}
226+
# How :crypto says the runtime cannot do ML-DSA-87, each measured: `badarg` ("Bad key type")
227+
# where the linked OpenSSL has no ML-DSA (3.0); `error` ("Can't create PKEY_CTX from id") from
228+
# `verify` in FIPS mode on Red Hat's provider (the `fips` job, PR #133); `notsup` ("Unsupported
229+
# algorithm in FIPS mode") for an algorithm the mode refuses. Key and signature sizes are checked
230+
# before any call, so these are the runtime's answer, not the caller's mistake: no trust.
231+
defp unavailable(%ErlangError{original: {reason, _, _}})
232+
when reason in [:notsup, :badarg, :error],
233+
do: {:error, :alg_unavailable}
230234

231235
defp unavailable(e), do: raise(e)
232236

0 commit comments

Comments
 (0)