-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose DeviceCommissioner::ComputePASEVerifier
to Obj-C.
#22112
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -668,6 +668,34 @@ - (void)setNocChainIssuer:(id<MTRNOCChainIssuer>)nocChainIssuer queue:(dispatch_ | |
}); | ||
} | ||
|
||
- (nullable NSData *)computePaseVerifier:(uint32_t)setupPincode iterations:(uint32_t)iterations salt:(NSData *)salt | ||
{ | ||
__block CHIP_ERROR errorCode = CHIP_ERROR_INCORRECT_STATE; | ||
if (![self isRunning]) { | ||
[self checkForError:errorCode logMsg:kErrorNotRunning error:nil]; | ||
return nil; | ||
} | ||
|
||
__block NSData * result; | ||
__block chip::Spake2pVerifier paseVerifier; | ||
__block chip::ByteSpan saltByteSpan = chip::ByteSpan(static_cast<const uint8_t *>(salt.bytes), salt.length); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use |
||
|
||
dispatch_sync(_chipWorkQueue, ^{ | ||
if ([self isRunning]) { | ||
errorCode = self.cppCommissioner->ComputePASEVerifier(iterations, setupPincode, saltByteSpan, paseVerifier); | ||
MTR_LOG_ERROR("ComputePaseVerifier: %s", chip::ErrorStr(errorCode)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And if this fails... now what? We return garbage? |
||
|
||
uint8_t serializedVerifier[sizeof(paseVerifier.mW0) + sizeof(paseVerifier.mL)]; | ||
memcpy(serializedVerifier, paseVerifier.mW0, chip::kSpake2p_WS_Length); | ||
memcpy(&serializedVerifier[sizeof(paseVerifier.mW0)], paseVerifier.mL, sizeof(paseVerifier.mL)); | ||
|
||
result = [NSData dataWithBytes:serializedVerifier length:sizeof(serializedVerifier)]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use |
||
} | ||
}); | ||
|
||
return result; | ||
} | ||
|
||
- (BOOL)checkForInitError:(BOOL)condition logMsg:(NSString *)logMsg | ||
{ | ||
if (condition) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use checkIsRunning.