Commit Graph

45 Commits

Author SHA1 Message Date
Lars Petersen
2a26202a32 Add implementation of bcrypt_pbkdf 2019-03-14 21:30:29 +01:00
Olivier Chéron
717de392cd Merge pull request #238 from lpeterse/master
Extend the internal interface of the Blowfish module.
2019-03-04 06:37:15 +01:00
Crockett
133c6e1b2d Added some redundant constraints for documentation/consistency. Added an INLINABLE pragma to i2ospOf to hopefully increase specializations. 2019-02-24 17:04:10 -08:00
Crockett
0fb8a73d3b Fixed compiler warnings 2019-02-03 16:06:05 -08:00
tom-bop
1288127d8e Fix typo in bcrypt example 2018-08-30 17:47:59 +01:00
Lars Petersen
ff8a1c524d Extend the internal interface of the Blowfish module.
In preparation of an implementation of the bcrypt_pbkdf (a
variant of PBKDF2 used by OpenSSH) algorithm,
certain low-level operations of the Blowfish algorithm need to
be generalized and exposed.

The Blowfish.Primitive module has already been extended to
account for the requirements imposed by the BCrypt algorithm,
but the salt length was limited to 16 bytes and the BCrypt
specific key schedule setup has been hard-coded into the Blowfish
module.

This commit makes a clear distintion between the expandKey and
expandKeyWithSalt operation. Both take arbitrary sized salts
and keys now. The specialized operation for 16 byte salts as used
by BCrypt has been preserved and is selected automatically.
Also, the BCrypt specific parts have been move to the BCrypt
module with regard to separation of concern.

A benchmark for generating BCrypt hashes with cost 10 shows a
performance improvement from 158 to 141ms on average (Intel i5-6500)
after this refactoring.
Further experiments suggest that the specialized expandKeyWithSalt128
does not have any advantage over the generalized version
and might be removed in favour of less branches and exceptional
behaviour.
2018-05-08 22:08:20 +02:00
Luke Taylor
d27d464627 Fix cost parsing for bcrypt
The tens value was wrong for values of 20+, as reported in #230.
It should be 10*costTens not 10^costTens. This wasn't detected because
the values are the same when costTens is 1, and using high cost values
is rare with bcrypt because of the performance hit.

Also added a simple hash and validate test since the KAT tests only do
validation. This doesn't cover this bug since the cost value is too
high to include in the test. It allows similar issues to be tested
locally though.
2018-04-17 13:51:04 +01:00
Luke Taylor
5e354f9bfc Use "2b" version prefix in bcrypt hashes
Makes docs and code consistent - the code now generates hashes
with the "2b" prefix instead of "2a". Shouldn't make any difference
in practice since previously generated hashes should still validate.
2017-11-27 15:19:23 +00:00
Vincent Hanquez
57fc438c83 typo in documentation 2017-09-18 10:32:21 +01:00
Elliot Cameron
8971458e06 Fix docs for Argon variants 2017-05-17 17:11:00 -04:00
Olivier Chéron
112d2fbb15 Decrease Argon2 maximum output length
Fixes #148.
2017-04-09 17:18:26 +02:00
Vincent Hanquez
c4936ce6d8 remove Typeable 2017-02-24 14:03:33 +00:00
Vincent Hanquez
253bf0cb8b Argon2: add working hash function
* Cleanup argon c files:
  * Remove encoded format and base64 encoder
  * Remove verification code
  * Remove all variants based simple caller
* Add basic hashing function
* Add a simple KAT test
* Define more things at the haskell level
2017-02-24 13:37:40 +00:00
Nicolas DI PRIMA
002f300021 add fastpbkdf2 with sha512 2017-02-11 14:08:27 +00:00
Nicolas DI PRIMA
4189aa9389 Port Fast PBKDF2 for sha1 and sha256 2017-02-11 14:08:23 +00:00
Kazu Yamamoto
58151b9965 making PRK an instance of ByteArrayAccess and removing fromPRK/toPRK. 2016-11-30 15:10:48 +09:00
Kazu Yamamoto
3a2eb3c631 using ByteArray(Access) instead of ByteString. 2016-11-30 14:19:39 +09:00
Kazu Yamamoto
39ecb3597a removing a trailing space / a warning. 2016-11-30 14:06:21 +09:00
Kazu Yamamoto
2b9dce2c8a Dropping Show from PRK. 2016-11-28 19:23:20 +09:00
Kazu Yamamoto
e00c89fb25 adding toByteString and fromByteString to PRK. 2016-11-15 15:04:06 +09:00
Luke Taylor
de17b66e31 Fix buffer length in scrypt
The temporary XY buffer passed to the scrypt_smix C function should be
256r+64 bytes in length, but the Haskell code was only allocating 256r
bytes, causing the additional 64 to be written past the end of the
buffer.

See #91.
2016-06-13 21:08:06 +01:00
Vincent Hanquez
149bfa6010 [HKDF] document a bit better extractSkip 2016-03-29 07:17:24 +01:00
Vincent Hanquez
f362d50d46 [bcrypt] make the haddock comment reflect what happens to the cost value.
also fix a tpyo
2016-02-25 07:48:30 +00:00
Vincent Hanquez
43890b1175 Add support for HKDF (RFC 5869) 2015-12-28 14:32:07 +00:00
Luke Taylor
6d33b66245 BCrypt module doc updates
- Add doctest style example usage
- List most relevant functions
- Reformat comments
- Minor corrections and additions
2015-09-01 15:22:58 +01:00
Luke Taylor
f346c46243 Add BCrypt module doc and a validatePasswordEither fn 2015-08-26 10:33:36 +01:00
Luke Taylor
39d5eb13fe Add bcrypt password hashing and validation API 2015-08-26 10:33:36 +01:00
Vincent Hanquez
ead424f793 [Scrypt] reduce line size of comment 2015-07-29 10:03:43 +01:00
Vincent Hanquez
02956f9ef0 [KDF] move PBKDF2 and Scrypt to not be pinned to ByteString 2015-05-22 15:19:42 +01:00
Vincent Hanquez
30b7b6412a align module imports 2015-05-11 09:34:26 +01:00
Vincent Hanquez
9ae9e38ce2 move to memory stuff 2015-05-09 14:23:32 +01:00
Vincent Hanquez
937b5d08dd [scrypt] cleanup module / extensiotn 2015-05-03 14:31:14 +01:00
Vincent Hanquez
c23ddb2eaa [PBKDF2] make the code more friendly to a future mutable PRF.
Prevent doing B.take . B.concat by allocating only once the output buffer
2015-05-03 08:17:03 +01:00
Vincent Hanquez
4cde4f9311 [scrypt] remove the need for byteable by using the more generic bytearray 2015-05-02 15:44:33 +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
969daf5af1 move more compat things into Internal.Compat. 2015-04-05 07:46:34 +01:00
Vincent Hanquez
7c6adacef9 add signature to compat popCount 2015-02-08 14:41:07 +00:00
Vincent Hanquez
d2a119d1ad add popCount for old version 2015-02-08 13:30:10 +00:00
Vincent Hanquez
a98b7548b2 fix integral type for older version of memcpy. fix ghc 7.4.x 2014-11-09 14:15:55 +00:00
Vincent Hanquez
022f16eeef While it's probably safe, don't use a "pure" bytestring as a buffer.
reallocate a new buffer and copy the old thing inside.
2014-10-04 22:37:31 +01:00
Vincent Hanquez
1f9d7af56f add a working implementation of scrypt. 2014-08-23 16:36:29 +01:00
Vincent Hanquez
c84acf079e add Scrypt placeholder 2014-07-27 11:09:45 -07:00
Vincent Hanquez
04912a180a correct a typo in PBKDF2 2014-07-27 11:07:59 -07:00
Vincent Hanquez
480ff26a34 cleanup in PBKDF2 2014-07-23 05:58:22 -07:00
Vincent Hanquez
a0ce598e37 add PBKDF2 2014-07-18 15:26:01 +01:00