Skip to content

Commit

Permalink
Merge branch 'jens/fix-broken-fido2-demo'
Browse files Browse the repository at this point in the history
  • Loading branch information
jensutbult committed Oct 17, 2024
2 parents 1ea9c97 + d019c73 commit 23773c7
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 198 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,23 @@ -(instancetype)initWithConnectionController:(id<YKFConnectionControllerProtocol>
}

- (void)selectApplication:(YKFSelectApplicationAPDU *)apdu completion:(YKFSmartCardInterfaceResponseBlock)completion {
[self.connectionController execute:apdu completion:^(NSData *response, NSError *error, NSTimeInterval executionTime) {
[self executeCommand:apdu completion:^(NSData * _Nullable data, NSError * _Nullable error) {
if (error) {
completion(nil, error);
return;
}
UInt16 statusCode = [self statusCodeFromKeyResponse:response];
NSData *data = [self dataFromKeyResponse:response];
if (statusCode == YKFAPDUErrorCodeNoError) {
completion(data, nil);
} else if (statusCode == YKFAPDUErrorCodeMissingFile || statusCode == YKFAPDUErrorCodeInsNotSupported) {
NSError *error = [YKFSessionError errorWithCode:YKFSessionErrorMissingApplicationCode];
completion(nil, error);
if ([error isKindOfClass:[YKFSessionError class]]) {
UInt16 statusCode = error.code;
if (statusCode == YKFAPDUErrorCodeMissingFile || statusCode == YKFAPDUErrorCodeInsNotSupported) {
NSError *error = [YKFSessionError errorWithCode:YKFSessionErrorMissingApplicationCode];
completion(nil, error);
} else {
NSAssert(TRUE, @"The key returned an unexpected SW when selecting application");
NSError *error = [YKFSessionError errorWithCode:YKFSessionErrorUnexpectedStatusCode];
completion(nil, error);
}
} else {
completion(nil, error);
}
} else {
NSAssert(TRUE, @"The key returned an unexpected SW when selecting application");
NSError *error = [YKFSessionError errorWithCode:YKFSessionErrorUnexpectedStatusCode];
completion(nil, error);
completion(data, nil);
}
}];
}
Expand Down Expand Up @@ -101,7 +102,7 @@ - (void)executeCommand:(YKFAPDU *)apdu sendRemainingIns:(YKFSmartCardInterfaceSe
ins = 0xA5;
break;
}
YKFAPDU *sendRemainingApdu = [[YKFAPDU alloc] initWithData:[NSData dataWithBytes:(unsigned char[]){0x00, ins, 0x00, 0x00} length:4]];
YKFAPDU *sendRemainingApdu = [[YKFAPDU alloc] initWithData:[NSData dataWithBytes:(unsigned char[]){0x00, ins, 0x00, 0x00, 0x00} length:5]];
// Queue a new request recursively
[self executeCommand:sendRemainingApdu sendRemainingIns:sendRemainingIns timeout:timeout data:data completion:completion];
return;
Expand Down
Loading

0 comments on commit 23773c7

Please sign in to comment.