Skip to content

Commit 045e90c

Browse files
crypto/ecies: use AES-192 for curve P384 (#24139)
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 <[email protected]>
1 parent 2c58e6b commit 045e90c

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

crypto/ecies/ecies_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ var testCases = []testCase{
279279
{
280280
Curve: elliptic.P384(),
281281
Name: "P384",
282-
Expected: ECIES_AES256_SHA384,
282+
Expected: ECIES_AES192_SHA384,
283283
},
284284
{
285285
Curve: elliptic.P521(),

crypto/ecies/params.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@ var (
8080
KeyLen: 16,
8181
}
8282

83+
ECIES_AES192_SHA384 = &ECIESParams{
84+
Hash: sha512.New384,
85+
hashAlgo: crypto.SHA384,
86+
Cipher: aes.NewCipher,
87+
BlockSize: aes.BlockSize,
88+
KeyLen: 24,
89+
}
90+
8391
ECIES_AES256_SHA256 = &ECIESParams{
8492
Hash: sha256.New,
8593
hashAlgo: crypto.SHA256,
@@ -108,7 +116,7 @@ var (
108116
var paramsFromCurve = map[elliptic.Curve]*ECIESParams{
109117
ethcrypto.S256(): ECIES_AES128_SHA256,
110118
elliptic.P256(): ECIES_AES128_SHA256,
111-
elliptic.P384(): ECIES_AES256_SHA384,
119+
elliptic.P384(): ECIES_AES192_SHA384,
112120
elliptic.P521(): ECIES_AES256_SHA512,
113121
}
114122

0 commit comments

Comments
 (0)