From 5854b092a88c37b5aa7e48cdfd641ba11e43d440 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Ch=C3=A9ron?= Date: Sun, 28 Aug 2016 16:38:04 +0200 Subject: [PATCH] Fix ECDH when scalar and coordinate bit sizes differ --- Crypto/PubKey/ECC/Types.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Crypto/PubKey/ECC/Types.hs b/Crypto/PubKey/ECC/Types.hs index 4f100f9..57ea9a9 100644 --- a/Crypto/PubKey/ECC/Types.hs +++ b/Crypto/PubKey/ECC/Types.hs @@ -164,7 +164,8 @@ curvesOIDs = -- | get the size of the curve in bits curveSizeBits :: Curve -> Int -curveSizeBits = numBits . ecc_n . common_curve +curveSizeBits (CurveFP c) = numBits (ecc_p c) +curveSizeBits (CurveF2m c) = numBits (ecc_fx c) - 1 -- | Get the curve definition associated with a recommended known curve name. getCurveByName :: CurveName -> Curve