Fix serialization of ECDH and DH

This commit is contained in:
Vincent Hanquez 2016-04-09 17:13:51 +01:00
parent e76d43470d
commit 0c3f68929b
3 changed files with 6 additions and 2 deletions

View File

@ -1,3 +1,7 @@
## 0.15
* Fix serialization of DH and ECDH
## 0.14
* Reduce size of SHA3 context instead of allocating all-size fit memory. save

View File

@ -76,4 +76,4 @@ generatePublic = calculatePublic
-- | generate a shared key using our private number and the other party public number
getShared :: Params -> PrivateNumber -> PublicNumber -> SharedKey
getShared (Params p _ bits) (PrivateNumber x) (PublicNumber y) = SharedKey $ i2ospOf_ (bits + 7 `div` 8) $ expSafe y x p
getShared (Params p _ bits) (PrivateNumber x) (PublicNumber y) = SharedKey $ i2ospOf_ ((bits + 7) `div` 8) $ expSafe y x p

View File

@ -42,7 +42,7 @@ calculatePublic curve d = q
-- | Generating a shared key using our private number and
-- the other party public point.
getShared :: Curve -> PrivateNumber -> PublicPoint -> SharedKey
getShared curve db qa = SharedKey $ i2ospOf_ (nbBits + 7 `div` 8) x
getShared curve db qa = SharedKey $ i2ospOf_ ((nbBits + 7) `div` 8) x
where
Point x _ = pointMul curve db qa
nbBits = curveSizeBits curve