Commit Graph

660 Commits

Author SHA1 Message Date
Sarah Vaupel
f78fca2504 Merge branch 'master' into uni2work 2024-01-09 02:48:31 +01:00
Felix Paulusma
9401b4e3fd
Small refactor
The same parameter was matched on twice, so why not just do it once?
2022-10-03 01:01:30 +02:00
Vincent Hanquez
20b194fc97
fix byteswap32 to work on Word32# instead of Word# (with compat for ghc < 9.2) 2022-03-13 20:49:11 +08:00
Gregor Kleen
71a630edaf resumable hashing 2021-06-23 12:29:34 +02:00
George Pollard
e9c9c770d3
Update HMAC.hs 2021-06-03 08:34:34 +12:00
George Pollard
9961606e5b
Merge branch 'master' into hmac-lazy 2021-06-03 08:33:55 +12:00
Vincent Hanquez
a6fbe0ed4c
fix miscompilation with ghc9 2021-05-08 22:57:36 +08:00
Vincent Hanquez
b6981a4ea5
latest integer-gmp breaks advance GMP functions again (...) 2021-05-08 22:57:26 +08:00
Vincent Hanquez
cf89276b5c
Merge pull request #312 from ocheron/eddsa-gen
Generic EdDSA implementation
2021-04-14 23:17:34 +08:00
Hamish Mackenzie
95b247e5eb
Fix for 32 bit platforms
The use of `(fromIntegral (maxBound :: Word32))` causes problems.  It is used to make an `Int` and 32 bit systems it winds up being -1.
2021-04-14 17:16:15 +12:00
Patrick Chilton
b29dc159fb Hash data in 4GB chunks to avoid uint32_t overflow. 2020-08-07 21:36:19 +02:00
Olivier Chéron
18ae7a7b40 Remove redundant brackets 2020-07-19 15:45:49 +02:00
Olivier Chéron
fa19117dfe Avoid thunk leak with AEAD state 2020-07-19 15:44:10 +02:00
Olivier Chéron
d49408156e Warn about instances exposing internals 2020-07-05 09:20:29 +02:00
Olivier Chéron
81cc351800 Note about drgNewTest and endianness 2020-07-05 09:20:29 +02:00
Olivier Chéron
e67d8fb223 Generate HashAlgorithmPrefix instances 2020-06-26 07:16:41 +02:00
Olivier Chéron
ba3ab1f0cd Add HashAlgorithmPrefix API 2020-06-26 07:16:18 +02:00
Olivier Chéron
dfc9fb9fb2 Fix powF2m when exponent is not a power of 2
Integer multiplication cannot be used because it includes carry
propagation.  This needs to use carry-less mulF2m instead.
2020-06-12 19:01:52 +02:00
Olivier Chéron
5f657fda2e Remove powF2m'
We keep only the function providing the base service, negative
exponents can be still computed with invF2m.
2020-06-12 18:54:37 +02:00
Will Song
f64efafbad update sqrtF2m 2020-06-08 10:16:42 -05:00
Will Song
17336857c5 implement square roots in f2m 2020-06-01 20:56:42 -05:00
Olivier Chéron
775855994c Use notElem 2020-03-15 15:44:35 +01:00
Olivier Chéron
981b97a132 Protect against negative argument 2020-02-24 06:54:23 +01:00
Olivier Chéron
2e0a60f7f7 Use Semigroup API 2020-02-24 06:54:23 +01:00
Olivier Chéron
b01f610aa2 Add and use Builder module
Avoids intermediate allocations and conversions when concatenating
byte arrays of different types.
2020-02-24 06:54:23 +01:00
Olivier Chéron
ef880291e3 Add EdDSA 'ctx' and 'ph' variants 2020-02-24 06:54:23 +01:00
Olivier Chéron
1cb2cd2f12 Ability to select the hash algorithm 2020-02-24 06:54:23 +01:00
Olivier Chéron
6f932998ad Fast hashing for EdDSA 2020-02-24 06:54:23 +01:00
Olivier Chéron
bd84c75f3e Use unsafe FFI calls
Changed Edwards primitives to unsafe when overhead of FFI call is
approximately 5% or more of total execution time.
2020-02-24 06:54:23 +01:00
Olivier Chéron
6f70986cb1 Avoid signature padding when not required 2020-02-24 06:54:23 +01:00
Olivier Chéron
633879f801 Avoid repeated point encoding 2020-02-24 06:54:23 +01:00
Olivier Chéron
6075b698e1 Generic EdDSA implementation 2020-02-24 06:54:23 +01:00
Olivier Chéron
4b8a8229cf Remove redundant where 2020-02-24 06:53:03 +01:00
Olivier Chéron
43a9967b1d Remove redundant superclass in MonadRandom
Reported by @frasertweedale
2020-02-16 19:49:49 +01:00
Olivier Chéron
7ac3060873 Better P256.pointMul performance
Use dedicated function to avoid multiplying the basepoint with 0.
2020-01-06 18:49:12 +01:00
Olivier Chéron
1f6ed5711c Warn about non-uniform distribution with QuickCheck 2020-01-04 10:58:22 +01:00
Olivier Chéron
9e0dbb3231 Modular square root 2019-12-07 08:35:14 +01:00
Olivier Chéron
0a1aa3517c Fix warnings and whitespace 2019-12-03 21:06:17 +01:00
Olivier Chéron
18c6e37ef1 Merge pull request #300 from ocheron/tc-ecdsa
ECDSA with a type class
2019-12-01 08:47:33 +01:00
Brian Wignall
78684bc62b Fix typos 2019-11-30 18:22:26 -05:00
Olivier Chéron
99820c742d Truncate the digest without Integer conversion 2019-11-11 17:46:16 +01:00
Olivier Chéron
b9a8a6b83d ECDSA with digest 2019-11-11 17:46:16 +01:00
Olivier Chéron
15327ecd4f ECDSA with a type class 2019-11-11 17:46:16 +01:00
Olivier Chéron
8f75165f8b Time-constant P256 scalar inversion 2019-11-11 17:46:16 +01:00
Olivier Chéron
977e75f478 Add P256 functions to implement ECDSA 2019-11-11 17:46:16 +01:00
Olivier Chéron
19b7ab375a Time-constant modular inverse 2019-11-11 17:46:16 +01:00
Olivier Chéron
6f2a59e470 Apply hlint suggestions 2019-10-05 08:34:12 +02:00
Olivier Chéron
db8d47a76c ECC arithmetic in prime-order subgroup
A type-class extension packs together additional functions related to
a chosen basepoint as well as scalar serialization and arithmetic
modulo the subgroup order.
2019-10-05 08:34:12 +02:00
Olivier Chéron
bdf1a7a133 Require point equality in EllipticCurveArith
This is an incompatible API change but is very useful to test
properties and algorithms derived from the primitives.  An ECC
instance sufficiently advanced to have math primitives should
implement equality too.
2019-10-05 08:34:12 +02:00
Olivier Chéron
2e92639679 Add P256.scalarMul 2019-10-05 08:34:12 +02:00