Skip to content

Commit

Permalink
Add a signature count to MTRTestKeys. (#28452)
Browse files Browse the repository at this point in the history
This lets us check whether CASE resumption is happening.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Dec 19, 2023
1 parent a5ec920 commit 3511670
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/darwin/Framework/CHIPTests/TestHelpers/MTRTestKeys.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/darwin/Framework/CHIPTests/TestHelpers/MTRTestKeys.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3511670

Please sign in to comment.