CommonCrypto framework added

This commit is contained in:
Alexey Gerasimov 2017-04-25 18:18:09 +03:00
parent 6efc671aea
commit f5ea2895cd
7 changed files with 214 additions and 5 deletions

View File

@ -0,0 +1,19 @@
//
// CommonCrypto.h
// CommonCrypto
//
// Created by Alexey Gerasimov on 25/04/2017.
// Copyright © 2017 TouchInstinct. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for CommonCrypto.
FOUNDATION_EXPORT double CommonCryptoVersionNumber;
//! Project version string for CommonCrypto.
FOUNDATION_EXPORT const unsigned char CommonCryptoVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <CommonCrypto/PublicHeader.h>

View File

@ -0,0 +1,10 @@
//
// CommonCrypto.xcconfig
// Chat
//
// Created by Alexey Gerasimov on 17/08/16.
// Copyright © 2016 Touch Instinct. All rights reserved.
//
MODULEMAP_FILE[sdk=iphoneos*] = $(SRCROOT)/CommonCrypto/iphoneos.modulemap
MODULEMAP_FILE[sdk=iphonesimulator*] = $(SRCROOT)/CommonCrypto/iphonesimulator.modulemap

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>

View File

@ -0,0 +1,4 @@
module CommonCrypto [system] {
header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/CommonCrypto/CommonCrypto.h"
export *
}

View File

@ -0,0 +1,4 @@
module CommonCrypto [system] {
header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/CommonCrypto/CommonCrypto.h"
export *
}

View File

@ -19,6 +19,8 @@
EF05EDC21EAF706200CAE7B6 /* DefaultNetworkService.swift in Sources */ = {isa = PBXBuildFile; fileRef = EF05EDBF1EAF706200CAE7B6 /* DefaultNetworkService.swift */; };
EF05EDC61EAF70EB00CAE7B6 /* TouchIDService.swift in Sources */ = {isa = PBXBuildFile; fileRef = EF05EDC51EAF70EB00CAE7B6 /* TouchIDService.swift */; };
EF05EDC81EAF91D500CAE7B6 /* BasePassCodeService.swift in Sources */ = {isa = PBXBuildFile; fileRef = EF05EDC71EAF91D500CAE7B6 /* BasePassCodeService.swift */; };
EF05EDD21EAF9CF100CAE7B6 /* CommonCrypto.h in Headers */ = {isa = PBXBuildFile; fileRef = EF05EDD01EAF9CF100CAE7B6 /* CommonCrypto.h */; settings = {ATTRIBUTES = (Public, ); }; };
EF05EDDA1EAF9D4A00CAE7B6 /* CommonCrypto.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EF05EDCE1EAF9CF100CAE7B6 /* CommonCrypto.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@ -38,6 +40,12 @@
EF05EDBF1EAF706200CAE7B6 /* DefaultNetworkService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DefaultNetworkService.swift; sourceTree = "<group>"; };
EF05EDC51EAF70EB00CAE7B6 /* TouchIDService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TouchIDService.swift; sourceTree = "<group>"; };
EF05EDC71EAF91D500CAE7B6 /* BasePassCodeService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BasePassCodeService.swift; sourceTree = "<group>"; };
EF05EDCE1EAF9CF100CAE7B6 /* CommonCrypto.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CommonCrypto.framework; sourceTree = BUILT_PRODUCTS_DIR; };
EF05EDD01EAF9CF100CAE7B6 /* CommonCrypto.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CommonCrypto.h; sourceTree = "<group>"; };
EF05EDD11EAF9CF100CAE7B6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
EF05EDD61EAF9D2900CAE7B6 /* CommonCrypto.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CommonCrypto.xcconfig; sourceTree = "<group>"; };
EF05EDD71EAF9D2900CAE7B6 /* iphoneos.modulemap */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.module-map"; path = iphoneos.modulemap; sourceTree = "<group>"; };
EF05EDD81EAF9D2900CAE7B6 /* iphonesimulator.modulemap */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.module-map"; path = iphonesimulator.modulemap; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -45,10 +53,18 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
EF05EDDA1EAF9D4A00CAE7B6 /* CommonCrypto.framework in Frameworks */,
7A94B4A5956B82BE1CEBA873 /* Pods_LeadKitAdditions.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
EF05EDCA1EAF9CF100CAE7B6 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
@ -64,6 +80,7 @@
isa = PBXGroup;
children = (
CAE698E51E968820000394B0 /* LeadKitAdditions */,
EF05EDCF1EAF9CF100CAE7B6 /* CommonCrypto */,
CAE698E41E968820000394B0 /* Products */,
F8A65FEC7C0EB4B93746E50F /* Pods */,
A3117951840B8B7D2E7A8A80 /* Frameworks */,
@ -74,6 +91,7 @@
isa = PBXGroup;
children = (
CAE698E31E968820000394B0 /* LeadKitAdditions.framework */,
EF05EDCE1EAF9CF100CAE7B6 /* CommonCrypto.framework */,
);
name = Products;
sourceTree = "<group>";
@ -129,6 +147,18 @@
path = Enums;
sourceTree = "<group>";
};
EF05EDCF1EAF9CF100CAE7B6 /* CommonCrypto */ = {
isa = PBXGroup;
children = (
EF05EDD01EAF9CF100CAE7B6 /* CommonCrypto.h */,
EF05EDD61EAF9D2900CAE7B6 /* CommonCrypto.xcconfig */,
EF05EDD11EAF9CF100CAE7B6 /* Info.plist */,
EF05EDD71EAF9D2900CAE7B6 /* iphoneos.modulemap */,
EF05EDD81EAF9D2900CAE7B6 /* iphonesimulator.modulemap */,
);
path = CommonCrypto;
sourceTree = "<group>";
};
F8A65FEC7C0EB4B93746E50F /* Pods */ = {
isa = PBXGroup;
children = (
@ -149,6 +179,14 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
EF05EDCB1EAF9CF100CAE7B6 /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
EF05EDD21EAF9CF100CAE7B6 /* CommonCrypto.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
@ -174,6 +212,24 @@
productReference = CAE698E31E968820000394B0 /* LeadKitAdditions.framework */;
productType = "com.apple.product-type.framework";
};
EF05EDCD1EAF9CF100CAE7B6 /* CommonCrypto */ = {
isa = PBXNativeTarget;
buildConfigurationList = EF05EDD31EAF9CF100CAE7B6 /* Build configuration list for PBXNativeTarget "CommonCrypto" */;
buildPhases = (
EF05EDC91EAF9CF100CAE7B6 /* Sources */,
EF05EDCA1EAF9CF100CAE7B6 /* Frameworks */,
EF05EDCB1EAF9CF100CAE7B6 /* Headers */,
EF05EDCC1EAF9CF100CAE7B6 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = CommonCrypto;
productName = CommonCrypto;
productReference = EF05EDCE1EAF9CF100CAE7B6 /* CommonCrypto.framework */;
productType = "com.apple.product-type.framework";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
@ -188,6 +244,10 @@
LastSwiftMigration = 0830;
ProvisioningStyle = Manual;
};
EF05EDCD1EAF9CF100CAE7B6 = {
CreatedOnToolsVersion = 8.3.1;
ProvisioningStyle = Manual;
};
};
};
buildConfigurationList = CAE698DD1E968820000394B0 /* Build configuration list for PBXProject "LeadKitAdditions" */;
@ -203,6 +263,7 @@
projectRoot = "";
targets = (
CAE698E21E968820000394B0 /* LeadKitAdditions */,
EF05EDCD1EAF9CF100CAE7B6 /* CommonCrypto */,
);
};
/* End PBXProject section */
@ -215,6 +276,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
EF05EDCC1EAF9CF100CAE7B6 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
@ -296,6 +364,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
EF05EDC91EAF9CF100CAE7B6 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
@ -449,6 +524,52 @@
};
name = Release;
};
EF05EDD41EAF9CF100CAE7B6 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = CommonCrypto/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
"MODULEMAP_FILE[sdk=iphoneos*]" = /Users/alexeygerasimov/Documents/dev/LeadKitAdditions/LeadKitAdditions/CommonCrypto/iphoneos.modulemap;
"MODULEMAP_FILE[sdk=iphonesimulator*]" = /Users/alexeygerasimov/Documents/dev/LeadKitAdditions/LeadKitAdditions/CommonCrypto/iphonesimulator.modulemap;
PRODUCT_BUNDLE_IDENTIFIER = com.touchin.CommonCrypto;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
};
name = Debug;
};
EF05EDD51EAF9CF100CAE7B6 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = CommonCrypto/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
"MODULEMAP_FILE[sdk=iphoneos*]" = /Users/alexeygerasimov/Documents/dev/LeadKitAdditions/LeadKitAdditions/CommonCrypto/iphoneos.modulemap;
"MODULEMAP_FILE[sdk=iphonesimulator*]" = /Users/alexeygerasimov/Documents/dev/LeadKitAdditions/LeadKitAdditions/CommonCrypto/iphonesimulator.modulemap;
PRODUCT_BUNDLE_IDENTIFIER = com.touchin.CommonCrypto;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
@ -470,6 +591,14 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
EF05EDD31EAF9CF100CAE7B6 /* Build configuration list for PBXNativeTarget "CommonCrypto" */ = {
isa = XCConfigurationList;
buildConfigurations = (
EF05EDD41EAF9CF100CAE7B6 /* Debug */,
EF05EDD51EAF9CF100CAE7B6 /* Release */,
);
defaultConfigurationIsVisible = 0;
};
/* End XCConfigurationList section */
};
rootObject = CAE698DA1E968820000394B0 /* Project object */;

View File

@ -22,6 +22,7 @@
import KeychainAccess
import CocoaLumberjack
import CommonCrypto
open class BasePassCodeService {
@ -76,11 +77,15 @@ extension BasePassCodeService {
}
public func save(passCode: String?) {
keychain[Keys.passCodeHash] = passCode?.hashMD5
if let passCode = passCode {
keychain[Keys.passCodeHash] = sha256(passCode)
} else {
keychain[Keys.passCodeHash] = nil
}
}
public func check(passCode: String) -> Bool {
return passCode.hashMD5 == passCodeHash
return sha256(passCode) == passCodeHash
}
public func reset() {
@ -90,10 +95,24 @@ extension BasePassCodeService {
}
private extension String {
private extension BasePassCodeService {
var hashMD5: String? {
return self
func sha256(_ str: String) -> String? {
guard let data = str.data(using: String.Encoding.utf8), let shaData = sha256(data) else {
return nil
}
let rc = shaData.base64EncodedString(options: [])
return rc
}
func sha256(_ data: Data) -> Data? {
guard let res = NSMutableData(length: Int(CC_SHA256_DIGEST_LENGTH)) else {
return nil
}
CC_SHA256((data as NSData).bytes, CC_LONG(data.count), res.mutableBytes.assumingMemoryBound(to: UInt8.self))
return res as Data
}
}