mirror of
https://github.com/jedisct1/libsodium.git
synced 2026-08-25 08:37:13 +09:00
No more abort() calls!
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "core.h"
|
||||
#include "crypto_aead_chacha20poly1305.h"
|
||||
#include "crypto_onetimeauth_poly1305.h"
|
||||
#include "crypto_stream_chacha20.h"
|
||||
@@ -70,7 +71,7 @@ crypto_aead_chacha20poly1305_encrypt(unsigned char *c,
|
||||
int ret;
|
||||
|
||||
if (mlen > UINT64_MAX - crypto_aead_chacha20poly1305_ABYTES) {
|
||||
abort(); /* LCOV_EXCL_LINE */
|
||||
sodium_misuse("crypto_aead_chacha20poly1305_encrypt(): message too long");
|
||||
}
|
||||
ret = crypto_aead_chacha20poly1305_encrypt_detached(c,
|
||||
c + mlen, NULL,
|
||||
@@ -145,7 +146,7 @@ crypto_aead_chacha20poly1305_ietf_encrypt(unsigned char *c,
|
||||
int ret;
|
||||
|
||||
if (mlen > UINT64_MAX - crypto_aead_chacha20poly1305_ietf_ABYTES) {
|
||||
abort(); /* LCOV_EXCL_LINE */
|
||||
sodium_misuse("crypto_aead_chacha20poly1305_ietf_encrypt(): message too long");
|
||||
}
|
||||
ret = crypto_aead_chacha20poly1305_ietf_encrypt_detached(c,
|
||||
c + mlen, NULL,
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "core.h"
|
||||
#include "crypto_aead_xchacha20poly1305.h"
|
||||
#include "crypto_aead_chacha20poly1305.h"
|
||||
#include "crypto_core_hchacha20.h"
|
||||
@@ -53,7 +54,7 @@ crypto_aead_xchacha20poly1305_ietf_encrypt(unsigned char *c,
|
||||
int ret;
|
||||
|
||||
if (mlen > UINT64_MAX - crypto_aead_xchacha20poly1305_ietf_ABYTES) {
|
||||
abort(); /* LCOV_EXCL_LINE */
|
||||
sodium_misuse("crypto_aead_xchacha20poly1305_ietf_encrypt(): message too long");
|
||||
}
|
||||
ret = crypto_aead_xchacha20poly1305_ietf_encrypt_detached
|
||||
(c, c + mlen, NULL, m, mlen, ad, adlen, nsec, npub, k);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "core.h"
|
||||
#include "crypto_stream_chacha20.h"
|
||||
#include "private/common.h"
|
||||
#include "private/sse2_64_32.h"
|
||||
@@ -77,7 +78,7 @@ chacha20_encrypt_bytes(chacha_ctx *ctx, const uint8_t *m, uint8_t *c,
|
||||
return; /* LCOV_EXCL_LINE */
|
||||
}
|
||||
if (bytes > 64ULL * (1ULL << 32) - 64ULL) {
|
||||
abort();
|
||||
sodium_misuse("chacha20_encrypt_bytes(): message too long");
|
||||
}
|
||||
# include "u8.h"
|
||||
# include "u4.h"
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "core.h"
|
||||
#include "crypto_stream_chacha20.h"
|
||||
#include "private/common.h"
|
||||
#include "private/sse2_64_32.h"
|
||||
@@ -72,7 +73,7 @@ chacha20_encrypt_bytes(chacha_ctx *ctx, const uint8_t *m, uint8_t *c,
|
||||
return; /* LCOV_EXCL_LINE */
|
||||
}
|
||||
if (bytes > 64ULL * (1ULL << 32) - 64ULL) {
|
||||
abort();
|
||||
sodium_misuse("chacha20_encrypt_bytes(): message too long");
|
||||
}
|
||||
# include "u4.h"
|
||||
# include "u1.h"
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "core.h"
|
||||
#include "crypto_stream_chacha20.h"
|
||||
#include "private/common.h"
|
||||
#include "utils.h"
|
||||
@@ -92,7 +93,7 @@ chacha20_encrypt_bytes(chacha_ctx *ctx, const uint8_t *m, uint8_t *c,
|
||||
return; /* LCOV_EXCL_LINE */
|
||||
}
|
||||
if (bytes > 64ULL * (1ULL << 32) - 64ULL) {
|
||||
abort();
|
||||
sodium_misuse("chacha20_encrypt_bytes(): message too long");
|
||||
}
|
||||
j0 = ctx->input[0];
|
||||
j1 = ctx->input[1];
|
||||
|
||||
Reference in New Issue
Block a user