Skip to content

Commit

Permalink
Add ML-KEM decapsulation key check.
Browse files Browse the repository at this point in the history
Described in section 7.3 of FIPS 203.

The check is only required if the private key is from an untrusted
source. We do not distinguish between a trusted and untrusted source
in the current API, so we'll perform the check every time we unmarshal
the private key.
  • Loading branch information
bwesterb authored and armfazh committed Aug 19, 2024
1 parent 2b4626d commit 62385a8
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 9 deletions.
3 changes: 3 additions & 0 deletions kem/kem.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ var (
// ErrPubKey is the error used if the provided public key is invalid.
ErrPubKey = errors.New("invalid public key")

// ErrPrivKey is the error used if the provided private key is invalid.
ErrPrivKey = errors.New("invalid private key")

// ErrCipherText is the error used if the provided ciphertext is invalid.
ErrCipherText = errors.New("invalid ciphertext")
)
28 changes: 28 additions & 0 deletions kem/kyber/templates/pkg.templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 16 additions & 3 deletions kem/mlkem/mlkem1024/kyber.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 16 additions & 3 deletions kem/mlkem/mlkem512/kyber.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 16 additions & 3 deletions kem/mlkem/mlkem768/kyber.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 62385a8

Please sign in to comment.