Skip to content

Commit

Permalink
Merge pull request #3 from jakinyele/master
Browse files Browse the repository at this point in the history
Security improvements to RSA/ECDSA code using OpenSSL
  • Loading branch information
chjj committed Aug 10, 2018
2 parents 85dec54 + 6577dcb commit 33e7c1d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/blake2b/blake2b.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,7 @@ bcrypto_blake2b_init_key(
memset(P->salt, 0, sizeof(P->salt));
memset(P->personal, 0, sizeof(P->personal));

if (bcrypto_blake2b_init_param(ctx, P) < 0)
return -1;
bcrypto_blake2b_init_param(ctx, P);

{
uint8_t block[BCRYPTO_BLAKE2B_BLOCKBYTES];
Expand Down
2 changes: 1 addition & 1 deletion src/ecdsa/ecdsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ bcrypto_ecdsa_verify(
if (!sig_ec)
goto fail;

if (!ECDSA_do_verify(msg, msg_len, sig_ec, pub_ec))
if (ECDSA_do_verify(msg, msg_len, sig_ec, pub_ec) <= 0)
goto fail;

EC_KEY_free(pub_ec);
Expand Down
6 changes: 2 additions & 4 deletions src/random/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ bcrypto_random(uint8_t *dst, size_t len) {
for (;;) {
int status = RAND_status();

assert(status >= 0);

if (status != 0)
if (status == 1)
break;

if (RAND_poll() == 0)
if (RAND_poll() == 1)
break;
}

Expand Down
2 changes: 1 addition & 1 deletion src/rsa/rsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ bcrypto_rsa_verify_priv(const bcrypto_rsa_key_t *priv) {
if (!priv_r)
goto fail;

if (!RSA_check_key(priv_r))
if (RSA_check_key(priv_r) <= 0)
goto fail;

RSA_free(priv_r);
Expand Down

0 comments on commit 33e7c1d

Please sign in to comment.