bcrypt-ruby 2.1.1 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bcrypt-ruby might be problematic. Click here for more details.
- data/CHANGELOG +3 -0
- data/Rakefile +1 -1
- data/ext/mri/bcrypt.c +34 -65
- data/ext/mri/bcrypt.h +3 -1
- data/ext/mri/bcrypt_ext.c +1 -1
- data/ext/mri/blf.h +17 -24
- data/ext/mri/blowfish.c +51 -101
- data/ext/mri/extconf.rb +1 -2
- metadata +2 -2
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
data/ext/mri/bcrypt.c
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
/* $OpenBSD: bcrypt.c,v 1.22 2007/02/20 01:44:16 ray Exp $ */
|
2
2
|
|
3
|
-
/*
|
3
|
+
/*
|
4
|
+
* Modified by <coda.hale@gmail.com> on 2009-09-16:
|
5
|
+
*
|
6
|
+
* - Standardized on stdint.h's numerical types and removed some debug cruft.
|
7
|
+
*
|
4
8
|
* Modified by <hongli@phusion.nl> on 2009-08-05:
|
5
9
|
*
|
6
10
|
* - Got rid of the global variables; they're not thread-safe.
|
@@ -58,13 +62,8 @@
|
|
58
62
|
*
|
59
63
|
*/
|
60
64
|
|
61
|
-
#if 0
|
62
|
-
#include <stdio.h>
|
63
|
-
#endif
|
64
|
-
|
65
65
|
#include <stdio.h>
|
66
66
|
#include <stdlib.h>
|
67
|
-
#include <sys/types.h>
|
68
67
|
#include <string.h>
|
69
68
|
#include "blf.h"
|
70
69
|
#include "bcrypt.h"
|
@@ -74,14 +73,14 @@
|
|
74
73
|
* time to come.
|
75
74
|
*/
|
76
75
|
|
77
|
-
static void encode_salt(char *,
|
78
|
-
static void encode_base64(
|
79
|
-
static void decode_base64(
|
76
|
+
static void encode_salt(char *, uint8_t *, uint16_t, uint8_t);
|
77
|
+
static void encode_base64(uint8_t *, uint8_t *, uint16_t);
|
78
|
+
static void decode_base64(uint8_t *, uint16_t, uint8_t *);
|
80
79
|
|
81
|
-
const static
|
80
|
+
const static uint8_t Base64Code[] =
|
82
81
|
"./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
83
82
|
|
84
|
-
const static
|
83
|
+
const static uint8_t index_64[128] = {
|
85
84
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
86
85
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
87
86
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
@@ -99,11 +98,11 @@ const static u_int8_t index_64[128] = {
|
|
99
98
|
#define CHAR64(c) ( (c) > 127 ? 255 : index_64[(c)])
|
100
99
|
|
101
100
|
static void
|
102
|
-
decode_base64(
|
101
|
+
decode_base64(uint8_t *buffer, uint16_t len, uint8_t *data)
|
103
102
|
{
|
104
|
-
|
105
|
-
|
106
|
-
|
103
|
+
uint8_t *bp = buffer;
|
104
|
+
uint8_t *p = data;
|
105
|
+
uint8_t c1, c2, c3, c4;
|
107
106
|
while (bp < buffer + len) {
|
108
107
|
c1 = CHAR64(*p);
|
109
108
|
c2 = CHAR64(*(p + 1));
|
@@ -134,7 +133,7 @@ decode_base64(u_int8_t *buffer, u_int16_t len, u_int8_t *data)
|
|
134
133
|
}
|
135
134
|
|
136
135
|
static void
|
137
|
-
encode_salt(char *salt,
|
136
|
+
encode_salt(char *salt, uint8_t *csalt, uint16_t clen, uint8_t logr)
|
138
137
|
{
|
139
138
|
salt[0] = '$';
|
140
139
|
salt[1] = BCRYPT_VERSION;
|
@@ -143,7 +142,7 @@ encode_salt(char *salt, u_int8_t *csalt, u_int16_t clen, u_int8_t logr)
|
|
143
142
|
|
144
143
|
snprintf(salt + 4, 4, "%2.2u$", logr);
|
145
144
|
|
146
|
-
encode_base64((
|
145
|
+
encode_base64((uint8_t *) salt + 7, csalt, clen);
|
147
146
|
}
|
148
147
|
/* Generates a salt for this version of crypt.
|
149
148
|
Since versions may change. Keeping this here
|
@@ -151,7 +150,7 @@ encode_salt(char *salt, u_int8_t *csalt, u_int16_t clen, u_int8_t logr)
|
|
151
150
|
*/
|
152
151
|
|
153
152
|
char *
|
154
|
-
bcrypt_gensalt(char *output,
|
153
|
+
bcrypt_gensalt(char *output, uint8_t log_rounds, uint8_t *rseed)
|
155
154
|
{
|
156
155
|
if (log_rounds < 4)
|
157
156
|
log_rounds = 4;
|
@@ -168,12 +167,12 @@ char *
|
|
168
167
|
bcrypt(char *output, const char *key, const char *salt)
|
169
168
|
{
|
170
169
|
blf_ctx state;
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
170
|
+
uint32_t rounds, i, k;
|
171
|
+
uint16_t j;
|
172
|
+
uint8_t key_len, salt_len, logr, minor;
|
173
|
+
uint8_t ciphertext[4 * BCRYPT_BLOCKS] = "OrpheanBeholderScryDoubt";
|
174
|
+
uint8_t csalt[BCRYPT_MAXSALT];
|
175
|
+
uint32_t cdata[BCRYPT_BLOCKS];
|
177
176
|
int n;
|
178
177
|
|
179
178
|
/* Discard "$" identifier */
|
@@ -208,8 +207,8 @@ bcrypt(char *output, const char *key, const char *salt)
|
|
208
207
|
n = atoi(salt);
|
209
208
|
if (n > 31 || n < 0)
|
210
209
|
return NULL;
|
211
|
-
logr = (
|
212
|
-
if ((rounds = (
|
210
|
+
logr = (uint8_t)n;
|
211
|
+
if ((rounds = (uint32_t) 1 << logr) < BCRYPT_MINROUNDS)
|
213
212
|
return NULL;
|
214
213
|
|
215
214
|
/* Discard num rounds + "$" identifier */
|
@@ -219,16 +218,16 @@ bcrypt(char *output, const char *key, const char *salt)
|
|
219
218
|
return NULL;
|
220
219
|
|
221
220
|
/* We dont want the base64 salt but the raw data */
|
222
|
-
decode_base64(csalt, BCRYPT_MAXSALT, (
|
221
|
+
decode_base64(csalt, BCRYPT_MAXSALT, (uint8_t *) salt);
|
223
222
|
salt_len = BCRYPT_MAXSALT;
|
224
223
|
key_len = strlen(key) + (minor >= 'a' ? 1 : 0);
|
225
224
|
|
226
225
|
/* Setting up S-Boxes and Subkeys */
|
227
226
|
Blowfish_initstate(&state);
|
228
227
|
Blowfish_expandstate(&state, csalt, salt_len,
|
229
|
-
(
|
228
|
+
(uint8_t *) key, key_len);
|
230
229
|
for (k = 0; k < rounds; k++) {
|
231
|
-
Blowfish_expand0state(&state, (
|
230
|
+
Blowfish_expand0state(&state, (uint8_t *) key, key_len);
|
232
231
|
Blowfish_expand0state(&state, csalt, salt_len);
|
233
232
|
}
|
234
233
|
|
@@ -261,18 +260,18 @@ bcrypt(char *output, const char *key, const char *salt)
|
|
261
260
|
|
262
261
|
snprintf(output + i, 4, "%2.2u$", logr);
|
263
262
|
|
264
|
-
encode_base64((
|
265
|
-
encode_base64((
|
263
|
+
encode_base64((uint8_t *) output + i + 3, csalt, BCRYPT_MAXSALT);
|
264
|
+
encode_base64((uint8_t *) output + strlen(output), ciphertext,
|
266
265
|
4 * BCRYPT_BLOCKS - 1);
|
267
266
|
return output;
|
268
267
|
}
|
269
268
|
|
270
269
|
static void
|
271
|
-
encode_base64(
|
270
|
+
encode_base64(uint8_t *buffer, uint8_t *data, uint16_t len)
|
272
271
|
{
|
273
|
-
|
274
|
-
|
275
|
-
|
272
|
+
uint8_t *bp = buffer;
|
273
|
+
uint8_t *p = data;
|
274
|
+
uint8_t c1, c2;
|
276
275
|
while (p < data + len) {
|
277
276
|
c1 = *p++;
|
278
277
|
*bp++ = Base64Code[(c1 >> 2)];
|
@@ -296,33 +295,3 @@ encode_base64(u_int8_t *buffer, u_int8_t *data, u_int16_t len)
|
|
296
295
|
}
|
297
296
|
*bp = '\0';
|
298
297
|
}
|
299
|
-
#if 0
|
300
|
-
void
|
301
|
-
main()
|
302
|
-
{
|
303
|
-
char blubber[73];
|
304
|
-
char salt[100];
|
305
|
-
char *p;
|
306
|
-
salt[0] = '$';
|
307
|
-
salt[1] = BCRYPT_VERSION;
|
308
|
-
salt[2] = '$';
|
309
|
-
|
310
|
-
snprintf(salt + 3, 4, "%2.2u$", 5);
|
311
|
-
|
312
|
-
printf("24 bytes of salt: ");
|
313
|
-
fgets(salt + 6, sizeof(salt) - 6, stdin);
|
314
|
-
salt[99] = 0;
|
315
|
-
printf("72 bytes of password: ");
|
316
|
-
fpurge(stdin);
|
317
|
-
fgets(blubber, sizeof(blubber), stdin);
|
318
|
-
blubber[72] = 0;
|
319
|
-
|
320
|
-
p = crypt(blubber, salt);
|
321
|
-
printf("Passwd entry: %s\n\n", p);
|
322
|
-
|
323
|
-
p = bcrypt_gensalt(5);
|
324
|
-
printf("Generated salt: %s\n", p);
|
325
|
-
p = crypt(blubber, p);
|
326
|
-
printf("Passwd entry: %s\n", p);
|
327
|
-
}
|
328
|
-
#endif
|
data/ext/mri/bcrypt.h
CHANGED
@@ -31,6 +31,8 @@
|
|
31
31
|
#ifndef _BCRYPT_H_
|
32
32
|
#define _BCRYPT_H_
|
33
33
|
|
34
|
+
#include <stdint.h>
|
35
|
+
|
34
36
|
#define BCRYPT_VERSION '2'
|
35
37
|
#define BCRYPT_MAXSALT 16 /* Precomputation is just so nice */
|
36
38
|
#define BCRYPT_BLOCKS 6 /* Ciphertext blocks */
|
@@ -49,7 +51,7 @@
|
|
49
51
|
* cryptographically secure random source.
|
50
52
|
* Returns: output
|
51
53
|
*/
|
52
|
-
char *bcrypt_gensalt(char *output,
|
54
|
+
char *bcrypt_gensalt(char *output, uint8_t log_rounds, uint8_t *rseed);
|
53
55
|
|
54
56
|
/*
|
55
57
|
* Given a secret and a salt, generates a salted hash (which you can then store safely).
|
data/ext/mri/bcrypt_ext.c
CHANGED
@@ -41,7 +41,7 @@ static VALUE bc_salt(VALUE self, VALUE cost, VALUE seed) {
|
|
41
41
|
int icost = NUM2INT(cost);
|
42
42
|
char salt[BCRYPT_SALT_OUTPUT_SIZE];
|
43
43
|
|
44
|
-
bcrypt_gensalt(salt, icost, (
|
44
|
+
bcrypt_gensalt(salt, icost, (uint8_t *)RSTRING_PTR(seed));
|
45
45
|
return rb_str_new2(salt);
|
46
46
|
}
|
47
47
|
|
data/ext/mri/blf.h
CHANGED
@@ -31,18 +31,11 @@
|
|
31
31
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
32
32
|
*/
|
33
33
|
|
34
|
-
/* Add this type so we'll compile nicely on Solaris.
|
35
|
-
Thanks to Jeremy LaTrasse and the Twitter crew. */
|
36
|
-
#ifdef __sun
|
37
|
-
#define u_int8_t uint8_t
|
38
|
-
#define u_int16_t uint16_t
|
39
|
-
#define u_int32_t uint32_t
|
40
|
-
#define u_int64_t uint64_t
|
41
|
-
#endif
|
42
|
-
|
43
34
|
#ifndef _BLF_H_
|
44
35
|
#define _BLF_H_
|
45
36
|
|
37
|
+
#include <stdint.h>
|
38
|
+
|
46
39
|
// Imported from pwd.h. <coda.hale@gmail.com>
|
47
40
|
#define _PASSWORD_LEN 128 /* max length, not counting NUL */
|
48
41
|
|
@@ -58,8 +51,8 @@
|
|
58
51
|
|
59
52
|
/* Blowfish context */
|
60
53
|
typedef struct BlowfishContext {
|
61
|
-
|
62
|
-
|
54
|
+
uint32_t S[4][256]; /* S-Boxes */
|
55
|
+
uint32_t P[BLF_N + 2]; /* Subkeys */
|
63
56
|
} blf_ctx;
|
64
57
|
|
65
58
|
/* Raw access to customized Blowfish
|
@@ -68,26 +61,26 @@ typedef struct BlowfishContext {
|
|
68
61
|
* Blowfish_expand0state( state, key, keylen )
|
69
62
|
*/
|
70
63
|
|
71
|
-
void Blowfish_encipher(blf_ctx *,
|
72
|
-
void Blowfish_decipher(blf_ctx *,
|
64
|
+
void Blowfish_encipher(blf_ctx *, uint32_t *, uint32_t *);
|
65
|
+
void Blowfish_decipher(blf_ctx *, uint32_t *, uint32_t *);
|
73
66
|
void Blowfish_initstate(blf_ctx *);
|
74
|
-
void Blowfish_expand0state(blf_ctx *, const
|
67
|
+
void Blowfish_expand0state(blf_ctx *, const uint8_t *, uint16_t);
|
75
68
|
void Blowfish_expandstate
|
76
|
-
(blf_ctx *, const
|
69
|
+
(blf_ctx *, const uint8_t *, uint16_t, const uint8_t *, uint16_t);
|
77
70
|
|
78
71
|
/* Standard Blowfish */
|
79
72
|
|
80
|
-
void blf_key(blf_ctx *, const
|
81
|
-
void blf_enc(blf_ctx *,
|
82
|
-
void blf_dec(blf_ctx *,
|
73
|
+
void blf_key(blf_ctx *, const uint8_t *, uint16_t);
|
74
|
+
void blf_enc(blf_ctx *, uint32_t *, uint16_t);
|
75
|
+
void blf_dec(blf_ctx *, uint32_t *, uint16_t);
|
83
76
|
|
84
|
-
void blf_ecb_encrypt(blf_ctx *,
|
85
|
-
void blf_ecb_decrypt(blf_ctx *,
|
77
|
+
void blf_ecb_encrypt(blf_ctx *, uint8_t *, uint32_t);
|
78
|
+
void blf_ecb_decrypt(blf_ctx *, uint8_t *, uint32_t);
|
86
79
|
|
87
|
-
void blf_cbc_encrypt(blf_ctx *,
|
88
|
-
void blf_cbc_decrypt(blf_ctx *,
|
80
|
+
void blf_cbc_encrypt(blf_ctx *, uint8_t *, uint8_t *, uint32_t);
|
81
|
+
void blf_cbc_decrypt(blf_ctx *, uint8_t *, uint8_t *, uint32_t);
|
89
82
|
|
90
|
-
/* Converts
|
91
|
-
|
83
|
+
/* Converts uint8_t to uint32_t */
|
84
|
+
uint32_t Blowfish_stream2word(const uint8_t *, uint16_t , uint16_t *);
|
92
85
|
|
93
86
|
#endif
|
data/ext/mri/blowfish.c
CHANGED
@@ -39,12 +39,6 @@
|
|
39
39
|
* Bruce Schneier.
|
40
40
|
*/
|
41
41
|
|
42
|
-
#if 0
|
43
|
-
#include <stdio.h> /* used for debugging */
|
44
|
-
#include <string.h>
|
45
|
-
#endif
|
46
|
-
|
47
|
-
#include <sys/types.h>
|
48
42
|
#include "blf.h"
|
49
43
|
|
50
44
|
#undef inline
|
@@ -64,12 +58,12 @@
|
|
64
58
|
#define BLFRND(s,p,i,j,n) (i ^= F(s,j) ^ (p)[n])
|
65
59
|
|
66
60
|
void
|
67
|
-
Blowfish_encipher(blf_ctx *c,
|
61
|
+
Blowfish_encipher(blf_ctx *c, uint32_t *xl, uint32_t *xr)
|
68
62
|
{
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
63
|
+
uint32_t Xl;
|
64
|
+
uint32_t Xr;
|
65
|
+
uint32_t *s = c->S[0];
|
66
|
+
uint32_t *p = c->P;
|
73
67
|
|
74
68
|
Xl = *xl;
|
75
69
|
Xr = *xr;
|
@@ -89,12 +83,12 @@ Blowfish_encipher(blf_ctx *c, u_int32_t *xl, u_int32_t *xr)
|
|
89
83
|
}
|
90
84
|
|
91
85
|
void
|
92
|
-
Blowfish_decipher(blf_ctx *c,
|
86
|
+
Blowfish_decipher(blf_ctx *c, uint32_t *xl, uint32_t *xr)
|
93
87
|
{
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
88
|
+
uint32_t Xl;
|
89
|
+
uint32_t Xr;
|
90
|
+
uint32_t *s = c->S[0];
|
91
|
+
uint32_t *p = c->P;
|
98
92
|
|
99
93
|
Xl = *xl;
|
100
94
|
Xr = *xr;
|
@@ -392,13 +386,13 @@ Blowfish_initstate(blf_ctx *c)
|
|
392
386
|
*c = initstate;
|
393
387
|
}
|
394
388
|
|
395
|
-
|
396
|
-
Blowfish_stream2word(const
|
397
|
-
|
389
|
+
uint32_t
|
390
|
+
Blowfish_stream2word(const uint8_t *data, uint16_t databytes,
|
391
|
+
uint16_t *current)
|
398
392
|
{
|
399
|
-
|
400
|
-
|
401
|
-
|
393
|
+
uint8_t i;
|
394
|
+
uint16_t j;
|
395
|
+
uint32_t temp;
|
402
396
|
|
403
397
|
temp = 0x00000000;
|
404
398
|
j = *current;
|
@@ -414,14 +408,14 @@ Blowfish_stream2word(const u_int8_t *data, u_int16_t databytes,
|
|
414
408
|
}
|
415
409
|
|
416
410
|
void
|
417
|
-
Blowfish_expand0state(blf_ctx *c, const
|
411
|
+
Blowfish_expand0state(blf_ctx *c, const uint8_t *key, uint16_t keybytes)
|
418
412
|
{
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
413
|
+
uint16_t i;
|
414
|
+
uint16_t j;
|
415
|
+
uint16_t k;
|
416
|
+
uint32_t temp;
|
417
|
+
uint32_t datal;
|
418
|
+
uint32_t datar;
|
425
419
|
|
426
420
|
j = 0;
|
427
421
|
for (i = 0; i < BLF_N + 2; i++) {
|
@@ -452,15 +446,15 @@ Blowfish_expand0state(blf_ctx *c, const u_int8_t *key, u_int16_t keybytes)
|
|
452
446
|
|
453
447
|
|
454
448
|
void
|
455
|
-
Blowfish_expandstate(blf_ctx *c, const
|
456
|
-
const
|
449
|
+
Blowfish_expandstate(blf_ctx *c, const uint8_t *data, uint16_t databytes,
|
450
|
+
const uint8_t *key, uint16_t keybytes)
|
457
451
|
{
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
452
|
+
uint16_t i;
|
453
|
+
uint16_t j;
|
454
|
+
uint16_t k;
|
455
|
+
uint32_t temp;
|
456
|
+
uint32_t datal;
|
457
|
+
uint32_t datar;
|
464
458
|
|
465
459
|
j = 0;
|
466
460
|
for (i = 0; i < BLF_N + 2; i++) {
|
@@ -495,7 +489,7 @@ Blowfish_expandstate(blf_ctx *c, const u_int8_t *data, u_int16_t databytes,
|
|
495
489
|
}
|
496
490
|
|
497
491
|
void
|
498
|
-
blf_key(blf_ctx *c, const
|
492
|
+
blf_key(blf_ctx *c, const uint8_t *k, uint16_t len)
|
499
493
|
{
|
500
494
|
/* Initialize S-boxes and subkeys with Pi */
|
501
495
|
Blowfish_initstate(c);
|
@@ -505,10 +499,10 @@ blf_key(blf_ctx *c, const u_int8_t *k, u_int16_t len)
|
|
505
499
|
}
|
506
500
|
|
507
501
|
void
|
508
|
-
blf_enc(blf_ctx *c,
|
502
|
+
blf_enc(blf_ctx *c, uint32_t *data, uint16_t blocks)
|
509
503
|
{
|
510
|
-
|
511
|
-
|
504
|
+
uint32_t *d;
|
505
|
+
uint16_t i;
|
512
506
|
|
513
507
|
d = data;
|
514
508
|
for (i = 0; i < blocks; i++) {
|
@@ -518,10 +512,10 @@ blf_enc(blf_ctx *c, u_int32_t *data, u_int16_t blocks)
|
|
518
512
|
}
|
519
513
|
|
520
514
|
void
|
521
|
-
blf_dec(blf_ctx *c,
|
515
|
+
blf_dec(blf_ctx *c, uint32_t *data, uint16_t blocks)
|
522
516
|
{
|
523
|
-
|
524
|
-
|
517
|
+
uint32_t *d;
|
518
|
+
uint16_t i;
|
525
519
|
|
526
520
|
d = data;
|
527
521
|
for (i = 0; i < blocks; i++) {
|
@@ -531,10 +525,10 @@ blf_dec(blf_ctx *c, u_int32_t *data, u_int16_t blocks)
|
|
531
525
|
}
|
532
526
|
|
533
527
|
void
|
534
|
-
blf_ecb_encrypt(blf_ctx *c,
|
528
|
+
blf_ecb_encrypt(blf_ctx *c, uint8_t *data, uint32_t len)
|
535
529
|
{
|
536
|
-
|
537
|
-
|
530
|
+
uint32_t l, r;
|
531
|
+
uint32_t i;
|
538
532
|
|
539
533
|
for (i = 0; i < len; i += 8) {
|
540
534
|
l = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3];
|
@@ -553,10 +547,10 @@ blf_ecb_encrypt(blf_ctx *c, u_int8_t *data, u_int32_t len)
|
|
553
547
|
}
|
554
548
|
|
555
549
|
void
|
556
|
-
blf_ecb_decrypt(blf_ctx *c,
|
550
|
+
blf_ecb_decrypt(blf_ctx *c, uint8_t *data, uint32_t len)
|
557
551
|
{
|
558
|
-
|
559
|
-
|
552
|
+
uint32_t l, r;
|
553
|
+
uint32_t i;
|
560
554
|
|
561
555
|
for (i = 0; i < len; i += 8) {
|
562
556
|
l = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3];
|
@@ -575,10 +569,10 @@ blf_ecb_decrypt(blf_ctx *c, u_int8_t *data, u_int32_t len)
|
|
575
569
|
}
|
576
570
|
|
577
571
|
void
|
578
|
-
blf_cbc_encrypt(blf_ctx *c,
|
572
|
+
blf_cbc_encrypt(blf_ctx *c, uint8_t *iv, uint8_t *data, uint32_t len)
|
579
573
|
{
|
580
|
-
|
581
|
-
|
574
|
+
uint32_t l, r;
|
575
|
+
uint32_t i, j;
|
582
576
|
|
583
577
|
for (i = 0; i < len; i += 8) {
|
584
578
|
for (j = 0; j < 8; j++)
|
@@ -600,11 +594,11 @@ blf_cbc_encrypt(blf_ctx *c, u_int8_t *iv, u_int8_t *data, u_int32_t len)
|
|
600
594
|
}
|
601
595
|
|
602
596
|
void
|
603
|
-
blf_cbc_decrypt(blf_ctx *c,
|
597
|
+
blf_cbc_decrypt(blf_ctx *c, uint8_t *iva, uint8_t *data, uint32_t len)
|
604
598
|
{
|
605
|
-
|
606
|
-
|
607
|
-
|
599
|
+
uint32_t l, r;
|
600
|
+
uint8_t *iv;
|
601
|
+
uint32_t i, j;
|
608
602
|
|
609
603
|
iv = data + len - 16;
|
610
604
|
data = data + len - 8;
|
@@ -639,47 +633,3 @@ blf_cbc_decrypt(blf_ctx *c, u_int8_t *iva, u_int8_t *data, u_int32_t len)
|
|
639
633
|
for (j = 0; j < 8; j++)
|
640
634
|
data[j] ^= iva[j];
|
641
635
|
}
|
642
|
-
|
643
|
-
#if 0
|
644
|
-
void
|
645
|
-
report(u_int32_t data[], u_int16_t len)
|
646
|
-
{
|
647
|
-
u_int16_t i;
|
648
|
-
for (i = 0; i < len; i += 2)
|
649
|
-
printf("Block %0hd: %08lx %08lx.\n",
|
650
|
-
i / 2, data[i], data[i + 1]);
|
651
|
-
}
|
652
|
-
void
|
653
|
-
main(void)
|
654
|
-
{
|
655
|
-
|
656
|
-
blf_ctx c;
|
657
|
-
char key[] = "AAAAA";
|
658
|
-
char key2[] = "abcdefghijklmnopqrstuvwxyz";
|
659
|
-
|
660
|
-
u_int32_t data[10];
|
661
|
-
u_int32_t data2[] =
|
662
|
-
{0x424c4f57l, 0x46495348l};
|
663
|
-
|
664
|
-
u_int16_t i;
|
665
|
-
|
666
|
-
/* First test */
|
667
|
-
for (i = 0; i < 10; i++)
|
668
|
-
data[i] = i;
|
669
|
-
|
670
|
-
blf_key(&c, (u_int8_t *) key, 5);
|
671
|
-
blf_enc(&c, data, 5);
|
672
|
-
blf_dec(&c, data, 1);
|
673
|
-
blf_dec(&c, data + 2, 4);
|
674
|
-
printf("Should read as 0 - 9.\n");
|
675
|
-
report(data, 10);
|
676
|
-
|
677
|
-
/* Second test */
|
678
|
-
blf_key(&c, (u_int8_t *) key2, strlen(key2));
|
679
|
-
blf_enc(&c, data2, 1);
|
680
|
-
printf("\nShould read as: 0x324ed0fe 0xf413a203.\n");
|
681
|
-
report(data2, 2);
|
682
|
-
blf_dec(&c, data2, 1);
|
683
|
-
report(data2, 2);
|
684
|
-
}
|
685
|
-
#endif
|
data/ext/mri/extconf.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bcrypt-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Coda Hale
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-09-16 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|