add missing pointer checks

This commit is contained in:
Steffen Jaeckel 2014-10-31 19:39:03 +01:00
parent 53917750d8
commit 4efa27ead1
5 changed files with 11 additions and 0 deletions

View File

@ -25,6 +25,9 @@ int ccm_add_aad(ccm_state *ccm,
unsigned long y;
int err;
LTC_ARGCHK(ccm != NULL);
LTC_ARGCHK(adata != NULL);
if (ccm->aadlen < ccm->current_aadlen + adatalen) {
return CRYPT_INVALID_ARG;
}

View File

@ -25,6 +25,9 @@ int ccm_add_nonce(ccm_state *ccm,
unsigned long x, y, len;
int err;
LTC_ARGCHK(ccm != NULL);
LTC_ARGCHK(nonce != NULL);
/* increase L to match the nonce len */
ccm->noncelen = (noncelen > 13) ? 13 : noncelen;
if ((15 - ccm->noncelen) > ccm->L) {

View File

@ -25,6 +25,8 @@ int ccm_done(ccm_state *ccm,
unsigned long x, y;
int err;
LTC_ARGCHK(ccm != NULL);
/* Check all data have been processed */
if (ccm->ptlen != ccm->current_ptlen) {
return CRYPT_ERROR;

View File

@ -29,6 +29,7 @@ int ccm_init(ccm_state *ccm, int cipher,
{
int err;
LTC_ARGCHK(ccm != NULL);
LTC_ARGCHK(key != NULL);
LTC_ARGCHK(taglen != 0);

View File

@ -29,6 +29,8 @@ int ccm_process(ccm_state *ccm,
unsigned char y, z, b;
int err;
LTC_ARGCHK(ccm != NULL);
/* Check aad has been correctly added */
if (ccm->aadlen != ccm->current_aadlen) {
return CRYPT_ERROR;