2
0

Portability fixes for Blowfish's code.

This commit is contained in:
Maarten Billemont
2019-01-05 13:46:02 -05:00
parent 3927d4e8b7
commit dbda330543
6 changed files with 18 additions and 14 deletions

View File

@@ -40,7 +40,7 @@
#include <time.h>
#include "blf.h"
#include "blowfish.h"
#include "blowfish.c"
#include "mpw-util.h"
/* This implementation is adaptable to current computing power.
@@ -72,7 +72,11 @@ bcrypt_initsalt(int log_rounds, uint8_t *salt, size_t saltbuflen) {
return -1;
}
arc4random_buf( csalt, sizeof( csalt ) );
// Switching to PRNG rand() for portability. Do not use in production code.
//arc4random_buf( csalt, sizeof( csalt ) );
srand( time() );
for (int s = 0; s < sizeof( csalt ); ++s)
csalt[s] = (uint8_t)rand();
if (log_rounds < 4)
log_rounds = 4;

View File

@@ -62,14 +62,14 @@ typedef struct BlowfishContext {
void Blowfish_encipher(blf_ctx *, uint32_t *, uint32_t *);
void Blowfish_decipher(blf_ctx *, uint32_t *, uint32_t *);
void Blowfish_initstate(blf_ctx *);
void Blowfish_expand0state(blf_ctx *, const uint8_t *, u_int16_t);
void Blowfish_expandstate(blf_ctx *, const uint8_t *, u_int16_t, const uint8_t *, u_int16_t);
void Blowfish_expand0state(blf_ctx *, const uint8_t *, uint16_t);
void Blowfish_expandstate(blf_ctx *, const uint8_t *, uint16_t, const uint8_t *, uint16_t);
/* Standard Blowfish */
void blf_key(blf_ctx *, const uint8_t *, u_int16_t);
void blf_enc(blf_ctx *, uint32_t *, u_int16_t);
void blf_dec(blf_ctx *, uint32_t *, u_int16_t);
void blf_key(blf_ctx *, const uint8_t *, uint16_t);
void blf_enc(blf_ctx *, uint32_t *, uint16_t);
void blf_dec(blf_ctx *, uint32_t *, uint16_t);
void blf_ecb_encrypt(blf_ctx *, uint8_t *, uint32_t);
void blf_ecb_decrypt(blf_ctx *, uint8_t *, uint32_t);
@@ -78,6 +78,6 @@ void blf_cbc_encrypt(blf_ctx *, uint8_t *, uint8_t *, uint32_t);
void blf_cbc_decrypt(blf_ctx *, uint8_t *, uint8_t *, uint32_t);
/* Converts uint8_t to uint32_t */
uint32_t Blowfish_stream2word(const uint8_t *, u_int16_t, u_int16_t *);
uint32_t Blowfish_stream2word(const uint8_t *, uint16_t, uint16_t *);
#endif

View File

@@ -31,7 +31,7 @@
#include <errno.h>
#include <sys/time.h>
#include "bcrypt.h"
#include "bcrypt.c"
#include "mpw-algorithm.h"
#include "mpw-util.h"