Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/encauth/ccm/ccm_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,9 @@ int ccm_memory(int cipher,

if (skey != uskey) {
cipher_descriptor[cipher].done(skey);
#ifdef LTC_CLEAN_STACK
zeromem(skey, sizeof(*skey));
#endif
}

if (direction == CCM_ENCRYPT) {
Expand Down Expand Up @@ -380,7 +383,6 @@ int ccm_memory(int cipher,
fastMask = 0;
#endif
mask = 0;
zeromem(skey, sizeof(*skey));
zeromem(PAD, sizeof(PAD));
zeromem(CTRPAD, sizeof(CTRPAD));
if (pt_work != NULL) {
Expand Down
11 changes: 11 additions & 0 deletions src/encauth/ccm/ccm_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,17 @@ int ccm_test(void)
tag, &taglen, 0)) != CRYPT_OK) {
return err;
}
/* run a second time to make sure skey is not touched */
if ((err = ccm_memory(idx,
tests[x].key, 16,
&skey,
tests[x].nonce, tests[x].noncelen,
tests[x].header, tests[x].headerlen,
(unsigned char*)tests[x].pt, tests[x].ptlen,
buf,
tag, &taglen, 0)) != CRYPT_OK) {
return err;
}
} else {
if ((err = ccm_init(&ccm, idx, tests[x].key, 16, tests[x].ptlen, tests[x].taglen, tests[x].headerlen)) != CRYPT_OK) {
return err;
Expand Down