summaryrefslogtreecommitdiff
path: root/openbsd-compat/bcrypt_pbkdf.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2015-05-05 19:10:23 +1000
committerDamien Miller <djm@mindrot.org>2015-05-10 11:57:27 +1000
commitf6391d4e59b058984163ab28f4e317e7a72478f1 (patch)
tree06075ecf44c25cc865c4a0445ef1e761908ba19b /openbsd-compat/bcrypt_pbkdf.c
parent8ac6b13cc9113eb47cd9e86c97d7b26b4b71b77f (diff)
upstream commit
- deraadt@cvs.openbsd.org 2015/01/08 00:30:07 [bcrypt_pbkdf.c] declare a local version of MIN(), call it MINIMUM()
Diffstat (limited to 'openbsd-compat/bcrypt_pbkdf.c')
-rw-r--r--openbsd-compat/bcrypt_pbkdf.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/openbsd-compat/bcrypt_pbkdf.c b/openbsd-compat/bcrypt_pbkdf.c
index f412829b6..905fc5d44 100644
--- a/openbsd-compat/bcrypt_pbkdf.c
+++ b/openbsd-compat/bcrypt_pbkdf.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bcrypt_pbkdf.c,v 1.10 2014/12/30 01:41:43 djm Exp $ */ 1/* $OpenBSD: bcrypt_pbkdf.c,v 1.12 2015/01/08 00:30:07 deraadt Exp $ */
2/* 2/*
3 * Copyright (c) 2013 Ted Unangst <tedu@openbsd.org> 3 * Copyright (c) 2013 Ted Unangst <tedu@openbsd.org>
4 * 4 *
@@ -37,6 +37,8 @@
37#endif 37#endif
38#define SHA512_DIGEST_LENGTH crypto_hash_sha512_BYTES 38#define SHA512_DIGEST_LENGTH crypto_hash_sha512_BYTES
39 39
40#define MINIMUM(a,b) (((a) < (b)) ? (a) : (b))
41
40/* 42/*
41 * pkcs #5 pbkdf2 implementation using the "bcrypt" hash 43 * pkcs #5 pbkdf2 implementation using the "bcrypt" hash
42 * 44 *
@@ -158,7 +160,7 @@ bcrypt_pbkdf(const char *pass, size_t passlen, const u_int8_t *salt, size_t salt
158 /* 160 /*
159 * pbkdf2 deviation: output the key material non-linearly. 161 * pbkdf2 deviation: output the key material non-linearly.
160 */ 162 */
161 amt = MIN(amt, keylen); 163 amt = MINIMUM(amt, keylen);
162 for (i = 0; i < amt; i++) { 164 for (i = 0; i < amt; i++) {
163 size_t dest = i * stride + (count - 1); 165 size_t dest = i * stride + (count - 1);
164 if (dest >= origkeylen) 166 if (dest >= origkeylen)