Skip to content

Commit 805a803

Browse files
committed
Merged PR 11163422: Wipe temporary values used by integrity test
## Description: FIPS 140-3 TE05.08.02 requires that "any temporary values generated during the integrity test are zeroised upon completion of the integrity test." We were not previously doing this, because the temporary values are not secrets, but it is required for certification. This PR adds the required zeroisation. ## Admin Checklist: - [X] You have updated CHANGELOG.md to reflect any changes in behavior (Others N/A) Related work items: #52849999
1 parent fcea477 commit 805a803

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
New changes will be listed here as they are developed. The version number is determined
44
prior to the creation of a new release, based on the changes contained in that release.
55

6+
- Internal self-test changes to support FIPS 140-3 certification
7+
68
# Version 103.4.3
79

810
- Added preliminary support for macOS (static libraries and unit tests only, no ASM optimizations)

modules/linux/common/integrity.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ size_t SymCryptModuleProcessSegmentWithRelocations(
479479
SymCryptHmacSha256Append( hmacState, segmentCopy, hashableSectionSize );
480480
#endif
481481

482+
SymCryptWipe( segmentCopy, hashableSectionSize );
482483
SymCryptCallbackFree( segmentCopy );
483484

484485
return hashableSectionSize;
@@ -492,7 +493,7 @@ VOID SymCryptModuleDoHmac(
492493
SYMCRYPT_ERROR scError = SYMCRYPT_NO_ERROR;
493494
SYMCRYPT_HMAC_SHA256_EXPANDED_KEY hmacKey;
494495
SYMCRYPT_HMAC_SHA256_STATE hmacState;
495-
BYTE actualDigest[SYMCRYPT_HMAC_SHA256_RESULT_SIZE] = {0xFF};
496+
BYTE actualDigest[SYMCRYPT_HMAC_SHA256_RESULT_SIZE];
496497

497498
scError = SymCryptHmacSha256ExpandKey( &hmacKey, SymCryptVolatileFipsHmacKey,
498499
sizeof(SymCryptVolatileFipsHmacKey) );
@@ -526,6 +527,12 @@ VOID SymCryptModuleDoHmac(
526527
// Verify that the HMAC result matches our expected digest
527528
SYMCRYPT_FIPS_ASSERT(
528529
memcmp( actualDigest, SymCryptVolatileFipsHmacDigest, SYMCRYPT_HMAC_SHA256_RESULT_SIZE ) == 0 );
530+
531+
// FIPS 140-3 TE05.08.02 requires that "any temporary values generated during the integrity
532+
// test are zeroised upon completion of the integrity test"
533+
SymCryptWipeKnownSize( actualDigest, SYMCRYPT_HMAC_SHA256_RESULT_SIZE );
534+
SymCryptWipeKnownSize( &hmacState, sizeof(hmacState) );
535+
SymCryptWipeKnownSize( &hmacKey, sizeof(hmacKey) );
529536
}
530537

531538
VOID SymCryptModuleVerifyIntegrity(void)

scripts/process_fips_module.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def value(self, value):
155155
# buffer, so we need to find the appropriate section within the stream using sh_offset and
156156
# write to that.
157157
# Note self.section.stream == self.elf_file.stream.
158-
logging.debug("Changing {} writing {} to offset {}".format(self.name, value.hex(), hex(self.offset)))
158+
logging.debug("Writing {} to offset {}".format(value.hex(), hex(self.offset)))
159159
self.section.stream.seek(self.offset)
160160
self.section.stream.write(value)
161161

@@ -164,7 +164,9 @@ def set_value(self, format, *args):
164164
assert(len(new_value) == self.length)
165165

166166
if self.name is not None:
167-
logging.debug("Changing {} value to {}".format(self.name, *args))
167+
logging.debug("Changing {} value to {}".format(
168+
self.name if self.name is not None else "(unnamed)",
169+
*args))
168170

169171
self.value = new_value
170172

0 commit comments

Comments
 (0)