Commit Graph

150 Commits

Author SHA1 Message Date
Fraser Tweedale
f6c1f21e59 clarify padding requirements for PKCS15 encrypt/decrypt
The types do not say whether it is necessary to apply pad/unpad to
the input/output of the PKCS15 encrypt/decrypt functions.  Add
comments to clarify that it is not necessary to manually pad/unpad
the message.
2017-06-26 15:30:01 +02:00
Olivier Chéron
a879845434 Add note about the optional all-zero test
This is actually a lie: the condition is tested in both curve
implementations but not returned by the Haskell API.  Will be a reminder to
add this in the future.  A function 'allocRetAndFreeze' could be useful.
2017-06-04 19:25:19 +02:00
Olivier Chéron
75e3bd555e Add Show instances for EdDSA secret keys
Other algorithms define Show instances for their secrets.
Here ScrubbedBytes will obfuscate the content anyway.

Will be useful for X509.PrivKey, which requires a Show instance.
2017-06-04 19:25:19 +02:00
Olivier Chéron
6805ddd4f7 Add support for Ed448
This replaces the Diffie-Hellman API that was previously exported.
2017-06-04 19:25:19 +02:00
Olivier Chéron
6fb412e2af Use decaf_x448_derive_public_key 2017-06-04 19:25:19 +02:00
Olivier Chéron
23b359d842 Switch Haskell APIs to decaf implementation
Module 'Curve448' now use decaf.
2017-06-04 19:25:19 +02:00
Olivier Chéron
ac7eaac523 Simplify Ed25519.generateSecretKey 2017-06-02 19:37:25 +02:00
Baojun Wang
a8902fe119 remove redundant condition test on `hashLen /= B.length mHash` 2017-05-18 21:00:14 -07:00
Baojun Wang
4270f00277 Use `Digest hash` to represent message digest 2017-05-16 10:54:31 -07:00
Baojun Wang
f9a0bc3c53 Allow sign/verify digest directly
currently sign/verify works on message directly, it would be nice if PSS could sign/verify digest directly. This is useful for:

  1) for some signing server it only has a digest (without message)
  2) message could be very large, for cases when client need request a singing server to sign, it may make more sense for the client to compute digest, then ask server to (PSS) sign the digest
  3) openSSL pkeyutl (PSS) sign operation signs with digest only, not the message, it would be nice to work with openSSL more easily 

*openSSL command line:
```shell
openssl pkeyutl -pkeyopt rsa_padding_mode:pss -pkeyopt rsa_pss_saltlen:-1  -pkeyopt digest:sha256 -sign -inkey "pri.key" -in hmac.bin > sig.bin
openssl pkeyutl -pkeyopt rsa_padding_mode:pss -pkeyopt rsa_pss_saltlen:-1  -pkeyopt digest:sha256 -verify -inkey "pri.key" -in hmac.bin -sigfile sig.bin
```
2017-05-15 19:42:19 -07:00
Parnell Springmeyer
94d67ad86d
ed25519: Adding generateSecretKey and a unit test 2017-05-02 16:18:26 -05:00
Kazu Yamamoto
697fe61f9b using pointSize in withTempPoint to fix #151. 2017-04-11 20:32:57 +09:00
Olivier Chéron
6d4a2bb707 Rename Ed448 to Curve448
This makes the API uniform for both D-H functions, avoids
confusion and leaves the name Ed448 available for EdDSA.
2017-01-19 20:26:25 +01:00
Vincent Hanquez
4b34abe310 add support For Ed448 in Crypto.ECC. fix #121 2016-12-09 06:42:50 +00:00
Kazu Yamamoto
9845734b2b fixing P256 endian. 2016-12-05 13:34:54 +09:00
Vincent Hanquez
f627bf437a make a faster and more secure related to memory blits of pointDh for P256 2016-12-02 15:47:51 +00:00
Vincent Hanquez
922bed5ac5 add some documentation to ECIES 2016-12-02 15:03:19 +00:00
Vincent Hanquez
8b5a36f44e fix ECIES to work with the rewrite 2016-12-02 15:03:08 +00:00
Vincent Hanquez
f1ebbff464 fixup haddock markup 2016-12-01 16:55:17 +00:00
Vincent Hanquez
a9e3917334 fix Curve25519 generate secret key to work in the MonadRandom instead of IO 2016-12-01 12:50:31 +00:00
Vincent Hanquez
a5fb2ee23a don't export function that replace existing functionality and by-pass errors handling 2016-12-01 12:50:01 +00:00
Kazu Yamamoto
f84aa5d7ce documentation & relaxing types. 2016-11-30 14:48:49 +09:00
Kazu Yamamoto
be6bf11138 using ScrubbedBytes directly. 2016-11-30 14:41:01 +09:00
Kazu Yamamoto
c0b0846232 implmenting encodePoint and decodePoint for TLS. 2016-11-17 13:08:21 +09:00
Kazu Yamamoto
a6f177352a Eq and Show for Point and Scalar. 2016-11-16 16:53:43 +09:00
Kazu Yamamoto
aa33c00855 adding Curve_X25519. 2016-11-16 13:10:57 +09:00
Vincent Hanquez
60bb2cacb4 [ECC] Improve the code base to allow multiples different implementations
* Use TypeFamilies; need to see what to do for older GHC versions
* Start implementing some API related to ECIES
2016-11-15 15:05:58 +09:00
Vincent Hanquez
01892ac494 Merge pull request #102 from ocheron/shamirs-trick
Implement Shamir's trick
2016-09-15 21:08:48 +01:00
Olivier Chéron
43233cb911 Double-scalar multiplication using Shamir's trick 2016-09-10 12:05:46 +02:00
Olivier Chéron
5854b092a8 Fix ECDH when scalar and coordinate bit sizes differ 2016-09-10 10:26:41 +02:00
Olivier Chéron
c84230c69a Fixed hash truncation used in ECDSA signature & verification
The function tHash shifted the hash number to an incorrect number of bits
when the bit string had leading zeros.  This is one of two issues reported
in vincenthz/hs-tls#152.
2016-08-24 23:29:55 +02:00
Bodigrim
7e53922f4f Fix pointMul with negative factor on CurveF2m 2016-07-24 13:40:24 +02:00
John Galt
e2b0e9ee6b [Ed448] Fixed incorrect base point 2016-04-18 13:25:11 -07:00
Vincent Hanquez
0c3f68929b Fix serialization of ECDH and DH 2016-04-09 17:13:51 +01:00
Vincent Hanquez
fd24980530 [ECC] add Bounded instance to CurveName 2016-04-09 13:46:06 +01:00
Vincent Hanquez
0fa83e32d8 [ECDH][DH] change SharedKey representation to be the usual bytes-like representation
Prevent mistake when the serialization is not done properly, for example missing
the padding when necessary.
2016-04-09 13:45:05 +01:00
Vincent Hanquez
e29c8a6fe5 [DH] Keep The field size in bits, in Params 2016-04-09 13:41:40 +01:00
Vincent Hanquez
b07a856127 Merge pull request #62 from clinty/dsa-truncate
Do DSS truncation on verify
2016-02-11 08:04:32 +00:00
John Galt
a04b56d2a3 Added Ed448-Goldilocks support 2016-02-09 01:22:55 -07:00
Clint Adams
4c6b774a3d Do DSS truncation on verify
RFC 4880 and FIPS 186-4 require that DSA signatures truncate the
hash to the size of q.  This changes Crypto.PubKey.DSA.verify
to do so in all cases.
2016-01-10 17:05:37 -05:00
Vincent Hanquez
2785a50228 Merge pull request #42 from Rufflewind/master
Document the arguments for DH.generateParams
2015-11-18 21:51:53 +00:00
Vincent Hanquez
7928198923 [doc] Add missing documentation call 2015-11-04 15:18:05 +00:00
Phil Ruffwind
fba0565d78 Document the arguments for DH.generateParams
Also fix the formatting in the docs of Serialize.i2ospOf
2015-11-03 20:20:53 +08:00
Vincent Hanquez
2191dddf5b [Curve25519] use the Crypto.Error api instead of an Either type for parsing types 2015-11-02 11:17:19 +00:00
Vincent Hanquez
c94df41f02 [ECC] fix compilation of missing numBits 2015-09-22 17:48:43 +01:00
Vincent Hanquez
b63dc38c49 [ECC] add generate for ECC generic's scalar and point Base Multiplication helper. 2015-09-22 17:23:22 +01:00
Vincent Hanquez
08a8155f12 [P256] add function to generate a new scalar, and to get the base point. 2015-09-22 17:22:13 +01:00
Vincent Hanquez
9a1f06e3e8 [ECC] add curveSizeBits 2015-09-22 17:21:35 +01:00
Vincent Hanquez
0d2290a4a1 [RSA] allow data to be passed as is, instead of hashed 2015-06-19 11:04:37 +01:00
Vincent Hanquez
39cf449ba7 add some missing instance of HashAlgorithmASN1 2015-06-19 11:04:17 +01:00
Vincent Hanquez
a9df2a2180 [RSA] remove hashdescr in favor of just specifying the algorithm directly
The extra information is embedded in the HashAlgorithmASN1 class
that allow a digest to ASN1 structured.
2015-06-10 12:27:37 +01:00
Luke Taylor
4e1437d4fd Minor haddock fixes
Fix some incorrect parameter descriptions and spelling/typos.
2015-06-07 13:26:26 +02:00
Vincent Hanquez
7301c719bf [P256] use ScrubbedBytes for Scalar 2015-06-02 14:22:48 +01:00
Vincent Hanquez
f63a3c6025 [p256] fix all the bugs found by the now useful P256 test suite 2015-06-01 07:48:31 +01:00
Vincent Hanquez
4edb580cda [P256] add warning for non constant time operation 2015-05-30 10:38:59 +01:00
Vincent Hanquez
78fa0c3650 [P256] implement missing function, and remove un-implementable one.
remove temporary removal, and properly fixes #1
2015-05-29 15:47:25 +01:00
Vincent Hanquez
e413290d8f [p256] temporary remove missing functions. fix #1 2015-05-26 22:09:12 +01:00
Vincent Hanquez
8eaaa06e1e add optional support for deepseq 2015-05-22 18:35:46 +01:00
Vincent Hanquez
5d85834264 remove unnecessary extension 2015-05-21 14:51:23 +01:00
Vincent Hanquez
7f11a66d50 [DSA] re-align imports 2015-05-21 14:46:45 +01:00
Vincent Hanquez
28958a6d03 [RSA] remove ByteString from Primitive module 2015-05-21 14:32:53 +01:00
Vincent Hanquez
c111dfeb8e [pubkey] remove bytestring from MaskGenFunction 2015-05-21 11:09:48 +01:00
Vincent Hanquez
c7de32a6f6 [RSA] remove the need for bytestring in HashDescr and work towards more removal 2015-05-21 09:46:13 +01:00
Vincent Hanquez
8065c26c2d remove dangerous OverloadedStrings 2015-05-21 06:45:46 +01:00
Vincent Hanquez
dc34ce8289 [RSA] properly indent modules imports 2015-05-21 06:35:19 +01:00
Vincent Hanquez
881d167cb5 more fixing up description and comments 2015-05-20 06:22:00 +01:00
Vincent Hanquez
92343f856a add comments and description 2015-05-20 06:07:31 +01:00
Vincent Hanquez
fdf735d4e2 [PubKey] move ElGamal to use HashAlgorithm and ByteArrayAccess. 2015-05-12 07:01:20 +01:00
Vincent Hanquez
5d2b417854 [pubkey] make DSA and ECDSA ByteString free 2015-05-11 14:18:49 +01:00
Vincent Hanquez
4bcf193a12 [number] further remove gcde_binary 2015-05-11 07:10:38 +01:00
Vincent Hanquez
9ae9e38ce2 move to memory stuff 2015-05-09 14:23:32 +01:00
Vincent Hanquez
df3c3523a4 [P256] add a point_add function 2015-05-04 06:56:27 +01:00
Vincent Hanquez
aa790db088 [P256] add more bindings 2015-05-03 20:36:00 +01:00
Vincent Hanquez
ad34f0e1e8 use mod after add/sub 2015-05-03 20:15:26 +01:00
Vincent Hanquez
1f30911e1c [P256] define the n/p/b constants 2015-05-03 20:14:54 +01:00
Vincent Hanquez
c360e77148 [P256] properly define some bindings with X and Y types 2015-05-03 20:14:10 +01:00
Vincent Hanquez
ea875e5c88 [P256] define pointMul 2015-05-03 19:52:00 +01:00
Vincent Hanquez
25c303602d [P256] add comment to `toPoint' 2015-05-03 19:51:21 +01:00
Vincent Hanquez
c751fd1a6b [QA] fix import 2015-05-03 14:48:40 +01:00
Vincent Hanquez
dfe3a9af93 [QA] fix module imports 2015-05-03 14:48:26 +01:00
Vincent Hanquez
87777784c1 [QA] fix issues from HSE so that it parse files 2015-05-03 14:47:16 +01:00
Vincent Hanquez
c1ed30b20e [DSA] fix badly written constraint (found by QA) 2015-05-02 15:46:07 +01:00
Vincent Hanquez
1267500318 [P256] improve bindings, still work in progress. 2015-05-02 14:50:11 +01:00
Vincent Hanquez
119b111b82 fix old build by importing ByteString module to get OverloadedString instance 2015-05-02 14:49:14 +01:00
Vincent Hanquez
d7a88da726 [Curve25519] fix build and get rid of bytestring by using direct addr# "string" 2015-05-02 07:59:42 +01:00
Vincent Hanquez
db7c3bbb4f [hash] massive overhaul of the hash interface
use the typeclass for the lowest IO impure C bindings definitions,
and define the pure interface as generic on top of this.

At the same time define an Hash.IO interface to allow mutable manipulations
of hash contextes when necessary.

Use HashAlgorithm instead of HashFunction in the [PubKey] sections

Tweak the HMAC, PBKDF2 functions to be more efficient and use the new interface
2015-04-30 06:18:07 +01:00
Vincent Hanquez
ec4e0c4ed9 remove all the byteArray prefix from byteArray function.
instead expect module import to be qualified for functions.
2015-04-24 06:54:33 +01:00
Vincent Hanquez
e52a75af75 add P256 work in progress binding 2015-04-22 10:15:23 +01:00
Vincent Hanquez
0424d67616 [Curve25519] convert to Bytearray 2015-04-22 06:26:06 +01:00
Vincent Hanquez
b487aef898 cleanup module imports 2015-04-20 07:36:51 +01:00
Vincent Hanquez
f86b493e32 remove warnings 2015-04-20 06:02:12 +01:00
Vincent Hanquez
0aaa6a9e9a [Ed25519] Add haskell bindings and tests 2015-04-19 09:24:37 +01:00
Vincent Hanquez
fb7855985e reorder extension 2015-04-07 06:52:54 +01:00
Vincent Hanquez
6eae9b0557 fix warnings 2015-04-05 12:19:26 +01:00
Vincent Hanquez
b556bdb649 add missing modules 2015-04-03 07:33:16 +01:00
Vincent Hanquez
b1e222cf3d merge crypto-pubkey-types and crypto-pubkey
adapt CPRG to MonadRandom
2015-04-03 07:33:16 +01:00
Vincent Hanquez
cd870d4259 really fix build issue with ghc 7.4 2015-01-27 16:26:01 +00:00
Vincent Hanquez
9754f8b31f add bytestring instances for old ghc 2015-01-27 16:04:04 +00:00
Vincent Hanquez
033b9ced81 add support for curve 25519 2015-01-27 06:25:41 +00:00
Vincent Hanquez
ec26f9a25b add initial support for curve25519 2015-01-27 06:20:19 +00:00