Skip to content

Commit

Permalink
crypto/ecies: use AES-192 for curve P384 (ethereum#24139)
Browse files Browse the repository at this point in the history
Using curve P384 for encryption causes the error "ecies: shared key params
are too big". Also, readme.md says curve P384 should use AES192 not AES256.

Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
  • Loading branch information
2 people authored and JacekGlen committed May 26, 2022
1 parent 9509f8a commit 09fc228
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crypto/ecies/ecies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ var testCases = []testCase{
{
Curve: elliptic.P384(),
Name: "P384",
Expected: ECIES_AES256_SHA384,
Expected: ECIES_AES192_SHA384,
},
{
Curve: elliptic.P521(),
Expand Down
10 changes: 9 additions & 1 deletion crypto/ecies/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ var (
KeyLen: 16,
}

ECIES_AES192_SHA384 = &ECIESParams{
Hash: sha512.New384,
hashAlgo: crypto.SHA384,
Cipher: aes.NewCipher,
BlockSize: aes.BlockSize,
KeyLen: 24,
}

ECIES_AES256_SHA256 = &ECIESParams{
Hash: sha256.New,
hashAlgo: crypto.SHA256,
Expand Down Expand Up @@ -108,7 +116,7 @@ var (
var paramsFromCurve = map[elliptic.Curve]*ECIESParams{
ethcrypto.S256(): ECIES_AES128_SHA256,
elliptic.P256(): ECIES_AES128_SHA256,
elliptic.P384(): ECIES_AES256_SHA384,
elliptic.P384(): ECIES_AES192_SHA384,
elliptic.P521(): ECIES_AES256_SHA512,
}

Expand Down

0 comments on commit 09fc228

Please sign in to comment.