summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2015-05-05 19:10:58 +1000
committerDamien Miller <djm@mindrot.org>2015-05-10 11:57:31 +1000
commitd028d5d3a697c71b21e4066d8672cacab3caa0a8 (patch)
tree4d1d725b33f2e4480fd8974bfbfb4d0204841a25
parentf6391d4e59b058984163ab28f4e317e7a72478f1 (diff)
upstream commit
- tedu@cvs.openbsd.org 2015/01/12 03:20:04 [bcrypt_pbkdf.c] rename blocks to words. bcrypt "blocks" are unrelated to blowfish blocks, nor are they the same size.
-rw-r--r--openbsd-compat/bcrypt_pbkdf.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/openbsd-compat/bcrypt_pbkdf.c b/openbsd-compat/bcrypt_pbkdf.c
index 905fc5d44..0a07f9a0f 100644
--- a/openbsd-compat/bcrypt_pbkdf.c
+++ b/openbsd-compat/bcrypt_pbkdf.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bcrypt_pbkdf.c,v 1.12 2015/01/08 00:30:07 deraadt Exp $ */ 1/* $OpenBSD: bcrypt_pbkdf.c,v 1.13 2015/01/12 03:20:04 tedu Exp $ */
2/* 2/*
3 * Copyright (c) 2013 Ted Unangst <tedu@openbsd.org> 3 * Copyright (c) 2013 Ted Unangst <tedu@openbsd.org>
4 * 4 *
@@ -63,8 +63,8 @@
63 * wise caller could do; we just do it for you. 63 * wise caller could do; we just do it for you.
64 */ 64 */
65 65
66#define BCRYPT_BLOCKS 8 66#define BCRYPT_WORDS 8
67#define BCRYPT_HASHSIZE (BCRYPT_BLOCKS * 4) 67#define BCRYPT_HASHSIZE (BCRYPT_WORDS * 4)
68 68
69static void 69static void
70bcrypt_hash(u_int8_t *sha2pass, u_int8_t *sha2salt, u_int8_t *out) 70bcrypt_hash(u_int8_t *sha2pass, u_int8_t *sha2salt, u_int8_t *out)
@@ -72,7 +72,7 @@ bcrypt_hash(u_int8_t *sha2pass, u_int8_t *sha2salt, u_int8_t *out)
72 blf_ctx state; 72 blf_ctx state;
73 u_int8_t ciphertext[BCRYPT_HASHSIZE] = 73 u_int8_t ciphertext[BCRYPT_HASHSIZE] =
74 "OxychromaticBlowfishSwatDynamite"; 74 "OxychromaticBlowfishSwatDynamite";
75 uint32_t cdata[BCRYPT_BLOCKS]; 75 uint32_t cdata[BCRYPT_WORDS];
76 int i; 76 int i;
77 uint16_t j; 77 uint16_t j;
78 size_t shalen = SHA512_DIGEST_LENGTH; 78 size_t shalen = SHA512_DIGEST_LENGTH;
@@ -87,14 +87,14 @@ bcrypt_hash(u_int8_t *sha2pass, u_int8_t *sha2salt, u_int8_t *out)
87 87
88 /* encryption */ 88 /* encryption */
89 j = 0; 89 j = 0;
90 for (i = 0; i < BCRYPT_BLOCKS; i++) 90 for (i = 0; i < BCRYPT_WORDS; i++)
91 cdata[i] = Blowfish_stream2word(ciphertext, sizeof(ciphertext), 91 cdata[i] = Blowfish_stream2word(ciphertext, sizeof(ciphertext),
92 &j); 92 &j);
93 for (i = 0; i < 64; i++) 93 for (i = 0; i < 64; i++)
94 blf_enc(&state, cdata, sizeof(cdata) / sizeof(uint64_t)); 94 blf_enc(&state, cdata, sizeof(cdata) / sizeof(uint64_t));
95 95
96 /* copy out */ 96 /* copy out */
97 for (i = 0; i < BCRYPT_BLOCKS; i++) { 97 for (i = 0; i < BCRYPT_WORDS; i++) {
98 out[4 * i + 3] = (cdata[i] >> 24) & 0xff; 98 out[4 * i + 3] = (cdata[i] >> 24) & 0xff;
99 out[4 * i + 2] = (cdata[i] >> 16) & 0xff; 99 out[4 * i + 2] = (cdata[i] >> 16) & 0xff;
100 out[4 * i + 1] = (cdata[i] >> 8) & 0xff; 100 out[4 * i + 1] = (cdata[i] >> 8) & 0xff;