From 11e42a256dc99ad6641558259a7affcdaa6a7d73 Mon Sep 17 00:00:00 2001 From: Vincent Hanquez Date: Fri, 2 Dec 2016 14:59:46 +0000 Subject: [PATCH] add the binding to get the size by bytes --- Crypto/ECC/Simple/Types.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Crypto/ECC/Simple/Types.hs b/Crypto/ECC/Simple/Types.hs index d45309a..c97daa2 100644 --- a/Crypto/ECC/Simple/Types.hs +++ b/Crypto/ECC/Simple/Types.hs @@ -18,6 +18,7 @@ module Crypto.ECC.Simple.Types , CurveBinaryParam(..) , CurvePrimeParam(..) , curveSizeBits + , curveSizeBytes , CurveParameters(..) -- * specific curves definition , SEC_p112r1(..) @@ -70,6 +71,10 @@ curveSizeBits proxy = CurvePrime (CurvePrimeParam p) -> numBits p CurveBinary (CurveBinaryParam c) -> numBits c - 1 +-- | get the size of the curve in bytes +curveSizeBytes :: Curve curve => proxy curve -> Int +curveSizeBytes proxy = (curveSizeBits proxy + 7) `div` 8 + -- | Define common parameters in a curve definition -- of the form: y^2 = x^3 + ax + b. data CurveParameters curve = CurveParameters