Skip to content

Commit

Permalink
Check PIN length and numbers (#22)
Browse files Browse the repository at this point in the history
IB-5757

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma authored and kristelmerilain committed Nov 22, 2019
1 parent 756f356 commit 876fc15
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 18 deletions.
4 changes: 2 additions & 2 deletions EstEIDToken/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>$(VERSION)</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(BUILD_NUMBER)</string>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSExtension</key>
Expand Down
16 changes: 16 additions & 0 deletions EstEIDToken/TokenSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ @implementation AuthOperation {
TokenSession *session;
}

- (BOOL)isAllDigits:(NSString*)data {
NSCharacterSet* nonNumbers = [[NSCharacterSet decimalDigitCharacterSet] invertedSet];
NSRange r = [data rangeOfCharacterFromSet: nonNumbers];
return r.location == NSNotFound && data.length > 0;
}

- (nullable instancetype)initWithSmartCard:(TKSmartCard *)smartCard tokenSession:(TokenSession *)esteidsession {
if (self = [super init]) {
self.smartCard = smartCard;
Expand All @@ -42,6 +48,16 @@ - (nullable instancetype)initWithSmartCard:(TKSmartCard *)smartCard tokenSession

- (BOOL)finishWithError:(NSError **)error {
NSLog(@"AuthOperation finishWithError %@", *error);
if (self.PIN.length < self.PINFormat.minPINLength || self.PIN.length > self.PINFormat.maxPINLength ||
![self isAllDigits:self.PIN]) {
NSLog(@"AuthOperation finishWithError invalid PIN lenght: %lu min: %lu max: %lu", self.PIN.length, self.PINFormat.minPINLength, self.PINFormat.maxPINLength);
[EstEIDTokenDriver showNotification:[NSString localizedStringWithFormat:NSLocalizedString(@"INVALID_PIN", nil)]];
if (error != nil) {
*error = [NSError errorWithDomain:TKErrorDomain code:TKErrorCodeAuthenticationFailed userInfo:
@{NSLocalizedDescriptionKey:[NSString localizedStringWithFormat:NSLocalizedString(@"INVALID_PIN", nil)]}];
}
return NO;
}
UInt16 sw = 0;
[self.smartCard sendIns:0x20 p1:0x00 p2:0x01 data:[session pinTemplate:self.PIN] le:nil sw:&sw error:error];
NSLog(@"AuthOperation finishWithError %@", *error);
Expand Down
1 change: 1 addition & 0 deletions EstEIDToken/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
"SIGN_KEY" = "Key For Digital Signature";
"WRONG_CONSTR" = "Unexpected constraint";
"ENTER_PINPAD" = "Please enter PIN code on PinPAD";
"INVALID_PIN" = "Invalid PIN entered";
3 changes: 2 additions & 1 deletion EstEIDToken/et.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
"AUTH_KEY" = "Key For Card Authentication";
"SIGN_KEY" = "Key For Digital Signature";
"WRONG_CONSTR" = "Unexpected constraint";
"ENTER_PINPAD" = "Please enter PIN code on PinPAD";
"ENTER_PINPAD" = "Palun sisestada PIN kaardilugeja sõrmistikult";
"INVALID_PIN" = "Sisestati ebakorrektne PIN";
6 changes: 3 additions & 3 deletions EstEIDToken/et.lproj/Localizable.stringsdict
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>zero</key>
<string>PIN verification failed, PIN blocked</string>
<string>PIN on lukus</string>
<key>one</key>
<string>PIN verification failed, one try left</string>
<string>Vale PIN, järgmise vale koodi sisestamisel PIN lukustub</string>
<key>other</key>
<string>PIN verification failed, %d tries left</string>
<string>Vale PIN, %d katset jäänud</string>
</dict>
</dict>
</dict>
Expand Down
1 change: 1 addition & 0 deletions EstEIDToken/ru.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
"SIGN_KEY" = "Key For Digital Signature";
"WRONG_CONSTR" = "Unexpected constraint";
"ENTER_PINPAD" = "Please enter PIN code on PinPAD";
"INVALID_PIN" = "Invalid PIN entered";
20 changes: 12 additions & 8 deletions EstEIDTokenApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objectVersion = 51;
objects = {

/* Begin PBXAggregateTarget section */
Expand Down Expand Up @@ -90,7 +90,7 @@
2F3883BC1CF46C9D00F114A7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
2F3883C41CF46D6F00F114A7 /* TokenSession.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TokenSession.m; sourceTree = "<group>"; };
2F7767741CF5E0A00062B0A8 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
2F7767761CF5E0A00062B0A8 /* en */ = {isa = PBXFileReference; explicitFileType = text.plist.xml; name = en; path = en.lproj/Localizable.stringsdict; sourceTree = "<group>"; };
2F7767761CF5E0A00062B0A8 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = en; path = en.lproj/Localizable.stringsdict; sourceTree = "<group>"; };
4EAFE859212C20BE00DD6D87 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/MainMenu.strings; sourceTree = "<group>"; };
4EAFE85B212C20BE00DD6D87 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/Localizable.strings; sourceTree = "<group>"; };
4EAFE85C212C20BE00DD6D87 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = ru; path = ru.lproj/Localizable.stringsdict; sourceTree = "<group>"; };
Expand Down Expand Up @@ -261,7 +261,7 @@
2F3883901CF46C6E00F114A7 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1010;
LastUpgradeCheck = 1120;
ORGANIZATIONNAME = "";
TargetAttributes = {
2F3883971CF46C6E00F114A7 = {
Expand All @@ -286,8 +286,8 @@
};
};
buildConfigurationList = 2F3883931CF46C6E00F114A7 /* Build configuration list for PBXProject "EstEIDTokenApp" */;
compatibilityVersion = "Xcode 9.3";
developmentRegion = English;
compatibilityVersion = "Xcode 10.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -483,8 +483,9 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 0;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = 4F425HHPH8;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand All @@ -504,9 +505,10 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 1.3.1;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
VERSION = 1.3.0;
VERSION = 1.3.1;
};
name = Debug;
};
Expand Down Expand Up @@ -547,6 +549,7 @@
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 0;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 4F425HHPH8;
ENABLE_NS_ASSERTIONS = NO;
Expand All @@ -560,9 +563,10 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 1.3.1;
OTHER_CODE_SIGN_FLAGS = "--timestamp --options=runtime";
SDKROOT = macosx;
VERSION = 1.3.0;
VERSION = 1.3.1;
};
name = Release;
};
Expand Down
4 changes: 2 additions & 2 deletions EstEIDTokenApp/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(VERSION)</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>$(BUILD_NUMBER)</string>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down
4 changes: 2 additions & 2 deletions EstEIDTokenNotify/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(VERSION)</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>$(BUILD_NUMBER)</string>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSBackgroundOnly</key>
<true/>
<key>LSMinimumSystemVersion</key>
Expand Down

0 comments on commit 876fc15

Please sign in to comment.