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);