From bec5712921884345301f2814b512b95c730202b9 Mon Sep 17 00:00:00 2001 From: xq840622 Date: Tue, 21 Dec 2021 15:49:29 +0800 Subject: [PATCH 1/2] update params.go There is an error, which says "ecies: shared key params are too big", if we use P384 for encrypt. As it is said in readme.md, curve P384 should use AES192 not AES256. --- crypto/ecies/params.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crypto/ecies/params.go b/crypto/ecies/params.go index 0bd3877ddd6f..0aa97a73b978 100644 --- a/crypto/ecies/params.go +++ b/crypto/ecies/params.go @@ -79,6 +79,14 @@ var ( BlockSize: aes.BlockSize, 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, @@ -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, } From 4903a9fd1ca9eed4b9a90ac146bc462accfff5b8 Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Thu, 6 Jan 2022 10:27:47 +0100 Subject: [PATCH 2/2] crypto/ecies: lint + fixed test --- crypto/ecies/ecies_test.go | 2 +- crypto/ecies/params.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crypto/ecies/ecies_test.go b/crypto/ecies/ecies_test.go index 0a6aeb2b5175..96e33da006fb 100644 --- a/crypto/ecies/ecies_test.go +++ b/crypto/ecies/ecies_test.go @@ -279,7 +279,7 @@ var testCases = []testCase{ { Curve: elliptic.P384(), Name: "P384", - Expected: ECIES_AES256_SHA384, + Expected: ECIES_AES192_SHA384, }, { Curve: elliptic.P521(), diff --git a/crypto/ecies/params.go b/crypto/ecies/params.go index 0aa97a73b978..39e7c8947373 100644 --- a/crypto/ecies/params.go +++ b/crypto/ecies/params.go @@ -79,7 +79,7 @@ var ( BlockSize: aes.BlockSize, KeyLen: 16, } - + ECIES_AES192_SHA384 = &ECIESParams{ Hash: sha512.New384, hashAlgo: crypto.SHA384,