flavor condition checks instead of asserts
This commit is contained in:
parent
48770bf79f
commit
fefe5d75e3
@ -30,7 +30,6 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include <cryptonite_cpu.h>
|
#include <cryptonite_cpu.h>
|
||||||
#include <cryptonite_aes.h>
|
#include <cryptonite_aes.h>
|
||||||
@ -530,7 +529,8 @@ void cryptonite_aes_ccm_aad(aes_ccm *ccm, aes_key *key, uint8_t *input, uint32_t
|
|||||||
{
|
{
|
||||||
block128 tmp;
|
block128 tmp;
|
||||||
|
|
||||||
assert (ccm->length_aad == 0);
|
if (ccm->length_aad == 0) return;
|
||||||
|
|
||||||
ccm->length_aad = length;
|
ccm->length_aad = length;
|
||||||
int len_len;
|
int len_len;
|
||||||
|
|
||||||
@ -915,7 +915,6 @@ void cryptonite_aes_generic_ccm_encrypt(uint8_t *output, aes_ccm *ccm, aes_key *
|
|||||||
block128_copy(&ccm->header_cbcmac, &ccm->xi);
|
block128_copy(&ccm->header_cbcmac, &ccm->xi);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert (length == ccm->length_input);
|
|
||||||
if (length != ccm->length_input) {
|
if (length != ccm->length_input) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -938,6 +937,10 @@ void cryptonite_aes_generic_ccm_decrypt(uint8_t *output, aes_ccm *ccm, aes_key *
|
|||||||
{
|
{
|
||||||
block128 tmp, ctr;
|
block128 tmp, ctr;
|
||||||
|
|
||||||
|
if (length != ccm->length_input) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* when aad is absent, reset b0 block */
|
/* when aad is absent, reset b0 block */
|
||||||
if (ccm->length_aad == 0) {
|
if (ccm->length_aad == 0) {
|
||||||
ccm_encode_b0(&ccm->b0, ccm, 0); /* assume aad is present */
|
ccm_encode_b0(&ccm->b0, ccm, 0); /* assume aad is present */
|
||||||
@ -945,11 +948,6 @@ void cryptonite_aes_generic_ccm_decrypt(uint8_t *output, aes_ccm *ccm, aes_key *
|
|||||||
block128_copy(&ccm->header_cbcmac, &ccm->xi);
|
block128_copy(&ccm->header_cbcmac, &ccm->xi);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert (length == ccm->length_input);
|
|
||||||
if (length != ccm->length_input) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ccm_encode_ctr(&ctr, ccm, 1);
|
ccm_encode_ctr(&ctr, ccm, 1);
|
||||||
cryptonite_aes_encrypt_ctr(output, key, &ctr, input, length);
|
cryptonite_aes_encrypt_ctr(output, key, &ctr, input, length);
|
||||||
block128_copy(&ccm->xi, &ccm->header_cbcmac);
|
block128_copy(&ccm->xi, &ccm->header_cbcmac);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user