Mercurial > projects > sencrypt
comparison sencrypt.c @ 3:f230c550e261
Correct check for errors from RAND_bytes()
author | Guido Berhoerster <guido+sencrypt@berhoerster.name> |
---|---|
date | Thu, 10 Apr 2014 00:05:56 +0200 |
parents | 73af139d1a94 |
children | abb770754967 |
comparison
equal
deleted
inserted
replaced
2:b1d7f4dd26fa | 3:f230c550e261 |
---|---|
630 goto out; | 630 goto out; |
631 } | 631 } |
632 | 632 |
633 if (cmd == CMD_SENCRYPT) { | 633 if (cmd == CMD_SENCRYPT) { |
634 /* generate random salt and IV */ | 634 /* generate random salt and IV */ |
635 if ((RAND_bytes(salt, sizeof (salt)) == 0) || | 635 if ((RAND_bytes(salt, sizeof (salt)) != 1) || |
636 (RAND_bytes(iv, EVP_CIPHER_iv_length(cipher)) == 0)) { | 636 (RAND_bytes(iv, EVP_CIPHER_iv_length(cipher)) != 1)) { |
637 /* not enough entropy or unknown error */ | 637 /* not enough entropy or unknown error */ |
638 warnx("failed to generate random data"); | 638 warnx("failed to generate random data"); |
639 status = EXIT_FAILURE; | 639 status = EXIT_FAILURE; |
640 goto out; | 640 goto out; |
641 } | 641 } |