Skip to content

Commit

Permalink
Add authenticate methods and cleanup code
Browse files Browse the repository at this point in the history
CDOC-11

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma committed Feb 26, 2025
1 parent b2afacb commit ac68ca3
Show file tree
Hide file tree
Showing 32 changed files with 253 additions and 689 deletions.
1 change: 1 addition & 0 deletions MoppApp/MoppApp/AddresseeActions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*
*/
import Foundation
import CryptoLib

protocol AddresseeActions {
func displayAddresseeType(_ policyIdentifiers: [String]) -> String
Expand Down
1 change: 1 addition & 0 deletions MoppApp/MoppApp/ContainerActions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import Foundation
import SkSigningLib
import CryptoLib

protocol ContainerActions {
func openExistingContainer(with url: URL, cleanup: Bool, isEmptyFileImported: Bool, isSendingToSivaAgreed: Bool)
Expand Down
1 change: 1 addition & 0 deletions MoppApp/MoppApp/ContainerAddAllButtonCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*/

import Foundation
import CryptoLib

class ContainerAddAllButtonCell: UITableViewCell {

Expand Down
1 change: 1 addition & 0 deletions MoppApp/MoppApp/ContainerFoundAddresseeCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*/

import Foundation
import CryptoLib

protocol ContainerFoundAddresseeCellDelegate : AnyObject {
func addAddresseeToSelectedArea(index: Int, completionHandler: @escaping () -> Void)
Expand Down
1 change: 1 addition & 0 deletions MoppApp/MoppApp/CryptoActions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*
*/
import Foundation
import CryptoLib

protocol CryptoActions {
func startEncryptingProcess()
Expand Down
1 change: 1 addition & 0 deletions MoppApp/MoppApp/CryptoContainerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*/

import UIKit
import CryptoLib

class CryptoContainerViewController : ContainerViewController, CryptoActions {

Expand Down
2 changes: 1 addition & 1 deletion MoppApp/MoppApp/IdCardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ extension IdCardViewController : MoppLibCardReaderManagerDelegate {
// Give some time for UI to update before executing data requests
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1, execute: { [weak self] in
guard let strongSelf = self else { return }
MoppLibCardActions.minimalCardPersonalData(success: { [weak self] moppLibPersonalData in
MoppLibCardActions.cardPersonalData(success: { [weak self] moppLibPersonalData in
DispatchQueue.main.async {
self?.idCardPersonalData = moppLibPersonalData
self?.state = .readyForTokenAction
Expand Down
4 changes: 2 additions & 2 deletions MoppApp/MoppApp/MyeIDInfoManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class MyeIDInfoManager {
self?.delegate?.didCompleteInformationRequest(success: false)
}

MoppLibCardActions.minimalCardPersonalData(success: { moppLibPersonalData in
MoppLibCardActions.cardPersonalData(success: { moppLibPersonalData in
MoppLibCardActions.authenticationCertificate(success: { moppLibAuthCertData in
MoppLibCardActions.signingCertificate(success: { [weak self] moppLibSignCertData in
self?.requestRetryCounts(with: viewController, success: { [weak self] (pin1RetryCount, pin2RetryCount, pukRetryCount) in
Expand Down Expand Up @@ -220,7 +220,7 @@ class MyeIDInfoManager {
guard let personalData = personalData else { return }
let certOrganization = authCertData?.organization ?? MoppLibCertificateOrganization.Unknown
personalInfo.items.append((type: .myeID, value: organizationDisplayString(certOrganization)))
personalInfo.items.append((type: .givenNames, value: personalData.givenNames()))
personalInfo.items.append((type: .givenNames, value: personalData.givenNames))
personalInfo.items.append((type: .surname, value: personalData.surname))
personalInfo.items.append((type: .personalCode, value: personalData.personalIdentificationCode))
personalInfo.items.append((type: .citizenship, value: personalData.nationality))
Expand Down
1 change: 1 addition & 0 deletions MoppApp/MoppApp/RecentContainersViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*/

import UIKit
import CryptoLib
class RecentContainersViewController : MoppModalViewController {
var requestCloseSearch: (() -> Void) = {}
@IBOutlet weak var tableView: UITableView!
Expand Down
4 changes: 0 additions & 4 deletions MoppLib/MoppLib.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
545111721E13BBA800296B80 /* MoppLibPersonalData.h in Headers */ = {isa = PBXBuildFile; fileRef = 545111701E13BBA800296B80 /* MoppLibPersonalData.h */; settings = {ATTRIBUTES = (Public, ); }; };
545111731E13BBA800296B80 /* MoppLibPersonalData.m in Sources */ = {isa = PBXBuildFile; fileRef = 545111711E13BBA800296B80 /* MoppLibPersonalData.m */; };
5463DA4C1E12927A008A1714 /* CardCommands.h in Headers */ = {isa = PBXBuildFile; fileRef = 5463DA4A1E12927A008A1714 /* CardCommands.h */; };
5463DA4D1E12927A008A1714 /* CardCommands.m in Sources */ = {isa = PBXBuildFile; fileRef = 5463DA4B1E12927A008A1714 /* CardCommands.m */; };
546E57611E2E07C7009A568D /* PinVerificationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 546E57601E2E07C7009A568D /* PinVerificationTests.m */; };
546E57631E2E07C7009A568D /* MoppLib.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4250CE71E09695100530370 /* MoppLib.framework */; };
546E576B1E2E1555009A568D /* MoppLibPinActions+Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 546E576A1E2E1555009A568D /* MoppLibPinActions+Tests.m */; };
Expand Down Expand Up @@ -116,7 +115,6 @@
545111701E13BBA800296B80 /* MoppLibPersonalData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MoppLibPersonalData.h; sourceTree = "<group>"; };
545111711E13BBA800296B80 /* MoppLibPersonalData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MoppLibPersonalData.m; sourceTree = "<group>"; };
5463DA4A1E12927A008A1714 /* CardCommands.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CardCommands.h; sourceTree = "<group>"; };
5463DA4B1E12927A008A1714 /* CardCommands.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CardCommands.m; sourceTree = "<group>"; };
546E575E1E2E07C7009A568D /* MoppLibTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MoppLibTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
546E57601E2E07C7009A568D /* PinVerificationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PinVerificationTests.m; sourceTree = "<group>"; };
546E57621E2E07C7009A568D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -305,7 +303,6 @@
54DC0DFB1E0D196D00C62B3D /* CardActionsManager.h */,
54DC0DFC1E0D196D00C62B3D /* CardActionsManager.m */,
5463DA4A1E12927A008A1714 /* CardCommands.h */,
5463DA4B1E12927A008A1714 /* CardCommands.m */,
);
name = CardActions;
sourceTree = "<group>";
Expand Down Expand Up @@ -619,7 +616,6 @@
C5E41C5E2180602B00D79B54 /* Idemia.m in Sources */,
54DC0DFE1E0D196D00C62B3D /* CardActionsManager.m in Sources */,
AE0A844B1E43853800CC1465 /* MoppLibMobileCreateSignatureResponse.m in Sources */,
5463DA4D1E12927A008A1714 /* CardCommands.m in Sources */,
39266A5320CFC0F4002E3F23 /* SmartToken.m in Sources */,
542DCB6D1E23968000899534 /* MoppLibPinActions.m in Sources */,
C54EA732204D5E860039AC78 /* CardReaderiR301.m in Sources */,
Expand Down
25 changes: 10 additions & 15 deletions MoppLib/MoppLib/CardActionsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
*
*/

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "CardCommands.h"
#import "MoppLibRoleAddressData.h"
#import "MoppLibConstants.h"

typedef NS_ENUM(NSUInteger, CodeType);
@class MoppLibRoleAddressData;
@protocol CardReaderWrapper;

@interface CardActionsManager : NSObject
+ (CardActionsManager *)sharedInstance;
Expand All @@ -33,15 +34,11 @@

- (void)setReader:(id<CardReaderWrapper>)cardReader;

- (void)minimalCardPersonalDataWithSuccess:(PersonalDataBlock)success failure:(FailureBlock)failure;

- (void)cardPersonalDataWithSuccess:(PersonalDataBlock)success failure:(FailureBlock)failure;

- (void)signingCertWithPin2:(NSString *)pin2 success:(CertDataBlock)success failure:(FailureBlock)failure;
- (void)authenticationCertWithSuccess:(CertDataBlock)success failure:(FailureBlock)failure;
- (void)signingCertWithSuccess:(DataSuccessBlock)success failure:(FailureBlock)failure;

- (void)authenticationCertDataWithSuccess:(DataSuccessBlock)success failure:(FailureBlock)failure;
- (void)signingCertDataWithPin2:(NSString *)pin2 success:(DataSuccessBlock)success failure:(FailureBlock)failure;
- (void)authenticationCertWithSuccess:(DataSuccessBlock)success failure:(FailureBlock)failure;

- (void)changePin:(CodeType)type withPuk:(NSString *)puk to:(NSString *)newPin success:(VoidBlock)success failure:(FailureBlock)failure;

Expand All @@ -53,13 +50,11 @@

- (void)addSignature:(NSString *)containerPath withPin2:(NSString *)pin2 roleData:(MoppLibRoleAddressData *)roleData success:(void (^)(MoppLibContainer *container, BOOL signatureWasAdded))success failure:(FailureBlock)failure;

- (void)calculateSignatureFor:(NSData *)hash pin2:(NSString *)pin2 useECC:(BOOL)useECC success:(DataSuccessBlock)success failure:(FailureBlock)failure;

- (void)decryptData:(NSData *)hash pin1:(NSString *)pin1 useECC:(BOOL)useECC success:(DataSuccessBlock)success failure:(FailureBlock)failure;
- (void)authenticateFor:(NSData *)hash pin1:(NSString *)pin2 success:(DataSuccessBlock)success failure:(FailureBlock)failure;

- (void)isCardInserted:(BoolBlock)completion;
- (void)calculateSignatureFor:(NSData *)hash pin2:(NSString *)pin2 success:(DataSuccessBlock)success failure:(FailureBlock)failure;

- (BOOL)isReaderConnected;
- (void)decryptData:(NSData *)hash pin1:(NSString *)pin1 success:(DataSuccessBlock)success failure:(FailureBlock)failure;

- (void)resetCardActions;
@end
Loading

0 comments on commit ac68ca3

Please sign in to comment.