From 3511670e51036f14448ee4d38e15db46af26dfa2 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 1 Aug 2023 15:53:24 -0400 Subject: [PATCH] Add a signature count to MTRTestKeys. (#28452) This lets us check whether CASE resumption is happening. --- src/darwin/Framework/CHIPTests/TestHelpers/MTRTestKeys.h | 3 +++ src/darwin/Framework/CHIPTests/TestHelpers/MTRTestKeys.m | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/darwin/Framework/CHIPTests/TestHelpers/MTRTestKeys.h b/src/darwin/Framework/CHIPTests/TestHelpers/MTRTestKeys.h index 8741eb584e3572..9afe75266d1eed 100644 --- a/src/darwin/Framework/CHIPTests/TestHelpers/MTRTestKeys.h +++ b/src/darwin/Framework/CHIPTests/TestHelpers/MTRTestKeys.h @@ -25,6 +25,9 @@ NS_ASSUME_NONNULL_BEGIN @property (readonly, nonatomic) NSData * publicKeyData; +// Count of how many times this keypair has been used to signMessageECDSA_DER. +@property (readonly, nonatomic, assign) unsigned signatureCount; + - (instancetype)init; @end diff --git a/src/darwin/Framework/CHIPTests/TestHelpers/MTRTestKeys.m b/src/darwin/Framework/CHIPTests/TestHelpers/MTRTestKeys.m index 2d073f64d11fb4..23b602e2e7208c 100644 --- a/src/darwin/Framework/CHIPTests/TestHelpers/MTRTestKeys.m +++ b/src/darwin/Framework/CHIPTests/TestHelpers/MTRTestKeys.m @@ -69,11 +69,15 @@ - (instancetype)init } _publicKey = SecKeyCopyPublicKey(_privateKey); + _signatureCount = 0; + return self; } - (NSData *)signMessageECDSA_DER:(NSData *)message { + ++_signatureCount; + CFErrorRef error = NULL; CFDataRef outData = SecKeyCreateSignature(_privateKey, kSecKeyAlgorithmECDSASignatureMessageX962SHA256, (__bridge CFDataRef) message, &error);