More abort() -> sodium_misuse()
This commit is contained in:
parent
a0e997b8ae
commit
74703c63a6
@ -10,6 +10,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "core.h"
|
||||||
#include "crypto_aead_aes256gcm.h"
|
#include "crypto_aead_aes256gcm.h"
|
||||||
#include "export.h"
|
#include "export.h"
|
||||||
#include "private/common.h"
|
#include "private/common.h"
|
||||||
@ -524,7 +525,7 @@ crypto_aead_aes256gcm_encrypt_detached_afternm(unsigned char *c,
|
|||||||
(void) nsec;
|
(void) nsec;
|
||||||
memcpy(H, ctx->H, sizeof H);
|
memcpy(H, ctx->H, sizeof H);
|
||||||
if (mlen > 16ULL * ((1ULL << 32) - 2)) {
|
if (mlen > 16ULL * ((1ULL << 32) - 2)) {
|
||||||
abort(); /* LCOV_EXCL_LINE */
|
sodium_misuse("crypto_aead_aes256gcm_encrypt_detached_afternm(): message too long"); /* LCOV_EXCL_LINE */
|
||||||
}
|
}
|
||||||
memcpy(&n2[0], npub, 3 * 4);
|
memcpy(&n2[0], npub, 3 * 4);
|
||||||
n2[3] = 0x01000000;
|
n2[3] = 0x01000000;
|
||||||
@ -662,7 +663,7 @@ crypto_aead_aes256gcm_decrypt_detached_afternm(unsigned char *m, unsigned char *
|
|||||||
|
|
||||||
(void) nsec;
|
(void) nsec;
|
||||||
if (clen > 16ULL * (1ULL << 32)) {
|
if (clen > 16ULL * (1ULL << 32)) {
|
||||||
abort(); /* LCOV_EXCL_LINE */
|
sodium_misuse("crypto_aead_aes256gcm_decrypt_detached_afternm(): ciphertext too long"); /* LCOV_EXCL_LINE */
|
||||||
}
|
}
|
||||||
mlen = clen;
|
mlen = clen;
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "core.h"
|
||||||
#include "crypto_auth_hmacsha256.h"
|
#include "crypto_auth_hmacsha256.h"
|
||||||
#include "pbkdf2-sha256.h"
|
#include "pbkdf2-sha256.h"
|
||||||
#include "private/common.h"
|
#include "private/common.h"
|
||||||
@ -56,7 +57,7 @@ PBKDF2_SHA256(const uint8_t *passwd, size_t passwdlen, const uint8_t *salt,
|
|||||||
|
|
||||||
#if SIZE_MAX > 0x1fffffffe0ULL
|
#if SIZE_MAX > 0x1fffffffe0ULL
|
||||||
if (dkLen > 0x1fffffffe0ULL) {
|
if (dkLen > 0x1fffffffe0ULL) {
|
||||||
abort();
|
sodium_misuse("PBKDF2_SHA256(): derived key length is too large"); /* LCOV_EXCL_LINE */
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
crypto_auth_hmacsha256_init(&PShctx, passwd, passwdlen);
|
crypto_auth_hmacsha256_init(&PShctx, passwd, passwdlen);
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#ifdef __native_client__
|
#ifdef __native_client__
|
||||||
# include <irt.h>
|
# include <irt.h>
|
||||||
|
|
||||||
|
# include "core.h"
|
||||||
# include "utils.h"
|
# include "utils.h"
|
||||||
# include "randombytes.h"
|
# include "randombytes.h"
|
||||||
# include "randombytes_nativeclient.h"
|
# include "randombytes_nativeclient.h"
|
||||||
@ -20,12 +21,12 @@ randombytes_nativeclient_buf(void * const buf, const size_t size)
|
|||||||
|
|
||||||
if (nacl_interface_query(NACL_IRT_RANDOM_v0_1, &rand_intf,
|
if (nacl_interface_query(NACL_IRT_RANDOM_v0_1, &rand_intf,
|
||||||
sizeof rand_intf) != sizeof rand_intf) {
|
sizeof rand_intf) != sizeof rand_intf) {
|
||||||
abort();
|
sodium_misuse("randombytes_nativeclient_buf(): NaCl IRT_RANDOM API failed");
|
||||||
}
|
}
|
||||||
while (toread > (size_t) 0U) {
|
while (toread > (size_t) 0U) {
|
||||||
if (rand_intf.get_random_bytes(buf_, size, &readnb) != 0 ||
|
if (rand_intf.get_random_bytes(buf_, size, &readnb) != 0 ||
|
||||||
readnb > size) {
|
readnb > size) {
|
||||||
abort();
|
sodium_misuse("randombytes_nativeclient_buf(): NaCl IRT_RANDOM API didn't return the correct amount of bytes");
|
||||||
}
|
}
|
||||||
toread -= readnb;
|
toread -= readnb;
|
||||||
buf_ += readnb;
|
buf_ += readnb;
|
||||||
|
Loading…
Reference in New Issue
Block a user