From 89fb81f5797007f04ecf80c2bf846402bd6b7121 Mon Sep 17 00:00:00 2001 From: Scott Talbot Date: Mon, 21 Oct 2019 11:48:27 +1100 Subject: [PATCH 1/4] Update to Xcode 10.3 on Travis --- .travis.yml | 5 +++-- STSecurity.xcodeproj/project.pbxproj | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 54e9fdc..fb8a546 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,11 @@ -osx_image: xcode8.2 +os: osx +osx_image: xcode10.3 language: objective-c xcode_project: STSecurity.xcodeproj xcode_sdk: iphonesimulator xcode_scheme: STSecurity env: - - TRAVIS_XCODE_DESTINATION="platform=iOS Simulator,name=iPhone 6,OS=9.3" + - TRAVIS_XCODE_DESTINATION="platform=iOS Simulator,name=iPhone 8,OS=11.4" branches: only: - master diff --git a/STSecurity.xcodeproj/project.pbxproj b/STSecurity.xcodeproj/project.pbxproj index 872193c..3771bf0 100644 --- a/STSecurity.xcodeproj/project.pbxproj +++ b/STSecurity.xcodeproj/project.pbxproj @@ -398,6 +398,10 @@ INFOPLIST_FILE = STSecurityTests/Info.plist; PRODUCT_BUNDLE_IDENTIFIER = "org.chikachow.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = STSecurityTests; + WARNING_CFLAGS = ( + "$(inherited)", + "-Wno-objc-messaging-id", + ); }; name = Debug; }; @@ -408,6 +412,10 @@ INFOPLIST_FILE = STSecurityTests/Info.plist; PRODUCT_BUNDLE_IDENTIFIER = "org.chikachow.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = STSecurityTests; + WARNING_CFLAGS = ( + "$(inherited)", + "-Wno-objc-messaging-id", + ); }; name = Release; }; From 54b1b0ce636211aa229231bd934ea66dc8ea9d5a Mon Sep 17 00:00:00 2001 From: Scott Talbot Date: Mon, 21 Oct 2019 11:57:34 +1100 Subject: [PATCH 2/4] Remove TRAVIS_ prefix from environment variable --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index fb8a546..076223e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,10 +5,10 @@ xcode_project: STSecurity.xcodeproj xcode_sdk: iphonesimulator xcode_scheme: STSecurity env: - - TRAVIS_XCODE_DESTINATION="platform=iOS Simulator,name=iPhone 8,OS=11.4" + - XCODE_DESTINATION="platform=iOS Simulator,name=iPhone 8,OS=11.4" branches: only: - master before_script: - gem install xcpretty -script: set -o pipefail && xcodebuild test -project "${TRAVIS_XCODE_PROJECT}" -scheme "${TRAVIS_XCODE_SCHEME}" -sdk "${TRAVIS_XCODE_SDK}" -destination "${TRAVIS_XCODE_DESTINATION}" | xcpretty +script: set -o pipefail && xcodebuild test -project "${TRAVIS_XCODE_PROJECT}" -scheme "${TRAVIS_XCODE_SCHEME}" -sdk "${TRAVIS_XCODE_SDK}" -destination "${XCODE_DESTINATION}" | xcpretty From 61fd319210e6465338915031c7471e2d7f2817c7 Mon Sep 17 00:00:00 2001 From: Scott Talbot Date: Sun, 27 Oct 2019 13:37:51 +1100 Subject: [PATCH 3/4] hack --- STSecurity.xcodeproj/project.pbxproj | 695 ++++++++++-------- .../xcschemes/STSecurity.framework.xcscheme | 113 --- .../xcschemes/STSecurity.xcscheme | 50 +- STSecurity/Project.xcconfig | 98 +-- .../STSecurityKeychainAccess+Internal.h | 4 + STSecurity/STSecurityKeychainAccess+RSA.m | 2 +- STSecurity/STSecurityKeychainAccess.m | 2 +- STSecurity/STSecurityRSAKey.m | 1 + STSecurity/Target.xcconfig | 2 +- STSecurityTestHost/AppDelegate.h | 15 + STSecurityTestHost/AppDelegate.m | 9 + .../AppIcon.appiconset/Contents.json | 98 +++ .../Assets.xcassets/Contents.json | 6 + .../Base.lproj/LaunchScreen.storyboard | 25 + STSecurityTestHost/Base.lproj/Main.storyboard | 8 + STSecurityTestHost/Info.plist | 64 ++ STSecurityTestHost/main.m | 19 + .../STSecurityKeychainAccessRSATests.m | 616 ++++++++-------- .../STSecurityRSAEncryptionTests.m | 590 +++++++-------- STSecurityTests/STSecurityRSAKeyTests.m | 84 +-- project.yml | 61 ++ 21 files changed, 1425 insertions(+), 1137 deletions(-) delete mode 100644 STSecurity.xcodeproj/xcshareddata/xcschemes/STSecurity.framework.xcscheme create mode 100644 STSecurityTestHost/AppDelegate.h create mode 100644 STSecurityTestHost/AppDelegate.m create mode 100644 STSecurityTestHost/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 STSecurityTestHost/Assets.xcassets/Contents.json create mode 100644 STSecurityTestHost/Base.lproj/LaunchScreen.storyboard create mode 100644 STSecurityTestHost/Base.lproj/Main.storyboard create mode 100644 STSecurityTestHost/Info.plist create mode 100644 STSecurityTestHost/main.m create mode 100644 project.yml diff --git a/STSecurity.xcodeproj/project.pbxproj b/STSecurity.xcodeproj/project.pbxproj index 3771bf0..7fcb81c 100644 --- a/STSecurity.xcodeproj/project.pbxproj +++ b/STSecurity.xcodeproj/project.pbxproj @@ -3,510 +3,607 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 51; objects = { /* Begin PBXBuildFile section */ - 2C1D8CC116186B6B009EB62A /* STSecurityRSAKey.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 2C55A16F1616E6A400C54B8C /* STSecurityRSAKey.h */; }; - 2C1D8CC316186B6F009EB62A /* STSecurityKeychainAccess.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 2C55A16C1616E68800C54B8C /* STSecurityKeychainAccess.h */; }; - 2C1D8CC416186B72009EB62A /* STSecurityRSAEncryption.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 2C55A1761617C70700C54B8C /* STSecurityRSAEncryption.h */; }; - 2C1D8D04161931CB009EB62A /* STSecurityRSAKeyTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C1D8D03161931CB009EB62A /* STSecurityRSAKeyTests.m */; }; - 2C2C12661D8A9C740039643D /* STSecurityKeychainAccess+RSA.h in Headers */ = {isa = PBXBuildFile; fileRef = 2C2C12641D8A9C740039643D /* STSecurityKeychainAccess+RSA.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 2C2C12671D8A9C740039643D /* STSecurityKeychainAccess+RSA.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C2C12651D8A9C740039643D /* STSecurityKeychainAccess+RSA.m */; }; - 2C2C12681D8A9C740039643D /* STSecurityKeychainAccess+RSA.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C2C12651D8A9C740039643D /* STSecurityKeychainAccess+RSA.m */; }; - 2C55A16E1616E68800C54B8C /* STSecurityKeychainAccess.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C55A16D1616E68800C54B8C /* STSecurityKeychainAccess.m */; }; - 2C55A1711616E6A400C54B8C /* STSecurityRSAKey.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C55A1701616E6A400C54B8C /* STSecurityRSAKey.m */; }; - 2C55A17516171D3000C54B8C /* STSecurityKeychainAccessRSATests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C55A17416171D3000C54B8C /* STSecurityKeychainAccessRSATests.m */; }; - 2C55A1781617C70700C54B8C /* STSecurityRSAEncryption.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C55A1771617C70700C54B8C /* STSecurityRSAEncryption.m */; }; - 2C55A17E161832D400C54B8C /* STSecurityRSAEncryptionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C55A17D161832D400C54B8C /* STSecurityRSAEncryptionTests.m */; }; - 2C5F7EED161B03D200001538 /* STSecurityKeychainAccessPasswordTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C5F7EEC161B03D200001538 /* STSecurityKeychainAccessPasswordTests.m */; }; - 2C62F2851E6BCA1600CE0D6B /* STSecurityKeychainAccess+Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 2C2C12691D8A9D380039643D /* STSecurityKeychainAccess+Internal.h */; }; - 2CBC57E61615D8C000FF15E9 /* STSecurityRandomization.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 2CBC57E51615D8C000FF15E9 /* STSecurityRandomization.h */; }; - 2CBC57E81615D8C000FF15E9 /* STSecurityRandomization.m in Sources */ = {isa = PBXBuildFile; fileRef = 2CBC57E71615D8C000FF15E9 /* STSecurityRandomization.m */; }; - 2CBC57F61615D8C000FF15E9 /* libSTSecurity.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2CBC57DD1615D8C000FF15E9 /* libSTSecurity.a */; }; - 2CBC57FF1615D8C000FF15E9 /* STSecurityRandomizationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2CBC57FE1615D8C000FF15E9 /* STSecurityRandomizationTests.m */; }; - 2CDDD09E1AE0F77A005BCF0E /* STSecurity.h in Headers */ = {isa = PBXBuildFile; fileRef = 2CDDD09D1AE0F3C1005BCF0E /* STSecurity.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 2CDDD09F1AE0F77A005BCF0E /* STSecurityRandomization.h in Headers */ = {isa = PBXBuildFile; fileRef = 2CBC57E51615D8C000FF15E9 /* STSecurityRandomization.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 2CDDD0A01AE0F77A005BCF0E /* STSecurityRandomization.m in Sources */ = {isa = PBXBuildFile; fileRef = 2CBC57E71615D8C000FF15E9 /* STSecurityRandomization.m */; }; - 2CDDD0A11AE0F77A005BCF0E /* STSecurityRSAKey.h in Headers */ = {isa = PBXBuildFile; fileRef = 2C55A16F1616E6A400C54B8C /* STSecurityRSAKey.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 2CDDD0A21AE0F77A005BCF0E /* STSecurityRSAKey+Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 2C55A17216171A7900C54B8C /* STSecurityRSAKey+Internal.h */; }; - 2CDDD0A31AE0F77A005BCF0E /* STSecurityRSAKey.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C55A1701616E6A400C54B8C /* STSecurityRSAKey.m */; }; - 2CDDD0A41AE0F77A005BCF0E /* STSecurityKeychainAccess.h in Headers */ = {isa = PBXBuildFile; fileRef = 2C55A16C1616E68800C54B8C /* STSecurityKeychainAccess.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 2CDDD0A51AE0F77A005BCF0E /* STSecurityKeychainAccess.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C55A16D1616E68800C54B8C /* STSecurityKeychainAccess.m */; }; - 2CDDD0A61AE0F77A005BCF0E /* STSecurityRSAEncryption.h in Headers */ = {isa = PBXBuildFile; fileRef = 2C55A1761617C70700C54B8C /* STSecurityRSAEncryption.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 2CDDD0A71AE0F77A005BCF0E /* STSecurityRSAEncryption.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C55A1771617C70700C54B8C /* STSecurityRSAEncryption.m */; }; + 02533B4A2F5826C3752686C9 /* STSecurityRandomizationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8FC2BAEB7A6711C6F6ED6C66 /* STSecurityRandomizationTests.m */; }; + 236740268DF6553567AFB477 /* STSecurityRSAEncryption.m in Sources */ = {isa = PBXBuildFile; fileRef = FA573CB251345E9E1CB24A10 /* STSecurityRSAEncryption.m */; }; + 267CA5C34E599B3EE0B18BD1 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D05E97FD52CEF20E2582F15 /* main.m */; }; + 430B10ED5EBC8756AF3F4C30 /* STSecurityRSAKey.m in Sources */ = {isa = PBXBuildFile; fileRef = 34AB1BAE5276E88BCE6FF4D7 /* STSecurityRSAKey.m */; }; + 6275BE7FB65B761BD4A054EC /* STSecurityKeychainAccess+RSA.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C6FEF158DC9F704496B914F /* STSecurityKeychainAccess+RSA.m */; }; + 7DF0F7C91E228A61BE5A7C54 /* STSecurityRSAKeyTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BFA77262D4AA318C7EBA7853 /* STSecurityRSAKeyTests.m */; }; + 8C2D206182792107E8E025A3 /* STSecurityRSAEncryptionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B43EB5ED4EA2BE6B00B12E3 /* STSecurityRSAEncryptionTests.m */; }; + 975C1274AE5425B906B7381B /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = DC42AEEFDB0E0AB77869B16A /* AppDelegate.m */; }; + A11A299D045248DC71FAA260 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6C2E1BB8D6F9A2C28856629E /* Main.storyboard */; }; + A4740393D1171B50F3EB72B1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8B4C7FF03E0C5642097132D7 /* Assets.xcassets */; }; + A63198F8A5684E98406ADC38 /* STSecurityKeychainAccessPasswordTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8023ABBB66B6FCFC2D137A74 /* STSecurityKeychainAccessPasswordTests.m */; }; + BBC6A9187E6AA7BE288D7000 /* STSecurity.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 01E1207782CC8C5BF25ED3F9 /* STSecurity.framework */; }; + C2373B44D806B7660F1DEE03 /* STSecurityKeychainAccessRSATests.m in Sources */ = {isa = PBXBuildFile; fileRef = 016B43F9A6D0E1C3B4DD787F /* STSecurityKeychainAccessRSATests.m */; }; + D479468A8186D116B4178CCB /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0F2690F315EE6F81FCC3B28B /* LaunchScreen.storyboard */; }; + E2C2CC140392685CD14A9E57 /* STSecurityRandomization.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DEEEF791A2F81243D64E64 /* STSecurityRandomization.m */; }; + FBFB1A9FF3E107BD71865F14 /* STSecurityKeychainAccess.m in Sources */ = {isa = PBXBuildFile; fileRef = D703037A80BF68AA9FE4D47D /* STSecurityKeychainAccess.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - 2CBC57F41615D8C000FF15E9 /* PBXContainerItemProxy */ = { + 3B74D3D2EBB998F025E3F77F /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; - containerPortal = 2CBC57D41615D8C000FF15E9 /* Project object */; + containerPortal = CCA7FD70531F7A1DC4E6CF85 /* Project object */; proxyType = 1; - remoteGlobalIDString = 2CBC57DC1615D8C000FF15E9; - remoteInfo = STSecurity; + remoteGlobalIDString = 7A0655DBB4EC3939F75FD2B7; + remoteInfo = STSecurityTestHost; }; /* End PBXContainerItemProxy section */ -/* Begin PBXCopyFilesBuildPhase section */ - 2CBC57DB1615D8C000FF15E9 /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = "include/${PRODUCT_NAME}"; - dstSubfolderSpec = 16; - files = ( - 2C1D8CC416186B72009EB62A /* STSecurityRSAEncryption.h in CopyFiles */, - 2C1D8CC316186B6F009EB62A /* STSecurityKeychainAccess.h in CopyFiles */, - 2C1D8CC116186B6B009EB62A /* STSecurityRSAKey.h in CopyFiles */, - 2CBC57E61615D8C000FF15E9 /* STSecurityRandomization.h in CopyFiles */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - /* Begin PBXFileReference section */ - 2C1D8D03161931CB009EB62A /* STSecurityRSAKeyTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = STSecurityRSAKeyTests.m; sourceTree = ""; }; - 2C2294C11711A497004E0D3E /* Target-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Target-Debug.xcconfig"; sourceTree = ""; }; - 2C2294C31711A4A8004E0D3E /* Target-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Target-Release.xcconfig"; sourceTree = ""; }; - 2C2C12641D8A9C740039643D /* STSecurityKeychainAccess+RSA.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "STSecurityKeychainAccess+RSA.h"; sourceTree = ""; }; - 2C2C12651D8A9C740039643D /* STSecurityKeychainAccess+RSA.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "STSecurityKeychainAccess+RSA.m"; sourceTree = ""; }; - 2C2C12691D8A9D380039643D /* STSecurityKeychainAccess+Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "STSecurityKeychainAccess+Internal.h"; sourceTree = ""; }; - 2C55A16C1616E68800C54B8C /* STSecurityKeychainAccess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = STSecurityKeychainAccess.h; sourceTree = ""; }; - 2C55A16D1616E68800C54B8C /* STSecurityKeychainAccess.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = STSecurityKeychainAccess.m; sourceTree = ""; }; - 2C55A16F1616E6A400C54B8C /* STSecurityRSAKey.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = STSecurityRSAKey.h; sourceTree = ""; }; - 2C55A1701616E6A400C54B8C /* STSecurityRSAKey.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = STSecurityRSAKey.m; sourceTree = ""; }; - 2C55A17216171A7900C54B8C /* STSecurityRSAKey+Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "STSecurityRSAKey+Internal.h"; sourceTree = ""; }; - 2C55A17416171D3000C54B8C /* STSecurityKeychainAccessRSATests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = STSecurityKeychainAccessRSATests.m; sourceTree = ""; }; - 2C55A1761617C70700C54B8C /* STSecurityRSAEncryption.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = STSecurityRSAEncryption.h; sourceTree = ""; }; - 2C55A1771617C70700C54B8C /* STSecurityRSAEncryption.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = STSecurityRSAEncryption.m; sourceTree = ""; }; - 2C55A17D161832D400C54B8C /* STSecurityRSAEncryptionTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = STSecurityRSAEncryptionTests.m; sourceTree = ""; }; - 2C5F7EEC161B03D200001538 /* STSecurityKeychainAccessPasswordTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = STSecurityKeychainAccessPasswordTests.m; sourceTree = ""; }; - 2C9C1E571711A2AA003E19B9 /* Target.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Target.xcconfig; sourceTree = ""; }; - 2C9C1E581711A2CC003E19B9 /* Project-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Project-Debug.xcconfig"; sourceTree = ""; }; - 2C9C1E5A1711A2F0003E19B9 /* Project-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Project-Release.xcconfig"; sourceTree = ""; }; - 2C9C1E5E1711A3CA003E19B9 /* Project.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Project.xcconfig; sourceTree = ""; }; - 2CBC57DD1615D8C000FF15E9 /* libSTSecurity.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSTSecurity.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 2CBC57E51615D8C000FF15E9 /* STSecurityRandomization.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = STSecurityRandomization.h; sourceTree = ""; }; - 2CBC57E71615D8C000FF15E9 /* STSecurityRandomization.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STSecurityRandomization.m; sourceTree = ""; }; - 2CBC57EE1615D8C000FF15E9 /* STSecurityTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = STSecurityTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 2CBC57F91615D8C000FF15E9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 2CBC57FE1615D8C000FF15E9 /* STSecurityRandomizationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STSecurityRandomizationTests.m; sourceTree = ""; }; - 2CDDD0821AE0F394005BCF0E /* STSecurity.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = STSecurity.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 2CDDD0851AE0F394005BCF0E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 2CDDD09D1AE0F3C1005BCF0E /* STSecurity.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = STSecurity.h; sourceTree = ""; }; + 016B43F9A6D0E1C3B4DD787F /* STSecurityKeychainAccessRSATests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STSecurityKeychainAccessRSATests.m; sourceTree = ""; }; + 01E1207782CC8C5BF25ED3F9 /* STSecurity.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = STSecurity.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 048DC3D896189D3EF4397777 /* STSecurityRSAEncryption.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = STSecurityRSAEncryption.h; sourceTree = ""; }; + 1C6FEF158DC9F704496B914F /* STSecurityKeychainAccess+RSA.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "STSecurityKeychainAccess+RSA.m"; sourceTree = ""; }; + 30BE5CDE0B5A469D422B0122 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 34AB1BAE5276E88BCE6FF4D7 /* STSecurityRSAKey.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STSecurityRSAKey.m; sourceTree = ""; }; + 34F811D4EEBC5A07B48AD63D /* STSecurityKeychainAccess+Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "STSecurityKeychainAccess+Internal.h"; sourceTree = ""; }; + 378AECA75EB26BB87BF3651D /* Target-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Target-Debug.xcconfig"; sourceTree = ""; }; + 3E08D146A0BBD8E5DC11FE34 /* STSecurityTests.xctest */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.cfbundle; path = STSecurityTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 498B9712BF6EED440D034165 /* STSecurityKeychainAccess.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = STSecurityKeychainAccess.h; sourceTree = ""; }; + 57C4BFA8D3FF21797D584727 /* STSecurity.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = STSecurity.h; sourceTree = ""; }; + 5A726C758CF7812CE8F6FDCF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 5B43EB5ED4EA2BE6B00B12E3 /* STSecurityRSAEncryptionTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STSecurityRSAEncryptionTests.m; sourceTree = ""; }; + 5D05E97FD52CEF20E2582F15 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 8023ABBB66B6FCFC2D137A74 /* STSecurityKeychainAccessPasswordTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STSecurityKeychainAccessPasswordTests.m; sourceTree = ""; }; + 8B3EF72E652E0F8EB33326E4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 8B4C7FF03E0C5642097132D7 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 8F79E47C797D92F67B5DA7E2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 8FC2BAEB7A6711C6F6ED6C66 /* STSecurityRandomizationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STSecurityRandomizationTests.m; sourceTree = ""; }; + 91A5C5664D1CCB44D11711D0 /* STSecurityRandomization.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = STSecurityRandomization.h; sourceTree = ""; }; + 93C56C37513B5D74A7152CFC /* STSecurityKeychainAccess+RSA.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "STSecurityKeychainAccess+RSA.h"; sourceTree = ""; }; + 997026ED2E387919195EC612 /* STSecurityTestHost.app */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.application; path = STSecurityTestHost.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 9A8BDA965A34BF9A0C28F78B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 9EA84057DE5799FABC611B1A /* STSecurityRSAKey.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = STSecurityRSAKey.h; sourceTree = ""; }; + A02FCA5AF4BD0D490B7138BD /* Project-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Project-Debug.xcconfig"; sourceTree = ""; }; + A294239AD0CCDC0BD35F032F /* Project.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Project.xcconfig; sourceTree = ""; }; + A367676B82D8402250A5A40A /* Project-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Project-Release.xcconfig"; sourceTree = ""; }; + B116B29AD7B6C059E5C9AA0F /* STSecurityRSAKey+Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "STSecurityRSAKey+Internal.h"; sourceTree = ""; }; + B760955CC57437437849144B /* Target.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Target.xcconfig; sourceTree = ""; }; + BB3F7328C19C9F672A365737 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + BFA77262D4AA318C7EBA7853 /* STSecurityRSAKeyTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STSecurityRSAKeyTests.m; sourceTree = ""; }; + D703037A80BF68AA9FE4D47D /* STSecurityKeychainAccess.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STSecurityKeychainAccess.m; sourceTree = ""; }; + DC42AEEFDB0E0AB77869B16A /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + E01354FE59E0C2D2E756208B /* Target-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Target-Release.xcconfig"; sourceTree = ""; }; + E8DEEEF791A2F81243D64E64 /* STSecurityRandomization.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STSecurityRandomization.m; sourceTree = ""; }; + FA573CB251345E9E1CB24A10 /* STSecurityRSAEncryption.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STSecurityRSAEncryption.m; sourceTree = ""; }; + FC0E67547D009E79D101D96C /* STSecurity.framework */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.framework; path = STSecurity.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ - 2CBC57DA1615D8C000FF15E9 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 2CBC57EA1615D8C000FF15E9 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 2CBC57F61615D8C000FF15E9 /* libSTSecurity.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 2CDDD07E1AE0F394005BCF0E /* Frameworks */ = { + CA23D3E5F434272E007F6B18 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + BBC6A9187E6AA7BE288D7000 /* STSecurity.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 2C9C1E561711A292003E19B9 /* xcconfig */ = { + 011334A827252BD8B132BB25 /* STSecurity */ = { isa = PBXGroup; children = ( - 2C9C1E5E1711A3CA003E19B9 /* Project.xcconfig */, - 2C9C1E581711A2CC003E19B9 /* Project-Debug.xcconfig */, - 2C9C1E5A1711A2F0003E19B9 /* Project-Release.xcconfig */, - 2C9C1E571711A2AA003E19B9 /* Target.xcconfig */, - 2C2294C11711A497004E0D3E /* Target-Debug.xcconfig */, - 2C2294C31711A4A8004E0D3E /* Target-Release.xcconfig */, + 8B3EF72E652E0F8EB33326E4 /* Info.plist */, + A02FCA5AF4BD0D490B7138BD /* Project-Debug.xcconfig */, + A367676B82D8402250A5A40A /* Project-Release.xcconfig */, + A294239AD0CCDC0BD35F032F /* Project.xcconfig */, + 57C4BFA8D3FF21797D584727 /* STSecurity.h */, + 498B9712BF6EED440D034165 /* STSecurityKeychainAccess.h */, + D703037A80BF68AA9FE4D47D /* STSecurityKeychainAccess.m */, + 34F811D4EEBC5A07B48AD63D /* STSecurityKeychainAccess+Internal.h */, + 93C56C37513B5D74A7152CFC /* STSecurityKeychainAccess+RSA.h */, + 1C6FEF158DC9F704496B914F /* STSecurityKeychainAccess+RSA.m */, + 91A5C5664D1CCB44D11711D0 /* STSecurityRandomization.h */, + E8DEEEF791A2F81243D64E64 /* STSecurityRandomization.m */, + 048DC3D896189D3EF4397777 /* STSecurityRSAEncryption.h */, + FA573CB251345E9E1CB24A10 /* STSecurityRSAEncryption.m */, + 9EA84057DE5799FABC611B1A /* STSecurityRSAKey.h */, + 34AB1BAE5276E88BCE6FF4D7 /* STSecurityRSAKey.m */, + B116B29AD7B6C059E5C9AA0F /* STSecurityRSAKey+Internal.h */, + 378AECA75EB26BB87BF3651D /* Target-Debug.xcconfig */, + E01354FE59E0C2D2E756208B /* Target-Release.xcconfig */, + B760955CC57437437849144B /* Target.xcconfig */, ); - name = xcconfig; path = STSecurity; sourceTree = ""; }; - 2CBC57D21615D8C000FF15E9 = { + 24C81723244780E813C4B11C /* STSecurityTestHost */ = { + isa = PBXGroup; + children = ( + BB3F7328C19C9F672A365737 /* AppDelegate.h */, + DC42AEEFDB0E0AB77869B16A /* AppDelegate.m */, + 8B4C7FF03E0C5642097132D7 /* Assets.xcassets */, + 30BE5CDE0B5A469D422B0122 /* Info.plist */, + 0F2690F315EE6F81FCC3B28B /* LaunchScreen.storyboard */, + 5D05E97FD52CEF20E2582F15 /* main.m */, + 6C2E1BB8D6F9A2C28856629E /* Main.storyboard */, + ); + path = STSecurityTestHost; + sourceTree = ""; + }; + 4A0471BCFFA3EDB58366DD2B /* Frameworks */ = { isa = PBXGroup; children = ( - 2C9C1E561711A292003E19B9 /* xcconfig */, - 2CBC57E21615D8C000FF15E9 /* STSecurity */, - 2CBC57F71615D8C000FF15E9 /* STSecurityTests */, - 2CBC57DE1615D8C000FF15E9 /* Products */, + 01E1207782CC8C5BF25ED3F9 /* STSecurity.framework */, ); + name = Frameworks; sourceTree = ""; }; - 2CBC57DE1615D8C000FF15E9 /* Products */ = { + 83BB89750F5E95BB70B8FCEC /* Products */ = { isa = PBXGroup; children = ( - 2CBC57DD1615D8C000FF15E9 /* libSTSecurity.a */, - 2CBC57EE1615D8C000FF15E9 /* STSecurityTests.xctest */, - 2CDDD0821AE0F394005BCF0E /* STSecurity.framework */, + FC0E67547D009E79D101D96C /* STSecurity.framework */, + 997026ED2E387919195EC612 /* STSecurityTestHost.app */, + 3E08D146A0BBD8E5DC11FE34 /* STSecurityTests.xctest */, ); name = Products; sourceTree = ""; }; - 2CBC57E21615D8C000FF15E9 /* STSecurity */ = { + EAC6299C2C9CA6A52F694F13 = { isa = PBXGroup; children = ( - 2CDDD0851AE0F394005BCF0E /* Info.plist */, - 2CDDD09D1AE0F3C1005BCF0E /* STSecurity.h */, - 2CBC57E51615D8C000FF15E9 /* STSecurityRandomization.h */, - 2CBC57E71615D8C000FF15E9 /* STSecurityRandomization.m */, - 2C55A16F1616E6A400C54B8C /* STSecurityRSAKey.h */, - 2C55A17216171A7900C54B8C /* STSecurityRSAKey+Internal.h */, - 2C55A1701616E6A400C54B8C /* STSecurityRSAKey.m */, - 2C55A16C1616E68800C54B8C /* STSecurityKeychainAccess.h */, - 2C2C12691D8A9D380039643D /* STSecurityKeychainAccess+Internal.h */, - 2C55A16D1616E68800C54B8C /* STSecurityKeychainAccess.m */, - 2C2C12641D8A9C740039643D /* STSecurityKeychainAccess+RSA.h */, - 2C2C12651D8A9C740039643D /* STSecurityKeychainAccess+RSA.m */, - 2C55A1761617C70700C54B8C /* STSecurityRSAEncryption.h */, - 2C55A1771617C70700C54B8C /* STSecurityRSAEncryption.m */, + 011334A827252BD8B132BB25 /* STSecurity */, + 24C81723244780E813C4B11C /* STSecurityTestHost */, + FD60A1EA9ACDC00753EFE9E4 /* STSecurityTests */, + 4A0471BCFFA3EDB58366DD2B /* Frameworks */, + 83BB89750F5E95BB70B8FCEC /* Products */, ); - path = STSecurity; sourceTree = ""; - usesTabs = 1; }; - 2CBC57F71615D8C000FF15E9 /* STSecurityTests */ = { + FD60A1EA9ACDC00753EFE9E4 /* STSecurityTests */ = { isa = PBXGroup; children = ( - 2CBC57F91615D8C000FF15E9 /* Info.plist */, - 2CBC57FE1615D8C000FF15E9 /* STSecurityRandomizationTests.m */, - 2C1D8D03161931CB009EB62A /* STSecurityRSAKeyTests.m */, - 2C55A17416171D3000C54B8C /* STSecurityKeychainAccessRSATests.m */, - 2C5F7EEC161B03D200001538 /* STSecurityKeychainAccessPasswordTests.m */, - 2C55A17D161832D400C54B8C /* STSecurityRSAEncryptionTests.m */, + 8F79E47C797D92F67B5DA7E2 /* Info.plist */, + 8023ABBB66B6FCFC2D137A74 /* STSecurityKeychainAccessPasswordTests.m */, + 016B43F9A6D0E1C3B4DD787F /* STSecurityKeychainAccessRSATests.m */, + 8FC2BAEB7A6711C6F6ED6C66 /* STSecurityRandomizationTests.m */, + 5B43EB5ED4EA2BE6B00B12E3 /* STSecurityRSAEncryptionTests.m */, + BFA77262D4AA318C7EBA7853 /* STSecurityRSAKeyTests.m */, ); path = STSecurityTests; sourceTree = ""; - usesTabs = 1; }; /* End PBXGroup section */ -/* Begin PBXHeadersBuildPhase section */ - 2CDDD07F1AE0F394005BCF0E /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - 2CDDD0A11AE0F77A005BCF0E /* STSecurityRSAKey.h in Headers */, - 2CDDD0A41AE0F77A005BCF0E /* STSecurityKeychainAccess.h in Headers */, - 2CDDD09E1AE0F77A005BCF0E /* STSecurity.h in Headers */, - 2CDDD0A61AE0F77A005BCF0E /* STSecurityRSAEncryption.h in Headers */, - 2CDDD09F1AE0F77A005BCF0E /* STSecurityRandomization.h in Headers */, - 2C2C12661D8A9C740039643D /* STSecurityKeychainAccess+RSA.h in Headers */, - 2C62F2851E6BCA1600CE0D6B /* STSecurityKeychainAccess+Internal.h in Headers */, - 2CDDD0A21AE0F77A005BCF0E /* STSecurityRSAKey+Internal.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXHeadersBuildPhase section */ - /* Begin PBXNativeTarget section */ - 2CBC57DC1615D8C000FF15E9 /* STSecurity */ = { + 7A0655DBB4EC3939F75FD2B7 /* STSecurityTestHost */ = { isa = PBXNativeTarget; - buildConfigurationList = 2CBC58021615D8C000FF15E9 /* Build configuration list for PBXNativeTarget "STSecurity" */; + buildConfigurationList = 41977EC0FBCC1B8E4262D0B0 /* Build configuration list for PBXNativeTarget "STSecurityTestHost" */; buildPhases = ( - 2CBC57D91615D8C000FF15E9 /* Sources */, - 2CBC57DA1615D8C000FF15E9 /* Frameworks */, - 2CBC57DB1615D8C000FF15E9 /* CopyFiles */, + 27BC8684740732D1F9C1DB64 /* Sources */, + 78F27D05F0F99A08C794CF84 /* Resources */, ); buildRules = ( ); dependencies = ( ); - name = STSecurity; - productName = STSecurity; - productReference = 2CBC57DD1615D8C000FF15E9 /* libSTSecurity.a */; - productType = "com.apple.product-type.library.static"; + name = STSecurityTestHost; + productName = STSecurityTestHost; + productReference = 997026ED2E387919195EC612 /* STSecurityTestHost.app */; + productType = "com.apple.product-type.application"; }; - 2CBC57ED1615D8C000FF15E9 /* STSecurityTests */ = { + CF357F52923DE8B03DDA6C61 /* STSecurityTests */ = { isa = PBXNativeTarget; - buildConfigurationList = 2CBC58051615D8C000FF15E9 /* Build configuration list for PBXNativeTarget "STSecurityTests" */; + buildConfigurationList = 0B17711BD06B1AAD40C1BC2A /* Build configuration list for PBXNativeTarget "STSecurityTests" */; buildPhases = ( - 2CBC57E91615D8C000FF15E9 /* Sources */, - 2CBC57EA1615D8C000FF15E9 /* Frameworks */, - 2CBC57EB1615D8C000FF15E9 /* Resources */, + 18856AE761D2A04896791E2B /* Sources */, + CA23D3E5F434272E007F6B18 /* Frameworks */, ); buildRules = ( ); dependencies = ( - 2CBC57F51615D8C000FF15E9 /* PBXTargetDependency */, + B9E6068A0241CDD516397499 /* PBXTargetDependency */, ); name = STSecurityTests; productName = STSecurityTests; - productReference = 2CBC57EE1615D8C000FF15E9 /* STSecurityTests.xctest */; + productReference = 3E08D146A0BBD8E5DC11FE34 /* STSecurityTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; - 2CDDD0811AE0F394005BCF0E /* STSecurity.framework */ = { + DD859FD535E9714036F7D718 /* STSecurity */ = { isa = PBXNativeTarget; - buildConfigurationList = 2CDDD09B1AE0F395005BCF0E /* Build configuration list for PBXNativeTarget "STSecurity.framework" */; + buildConfigurationList = CF55168A26B8141EFBC21492 /* Build configuration list for PBXNativeTarget "STSecurity" */; buildPhases = ( - 2CDDD07D1AE0F394005BCF0E /* Sources */, - 2CDDD07E1AE0F394005BCF0E /* Frameworks */, - 2CDDD07F1AE0F394005BCF0E /* Headers */, - 2CDDD0801AE0F394005BCF0E /* Resources */, + 434A3EE608CBAD5901DBB4F4 /* Sources */, ); buildRules = ( ); dependencies = ( ); - name = STSecurity.framework; - productName = STSecurity.framework; - productReference = 2CDDD0821AE0F394005BCF0E /* STSecurity.framework */; - productType = "com.apple.product-type.framework"; + name = STSecurity; + productName = STSecurity; + productReference = FC0E67547D009E79D101D96C /* STSecurity.framework */; + productType = "com.apple.product-type.framework.static"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ - 2CBC57D41615D8C000FF15E9 /* Project object */ = { + CCA7FD70531F7A1DC4E6CF85 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0830; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = "Scott Talbot"; TargetAttributes = { - 2CDDD0811AE0F394005BCF0E = { - CreatedOnToolsVersion = 6.4; + 7A0655DBB4EC3939F75FD2B7 = { + SystemCapabilities = { + com.apple.Keychain = { + enabled = 1; + }; + }; + }; + CF357F52923DE8B03DDA6C61 = { + TestTargetID = 7A0655DBB4EC3939F75FD2B7; }; }; }; - buildConfigurationList = 2CBC57D71615D8C000FF15E9 /* Build configuration list for PBXProject "STSecurity" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + buildConfigurationList = 8970ACD88F2B10ADCFDB223C /* Build configuration list for PBXProject "STSecurity" */; + compatibilityVersion = "Xcode 10.0"; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( - en, + Base, ); - mainGroup = 2CBC57D21615D8C000FF15E9; - productRefGroup = 2CBC57DE1615D8C000FF15E9 /* Products */; + mainGroup = EAC6299C2C9CA6A52F694F13; projectDirPath = ""; projectRoot = ""; targets = ( - 2CBC57DC1615D8C000FF15E9 /* STSecurity */, - 2CDDD0811AE0F394005BCF0E /* STSecurity.framework */, - 2CBC57ED1615D8C000FF15E9 /* STSecurityTests */, + DD859FD535E9714036F7D718 /* STSecurity */, + 7A0655DBB4EC3939F75FD2B7 /* STSecurityTestHost */, + CF357F52923DE8B03DDA6C61 /* STSecurityTests */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ - 2CBC57EB1615D8C000FF15E9 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 2CDDD0801AE0F394005BCF0E /* Resources */ = { + 78F27D05F0F99A08C794CF84 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + A4740393D1171B50F3EB72B1 /* Assets.xcassets in Resources */, + D479468A8186D116B4178CCB /* LaunchScreen.storyboard in Resources */, + A11A299D045248DC71FAA260 /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ - 2CBC57D91615D8C000FF15E9 /* Sources */ = { + 18856AE761D2A04896791E2B /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 2CBC57E81615D8C000FF15E9 /* STSecurityRandomization.m in Sources */, - 2C2C12671D8A9C740039643D /* STSecurityKeychainAccess+RSA.m in Sources */, - 2C55A16E1616E68800C54B8C /* STSecurityKeychainAccess.m in Sources */, - 2C55A1711616E6A400C54B8C /* STSecurityRSAKey.m in Sources */, - 2C55A1781617C70700C54B8C /* STSecurityRSAEncryption.m in Sources */, + A63198F8A5684E98406ADC38 /* STSecurityKeychainAccessPasswordTests.m in Sources */, + C2373B44D806B7660F1DEE03 /* STSecurityKeychainAccessRSATests.m in Sources */, + 8C2D206182792107E8E025A3 /* STSecurityRSAEncryptionTests.m in Sources */, + 7DF0F7C91E228A61BE5A7C54 /* STSecurityRSAKeyTests.m in Sources */, + 02533B4A2F5826C3752686C9 /* STSecurityRandomizationTests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; - 2CBC57E91615D8C000FF15E9 /* Sources */ = { + 27BC8684740732D1F9C1DB64 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 2CBC57FF1615D8C000FF15E9 /* STSecurityRandomizationTests.m in Sources */, - 2C55A17516171D3000C54B8C /* STSecurityKeychainAccessRSATests.m in Sources */, - 2C55A17E161832D400C54B8C /* STSecurityRSAEncryptionTests.m in Sources */, - 2C1D8D04161931CB009EB62A /* STSecurityRSAKeyTests.m in Sources */, - 2C5F7EED161B03D200001538 /* STSecurityKeychainAccessPasswordTests.m in Sources */, + 975C1274AE5425B906B7381B /* AppDelegate.m in Sources */, + 267CA5C34E599B3EE0B18BD1 /* main.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; - 2CDDD07D1AE0F394005BCF0E /* Sources */ = { + 434A3EE608CBAD5901DBB4F4 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 2CDDD0A71AE0F77A005BCF0E /* STSecurityRSAEncryption.m in Sources */, - 2C2C12681D8A9C740039643D /* STSecurityKeychainAccess+RSA.m in Sources */, - 2CDDD0A01AE0F77A005BCF0E /* STSecurityRandomization.m in Sources */, - 2CDDD0A51AE0F77A005BCF0E /* STSecurityKeychainAccess.m in Sources */, - 2CDDD0A31AE0F77A005BCF0E /* STSecurityRSAKey.m in Sources */, + 6275BE7FB65B761BD4A054EC /* STSecurityKeychainAccess+RSA.m in Sources */, + FBFB1A9FF3E107BD71865F14 /* STSecurityKeychainAccess.m in Sources */, + 236740268DF6553567AFB477 /* STSecurityRSAEncryption.m in Sources */, + 430B10ED5EBC8756AF3F4C30 /* STSecurityRSAKey.m in Sources */, + E2C2CC140392685CD14A9E57 /* STSecurityRandomization.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ - 2CBC57F51615D8C000FF15E9 /* PBXTargetDependency */ = { + B9E6068A0241CDD516397499 /* PBXTargetDependency */ = { isa = PBXTargetDependency; - target = 2CBC57DC1615D8C000FF15E9 /* STSecurity */; - targetProxy = 2CBC57F41615D8C000FF15E9 /* PBXContainerItemProxy */; + target = 7A0655DBB4EC3939F75FD2B7 /* STSecurityTestHost */; + targetProxy = 3B74D3D2EBB998F025E3F77F /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ +/* Begin PBXVariantGroup section */ + 0F2690F315EE6F81FCC3B28B /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 9A8BDA965A34BF9A0C28F78B /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; + 6C2E1BB8D6F9A2C28856629E /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 5A726C758CF7812CE8F6FDCF /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + /* Begin XCBuildConfiguration section */ - 2CBC58001615D8C000FF15E9 /* Debug */ = { + 19EC5EE2724E64BB97C639B6 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 2C9C1E581711A2CC003E19B9 /* Project-Debug.xcconfig */; buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "iPhone Developer"; + INFOPLIST_FILE = STSecurityTestHost/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = org.chikachow.STSecurityTestHost; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; - 2CBC58011615D8C000FF15E9 /* Release */ = { + 1C7D290BC36352B3A1560A54 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 2C9C1E5A1711A2F0003E19B9 /* Project-Release.xcconfig */; buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "iPhone Developer"; + INFOPLIST_FILE = STSecurityTestHost/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = org.chikachow.STSecurityTestHost; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; }; - 2CBC58031615D8C000FF15E9 /* Debug */ = { + 63D1AD9539F3138CCE087DF6 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 2C2294C11711A497004E0D3E /* Target-Debug.xcconfig */; + baseConfigurationReference = A367676B82D8402250A5A40A /* Project-Release.xcconfig */; buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)", + ); + IPHONEOS_DEPLOYMENT_TARGET = 11.4; + MACOSX_DEPLOYMENT_TARGET = 10.14; + PRODUCT_NAME = "$(TARGET_NAME)"; + RUN_CLANG_STATIC_ANALYZER = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + SWIFT_VERSION = 5.0; + VALIDATE_PRODUCT = YES; }; - name = Debug; + name = Release; }; - 2CBC58041615D8C000FF15E9 /* Release */ = { + 7491E4B2D4CC8DF6584BC713 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 2C2294C31711A4A8004E0D3E /* Target-Release.xcconfig */; + baseConfigurationReference = 378AECA75EB26BB87BF3651D /* Target-Debug.xcconfig */; buildSettings = { + INFOPLIST_FILE = STSecurity/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = org.chikachow.STSecurity; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; }; - name = Release; + name = Debug; }; - 2CBC58061615D8C000FF15E9 /* Debug */ = { + AA52D0330E16DF65F7589A2F /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 2C2294C11711A497004E0D3E /* Target-Debug.xcconfig */; buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "\".\"", + ); INFOPLIST_FILE = STSecurityTests/Info.plist; - PRODUCT_BUNDLE_IDENTIFIER = "org.chikachow.${PRODUCT_NAME:rfc1034identifier}"; - PRODUCT_NAME = STSecurityTests; - WARNING_CFLAGS = ( + LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", - "-Wno-objc-messaging-id", + "@executable_path/Frameworks", + "@loader_path/Frameworks", ); + PRODUCT_BUNDLE_IDENTIFIER = org.chikachow.STSecurityTests; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/STSecurityTestHost.app/STSecurityTestHost"; + TEST_TARGET_NAME = STSecurityTestHost; }; name = Debug; }; - 2CBC58071615D8C000FF15E9 /* Release */ = { + CA37BDE2BD46B1BF3CEF3B28 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 2C2294C31711A4A8004E0D3E /* Target-Release.xcconfig */; + baseConfigurationReference = A02FCA5AF4BD0D490B7138BD /* Project-Debug.xcconfig */; buildSettings = { - INFOPLIST_FILE = STSecurityTests/Info.plist; - PRODUCT_BUNDLE_IDENTIFIER = "org.chikachow.${PRODUCT_NAME:rfc1034identifier}"; - PRODUCT_NAME = STSecurityTests; - WARNING_CFLAGS = ( + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( "$(inherited)", - "-Wno-objc-messaging-id", + "$(PROJECT_DIR)", ); + IPHONEOS_DEPLOYMENT_TARGET = 11.4; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + RUN_CLANG_STATIC_ANALYZER = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; }; - name = Release; + name = Debug; }; - 2CDDD0951AE0F395005BCF0E /* Debug */ = { + F26E8B7F4B7B3B7F0129809C /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 2C2294C11711A497004E0D3E /* Target-Debug.xcconfig */; + baseConfigurationReference = E01354FE59E0C2D2E756208B /* Target-Release.xcconfig */; buildSettings = { - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; - DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - GCC_NO_COMMON_BLOCKS = YES; INFOPLIST_FILE = STSecurity/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "org.chikachow.$(PRODUCT_NAME:rfc1034identifier)"; - PRODUCT_NAME = STSecurity; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = org.chikachow.STSecurity; + SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; }; - name = Debug; + name = Release; }; - 2CDDD0971AE0F395005BCF0E /* Release */ = { + FFE3815451ADB496FAEE510B /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 2C2294C31711A4A8004E0D3E /* Target-Release.xcconfig */; buildSettings = { - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; - DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - GCC_NO_COMMON_BLOCKS = YES; - INFOPLIST_FILE = STSecurity/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "org.chikachow.$(PRODUCT_NAME:rfc1034identifier)"; - PRODUCT_NAME = STSecurity; + BUNDLE_LOADER = "$(TEST_HOST)"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "\".\"", + ); + INFOPLIST_FILE = STSecurityTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = org.chikachow.STSecurityTests; + SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/STSecurityTestHost.app/STSecurityTestHost"; + TEST_TARGET_NAME = STSecurityTestHost; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 2CBC57D71615D8C000FF15E9 /* Build configuration list for PBXProject "STSecurity" */ = { + 0B17711BD06B1AAD40C1BC2A /* Build configuration list for PBXNativeTarget "STSecurityTests" */ = { isa = XCConfigurationList; buildConfigurations = ( - 2CBC58001615D8C000FF15E9 /* Debug */, - 2CBC58011615D8C000FF15E9 /* Release */, + AA52D0330E16DF65F7589A2F /* Debug */, + FFE3815451ADB496FAEE510B /* Release */, ); defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; + defaultConfigurationName = ""; }; - 2CBC58021615D8C000FF15E9 /* Build configuration list for PBXNativeTarget "STSecurity" */ = { + 41977EC0FBCC1B8E4262D0B0 /* Build configuration list for PBXNativeTarget "STSecurityTestHost" */ = { isa = XCConfigurationList; buildConfigurations = ( - 2CBC58031615D8C000FF15E9 /* Debug */, - 2CBC58041615D8C000FF15E9 /* Release */, + 19EC5EE2724E64BB97C639B6 /* Debug */, + 1C7D290BC36352B3A1560A54 /* Release */, ); defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; + defaultConfigurationName = ""; }; - 2CBC58051615D8C000FF15E9 /* Build configuration list for PBXNativeTarget "STSecurityTests" */ = { + 8970ACD88F2B10ADCFDB223C /* Build configuration list for PBXProject "STSecurity" */ = { isa = XCConfigurationList; buildConfigurations = ( - 2CBC58061615D8C000FF15E9 /* Debug */, - 2CBC58071615D8C000FF15E9 /* Release */, + CA37BDE2BD46B1BF3CEF3B28 /* Debug */, + 63D1AD9539F3138CCE087DF6 /* Release */, ); defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; + defaultConfigurationName = Debug; }; - 2CDDD09B1AE0F395005BCF0E /* Build configuration list for PBXNativeTarget "STSecurity.framework" */ = { + CF55168A26B8141EFBC21492 /* Build configuration list for PBXNativeTarget "STSecurity" */ = { isa = XCConfigurationList; buildConfigurations = ( - 2CDDD0951AE0F395005BCF0E /* Debug */, - 2CDDD0971AE0F395005BCF0E /* Release */, + 7491E4B2D4CC8DF6584BC713 /* Debug */, + F26E8B7F4B7B3B7F0129809C /* Release */, ); defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; + defaultConfigurationName = ""; }; /* End XCConfigurationList section */ }; - rootObject = 2CBC57D41615D8C000FF15E9 /* Project object */; + rootObject = CCA7FD70531F7A1DC4E6CF85 /* Project object */; } diff --git a/STSecurity.xcodeproj/xcshareddata/xcschemes/STSecurity.framework.xcscheme b/STSecurity.xcodeproj/xcshareddata/xcschemes/STSecurity.framework.xcscheme deleted file mode 100644 index a167f4e..0000000 --- a/STSecurity.xcodeproj/xcshareddata/xcschemes/STSecurity.framework.xcscheme +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/STSecurity.xcodeproj/xcshareddata/xcschemes/STSecurity.xcscheme b/STSecurity.xcodeproj/xcshareddata/xcschemes/STSecurity.xcscheme index 94c2710..c9e9e52 100644 --- a/STSecurity.xcodeproj/xcshareddata/xcschemes/STSecurity.xcscheme +++ b/STSecurity.xcodeproj/xcshareddata/xcschemes/STSecurity.xcscheme @@ -1,6 +1,6 @@ - - - - + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -57,14 +42,18 @@ + + + + + + @@ -94,15 +85,18 @@ savedToolIdentifier = "" useCustomWorkingDirectory = "NO" debugDocumentVersioning = "YES"> - + - + + + diff --git a/STSecurity/Project.xcconfig b/STSecurity/Project.xcconfig index c3f82a5..0803512 100644 --- a/STSecurity/Project.xcconfig +++ b/STSecurity/Project.xcconfig @@ -1,49 +1,49 @@ -// Copyright (c) 2013 Scott Talbot. All rights reserved. - -SDKROOT = iphoneos -IPHONEOS_DEPLOYMENT_TARGET = 8.0 -ALWAYS_SEARCH_USER_PATHS = NO -GCC_DYNAMIC_NO_PIC = NO -GCC_SYMBOLS_PRIVATE_EXTERN = NO -GCC_C_LANGUAGE_STANDARD = gnu99 -CLANG_CXX_LANGUAGE_STANDARD = gnu++0x -CLANG_CXX_LIBRARY = libc++ -CLANG_ENABLE_OBJC_ARC = YES -CLANG_ENABLE_MODULES = YES -CLANG_WARN_EMPTY_BODY = YES -GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES -GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR -GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES -GCC_WARN_ABOUT_MISSING_NEWLINE = YES -CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES -GCC_WARN_UNINITIALIZED_AUTOS = YES -GCC_WARN_UNUSED_VARIABLE = YES -CLANG_WARN__DUPLICATE_METHOD_MATCH = YES -CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES -CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES -OTHER_LDFLAGS = -ObjC -GCC_TREAT_WARNINGS_AS_ERRORS = YES -CLANG_WARN_ASSIGN_ENUM = YES -GCC_WARN_SIGN_COMPARE = YES -CLANG_WARN_UNREACHABLE_CODE = YES -CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES -CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES -RUN_CLANG_STATIC_ANALYZER = YES -ENABLE_STRICT_OBJC_MSGSEND = YES -CLANG_WARN_BOOL_CONVERSION = YES -CLANG_WARN_CONSTANT_CONVERSION = YES -GCC_WARN_64_TO_32_BIT_CONVERSION = YES -CLANG_WARN_ENUM_CONVERSION = YES -CLANG_WARN_INT_CONVERSION = YES -GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE -GCC_WARN_UNUSED_FUNCTION = YES -CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR -GCC_WARN_UNDECLARED_SELECTOR = YES -CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR -CLANG_WARN_INFINITE_RECURSION = YES -CLANG_WARN_SUSPICIOUS_MOVE = YES -GCC_NO_COMMON_BLOCKS = YES - -FRAMEWORK_SEARCH_PATHS = $(SRCROOT)/.. - -WARNING_CFLAGS = -Weverything -Wno-auto-import -Wno-direct-ivar-access -Wno-documentation-unknown-command -Wno-gnu -Wno-gnu-conditional-omitted-operand -Wno-partial-availability -Wno-reserved-id-macro -Wno-system-headers +//// Copyright (c) 2013 Scott Talbot. All rights reserved. +// +////SDKROOT = iphoneos +////IPHONEOS_DEPLOYMENT_TARGET = 8.0 +//ALWAYS_SEARCH_USER_PATHS = NO +//GCC_DYNAMIC_NO_PIC = NO +//GCC_SYMBOLS_PRIVATE_EXTERN = NO +//GCC_C_LANGUAGE_STANDARD = gnu99 +//CLANG_CXX_LANGUAGE_STANDARD = gnu++0x +//CLANG_CXX_LIBRARY = libc++ +//CLANG_ENABLE_OBJC_ARC = YES +//CLANG_ENABLE_MODULES = YES +//CLANG_WARN_EMPTY_BODY = YES +//GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES +//GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR +//GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES +//GCC_WARN_ABOUT_MISSING_NEWLINE = YES +//CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES +//GCC_WARN_UNINITIALIZED_AUTOS = YES +//GCC_WARN_UNUSED_VARIABLE = YES +//CLANG_WARN__DUPLICATE_METHOD_MATCH = YES +//CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES +//CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES +//OTHER_LDFLAGS = -ObjC +//GCC_TREAT_WARNINGS_AS_ERRORS = YES +//CLANG_WARN_ASSIGN_ENUM = YES +//GCC_WARN_SIGN_COMPARE = YES +//CLANG_WARN_UNREACHABLE_CODE = YES +//CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES +//CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES +//RUN_CLANG_STATIC_ANALYZER = YES +//ENABLE_STRICT_OBJC_MSGSEND = YES +//CLANG_WARN_BOOL_CONVERSION = YES +//CLANG_WARN_CONSTANT_CONVERSION = YES +//GCC_WARN_64_TO_32_BIT_CONVERSION = YES +//CLANG_WARN_ENUM_CONVERSION = YES +//CLANG_WARN_INT_CONVERSION = YES +//GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE +//GCC_WARN_UNUSED_FUNCTION = YES +//CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR +//GCC_WARN_UNDECLARED_SELECTOR = YES +//CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR +//CLANG_WARN_INFINITE_RECURSION = YES +//CLANG_WARN_SUSPICIOUS_MOVE = YES +//GCC_NO_COMMON_BLOCKS = YES +// +////FRAMEWORK_SEARCH_PATHS = $(SRCROOT)/.. +// +////WARNING_CFLAGS = -Weverything -Wno-auto-import -Wno-direct-ivar-access -Wno-documentation-unknown-command -Wno-gnu -Wno-gnu-conditional-omitted-operand -Wno-partial-availability -Wno-reserved-id-macro -Wno-system-headers diff --git a/STSecurity/STSecurityKeychainAccess+Internal.h b/STSecurity/STSecurityKeychainAccess+Internal.h index e9a1ad7..ff34a49 100644 --- a/STSecurity/STSecurityKeychainAccess+Internal.h +++ b/STSecurity/STSecurityKeychainAccess+Internal.h @@ -10,6 +10,10 @@ // +@import Security; + +#import + static inline CFTypeRef STSecurityKeychainItemAccessibilityToCFType(enum STSecurityKeychainItemAccessibility accessibility) { switch (accessibility) { case STSecurityKeychainItemAccessibleWhenUnlocked: diff --git a/STSecurity/STSecurityKeychainAccess+RSA.m b/STSecurity/STSecurityKeychainAccess+RSA.m index 036b6d9..f7dbd64 100644 --- a/STSecurity/STSecurityKeychainAccess+RSA.m +++ b/STSecurity/STSecurityKeychainAccess+RSA.m @@ -9,7 +9,7 @@ // Copyright © 2016 Scott Talbot. All rights reserved. // -#import +//#import #import "STSecurityKeychainAccess+Internal.h" #import "STSecurityRSAKey+Internal.h" diff --git a/STSecurity/STSecurityKeychainAccess.m b/STSecurity/STSecurityKeychainAccess.m index 8c594b5..b22678f 100644 --- a/STSecurity/STSecurityKeychainAccess.m +++ b/STSecurity/STSecurityKeychainAccess.m @@ -15,7 +15,7 @@ @import Security; -#import +//#import #import "STSecurityKeychainAccess+Internal.h" diff --git a/STSecurity/STSecurityRSAKey.m b/STSecurity/STSecurityRSAKey.m index 756fa96..31c2a65 100644 --- a/STSecurity/STSecurityRSAKey.m +++ b/STSecurity/STSecurityRSAKey.m @@ -13,6 +13,7 @@ # error "STSecurity must be compiled with ARC enabled" #endif +@import Foundation; @import Security; #import diff --git a/STSecurity/Target.xcconfig b/STSecurity/Target.xcconfig index e1ed427..009dad0 100644 --- a/STSecurity/Target.xcconfig +++ b/STSecurity/Target.xcconfig @@ -1,5 +1,5 @@ // Copyright (c) 2013 Scott Talbot. All rights reserved. -DSTROOT = /tmp/STSecurity.dst +//DSTROOT = /tmp/STSecurity.dst SKIP_INSTALL = YES PRODUCT_NAME = STSecurity diff --git a/STSecurityTestHost/AppDelegate.h b/STSecurityTestHost/AppDelegate.h new file mode 100644 index 0000000..8b5403b --- /dev/null +++ b/STSecurityTestHost/AppDelegate.h @@ -0,0 +1,15 @@ +// +// AppDelegate.h +// STSecurityTestHost +// +// Created by Scott Talbot on 27/10/19. +// Copyright © 2019 Scott Talbot. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + + +@end + diff --git a/STSecurityTestHost/AppDelegate.m b/STSecurityTestHost/AppDelegate.m new file mode 100644 index 0000000..56e2948 --- /dev/null +++ b/STSecurityTestHost/AppDelegate.m @@ -0,0 +1,9 @@ +#import "AppDelegate.h" + +@implementation AppDelegate + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + return YES; +} + +@end diff --git a/STSecurityTestHost/Assets.xcassets/AppIcon.appiconset/Contents.json b/STSecurityTestHost/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..d8db8d6 --- /dev/null +++ b/STSecurityTestHost/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/STSecurityTestHost/Assets.xcassets/Contents.json b/STSecurityTestHost/Assets.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/STSecurityTestHost/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/STSecurityTestHost/Base.lproj/LaunchScreen.storyboard b/STSecurityTestHost/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..865e932 --- /dev/null +++ b/STSecurityTestHost/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/STSecurityTestHost/Base.lproj/Main.storyboard b/STSecurityTestHost/Base.lproj/Main.storyboard new file mode 100644 index 0000000..8de98f7 --- /dev/null +++ b/STSecurityTestHost/Base.lproj/Main.storyboard @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/STSecurityTestHost/Info.plist b/STSecurityTestHost/Info.plist new file mode 100644 index 0000000..7b6037c --- /dev/null +++ b/STSecurityTestHost/Info.plist @@ -0,0 +1,64 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + SceneDelegate + UISceneStoryboardFile + Main + + + + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/STSecurityTestHost/main.m b/STSecurityTestHost/main.m new file mode 100644 index 0000000..4cc9deb --- /dev/null +++ b/STSecurityTestHost/main.m @@ -0,0 +1,19 @@ +// +// main.m +// STSecurityTestHost +// +// Created by Scott Talbot on 27/10/19. +// Copyright © 2019 Scott Talbot. All rights reserved. +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + NSString * appDelegateClassName; + @autoreleasepool { + // Setup code that might create autoreleased objects goes here. + appDelegateClassName = NSStringFromClass([AppDelegate class]); + } + return UIApplicationMain(argc, argv, nil, appDelegateClassName); +} diff --git a/STSecurityTests/STSecurityKeychainAccessRSATests.m b/STSecurityTests/STSecurityKeychainAccessRSATests.m index 8eb5411..825945c 100644 --- a/STSecurityTests/STSecurityKeychainAccessRSATests.m +++ b/STSecurityTests/STSecurityKeychainAccessRSATests.m @@ -1,309 +1,309 @@ +//// +//// STSecurityKeychainAccessRSATests.m +//// STSecurity +//// +//// Copyright (c) 2012 Scott Talbot. All rights reserved. +//// // -// STSecurityKeychainAccessRSATests.m -// STSecurity -// -// Copyright (c) 2012 Scott Talbot. All rights reserved. -// - -@import XCTest; - -#import "STSecurity.h" - - -@interface STSecurityKeychainAccessRSATests : XCTestCase -@end - -@implementation STSecurityKeychainAccessRSATests - -- (void)testFetchNonexistent { - { - STSecurityRSAPublicKey *key = [STSecurityKeychainAccess fetchRSAPublicKeyForTag:@"STSecurityTest.nonexistent"]; - XCTAssertNil(key, @"Keychain returned key for nonexistent tag"); - } - { - NSError *error = nil; - STSecurityRSAPublicKey *key = [STSecurityKeychainAccess fetchRSAPublicKeyForTag:@"STSecurityTest.nonexistent" error:&error]; - XCTAssertNil(key, @"Keychain returned key for nonexistent tag"); - XCTAssertNotNil(error, @"Keychain returned nil error"); - } -} - -- (void)testDeleteNonexistent { - { - NSError *error = nil; - BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:@"STSecurityTest.nonexistent" error:&error]; - XCTAssertFalse(status, @"Keychain returned success deleting nonexistent key"); - XCTAssertNotNil(error, @"Keychain returned nil error"); - XCTAssertEqual(error.code, errSecItemNotFound, @"Keychain returned error.code not ItemNotFound: %ld", (long)error.code); - } -} - - -#if !defined(TRAVIS) || !(TRAVIS + 0) - -- (void)_st_testGenerationOfSize:(NSUInteger)keySize { - NSString * const keyTag = @"STSecurityTest.testGeneration"; - STSecurityRSAPublicKey *publicKey = nil; - STSecurityRSAPrivateKey *privateKey = nil; - - { - NSError *error = nil; - BOOL status = [STSecurityKeychainAccess generateRSAKeypairOfSize:keySize insertedIntoKeychainWithTag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; - XCTAssertTrue(status, @"Keychain could not generate key pair"); - XCTAssertNil(error, @"Key generation returned error: %@", error); - } - XCTAssertNotNil(publicKey, @"Key generation resulted in no public key"); - XCTAssertNotNil(privateKey, @"Key generation resulted in no private key"); - - { - NSError *error = nil; - BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:&error]; - XCTAssertTrue(status, @"Keychain could not delete public key"); - XCTAssertNil(error, @"Public key deletion returned error: %@", error); - } -} - -//- (void)testGenerationSize384 { [self _st_testGenerationOfSize:384]; } -- (void)testGenerationSize512 { [self _st_testGenerationOfSize:512]; } -- (void)testGenerationSize768 { [self _st_testGenerationOfSize:768]; } -- (void)testGenerationSize1024 { [self _st_testGenerationOfSize:1024]; } -- (void)testGenerationSize1536 { [self _st_testGenerationOfSize:1536]; } -//- (void)testGenerationSize2048 { [self _st_testGenerationOfSize:2048]; } -//- (void)testGenerationSize3072 { [self _st_testGenerationOfSize:3072]; } -//- (void)testGenerationSize4096 { [self _st_testGenerationOfSize:4096]; } - - -- (void)testGenerationAnonymous { - STSecurityRSAPublicKey *publicKey = nil; - STSecurityRSAPrivateKey *privateKey = nil; - - { - NSError *error = nil; - BOOL status = [STSecurityKeychainAccess generateRSAKeypairOfSize:1024 insertedIntoKeychainWithTag:nil publicKey:&publicKey privateKey:&privateKey error:&error]; - XCTAssertFalse(status, @"Keychain generated key pair without tags"); - XCTAssertNotNil(error, @"Key generation returned nil error"); - } - XCTAssertNil(publicKey, @"Key generation resulted in no public key"); - XCTAssertNil(privateKey, @"Key generation resulted in no private key"); -} - -- (void)testGenerationAndFetch { - NSString * const keyTag = @"STSecurityTest.testGenerationAndFetch"; - STSecurityRSAPublicKey *publicKey = nil; - STSecurityRSAPrivateKey *privateKey = nil; - NSUInteger keySize = 1024; - - { - NSError *error = nil; - BOOL status = [STSecurityKeychainAccess generateRSAKeypairOfSize:keySize insertedIntoKeychainWithTag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; - XCTAssertTrue(status, @"Keychain could not generate key pair"); - XCTAssertNil(error, @"Key generation returned error: %@", error); - } - XCTAssertNotNil(publicKey, @"Key generation resulted in no public key"); - XCTAssertNotNil(privateKey, @"Key generation resulted in no private key"); - - NSData *privateKeyData = nil; - { - NSError *error = nil; - privateKeyData = [STSecurityKeychainAccess fetchKeyDataForRSAPrivateKey:privateKey error:&error]; - XCTAssertNotNil(privateKeyData, @"Could not fetch private key data"); - XCTAssertNil(error, @"Private key data fetch returned error: %@", error); - } - - STSecurityRSAPublicKey *fetchedPublicKey = nil; - { - NSError *error = nil; - fetchedPublicKey = [STSecurityKeychainAccess fetchRSAPublicKeyForTag:keyTag error:&error]; - XCTAssertNotNil(fetchedPublicKey, @"Keychain could not find public key"); - XCTAssertNil(error, @"Keychain fetch returned error: %@", error); - } - - STSecurityRSAPrivateKey *fetchedPrivateKey = nil; - { - NSError *error = nil; - fetchedPrivateKey = [STSecurityKeychainAccess fetchRSAPrivateKeyForTag:keyTag error:&error]; - XCTAssertNotNil(fetchedPrivateKey, @"Keychain could not find private key"); - XCTAssertNil(error, @"Keychain fetch returned error: %@", error); - } - - NSData *fetchedPrivateKeyData = nil; - { - NSError *error = nil; - fetchedPrivateKeyData = [STSecurityKeychainAccess fetchKeyDataForRSAPrivateKey:fetchedPrivateKey error:&error]; - XCTAssertNotNil(fetchedPrivateKeyData, @"Could not fetch private key data"); - XCTAssertNil(error, @"Private key data fetch returned error: %@", error); - } - - XCTAssertEqualObjects(publicKey.keyData, fetchedPublicKey.keyData, @"Fetched public key doesn't equal original"); - XCTAssertEqualObjects(privateKeyData, fetchedPrivateKeyData, @"Fetched private key doesn't equal original"); - - { - NSError *error = nil; - BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:&error]; - XCTAssertTrue(status, @"Keychain could not delete public key"); - XCTAssertNil(error, @"Public key deletion returned error: %@", error); - } -} - -- (void)testConflictingGeneration { - NSString * const keyTag = @"STSecurityTest.testConflictingGeneration"; - STSecurityRSAPublicKey *publicKey = nil; - STSecurityRSAPrivateKey *privateKey = nil; - NSUInteger keySize = 1024; - - { - NSError *error = nil; - BOOL status = [STSecurityKeychainAccess generateRSAKeypairOfSize:keySize insertedIntoKeychainWithTag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; - XCTAssertTrue(status, @"Keychain could not generate key pair"); - XCTAssertNil(error, @"Key generation returned error: %@", error); - } - XCTAssertNotNil(publicKey, @"Key generation resulted in no public key"); - XCTAssertNotNil(privateKey, @"Key generation resulted in no private key"); - - { - NSError *error = nil; - BOOL status = [STSecurityKeychainAccess generateRSAKeypairOfSize:keySize insertedIntoKeychainWithTag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; - XCTAssertFalse(status, @"Keychain generated conflicting key pair"); - XCTAssertNotNil(error, @"Key generation returned no error"); - } - - { - NSError *error = nil; - BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:&error]; - XCTAssertTrue(status, @"Keychain could not delete public key"); - XCTAssertNil(error, @"Public key deletion returned error: %@", error); - } -} -#endif - -- (void)testInsertion { - unsigned char const pub_bytes[] = { - 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, - 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, - 0x00, 0xb6, 0x63, 0x51, 0x02, 0xee, 0xd9, 0x71, 0x5e, 0x2e, 0x88, 0x6a, 0x61, 0xd1, 0x6a, 0x22, - 0xb6, 0x7d, 0x3e, 0xae, 0xb3, 0xf1, 0x2c, 0x7f, 0xa7, 0xb3, 0xd7, 0xe1, 0x1e, 0x25, 0x41, 0x38, - 0xc4, 0xab, 0xef, 0x43, 0x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, 0x0c, 0x09, 0xe4, 0xf0, 0x7f, - 0x8a, 0xc6, 0x1b, 0xe3, 0x63, 0xae, 0x57, 0xe7, 0x6c, 0xe7, 0x92, 0xb7, 0x7b, 0xab, 0x74, 0xdb, - 0x1f, 0x69, 0x3c, 0x45, 0x41, 0x8d, 0x29, 0xd0, 0xda, 0xe7, 0x99, 0xd4, 0xc7, 0x40, 0x58, 0xce, - 0x23, 0x02, 0x03, 0x01, 0x00, 0x01 - }; - unsigned int const pub_bytes_len = 294; - - unsigned char const prv_bytes[] = { - 0x30, 0x82, 0x04, 0xa5, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, 0xb6, 0x63, 0x51, 0x02, - 0xee, 0xd9, 0x71, 0x5e, 0x2e, 0x88, 0x6a, 0x61, 0xd1, 0x6a, 0x22, 0xb6, 0x7d, 0x3e, 0xae, 0xb3, - 0xf1, 0x2c, 0x7f, 0xa7, 0xb3, 0xd7, 0xe1, 0x1e, 0x25, 0x41, 0x38, 0xc4, 0xab, 0xef, 0x43, 0xd8, - 0x93, 0x55, 0xff, 0x42, 0x89, 0xda, 0x54, 0x46, 0x8b, 0xce, 0x54, 0x06, 0x28, 0x9d, 0xae, 0x42, - 0x12, 0xf3, 0x3f, 0x26, 0x70, 0x31, 0x03, 0x6f, 0xa5, 0x61, 0x08, 0x48, 0x73, 0xd7, 0xdf, 0x74, - 0x65, 0x01, 0xec, 0xb8, 0x48, 0x11, 0xdf, 0x45, 0x8d, 0x2c, 0x98, 0x08, 0xd9, 0x49, 0xbd, 0xfb, - 0x71, 0x52, 0x21, 0xd6, 0x15, 0x84, 0xf8, 0xde, 0xfa, 0xcc, 0xdd, 0x12, 0xbc, 0xad, 0xd5, 0x7e, - 0xac, 0x7b, 0x6e, 0xcf, 0x52, 0xdb, 0xf6, 0x6e, 0x22, 0x65, 0xd0, 0xa5, 0xfd, 0x39, 0xc6, 0xbc, - 0xbb, 0x4a, 0x3a, 0x55, 0xfd, 0xd5, 0x2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x79, 0x73, - 0xbb, 0xeb, 0x78, 0x90, 0x2a, 0x40, 0x32, 0xad, 0xe9, 0x2f, 0xab, 0xb4, 0x4c, 0x70, 0x34, 0xbe, - 0x4f, 0x40, 0x5f, 0xa7, 0x9b, 0x74, 0x8e, 0x50, 0x39, 0x14, 0x00, 0x21, 0x03, 0x18, 0x68, 0x4d, - 0xac, 0x2a, 0xe7, 0x49, 0xc2, 0x0c, 0x0f, 0x3e, 0x95, 0xe0, 0x09, 0x1e, 0xfc, 0xe6, 0xfb, 0xd1, - 0x95, 0x57, 0x29, 0x6b, 0xaa, 0x6b, 0xcb, 0x7f, 0x94, 0x83, 0x23, 0xcf, 0x6e, 0x68, 0xf3, 0x96, - 0xf5, 0x02, 0x81, 0x81, 0x00, 0xb6, 0xa5, 0x2a, 0x16, 0x0e, 0xe8, 0x95, 0x4c, 0xa7, 0x7b, 0x92, - 0x5e, 0x5e, 0x34, 0x00, 0x14, 0x16, 0xb2, 0x24, 0xfd, 0x20, 0x66, 0x29, 0xd6, 0x82, 0xa1, 0x71, - 0x55, 0xb0, 0x83, 0x37, 0x2e, 0x8c, 0xcc, 0x82, 0xaa, 0x54, 0x7f, 0xa0, 0x5b, 0x22, 0x36, 0x8e, - 0xa0, 0x2c, 0x60, 0x48, 0xc9, 0x91, 0xd6, 0x92, 0x66, 0xa1, 0x70, 0xa2, 0x8b, 0xa6, 0x9e, 0x60, - 0x1d, 0xad, 0x0f, 0x63, 0x14, 0x55, 0xca, 0xe2, 0x20, 0x74, 0xec, 0x88, 0x48, 0xda, 0xac, 0x4c, - 0x1e, 0x20, 0x6b, 0xe1, 0x22, 0x76, 0x94, 0x1f, 0xb3, 0x62, 0x95, 0x1c, 0x5a, 0x48, 0xe0, 0xec, - 0x7f, 0xc3, 0x8c, 0x0b, 0x86, 0x47, 0x23, 0x4c, 0xf5, 0xaa, 0x42, 0x06, 0x04, 0x39, 0x79, 0xe0, - 0xea, 0x34, 0x81, 0xac, 0xf6, 0x1d, 0x40, 0x5d, 0xf4, 0x84, 0x90, 0x6e, 0xa3, 0x27, 0x1e, 0x22, - 0x9e, 0xab, 0xc7, 0x0a, 0x37, 0x02, 0x81, 0x81, 0x00, 0x85, 0xee, 0x09, 0x5e, 0x36, 0x6f, 0x0f, - 0x95, 0x03, 0x80, 0x3e, 0x08, 0xa4, 0x8a, 0x91, 0x06, 0xb3, 0xff, 0x79, 0x06, 0x31, 0x5b, 0x18, - 0xeb, 0xfd, 0x2f, 0xa9, 0x0d, 0x19, 0x9d, 0xc4, 0xf0, 0x02, 0xf7, 0x4d, 0x77, 0x23, 0xd7, 0x68, - 0xbf, 0xef, 0x15, 0x43, 0x33, 0xa1, 0x79, 0x7f, 0xc5, 0xc1, 0xfd, 0xc7, 0xa7, 0xba, 0xfb, 0xac, - 0x24, 0xb1, 0x82, 0x0c, 0xe1, 0x17, 0xb5, 0xda, 0x05, 0x4c, 0x90, 0x80, 0xd8, 0x82, 0x62, 0x2c, - 0x6d, 0xc8, 0x65, 0xac, 0xa1, 0xb6, 0x6f, 0x82, 0xbd, 0xfd, 0x5f, 0x06, 0x65, 0x7f, 0xda, 0x8b, - 0xee, 0xb8, 0x8a, 0x4e, 0x59, 0x8b, 0xb3, 0x5e, 0xfc, 0xf0, 0x6d, 0x2f, 0xbc, 0x31, 0x2b, 0xb6, - 0x97, 0x84, 0x88, 0x0e, 0x51, 0x9b, 0x03, 0x38, 0x56, 0x34, 0x8a, 0x80, 0x7f, 0x67, 0x85, 0x3f, - 0x70, 0xad, 0x99, 0x20, 0x5e, 0x2a, 0xf2, 0x97, 0x38 - }; - unsigned int const prv_bytes_len = 1193; - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wcast-qual" - NSData * const publicKeyData = [NSData dataWithBytesNoCopy:(void *)pub_bytes length:pub_bytes_len freeWhenDone:NO]; - NSData * const privateKeyData = [NSData dataWithBytesNoCopy:(void *)prv_bytes length:prv_bytes_len freeWhenDone:NO]; -#pragma clang diagnostic pop - - NSString * const keyTag = @"STSecurityTest.testInsertion"; - STSecurityRSAPublicKey *publicKey = nil; - STSecurityRSAPrivateKey *privateKey = nil; - - { - NSError *error = nil; - BOOL status = [STSecurityKeychainAccess insertRSAKeypairWithPublicKeyData:publicKeyData privateKeyData:privateKeyData intoKeychainWithAccessibility:STSecurityKeychainItemAccessibleAlways tag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; - XCTAssertTrue(status, @"Keychain could not insertion key pair"); - XCTAssertNil(error, @"Key insertion returned error: %@", error); - } - XCTAssertNotNil(publicKey, @"Key insertion resulted in no public key"); - XCTAssertNotNil(privateKey, @"Key insertion resulted in no private key"); - - { - NSError *error = nil; - BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:&error]; - XCTAssertTrue(status, @"Keychain could not delete public key"); - XCTAssertNil(error, @"Public key deletion returned error: %@", error); - } -} - -@end +//@import XCTest; +// +//#import "STSecurity.h" +// +// +//@interface STSecurityKeychainAccessRSATests : XCTestCase +//@end +// +//@implementation STSecurityKeychainAccessRSATests +// +//- (void)testFetchNonexistent { +// { +// STSecurityRSAPublicKey *key = [STSecurityKeychainAccess fetchRSAPublicKeyForTag:@"STSecurityTest.nonexistent"]; +// XCTAssertNil(key, @"Keychain returned key for nonexistent tag"); +// } +// { +// NSError *error = nil; +// STSecurityRSAPublicKey *key = [STSecurityKeychainAccess fetchRSAPublicKeyForTag:@"STSecurityTest.nonexistent" error:&error]; +// XCTAssertNil(key, @"Keychain returned key for nonexistent tag"); +// XCTAssertNotNil(error, @"Keychain returned nil error"); +// } +//} +// +//- (void)testDeleteNonexistent { +// { +// NSError *error = nil; +// BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:@"STSecurityTest.nonexistent" error:&error]; +// XCTAssertFalse(status, @"Keychain returned success deleting nonexistent key"); +// XCTAssertNotNil(error, @"Keychain returned nil error"); +// XCTAssertEqual(error.code, errSecItemNotFound, @"Keychain returned error.code not ItemNotFound: %ld", (long)error.code); +// } +//} +// +// +//#if !defined(TRAVIS) || !(TRAVIS + 0) +// +//- (void)_st_testGenerationOfSize:(NSUInteger)keySize { +// NSString * const keyTag = @"STSecurityTest.testGeneration"; +// STSecurityRSAPublicKey *publicKey = nil; +// STSecurityRSAPrivateKey *privateKey = nil; +// +// { +// NSError *error = nil; +// BOOL status = [STSecurityKeychainAccess generateRSAKeypairOfSize:keySize insertedIntoKeychainWithTag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; +// XCTAssertTrue(status, @"Keychain could not generate key pair"); +// XCTAssertNil(error, @"Key generation returned error: %@", error); +// } +// XCTAssertNotNil(publicKey, @"Key generation resulted in no public key"); +// XCTAssertNotNil(privateKey, @"Key generation resulted in no private key"); +// +// { +// NSError *error = nil; +// BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:&error]; +// XCTAssertTrue(status, @"Keychain could not delete public key"); +// XCTAssertNil(error, @"Public key deletion returned error: %@", error); +// } +//} +// +////- (void)testGenerationSize384 { [self _st_testGenerationOfSize:384]; } +//- (void)testGenerationSize512 { [self _st_testGenerationOfSize:512]; } +//- (void)testGenerationSize768 { [self _st_testGenerationOfSize:768]; } +//- (void)testGenerationSize1024 { [self _st_testGenerationOfSize:1024]; } +//- (void)testGenerationSize1536 { [self _st_testGenerationOfSize:1536]; } +////- (void)testGenerationSize2048 { [self _st_testGenerationOfSize:2048]; } +////- (void)testGenerationSize3072 { [self _st_testGenerationOfSize:3072]; } +////- (void)testGenerationSize4096 { [self _st_testGenerationOfSize:4096]; } +// +// +//- (void)testGenerationAnonymous { +// STSecurityRSAPublicKey *publicKey = nil; +// STSecurityRSAPrivateKey *privateKey = nil; +// +// { +// NSError *error = nil; +// BOOL status = [STSecurityKeychainAccess generateRSAKeypairOfSize:1024 insertedIntoKeychainWithTag:nil publicKey:&publicKey privateKey:&privateKey error:&error]; +// XCTAssertFalse(status, @"Keychain generated key pair without tags"); +// XCTAssertNotNil(error, @"Key generation returned nil error"); +// } +// XCTAssertNil(publicKey, @"Key generation resulted in no public key"); +// XCTAssertNil(privateKey, @"Key generation resulted in no private key"); +//} +// +//- (void)testGenerationAndFetch { +// NSString * const keyTag = @"STSecurityTest.testGenerationAndFetch"; +// STSecurityRSAPublicKey *publicKey = nil; +// STSecurityRSAPrivateKey *privateKey = nil; +// NSUInteger keySize = 1024; +// +// { +// NSError *error = nil; +// BOOL status = [STSecurityKeychainAccess generateRSAKeypairOfSize:keySize insertedIntoKeychainWithTag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; +// XCTAssertTrue(status, @"Keychain could not generate key pair"); +// XCTAssertNil(error, @"Key generation returned error: %@", error); +// } +// XCTAssertNotNil(publicKey, @"Key generation resulted in no public key"); +// XCTAssertNotNil(privateKey, @"Key generation resulted in no private key"); +// +// NSData *privateKeyData = nil; +// { +// NSError *error = nil; +// privateKeyData = [STSecurityKeychainAccess fetchKeyDataForRSAPrivateKey:privateKey error:&error]; +// XCTAssertNotNil(privateKeyData, @"Could not fetch private key data"); +// XCTAssertNil(error, @"Private key data fetch returned error: %@", error); +// } +// +// STSecurityRSAPublicKey *fetchedPublicKey = nil; +// { +// NSError *error = nil; +// fetchedPublicKey = [STSecurityKeychainAccess fetchRSAPublicKeyForTag:keyTag error:&error]; +// XCTAssertNotNil(fetchedPublicKey, @"Keychain could not find public key"); +// XCTAssertNil(error, @"Keychain fetch returned error: %@", error); +// } +// +// STSecurityRSAPrivateKey *fetchedPrivateKey = nil; +// { +// NSError *error = nil; +// fetchedPrivateKey = [STSecurityKeychainAccess fetchRSAPrivateKeyForTag:keyTag error:&error]; +// XCTAssertNotNil(fetchedPrivateKey, @"Keychain could not find private key"); +// XCTAssertNil(error, @"Keychain fetch returned error: %@", error); +// } +// +// NSData *fetchedPrivateKeyData = nil; +// { +// NSError *error = nil; +// fetchedPrivateKeyData = [STSecurityKeychainAccess fetchKeyDataForRSAPrivateKey:fetchedPrivateKey error:&error]; +// XCTAssertNotNil(fetchedPrivateKeyData, @"Could not fetch private key data"); +// XCTAssertNil(error, @"Private key data fetch returned error: %@", error); +// } +// +// XCTAssertEqualObjects(publicKey.keyData, fetchedPublicKey.keyData, @"Fetched public key doesn't equal original"); +// XCTAssertEqualObjects(privateKeyData, fetchedPrivateKeyData, @"Fetched private key doesn't equal original"); +// +// { +// NSError *error = nil; +// BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:&error]; +// XCTAssertTrue(status, @"Keychain could not delete public key"); +// XCTAssertNil(error, @"Public key deletion returned error: %@", error); +// } +//} +// +//- (void)testConflictingGeneration { +// NSString * const keyTag = @"STSecurityTest.testConflictingGeneration"; +// STSecurityRSAPublicKey *publicKey = nil; +// STSecurityRSAPrivateKey *privateKey = nil; +// NSUInteger keySize = 1024; +// +// { +// NSError *error = nil; +// BOOL status = [STSecurityKeychainAccess generateRSAKeypairOfSize:keySize insertedIntoKeychainWithTag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; +// XCTAssertTrue(status, @"Keychain could not generate key pair"); +// XCTAssertNil(error, @"Key generation returned error: %@", error); +// } +// XCTAssertNotNil(publicKey, @"Key generation resulted in no public key"); +// XCTAssertNotNil(privateKey, @"Key generation resulted in no private key"); +// +// { +// NSError *error = nil; +// BOOL status = [STSecurityKeychainAccess generateRSAKeypairOfSize:keySize insertedIntoKeychainWithTag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; +// XCTAssertFalse(status, @"Keychain generated conflicting key pair"); +// XCTAssertNotNil(error, @"Key generation returned no error"); +// } +// +// { +// NSError *error = nil; +// BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:&error]; +// XCTAssertTrue(status, @"Keychain could not delete public key"); +// XCTAssertNil(error, @"Public key deletion returned error: %@", error); +// } +//} +//#endif +// +//- (void)testInsertion { +// unsigned char const pub_bytes[] = { +// 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, +// 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, +// 0x00, 0xb6, 0x63, 0x51, 0x02, 0xee, 0xd9, 0x71, 0x5e, 0x2e, 0x88, 0x6a, 0x61, 0xd1, 0x6a, 0x22, +// 0xb6, 0x7d, 0x3e, 0xae, 0xb3, 0xf1, 0x2c, 0x7f, 0xa7, 0xb3, 0xd7, 0xe1, 0x1e, 0x25, 0x41, 0x38, +// 0xc4, 0xab, 0xef, 0x43, 0xd8, 0x93, 0x55, 0xff, 0x42, 0x89, 0xda, 0x54, 0x46, 0x8b, 0xce, 0x54, +// 0x06, 0x28, 0x9d, 0xae, 0x42, 0x12, 0xf3, 0x3f, 0x26, 0x70, 0x31, 0x03, 0x6f, 0xa5, 0x61, 0x08, +// 0x48, 0x73, 0xd7, 0xdf, 0x74, 0x65, 0x01, 0xec, 0xb8, 0x48, 0x11, 0xdf, 0x45, 0x8d, 0x2c, 0x98, +// 0x08, 0xd9, 0x49, 0xbd, 0xfb, 0x71, 0x52, 0x21, 0xd6, 0x15, 0x84, 0xf8, 0xde, 0xfa, 0xcc, 0xdd, +// 0x12, 0xbc, 0xad, 0xd5, 0x7e, 0xac, 0x7b, 0x6e, 0xcf, 0x52, 0xdb, 0xf6, 0x6e, 0x22, 0x65, 0xd0, +// 0xa5, 0xfd, 0x39, 0xc6, 0xbc, 0xbb, 0x4a, 0x3a, 0x55, 0xfd, 0xd5, 0x2a, 0xe7, 0xee, 0x7e, 0xaf, +// 0x6f, 0xc3, 0x7c, 0x8b, 0x0e, 0x6c, 0xb4, 0xfb, 0x51, 0xb9, 0x22, 0xa1, 0x4a, 0xb0, 0x6d, 0x21, +// 0x6d, 0xe4, 0xc4, 0x9c, 0x72, 0x26, 0xe7, 0xef, 0x76, 0xa6, 0xaf, 0x84, 0x5e, 0xff, 0x4a, 0x90, +// 0x93, 0x49, 0xfb, 0x4c, 0xee, 0xdc, 0x87, 0x5f, 0x9a, 0xfa, 0x8b, 0x07, 0xaa, 0x96, 0x5c, 0xe9, +// 0x34, 0x51, 0x5e, 0x8c, 0x14, 0xc5, 0x48, 0x1e, 0x42, 0x7d, 0x10, 0xfb, 0xbd, 0x62, 0x4a, 0xfc, +// 0x96, 0x57, 0xea, 0x4c, 0x0c, 0x7d, 0xd1, 0x18, 0x3e, 0xd2, 0xea, 0xd7, 0x0d, 0xad, 0x5d, 0xfd, +// 0x3a, 0xc6, 0xb9, 0xed, 0x78, 0x22, 0xf3, 0x7f, 0x69, 0xe6, 0xb8, 0x0c, 0x09, 0xe4, 0xf0, 0x7f, +// 0x8a, 0xc6, 0x1b, 0xe3, 0x63, 0xae, 0x57, 0xe7, 0x6c, 0xe7, 0x92, 0xb7, 0x7b, 0xab, 0x74, 0xdb, +// 0x1f, 0x69, 0x3c, 0x45, 0x41, 0x8d, 0x29, 0xd0, 0xda, 0xe7, 0x99, 0xd4, 0xc7, 0x40, 0x58, 0xce, +// 0x23, 0x02, 0x03, 0x01, 0x00, 0x01 +// }; +// unsigned int const pub_bytes_len = 294; +// +// unsigned char const prv_bytes[] = { +// 0x30, 0x82, 0x04, 0xa5, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, 0xb6, 0x63, 0x51, 0x02, +// 0xee, 0xd9, 0x71, 0x5e, 0x2e, 0x88, 0x6a, 0x61, 0xd1, 0x6a, 0x22, 0xb6, 0x7d, 0x3e, 0xae, 0xb3, +// 0xf1, 0x2c, 0x7f, 0xa7, 0xb3, 0xd7, 0xe1, 0x1e, 0x25, 0x41, 0x38, 0xc4, 0xab, 0xef, 0x43, 0xd8, +// 0x93, 0x55, 0xff, 0x42, 0x89, 0xda, 0x54, 0x46, 0x8b, 0xce, 0x54, 0x06, 0x28, 0x9d, 0xae, 0x42, +// 0x12, 0xf3, 0x3f, 0x26, 0x70, 0x31, 0x03, 0x6f, 0xa5, 0x61, 0x08, 0x48, 0x73, 0xd7, 0xdf, 0x74, +// 0x65, 0x01,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0xe7, 0x99, 0xd4, 0xc7, 0x40, 0x58, 0xce, 0x23, 0x02, 0x03, 0x01, 0x00, +// 0x01, 0x02, 0x82, 0x01, 0x00, 0x08, 0xce, 0x2a, 0xaf, 0x15, 0x90, 0xf1, 0xe4, 0x36, 0x22, 0xe7, +// 0xdf, 0xe9, 0x18, 0x52, 0xac, 0xb4, 0xc7, 0x3d, 0xef, 0xfa, 0x08, 0xc7, 0xf0, 0xf4, 0xc1, 0xcb, +// 0x60, 0x85, 0x33, 0xec, 0xe5, 0xb1, 0xd7, 0x4f, 0x53, 0x39, 0x69, 0xc1, 0x75, 0x18, 0xea, 0xad, +// 0x7e, 0xea, 0x68, 0xff, 0xad, 0x7c, 0x70, 0x80, 0x65, 0x38, 0x3c, 0xfe, 0x23, 0x80, 0xef, 0x1c, +// 0xd7, 0x5b, 0x08, 0xa0, 0x39, 0xbf, 0x3e, 0x00, 0xcf, 0xc1, 0xc0, 0xa2, 0x09, 0x13, 0x91, 0xa9, +// 0x51, 0xd6, 0x4a, 0xfc, 0xdc, 0x10, 0x81, 0x7a, 0xe6, 0x94, 0xc5, 0xfe, 0x54, 0x33, 0x9d, 0xc3, +// 0xd6, 0x20, 0x0d, 0x9b, 0xee, 0xb7, 0xa5, 0x3c, 0xd5, 0x6c, 0xc6, 0x58, 0xc7, 0x31, 0x9c, 0xe4, +// 0xfc, 0xd4, 0x34, 0x4e, 0x2a, 0x75, 0x5b, 0x40, 0xb9, 0x03, 0xe1, 0xc5, 0x87, 0x39, 0x45, 0xfd, +// 0x58, 0x4d, 0x2f, 0x58, 0x90, 0xdb, 0xdf, 0x00, 0x3e, 0xc2, 0xc5, 0x0b, 0x80, 0x7e, 0xbb, 0xbc, +// 0xdc, 0xbd, 0x6d, 0xcc, 0x20, 0x89, 0x74, 0xb9, 0x4d, 0x4a, 0xb4, 0xe0, 0x9a, 0x61, 0xf0, 0xa7, +// 0x58, 0xe5, 0x3d, 0xf4, 0x65, 0x8a, 0xb5, 0x3d, 0xe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60, 0x30, 0xc2, 0x9b, +// 0xda, 0xd6, 0xf1, 0xe6, 0xda, 0xa9, 0x85, 0xd4, 0x47, 0xa8, 0xe3, 0x51, 0x99, 0x85, 0x77, 0xd9, +// 0x70, 0x09, 0xfd, 0x0b, 0x88, 0x20, 0xac, 0x1f, 0x2f, 0x19, 0xf8, 0x47, 0x31, 0xa7, 0xf7, 0x73, +// 0xa0, 0x41, 0x4b, 0xfd, 0x6d, 0xe2, 0xc0, 0xef, 0x65, 0x02, 0x81, 0x81, 0x00, 0xcd, 0x54, 0x03, +// 0x67, 0x7c, 0x4a, 0x3b, 0x47, 0x7f, 0x90, 0x66, 0x0f, 0xfe, 0xe2, 0xdf, 0xaa, 0xcd, 0xa3, 0x1a, +// 0xdb, 0xc1, 0x7f, 0xf3, 0x56, 0xa3, 0x5d, 0x7c, 0x82, 0xfd, 0xf4, 0x07, 0x28, 0x24, 0x0e, 0xaa, +// 0x23, 0xf6, 0x0c, 0x92, 0x59, 0x17, 0xe4, 0x49, 0x27, 0x51, 0xdc, 0x40, 0x47, 0x80, 0x83, 0x20, +// 0x1e, 0x70, 0x99, 0x41, 0xac, 0x59, 0xc8, 0xe6, 0xaf, 0x31, 0x23, 0x95, 0x57, 0xbc, 0xdc, 0xbd, +// 0xe9, 0x8e, 0x66, 0xb7, 0xcc, 0xc1, 0xf5, 0xd5, 0x4d, 0x01, 0x01, 0x71, 0x5a, 0xb3, 0x80, 0x6a, +// 0x8c, 0x6a, 0xeb, 0xf5, 0x31, 0xd9, 0xe3, 0x86, 0x27, 0x2d, 0xef, 0xc6, 0x41, 0x77, 0xf0, 0x1a, +// 0x99, 0x16, 0x17, 0x5f, 0x2a, 0x43, 0x9b, 0xe8, 0x01, 0x9a, 0xcc, 0x24, 0x06, 0x7d, 0xc4, 0xe5, +// 0xf7, 0xc3, 0xa1, 0xea, 0xc9, 0xc5, 0x4b, 0x3c, 0x2f, 0xb7, 0xba, 0x02, 0xe7, 0x02, 0x81, 0x81, +// 0x00, 0xa9, 0x3b, 0x31, 0x19, 0x1d, 0xfb, 0xa6, 0x54, 0xaa, 0x42, 0x6f, 0xc3, 0x71, 0x67, 0x3a, +// 0xd5, 0x95, 0x35, 0x26, 0x3e, 0x59, 0x1f, 0xf7, 0x1a, 0x34, 0xac, 0xea, 0x23, 0xdc, 0x34, 0x03, +// 0xe6, 0x33, 0xb4, 0x95, 0x0b, 0x62, 0x03, 0xd4, 0x53, 0x98, 0xa2, 0xa5, 0xaa, 0x75, 0xa1, 0x4b, +// 0x9c, 0x12, 0x0e, 0xcc, 0x03, 0x5a, 0xb0, 0x02, 0xf1, 0x19, 0xf2, 0xb1, 0x7c, 0x27, 0x79, 0x73, +// 0xbb, 0xeb, 0x78, 0x90, 0x2a, 0x40, 0x32, 0xad, 0xe9, 0x2f, 0xab, 0xb4, 0x4c, 0x70, 0x34, 0xbe, +// 0x4f, 0x40, 0x5f, 0xa7, 0x9b, 0x74, 0x8e, 0x50, 0x39, 0x14, 0x00, 0x21, 0x03, 0x18, 0x68, 0x4d, +// 0xac, 0x2a, 0xe7, 0x49, 0xc2, 0x0c, 0x0f, 0x3e, 0x95, 0xe0, 0x09, 0x1e, 0xfc, 0xe6, 0xfb, 0xd1, +// 0x95, 0x57, 0x29, 0x6b, 0xaa, 0x6b, 0xcb, 0x7f, 0x94, 0x83, 0x23, 0xcf, 0x6e, 0x68, 0xf3, 0x96, +// 0xf5, 0x02, 0x81, 0x81, 0x00, 0xb6, 0xa5, 0x2a, 0x16, 0x0e, 0xe8, 0x95, 0x4c, 0xa7, 0x7b, 0x92, +// 0x5e, 0x5e, 0x34, 0x00, 0x14, 0x16, 0xb2, 0x24, 0xfd, 0x20, 0x66, 0x29, 0xd6, 0x82, 0xa1, 0x71, +// 0x55, 0xb0, 0x83, 0x37, 0x2e, 0x8c, 0xcc, 0x82, 0xaa, 0x54, 0x7f, 0xa0, 0x5b, 0x22, 0x36, 0x8e, +// 0xa0, 0x2c, 0x60, 0x48, 0xc9, 0x91, 0xd6, 0x92, 0x66, 0xa1, 0x70, 0xa2, 0x8b, 0xa6, 0x9e, 0x60, +// 0x1d, 0xad, 0x0f, 0x63, 0x14, 0x55, 0xca, 0xe2, 0x20, 0x74, 0xec, 0x88, 0x48, 0xda, 0xac, 0x4c, +// 0x1e, 0x20, 0x6b, 0xe1, 0x22, 0x76, 0x94, 0x1f, 0xb3, 0x62, 0x95, 0x1c, 0x5a, 0x48, 0xe0, 0xec, +// 0x7f, 0xc3, 0x8c, 0x0b, 0x86, 0x47, 0x23, 0x4c, 0xf5, 0xaa, 0x42, 0x06, 0x04, 0x39, 0x79, 0xe0, +// 0xea, 0x34, 0x81, 0xac, 0xf6, 0x1d, 0x40, 0x5d, 0xf4, 0x84, 0x90, 0x6e, 0xa3, 0x27, 0x1e, 0x22, +// 0x9e, 0xab, 0xc7, 0x0a, 0x37, 0x02, 0x81, 0x81, 0x00, 0x85, 0xee, 0x09, 0x5e, 0x36, 0x6f, 0x0f, +// 0x95, 0x03, 0x80, 0x3e, 0x08, 0xa4, 0x8a, 0x91, 0x06, 0xb3, 0xff, 0x79, 0x06, 0x31, 0x5b, 0x18, +// 0xeb, 0xfd, 0x2f, 0xa9, 0x0d, 0x19, 0x9d, 0xc4, 0xf0, 0x02, 0xf7, 0x4d, 0x77, 0x23, 0xd7, 0x68, +// 0xbf, 0xef, 0x15, 0x43, 0x33, 0xa1, 0x79, 0x7f, 0xc5, 0xc1, 0xfd, 0xc7, 0xa7, 0xba, 0xfb, 0xac, +// 0x24, 0xb1, 0x82, 0x0c, 0xe1, 0x17, 0xb5, 0xda, 0x05, 0x4c, 0x90, 0x80, 0xd8, 0x82, 0x62, 0x2c, +// 0x6d, 0xc8, 0x65, 0xac, 0xa1, 0xb6, 0x6f, 0x82, 0xbd, 0xfd, 0x5f, 0x06, 0x65, 0x7f, 0xda, 0x8b, +// 0xee, 0xb8, 0x8a, 0x4e, 0x59, 0x8b, 0xb3, 0x5e, 0xfc, 0xf0, 0x6d, 0x2f, 0xbc, 0x31, 0x2b, 0xb6, +// 0x97, 0x84, 0x88, 0x0e, 0x51, 0x9b, 0x03, 0x38, 0x56, 0x34, 0x8a, 0x80, 0x7f, 0x67, 0x85, 0x3f, +// 0x70, 0xad, 0x99, 0x20, 0x5e, 0x2a, 0xf2, 0x97, 0x38 +// }; +// unsigned int const prv_bytes_len = 1193; +// +//#pragma clang diagnostic push +//#pragma clang diagnostic ignored "-Wcast-qual" +// NSData * const publicKeyData = [NSData dataWithBytesNoCopy:(void *)pub_bytes length:pub_bytes_len freeWhenDone:NO]; +// NSData * const privateKeyData = [NSData dataWithBytesNoCopy:(void *)prv_bytes length:prv_bytes_len freeWhenDone:NO]; +//#pragma clang diagnostic pop +// +// NSString * const keyTag = @"STSecurityTest.testInsertion"; +// STSecurityRSAPublicKey *publicKey = nil; +// STSecurityRSAPrivateKey *privateKey = nil; +// +// { +// NSError *error = nil; +// BOOL status = [STSecurityKeychainAccess insertRSAKeypairWithPublicKeyData:publicKeyData privateKeyData:privateKeyData intoKeychainWithAccessibility:STSecurityKeychainItemAccessibleAlways tag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; +// XCTAssertTrue(status, @"Keychain could not insertion key pair"); +// XCTAssertNil(error, @"Key insertion returned error: %@", error); +// } +// XCTAssertNotNil(publicKey, @"Key insertion resulted in no public key"); +// XCTAssertNotNil(privateKey, @"Key insertion resulted in no private key"); +// +// { +// NSError *error = nil; +// BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:&error]; +// XCTAssertTrue(status, @"Keychain could not delete public key"); +// XCTAssertNil(error, @"Public key deletion returned error: %@", error); +// } +//} +// +//@end diff --git a/STSecurityTests/STSecurityRSAEncryptionTests.m b/STSecurityTests/STSecurityRSAEncryptionTests.m index e344d01..e1ee4ee 100644 --- a/STSecurityTests/STSecurityRSAEncryptionTests.m +++ b/STSecurityTests/STSecurityRSAEncryptionTests.m @@ -1,296 +1,296 @@ +//// +//// STSecurityRSAEncryptionTests.m +//// STSecurity +//// +//// Copyright (c) 2012 Scott Talbot. All rights reserved. +//// // -// STSecurityRSAEncryptionTests.m -// STSecurity -// -// Copyright (c) 2012 Scott Talbot. All rights reserved. -// - -@import XCTest; - -#import "STSecurity.h" - - -@interface STSecurityRSAEncryptionTests : XCTestCase -@end - -@implementation STSecurityRSAEncryptionTests - -#if !defined(TRAVIS) || !(TRAVIS + 0) - -- (void)testEncryptionInvalid { - NSString * const keyTag = @"STSecurityTest.testEncryptionInvalid"; - STSecurityRSAPublicKey *publicKey = nil; - STSecurityRSAPrivateKey *privateKey = nil; - NSUInteger keySize = 512; - - [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:NULL]; - - { - NSError *error = nil; - BOOL status = [STSecurityKeychainAccess generateRSAKeypairOfSize:keySize insertedIntoKeychainWithTag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; - XCTAssertTrue(status, @"Keychain could not generate key pair"); - XCTAssertNil(error, @"Key generation returned error: %@", error); - } - XCTAssertNotNil(publicKey, @"Key generation resulted in no public key"); - XCTAssertNotNil(privateKey, @"Key generation resulted in no private key"); - - { - NSError *error = nil; - NSData *data = [STSecurityRSAEncryption dataByEncryptingData:nil withPublicKey:publicKey padding:STSecurityRSAPaddingPKCS1 error:&error]; - XCTAssertNil(data); - XCTAssertNil(error); - } - - { - NSError *error = nil; - NSData *data = [STSecurityRSAEncryption dataByEncryptingData:[NSData data] withPublicKey:publicKey padding:STSecurityRSAPaddingPKCS1 error:&error]; - XCTAssertNotNil(data); - XCTAssertNil(error); - } - - { - NSError *error = nil; - BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:&error]; - XCTAssertTrue(status, @"Keychain could not delete public key"); - XCTAssertNil(error, @"Public key deletion returned error: %@", error); - } -} - -- (void)_st_testEncryptionRoundtripWithData:(NSData *)data keySize:(NSUInteger)keySize padding:(enum STSecurityRSAPadding)padding { - NSString * const keyTag = @"STSecurityTest.testEncryption"; - STSecurityRSAPublicKey *publicKey = nil; - STSecurityRSAPrivateKey *privateKey = nil; - - { - NSError *error = nil; - BOOL status = [STSecurityKeychainAccess generateRSAKeypairOfSize:keySize insertedIntoKeychainWithTag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; - XCTAssertTrue(status, @"Keychain could not generate key pair"); - XCTAssertNil(error, @"Key generation returned error: %@", error); - } - XCTAssertNotNil(publicKey, @"Key generation resulted in no public key"); - XCTAssertNotNil(privateKey, @"Key generation resulted in no private key"); - - NSData *dataEncrypted = nil; - { - NSError *error = nil; - dataEncrypted = [STSecurityRSAEncryption dataByEncryptingData:data withPublicKey:publicKey padding:padding error:&error]; - XCTAssertNotNil(dataEncrypted, @"Encryption returned nil data"); - XCTAssertNil(error, @"Encryption returned error: %@", error); - } - XCTAssertFalse([data isEqualToData:dataEncrypted], @"Encrypted data isEqual: initial"); - - NSData *dataDecrypted = nil; - { - NSError *error = nil; - dataDecrypted = [STSecurityRSAEncryption dataByDecryptingData:dataEncrypted withPrivateKey:privateKey padding:padding error:&error]; - XCTAssertNotNil(dataDecrypted, @"Decryption returned nil data"); - XCTAssertNil(error, @"Decryption returned error: %@", error); - } - XCTAssertEqualObjects(data, dataDecrypted, @"Decrypted data doesn't match input"); - - { - NSError *error = nil; - BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:&error]; - XCTAssertTrue(status, @"Keychain could not delete public key"); - XCTAssertNil(error, @"Public key deletion returned error: %@", error); - } -} - -- (void)testEncryptionRoundtrip0 { - [self _st_testEncryptionRoundtripWithData:[@"plaintext" dataUsingEncoding:NSUTF8StringEncoding] keySize:1024 padding:STSecurityRSAPaddingPKCS1]; -} - -- (void)testEncryptionRoundtrip1 { - NSData *randomData = [STSecurityRandomization dataWithRandomBytesOfLength:16]; - NSMutableData *data = [NSMutableData dataWithCapacity:128]; - while ([data length] < 128) { - [data appendData:randomData]; - } - [data setLength:128 - 11]; - [self _st_testEncryptionRoundtripWithData:data keySize:1024 padding:STSecurityRSAPaddingPKCS1]; -} - -- (void)testEncryptionRoundtrip2 { - NSData *randomData = [STSecurityRandomization dataWithRandomBytesOfLength:16]; - NSMutableData *data = [NSMutableData dataWithCapacity:64]; - for (int i = 0; i < 4; ++i) { - [data appendData:randomData]; - } - [data setLength:64]; - [self _st_testEncryptionRoundtripWithData:data keySize:1024 padding:STSecurityRSAPaddingOAEP]; -} -#endif - -- (void)testEncryptionInserted { - NSString * const keyTag = @"STSecurityTest.testInsertion"; - STSecurityRSAPublicKey *publicKey = nil; - STSecurityRSAPrivateKey *privateKey = nil; - - unsigned char const pub_bytes[] = { - 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, - 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, - 0x00, 0xb6, 0x63, 0x51, 0x02, 0xee, 0xd9, 0x71, 0x5e, 0x2e, 0x88, 0x6a, 0x61, 0xd1, 0x6a, 0x22, - 0xb6, 0x7d, 0x3e, 0xae, 0xb3, 0xf1, 0x2c, 0x7f, 0xa7, 0xb3, 0xd7, 0xe1, 0x1e, 0x25, 0x41, 0x38, - 0xc4, 0xab, 0xef, 0x43, 0xd8, 0x93, 0x55, 0xff, 0x42, 0x89, 0xda, 0x54, 0x46, 0x8b, 0xce, 0x54, - 0x06, 0x28, 0x9d, 0xae, 0x42, 0x12, 0xf3, 0x3f, 0x26, 0x70, 0x31, 0x03, 0x6f, 0xa5, 0x61, 0x08, - 0x48, 0x73, 0xd7, 0xdf, 0x74, 0x65, 0x01, 0xec, 0xb8, 0x48, 0x11, 0xdf, 0x45, 0x8d, 0x2c, 0x98, - 0x08, 0xd9, 0x49, 0xbd, 0xfb, 0x71, 0x52, 0x21, 0xd6, 0x15, 0x84, 0xf8, 0xde, 0xfa, 0xcc, 0xdd, - 0x12, 0xbc, 0xad, 0xd5, 0x7e, 0xac, 0x7b, 0x6e, 0xcf, 0x52, 0xdb, 0xf6, 0x6e, 0x22, 0x65, 0xd0, - 0xa5, 0xfd, 0x39, 0xc6, 0xbc, 0xbb, 0x4a, 0x3a, 0x55, 0xfd, 0xd5, 0x2a, 0xe7, 0xee, 0x7e, 0xaf, - 0x6f, 0xc3, 0x7c, 0x8b, 0x0e, 0x6c, 0xb4, 0xfb, 0x51, 0xb9, 0x22, 0xa1, 0x4a, 0xb0, 0x6d, 0x21, - 0x6d, 0xe4, 0xc4, 0x9c, 0x72, 0x26, 0xe7, 0xef, 0x76, 0xa6, 0xaf, 0x84, 0x5e, 0xff, 0x4a, 0x90, - 0x93, 0x49, 0xfb, 0x4c, 0xee, 0xdc, 0x87, 0x5f, 0x9a, 0xfa, 0x8b, 0x07, 0xaa, 0x96, 0x5c, 0xe9, - 0x34, 0x51, 0x5e, 0x8c, 0x14, 0xc5, 0x48, 0x1e, 0x42, 0x7d, 0x10, 0xfb, 0xbd, 0x62, 0x4a, 0xfc, - 0x96, 0x57, 0xea, 0x4c, 0x0c, 0x7d, 0xd1, 0x18, 0x3e, 0xd2, 0xea, 0xd7, 0x0d, 0xad, 0x5d, 0xfd, - 0x3a, 0xc6, 0xb9, 0xed, 0x78, 0x22, 0xf3, 0x7f, 0x69, 0xe6, 0xb8, 0x0c, 0x09, 0xe4, 0xf0, 0x7f, - 0x8a, 0xc6, 0x1b, 0xe3, 0x63, 0xae, 0x57, 0xe7, 0x6c, 0xe7, 0x92, 0xb7, 0x7b, 0xab, 0x74, 0xdb, - 0x1f, 0x69, 0x3c, 0x45, 0x41, 0x8d, 0x29, 0xd0, 0xda, 0xe7, 0x99, 0xd4, 0xc7, 0x40, 0x58, 0xce, - 0x23, 0x02, 0x03, 0x01, 0x00, 0x01 - }; - unsigned int const pub_bytes_len = 294; - - unsigned char const prv_bytes[] = { - 0x30, 0x82, 0x04, 0xa5, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, 0xb6, 0x63, 0x51,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f3, 0x96, - 0xf5, 0x02, 0x81, 0x81, 0x00, 0xb6, 0xa5, 0x2a, 0x16, 0x0e, 0xe8, 0x95, 0x4c, 0xa7, 0x7b, 0x92, - 0x5e, 0x5e, 0x34, 0x00, 0x14, 0x16, 0xb2, 0x24, 0xfd, 0x20, 0x66, 0x29, 0xd6, 0x82, 0xa1, 0x71, - 0x55, 0xb0, 0x83, 0x37, 0x2e, 0x8c, 0xcc, 0x82, 0xaa, 0x54, 0x7f, 0xa0, 0x5b, 0x22, 0x36, 0x8e, - 0xa0, 0x2c, 0x60, 0x48, 0xc9, 0x91, 0xd6, 0x92, 0x66, 0xa1, 0x70, 0xa2, 0x8b, 0xa6, 0x9e, 0x60, - 0x1d, 0xad, 0x0f, 0x63, 0x14, 0x55, 0xca, 0xe2, 0x20, 0x74, 0xec, 0x88, 0x48, 0xda, 0xac, 0x4c, - 0x1e, 0x20, 0x6b, 0xe1, 0x22, 0x76, 0x94, 0x1f, 0xb3, 0x62, 0x95, 0x1c, 0x5a, 0x48, 0xe0, 0xec, - 0x7f, 0xc3, 0x8c, 0x0b, 0x86, 0x47, 0x23, 0x4c, 0xf5, 0xaa, 0x42, 0x06, 0x04, 0x39, 0x79, 0xe0, - 0xea, 0x34, 0x81, 0xac, 0xf6, 0x1d, 0x40, 0x5d, 0xf4, 0x84, 0x90, 0x6e, 0xa3, 0x27, 0x1e, 0x22, - 0x9e, 0xab, 0xc7, 0x0a, 0x37, 0x02, 0x81, 0x81, 0x00, 0x85, 0xee, 0x09, 0x5e, 0x36, 0x6f, 0x0f, - 0x95, 0x03, 0x80, 0x3e, 0x08, 0xa4, 0x8a, 0x91, 0x06, 0xb3, 0xff, 0x79, 0x06, 0x31, 0x5b, 0x18, - 0xeb, 0xfd, 0x2f, 0xa9, 0x0d, 0x19, 0x9d, 0xc4, 0xf0, 0x02, 0xf7, 0x4d, 0x77, 0x23, 0xd7, 0x68, - 0xbf, 0xef, 0x15, 0x43, 0x33, 0xa1, 0x79, 0x7f, 0xc5, 0xc1, 0xfd, 0xc7, 0xa7, 0xba, 0xfb, 0xac, - 0x24, 0xb1, 0x82, 0x0c, 0xe1, 0x17, 0xb5, 0xda, 0x05, 0x4c, 0x90, 0x80, 0xd8, 0x82, 0x62, 0x2c, - 0x6d, 0xc8, 0x65, 0xac, 0xa1, 0xb6, 0x6f, 0x82, 0xbd, 0xfd, 0x5f, 0x06, 0x65, 0x7f, 0xda, 0x8b, - 0xee, 0xb8, 0x8a, 0x4e, 0x59, 0x8b, 0xb3, 0x5e, 0xfc, 0xf0, 0x6d, 0x2f, 0xbc, 0x31, 0x2b, 0xb6, - 0x97, 0x84, 0x88, 0x0e, 0x51, 0x9b, 0x03, 0x38, 0x56, 0x34, 0x8a, 0x80, 0x7f, 0x67, 0x85, 0x3f, - 0x70, 0xad, 0x99, 0x20, 0x5e, 0x2a, 0xf2, 0x97, 0x38 - }; - unsigned int const prv_bytes_len = 1193; - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wcast-qual" - NSData * const publicKeyData = [NSData dataWithBytesNoCopy:(void *)pub_bytes length:pub_bytes_len freeWhenDone:NO]; - NSData * const privateKeyData = [NSData dataWithBytesNoCopy:(void *)prv_bytes length:prv_bytes_len freeWhenDone:NO]; -#pragma clang diagnostic pop - - unsigned char const plaintext_bytes[] = { - 0x70, 0x6c, 0x61, 0x69, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x0a - }; - unsigned int const plaintext_bytes_len = 10; - - unsigned char const ciphertext_bytes[] = { - 0x7e, 0x7f, 0x35, 0xf0, 0x10, 0x3b, 0xf5, 0x8b, 0x72, 0xb1, 0xad, 0xea, 0x4d, 0x50, 0xca, 0xfb, - 0xb9, 0xb8, 0x9c, 0x01, 0xe4, 0xbd, 0x63, 0x7a, 0xd5, 0x73, 0x80, 0x23, 0x9f, 0x9a, 0xf1, 0xff, - 0x63, 0xc4, 0x3a, 0xd6, 0xa3, 0xe4, 0xbb, 0x47, 0xd1, 0x64, 0x1e, 0x4f,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 0x74, 0x71, 0x38, 0xeb, 0xe7, 0x9f, 0x50, 0xfb, 0x14, 0x24, 0xbe, 0x40, 0xc5, 0x9c, - 0xfd, 0x96, 0x9e, 0x66, 0x73, 0x3c, 0x20, 0xff, 0xa6, 0x64, 0xe4, 0x93, 0xe9, 0xa4, 0x44, 0x20 - }; - unsigned int const ciphertext_bytes_len = 256; - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wcast-qual" - NSData * const plaintextDataExpected = [NSData dataWithBytesNoCopy:(void *)plaintext_bytes length:plaintext_bytes_len freeWhenDone:NO]; - NSData * const ciphertextData = [NSData dataWithBytesNoCopy:(void *)ciphertext_bytes length:ciphertext_bytes_len freeWhenDone:NO]; -#pragma clang diagnostic pop - - [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:NULL]; - - { - NSError *error = nil; - BOOL status = [STSecurityKeychainAccess insertRSAKeypairWithPublicKeyData:publicKeyData privateKeyData:privateKeyData intoKeychainWithAccessibility:STSecurityKeychainItemAccessibleAlways tag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; - XCTAssertTrue(status, @"Keychain could not insertion key pair"); - XCTAssertNil(error, @"Key insertion returned error: %@", error); - } - XCTAssertNotNil(publicKey, @"Key insertion resulted in no public key"); - XCTAssertNotNil(privateKey, @"Key insertion resulted in no private key"); - - NSData *ciphertextDataDecrypted = nil; - { - NSError *error = nil; - ciphertextDataDecrypted = [STSecurityRSAEncryption dataByDecryptingData:ciphertextData withPrivateKey:privateKey padding:STSecurityRSAPaddingPKCS1 error:&error]; - XCTAssertNotNil(ciphertextDataDecrypted); - XCTAssertNil(error, @"error: %@", error); - } - XCTAssertEqualObjects(ciphertextDataDecrypted, plaintextDataExpected); - - { - NSError *error = nil; - BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:&error]; - XCTAssertTrue(status, @"Keychain could not delete public key"); - XCTAssertNil(error, @"Public key deletion returned error: %@", error); - } -} - -@end +//@import XCTest; +// +//#import "STSecurity.h" +// +// +//@interface STSecurityRSAEncryptionTests : XCTestCase +//@end +// +//@implementation STSecurityRSAEncryptionTests +// +//#if !defined(TRAVIS) || !(TRAVIS + 0) +// +//- (void)testEncryptionInvalid { +// NSString * const keyTag = @"STSecurityTest.testEncryptionInvalid"; +// STSecurityRSAPublicKey *publicKey = nil; +// STSecurityRSAPrivateKey *privateKey = nil; +// NSUInteger keySize = 512; +// +// [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:NULL]; +// +// { +// NSError *error = nil; +// BOOL status = [STSecurityKeychainAccess generateRSAKeypairOfSize:keySize insertedIntoKeychainWithTag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; +// XCTAssertTrue(status, @"Keychain could not generate key pair"); +// XCTAssertNil(error, @"Key generation returned error: %@", error); +// } +// XCTAssertNotNil(publicKey, @"Key generation resulted in no public key"); +// XCTAssertNotNil(privateKey, @"Key generation resulted in no private key"); +// +// { +// NSError *error = nil; +// NSData *data = [STSecurityRSAEncryption dataByEncryptingData:nil withPublicKey:publicKey padding:STSecurityRSAPaddingPKCS1 error:&error]; +// XCTAssertNil(data); +// XCTAssertNil(error); +// } +// +// { +// NSError *error = nil; +// NSData *data = [STSecurityRSAEncryption dataByEncryptingData:[NSData data] withPublicKey:publicKey padding:STSecurityRSAPaddingPKCS1 error:&error]; +// XCTAssertNotNil(data); +// XCTAssertNil(error); +// } +// +// { +// NSError *error = nil; +// BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:&error]; +// XCTAssertTrue(status, @"Keychain could not delete public key"); +// XCTAssertNil(error, @"Public key deletion returned error: %@", error); +// } +//} +// +//- (void)_st_testEncryptionRoundtripWithData:(NSData *)data keySize:(NSUInteger)keySize padding:(enum STSecurityRSAPadding)padding { +// NSString * const keyTag = @"STSecurityTest.testEncryption"; +// STSecurityRSAPublicKey *publicKey = nil; +// STSecurityRSAPrivateKey *privateKey = nil; +// +// { +// NSError *error = nil; +// BOOL status = [STSecurityKeychainAccess generateRSAKeypairOfSize:keySize insertedIntoKeychainWithTag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; +// XCTAssertTrue(status, @"Keychain could not generate key pair"); +// XCTAssertNil(error, @"Key generation returned error: %@", error); +// } +// XCTAssertNotNil(publicKey, @"Key generation resulted in no public key"); +// XCTAssertNotNil(privateKey, @"Key generation resulted in no private key"); +// +// NSData *dataEncrypted = nil; +// { +// NSError *error = nil; +// dataEncrypted = [STSecurityRSAEncryption dataByEncryptingData:data withPublicKey:publicKey padding:padding error:&error]; +// XCTAssertNotNil(dataEncrypted, @"Encryption returned nil data"); +// XCTAssertNil(error, @"Encryption returned error: %@", error); +// } +// XCTAssertFalse([data isEqualToData:dataEncrypted], @"Encrypted data isEqual: initial"); +// +// NSData *dataDecrypted = nil; +// { +// NSError *error = nil; +// dataDecrypted = [STSecurityRSAEncryption dataByDecryptingData:dataEncrypted withPrivateKey:privateKey padding:padding error:&error]; +// XCTAssertNotNil(dataDecrypted, @"Decryption returned nil data"); +// XCTAssertNil(error, @"Decryption returned error: %@", error); +// } +// XCTAssertEqualObjects(data, dataDecrypted, @"Decrypted data doesn't match input"); +// +// { +// NSError *error = nil; +// BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:&error]; +// XCTAssertTrue(status, @"Keychain could not delete public key"); +// XCTAssertNil(error, @"Public key deletion returned error: %@", error); +// } +//} +// +//- (void)testEncryptionRoundtrip0 { +// [self _st_testEncryptionRoundtripWithData:[@"plaintext" dataUsingEncoding:NSUTF8StringEncoding] keySize:1024 padding:STSecurityRSAPaddingPKCS1]; +//} +// +//- (void)testEncryptionRoundtrip1 { +// NSData *randomData = [STSecurityRandomization dataWithRandomBytesOfLength:16]; +// NSMutableData *data = [NSMutableData dataWithCapacity:128]; +// while ([data length] < 128) { +// [data appendData:randomData]; +// } +// [data setLength:128 - 11]; +// [self _st_testEncryptionRoundtripWithData:data keySize:1024 padding:STSecurityRSAPaddingPKCS1]; +//} +// +//- (void)testEncryptionRoundtrip2 { +// NSData *randomData = [STSecurityRandomization dataWithRandomBytesOfLength:16]; +// NSMutableData *data = [NSMutableData dataWithCapacity:64]; +// for (int i = 0; i < 4; ++i) { +// [data appendData:randomData]; +// } +// [data setLength:64]; +// [self _st_testEncryptionRoundtripWithData:data keySize:1024 padding:STSecurityRSAPaddingOAEP]; +//} +//#endif +// +//- (void)testEncryptionInserted { +// NSString * const keyTag = @"STSecurityTest.testInsertion"; +// STSecurityRSAPublicKey *publicKey = nil; +// STSecurityRSAPrivateKey *privateKey = nil; +// +// unsigned char const pub_bytes[] = { +// 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, +// 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, +// 0x00, 0xb6, 0x63, 0x51, 0x02, 0xee, 0xd9, 0x71, 0x5e, 0x2e, 0x88, 0x6a, 0x61, 0xd1, 0x6a, 0x22, +// 0xb6, 0x7d, 0x3e, 0xae, 0xb3, 0xf1, 0x2c, 0x7f, 0xa7, 0xb3, 0xd7, 0xe1, 0x1e, 0x25, 0x41, 0x38, +// 0xc4, 0xab, 0xef, 0x43, 0xd8, 0x93, 0x55, 0xff, 0x42, 0x89, 0xda, 0x54, 0x46, 0x8b, 0xce, 0x54, +// 0x06, 0x28, 0x9d, 0xae, 0x42, 0x12, 0xf3, 0x3f, 0x26, 0x70, 0x31, 0x03, 0x6f, 0xa5, 0x61, 0x08, +// 0x48, 0x73, 0xd7, 0xdf, 0x74, 0x65, 0x01, 0xec, 0xb8, 0x48, 0x11, 0xdf, 0x45, 0x8d, 0x2c, 0x98, +// 0x08, 0xd9, 0x49, 0xbd, 0xfb, 0x71, 0x52, 0x21, 0xd6, 0x15, 0x84, 0xf8, 0xde, 0xfa, 0xcc, 0xdd, +// 0x12, 0xbc, 0xad, 0xd5, 0x7e, 0xac, 0x7b, 0x6e, 0xcf, 0x52, 0xdb, 0xf6, 0x6e, 0x22, 0x65, 0xd0, +// 0xa5, 0xfd, 0x39, 0xc6, 0xbc, 0xbb, 0x4a, 0x3a, 0x55, 0xfd, 0xd5, 0x2a, 0xe7, 0xee, 0x7e, 0xaf, +// 0x6f, 0xc3, 0x7c, 0x8b, 0x0e, 0x6c, 0xb4, 0xfb, 0x51, 0xb9, 0x22, 0xa1, 0x4a, 0xb0, 0x6d, 0x21, +// 0x6d, 0xe4, 0xc4, 0x9c, 0x72, 0x26, 0xe7, 0xef, 0x76, 0xa6, 0xaf, 0x84, 0x5e, 0xff, 0x4a, 0x90, +// 0x93, 0x49, 0xfb, 0x4c, 0xee, 0xdc, 0x87, 0x5f, 0x9a, 0xfa, 0x8b, 0x07, 0xaa, 0x96, 0x5c, 0xe9, +// 0x34, 0x51, 0x5e, 0x8c, 0x14, 0xc5, 0x48, 0x1e, 0x42, 0x7d, 0x10, 0xfb, 0xbd, 0x62, 0x4a, 0xfc, +// 0x96, 0x57, 0xea, 0x4c, 0x0c, 0x7d, 0xd1, 0x18, 0x3e, 0xd2, 0xea, 0xd7, 0x0d, 0xad, 0x5d, 0xfd, +// 0x3a, 0xc6, 0xb9, 0xed, 0x78, 0x22, 0xf3, 0x7f, 0x69, 0xe6, 0xb8, 0x0c, 0x09, 0xe4, 0xf0, 0x7f, +// 0x8a, 0xc6, 0x1b, 0xe3, 0x63, 0xae, 0x57, 0xe7, 0x6c, 0xe7, 0x92, 0xb7, 0x7b, 0xab, 0x74, 0xdb, +// 0x1f, 0x69, 0x3c, 0x45, 0x41, 0x8d, 0x29, 0xd0, 0xda, 0xe7, 0x99, 0xd4, 0xc7, 0x40, 0x58, 0xce, +// 0x23, 0x02, 0x03, 0x01, 0x00, 0x01 +// }; +// unsigned int const pub_bytes_len = 294; +// +// unsigned char const prv_bytes[] = { +// 0x30, 0x82, 0x04, 0xa5, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, 0xb6, 0x63, 0x51, 0x02, +// 0xee, 0xd9, 0x71, 0x5e, 0x2e, 0x88, 0x6a, 0x61, 0xd1, 0x6a, 0x22, 0xb6, 0x7d, 0x3e, 0xae, 0xb3, +// 0xf1, 0x2c, 0x7f, 0xa7, 0xb3, 0xd7, 0xe1, 0x1e, 0x25, 0x41, 0x38, 0xc4, 0xab, 0xef, 0x43, 0xd8, +// 0x93, 0x55, 0xff, 0x42, 0x89, 0xda, 0x54, 0x46, 0x8b, 0xce, 0x54, 0x06, 0x28, 0x9d, 0xae, 0x42, +// 0x12, 0xf3, 0x3f, 0x26, 0x70, 0x31, 0x03, 0x6f, 0xa5, 0x61, 0x08, 0x48, 0x73, 0xd7, 0xdf, 0x74, +// 0x65, 0x01, 0xec, 0xb8, 0x48, 0x11, 0xdf, 0x45, 0x8d, 0x2c, 0x98, 0x08, 0xd9, 0x49, 0xbd, 0xfb, +// 0x71, 0x52, 0x21, 0xd6, 0x15, 0x84, 0xf8, 0xde, 0xfa, 0xcc, 0xdd, 0x12, 0xbc, 0xad, 0xd5, 0x7e, +// 0xac, 0x7b, 0x6e, 0xcf, 0x52, 0xdb, 0xf6, 0x6e, 0x22, 0x65, 0xd0, 0xa5, 0xfd, 0x39, 0xc6, 0xbc, +// 0xbb, 0x4a, 0x3a, 0x55, 0xfd, 0xd5, 0x2a, 0xe7, 0xee, 0x7e, 0xaf, 0x6f, 0xc3, 0x7c, 0x8b, 0x0e, +// 0x6c, 0xb4, 0xfb, 0x51, 0xb9, 0x22, 0xa1, 0x4a, 0xb0, 0x6d, 0x21, 0x6d, 0xe4, 0xc4, 0x9c, 0x72, +// 0x26, 0xe7, 0xef, 0x76, 0xa6, 0xaf, 0x84, 0x5e, 0xff, 0x4a, 0x90, 0x93, 0x49, 0xfb, 0x4c, 0xee, +// 0xdc, 0x87, 0x5f, 0x9a, 0xfa, 0x8b, 0x07, 0xaa, 0x96, 0x5c, 0xe9, 0x34, 0x51, 0x5e, 0x8c, 0x14, +// 0xc5, 0x48, 0x1e, 0x42, 0x7d, 0x10, 0xfb, 0xbd, 0x62, 0x4a, 0xfc, 0x96, 0x57, 0xea, 0x4c, 0x0c, +// 0x7d, 0xd1, 0x18, 0x3e, 0xd2, 0xea, 0xd7, 0x0d, 0xad, 0x5d, 0xfd, 0x3a, 0xc6, 0xb9, 0xed, 0x78, +// 0x22, 0xf3, 0x7f, 0x69, 0xe6, 0xb8, 0x0c, 0x09, 0xe4, 0xf0, 0x7f, 0x8a, 0xc6, 0x1b, 0xe3, 0x63, +// 0xae, 0x57, 0xe7, 0x6c, 0xe7, 0x92, 0xb7, 0x7b, 0xab, 0x74, 0xdb, 0x1f, 0x69, 0x3c, 0x45, 0x41, +// 0x8d, 0x29, 0xd0, 0xda, 0xe7, 0x99, 0xd4, 0xc7, 0x40, 0x58, 0xce, 0x23, 0x02, 0x03, 0x01, 0x00, +// 0x01, 0x02, 0x82, 0x01, 0x00, 0x08, 0xce, 0x2a, 0xaf, 0x15, 0x90, 0xf1, 0xe4, 0x36, 0x22, 0xe7, +// 0xdf, 0xe9, 0x18, 0x52, 0xac, 0xb4, 0xc7, 0x3d, 0xef, 0xfa, 0x08, 0xc7, 0xf0, 0xf4, 0xc1, 0xcb, +// 0x60, 0x85, 0x33, 0xec, 0xe5, 0xb1, 0xd7, 0x4f, 0x53, 0x39, 0x69, 0xc1, 0x75, 0x18, 0xea, 0xad, +// 0x7e, 0xea, 0x68, 0xff, 0xad, 0x7c, 0x70, 0x80, 0x65, 0x38, 0x3c, 0xfe, 0x23, 0x80, 0xef, 0x1c, +// 0xd7, 0x5b, 0x08, 0xa0, 0x39, 0xbf, 0x3e, 0x00, 0xcf, 0xc1, 0xc0, 0xa2, 0x09, 0x13, 0x91, 0xa9, +// 0x51, 0xd6, 0x4a, 0xfc, 0xdc, 0x10, 0x81, 0x7a, 0xe6, 0x94, 0xc5, 0xfe, 0x54, 0x33, 0x9d, 0xc3, +// 0xd6, 0x20, 0x0d, 0x9b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 0x6d, 0xf9, 0x66, 0xb9, 0x7f, 0x23, 0x91, 0x8a, 0x73, 0x0b, +// 0x65, 0x63, 0xd7, 0xe9, 0xf5, 0x86, 0x72, 0x8f, 0x9b, 0xc4, 0x48, 0x80, 0x1c, 0xd7, 0xae, 0x06, +// 0xa4, 0x58, 0x5c, 0x13, 0x7d, 0x47, 0xb1, 0x30, 0xc0, 0xb9, 0x51, 0xa2, 0x92, 0x72, 0x02, 0xdf, +// 0xd8, 0xae, 0x3c, 0xff, 0xa7, 0x1c, 0x7b, 0xb3, 0x1f, 0x68, 0xf1, 0x20, 0xd3, 0x36, 0xbe, 0xa3, +// 0x1f, 0x26, 0x43, 0x62, 0x4e, 0x3d, 0xc8, 0xde, 0x87, 0x41, 0x3b, 0x4e, 0x60, 0x30, 0xc2, 0x9b, +// 0xda, 0xd6, 0xf1, 0xe6, 0xda, 0xa9, 0x85, 0xd4, 0x47, 0xa8, 0xe3, 0x51, 0x99, 0x85, 0x77, 0xd9, +// 0x70, 0x09, 0xfd, 0x0b, 0x88, 0x20, 0xac, 0x1f, 0x2f, 0x19, 0xf8, 0x47, 0x31, 0xa7, 0xf7, 0x73, +// 0xa0, 0x41, 0x4b, 0xfd, 0x6d, 0xe2, 0xc0, 0xef, 0x65, 0x02, 0x81, 0x81, 0x00, 0xcd, 0x54, 0x03, +// 0x67, 0x7c, 0x4a, 0x3b, 0x47, 0x7f, 0x90, 0x66, 0x0f, 0xfe, 0xe2, 0xdf, 0xaa, 0xcd, 0xa3, 0x1a, +// 0xdb, 0xc1, 0x7f, 0xf3, 0x56, 0xa3, 0x5d, 0x7c, 0x82, 0xfd, 0xf4, 0x07, 0x28, 0x24, 0x0e, 0xaa, +// 0x23, 0xf6, 0x0c, 0x92, 0x59, 0x17, 0xe4, 0x49, 0x27, 0x51, 0xdc, 0x40, 0x47, 0x80, 0x83, 0x20, +// 0x1e, 0x70, 0x99, 0x41, 0xac, 0x59, 0xc8, 0xe6, 0xaf, 0x31, 0x23, 0x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1, +// 0x95, 0x57, 0x29, 0x6b, 0xaa, 0x6b, 0xcb, 0x7f, 0x94, 0x83, 0x23, 0xcf, 0x6e, 0x68, 0xf3, 0x96, +// 0xf5, 0x02, 0x81, 0x81, 0x00, 0xb6, 0xa5, 0x2a, 0x16, 0x0e, 0xe8, 0x95, 0x4c, 0xa7, 0x7b, 0x92, +// 0x5e, 0x5e, 0x34, 0x00, 0x14, 0x16, 0xb2, 0x24, 0xfd, 0x20, 0x66, 0x29, 0xd6, 0x82, 0xa1, 0x71, +// 0x55, 0xb0, 0x83, 0x37, 0x2e, 0x8c, 0xcc, 0x82, 0xaa, 0x54, 0x7f, 0xa0, 0x5b, 0x22, 0x36, 0x8e, +// 0xa0, 0x2c, 0x60, 0x48, 0xc9, 0x91, 0xd6, 0x92, 0x66, 0xa1, 0x70, 0xa2, 0x8b, 0xa6, 0x9e, 0x60, +// 0x1d, 0xad, 0x0f, 0x63, 0x14, 0x55, 0xca, 0xe2, 0x20, 0x74, 0xec, 0x88, 0x48, 0xda, 0xac, 0x4c, +// 0x1e, 0x20, 0x6b, 0xe1, 0x22, 0x76, 0x94, 0x1f, 0xb3, 0x62, 0x95, 0x1c, 0x5a, 0x48, 0xe0, 0xec, +// 0x7f, 0xc3, 0x8c, 0x0b, 0x86, 0x47, 0x23, 0x4c, 0xf5, 0xaa, 0x42, 0x06, 0x04, 0x39, 0x79, 0xe0, +// 0xea, 0x34, 0x81, 0xac, 0xf6, 0x1d, 0x40, 0x5d, 0xf4, 0x84, 0x90, 0x6e, 0xa3, 0x27, 0x1e, 0x22, +// 0x9e, 0xab, 0xc7, 0x0a, 0x37, 0x02, 0x81, 0x81, 0x00, 0x85, 0xee, 0x09, 0x5e, 0x36, 0x6f, 0x0f, +// 0x95, 0x03, 0x80, 0x3e, 0x08, 0xa4, 0x8a, 0x91, 0x06, 0xb3, 0xff, 0x79, 0x06, 0x31, 0x5b, 0x18, +// 0xeb, 0xfd, 0x2f, 0xa9, 0x0d, 0x19, 0x9d, 0xc4, 0xf0, 0x02, 0xf7, 0x4d, 0x77, 0x23, 0xd7, 0x68, +// 0xbf, 0xef, 0x15, 0x43, 0x33, 0xa1, 0x79, 0x7f, 0xc5, 0xc1, 0xfd, 0xc7, 0xa7, 0xba, 0xfb, 0xac, +// 0x24, 0xb1, 0x82, 0x0c, 0xe1, 0x17, 0xb5, 0xda, 0x05, 0x4c, 0x90, 0x80, 0xd8, 0x82, 0x62, 0x2c, +// 0x6d, 0xc8, 0x65, 0xac, 0xa1, 0xb6, 0x6f, 0x82, 0xbd, 0xfd, 0x5f, 0x06, 0x65, 0x7f, 0xda, 0x8b, +// 0xee, 0xb8, 0x8a, 0x4e, 0x59, 0x8b, 0xb3, 0x5e, 0xfc, 0xf0, 0x6d, 0x2f, 0xbc, 0x31, 0x2b, 0xb6, +// 0x97, 0x84, 0x88, 0x0e, 0x51, 0x9b, 0x03, 0x38, 0x56, 0x34, 0x8a, 0x80, 0x7f, 0x67, 0x85, 0x3f, +// 0x70, 0xad, 0x99, 0x20, 0x5e, 0x2a, 0xf2, 0x97, 0x38 +// }; +// unsigned int const prv_bytes_len = 1193; +// +//#pragma clang diagnostic push +//#pragma clang diagnostic ignored "-Wcast-qual" +// NSData * const publicKeyData = [NSData dataWithBytesNoCopy:(void *)pub_bytes length:pub_bytes_len freeWhenDone:NO]; +// NSData * const privateKeyData = [NSData dataWithBytesNoCopy:(void *)prv_bytes length:prv_bytes_len freeWhenDone:NO]; +//#pragma clang diagnostic pop +// +// unsigned char const plaintext_bytes[] = { +// 0x70, 0x6c, 0x61, 0x69, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x0a +// }; +// unsigned int const plaintext_bytes_len = 10; +// +// unsigned char const ciphertext_bytes[] = { +// 0x7e, 0x7f, 0x35, 0xf0, 0x10, 0x3b, 0xf5, 0x8b, 0x72, 0xb1, 0xad, 0xea, 0x4d, 0x50, 0xca, 0xfb, +// 0xb9, 0xb8, 0x9c, 0x01, 0xe4, 0xbd, 0x63, 0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0xf6, 0x95, 0xcc, 0x5c, 0xb0, +// 0x8f, 0xbf, 0x5d, 0xdb, 0xfa, 0x94, 0xf4, 0xff, 0x36, 0x65, 0x6b, 0x34, 0x75, 0x96, 0xaa, 0x59, +// 0xf1, 0x81, 0x74, 0x71, 0x38, 0xeb, 0xe7, 0x9f, 0x50, 0xfb, 0x14, 0x24, 0xbe, 0x40, 0xc5, 0x9c, +// 0xfd, 0x96, 0x9e, 0x66, 0x73, 0x3c, 0x20, 0xff, 0xa6, 0x64, 0xe4, 0x93, 0xe9, 0xa4, 0x44, 0x20 +// }; +// unsigned int const ciphertext_bytes_len = 256; +// +//#pragma clang diagnostic push +//#pragma clang diagnostic ignored "-Wcast-qual" +// NSData * const plaintextDataExpected = [NSData dataWithBytesNoCopy:(void *)plaintext_bytes length:plaintext_bytes_len freeWhenDone:NO]; +// NSData * const ciphertextData = [NSData dataWithBytesNoCopy:(void *)ciphertext_bytes length:ciphertext_bytes_len freeWhenDone:NO]; +//#pragma clang diagnostic pop +// +// [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:NULL]; +// +// { +// NSError *error = nil; +// BOOL status = [STSecurityKeychainAccess insertRSAKeypairWithPublicKeyData:publicKeyData privateKeyData:privateKeyData intoKeychainWithAccessibility:STSecurityKeychainItemAccessibleAlways tag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; +// XCTAssertTrue(status, @"Keychain could not insertion key pair"); +// XCTAssertNil(error, @"Key insertion returned error: %@", error); +// } +// XCTAssertNotNil(publicKey, @"Key insertion resulted in no public key"); +// XCTAssertNotNil(privateKey, @"Key insertion resulted in no private key"); +// +// NSData *ciphertextDataDecrypted = nil; +// { +// NSError *error = nil; +// ciphertextDataDecrypted = [STSecurityRSAEncryption dataByDecryptingData:ciphertextData withPrivateKey:privateKey padding:STSecurityRSAPaddingPKCS1 error:&error]; +// XCTAssertNotNil(ciphertextDataDecrypted); +// XCTAssertNil(error, @"error: %@", error); +// } +// XCTAssertEqualObjects(ciphertextDataDecrypted, plaintextDataExpected); +// +// { +// NSError *error = nil; +// BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:&error]; +// XCTAssertTrue(status, @"Keychain could not delete public key"); +// XCTAssertNil(error, @"Public key deletion returned error: %@", error); +// } +//} +// +//@end diff --git a/STSecurityTests/STSecurityRSAKeyTests.m b/STSecurityTests/STSecurityRSAKeyTests.m index ec9af9b..83c4868 100644 --- a/STSecurityTests/STSecurityRSAKeyTests.m +++ b/STSecurityTests/STSecurityRSAKeyTests.m @@ -1,43 +1,43 @@ +//// +//// STSecurityRSAKeyTests.m +//// STSecurity +//// +//// Copyright (c) 2012 Scott Talbot. All rights reserved. +//// // -// STSecurityRSAKeyTests.m -// STSecurity -// -// Copyright (c) 2012 Scott Talbot. All rights reserved. -// - -@import XCTest; - -#import -#import "STSecurityRSAKey+Internal.h" - - -@interface STSecurityRSAKeyTests : XCTestCase -@end - -@implementation STSecurityRSAKeyTests - -- (void)testPublicKeyInstantiation { - { - STSecurityRSAPublicKey *key; -#if defined(NS_BLOCK_ASSERTIONS) - key = [[STSecurityRSAPublicKey alloc] initWithKeyRef:NULL keyData:nil]; -#else - XCTAssertThrows(key = [[STSecurityRSAPublicKey alloc] initWithKeyRef:NULL keyData:nil], @"Creating public key with neither keyRef nor data didn't throw"); -#endif - XCTAssertNil(key, @"Created public key with neither keyRef nor keyData"); - } -} - -- (void)testPrivateKeyInstantiation { - { - STSecurityRSAPrivateKey *key; -#if defined(NS_BLOCK_ASSERTIONS) - key = [[STSecurityRSAPrivateKey alloc] initWithKeyRef:NULL]; -#else - XCTAssertThrows(key = [[STSecurityRSAPrivateKey alloc] initWithKeyRef:NULL], @"Creating private key with NULL keyRef"); -#endif - XCTAssertNil(key, @"Created private key with NULL keyRef"); - } -} - -@end +//@import XCTest; +// +//#import +//#import "STSecurityRSAKey+Internal.h" +// +// +//@interface STSecurityRSAKeyTests : XCTestCase +//@end +// +//@implementation STSecurityRSAKeyTests +// +//- (void)testPublicKeyInstantiation { +// { +// STSecurityRSAPublicKey *key; +//#if defined(NS_BLOCK_ASSERTIONS) +// key = [[STSecurityRSAPublicKey alloc] initWithKeyRef:NULL keyData:nil]; +//#else +// XCTAssertThrows(key = [[STSecurityRSAPublicKey alloc] initWithKeyRef:NULL keyData:nil], @"Creating public key with neither keyRef nor data didn't throw"); +//#endif +// XCTAssertNil(key, @"Created public key with neither keyRef nor keyData"); +// } +//} +// +//- (void)testPrivateKeyInstantiation { +// { +// STSecurityRSAPrivateKey *key; +//#if defined(NS_BLOCK_ASSERTIONS) +// key = [[STSecurityRSAPrivateKey alloc] initWithKeyRef:NULL]; +//#else +// XCTAssertThrows(key = [[STSecurityRSAPrivateKey alloc] initWithKeyRef:NULL], @"Creating private key with NULL keyRef"); +//#endif +// XCTAssertNil(key, @"Created private key with NULL keyRef"); +// } +//} +// +//@end diff --git a/project.yml b/project.yml new file mode 100644 index 0000000..2885238 --- /dev/null +++ b/project.yml @@ -0,0 +1,61 @@ +--- +name: STSecurity +attributes: + ORGANIZATIONNAME: "Scott Talbot" +options: + bundleIdPrefix: org.chikachow + deploymentTarget: + iOS: "11.4" + macOS: "10.14" +configFiles: + Debug: STSecurity/Project-Debug.xcconfig + Release: STSecurity/Project-Release.xcconfig +settings: + groups: + - swift +settingGroups: + swift: + base: + HEADER_SEARCH_PATHS: + - $(inherited) + - $(PROJECT_DIR) + RUN_CLANG_STATIC_ANALYZER: YES + SWIFT_VERSION: "5.0" + SWIFT_OPTIMIZATION_LEVEL: "-O" + configs: + Debug: + SWIFT_OPTIMIZATION_LEVEL: "-Onone" + Release: + SWIFT_COMPILATION_MODE: wholemodule + +targets: + STSecurity: + type: framework.static + platform: iOS + scheme: + testTargets: + - STSecurityTests + configFiles: + Debug: STSecurity/Target-Debug.xcconfig + Release: STSecurity/Target-Release.xcconfig + sources: + - path: STSecurity + STSecurityTests: + type: bundle.unit-test + platform: iOS + sources: + - path: STSecurityTests + dependencies: + - framework: STSecurity.framework + implicit: true + embed: false + - target: STSecurityTestHost + STSecurityTestHost: + type: application + platform: iOS + attributes: + SystemCapabilities: + com.apple.Keychain: + enabled: 1 + sources: + - path: STSecurityTestHost From ba8da086a933f4e2e87be3a096b32515022666ef Mon Sep 17 00:00:00 2001 From: Scott Talbot Date: Sun, 27 Oct 2019 13:52:54 +1100 Subject: [PATCH 4/4] hack --- STSecurity.xcodeproj/project.pbxproj | 9 +- .../xcschemes/STSecurity.xcscheme | 33 +- STSecurity/STSecurityKeychainAccess.h | 12 +- STSecurity/Target.xcconfig | 1 - .../STSecurityKeychainAccessRSATests.m | 616 +++++++++--------- .../STSecurityRSAEncryptionTests.m | 590 ++++++++--------- STSecurityTests/STSecurityRSAKeyTests.m | 84 +-- 7 files changed, 669 insertions(+), 676 deletions(-) diff --git a/STSecurity.xcodeproj/project.pbxproj b/STSecurity.xcodeproj/project.pbxproj index 7fcb81c..5dfeaa7 100644 --- a/STSecurity.xcodeproj/project.pbxproj +++ b/STSecurity.xcodeproj/project.pbxproj @@ -44,7 +44,7 @@ 34AB1BAE5276E88BCE6FF4D7 /* STSecurityRSAKey.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STSecurityRSAKey.m; sourceTree = ""; }; 34F811D4EEBC5A07B48AD63D /* STSecurityKeychainAccess+Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "STSecurityKeychainAccess+Internal.h"; sourceTree = ""; }; 378AECA75EB26BB87BF3651D /* Target-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Target-Debug.xcconfig"; sourceTree = ""; }; - 3E08D146A0BBD8E5DC11FE34 /* STSecurityTests.xctest */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.cfbundle; path = STSecurityTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 3E08D146A0BBD8E5DC11FE34 /* STSecurityTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = STSecurityTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 498B9712BF6EED440D034165 /* STSecurityKeychainAccess.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = STSecurityKeychainAccess.h; sourceTree = ""; }; 57C4BFA8D3FF21797D584727 /* STSecurity.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = STSecurity.h; sourceTree = ""; }; 5A726C758CF7812CE8F6FDCF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; @@ -72,7 +72,7 @@ E01354FE59E0C2D2E756208B /* Target-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Target-Release.xcconfig"; sourceTree = ""; }; E8DEEEF791A2F81243D64E64 /* STSecurityRandomization.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STSecurityRandomization.m; sourceTree = ""; }; FA573CB251345E9E1CB24A10 /* STSecurityRSAEncryption.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STSecurityRSAEncryption.m; sourceTree = ""; }; - FC0E67547D009E79D101D96C /* STSecurity.framework */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.framework; path = STSecurity.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + FC0E67547D009E79D101D96C /* STSecurity.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework.static; includeInIndex = 0; path = STSecurity.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -247,6 +247,7 @@ developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( + en, Base, ); mainGroup = EAC6299C2C9CA6A52F694F13; @@ -419,6 +420,7 @@ ); IPHONEOS_DEPLOYMENT_TARGET = 11.4; MACOSX_DEPLOYMENT_TARGET = 10.14; + OTHER_LDFLAGS = ""; PRODUCT_NAME = "$(TARGET_NAME)"; RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = iphoneos; @@ -458,6 +460,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); + OTHER_LDFLAGS = "-ObjC"; PRODUCT_BUNDLE_IDENTIFIER = org.chikachow.STSecurityTests; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; @@ -518,6 +521,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.14; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; + OTHER_LDFLAGS = ""; PRODUCT_NAME = "$(TARGET_NAME)"; RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = iphoneos; @@ -556,6 +560,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); + OTHER_LDFLAGS = "-ObjC"; PRODUCT_BUNDLE_IDENTIFIER = org.chikachow.STSecurityTests; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/STSecurity.xcodeproj/xcshareddata/xcschemes/STSecurity.xcscheme b/STSecurity.xcodeproj/xcshareddata/xcschemes/STSecurity.xcscheme index c9e9e52..1861f43 100644 --- a/STSecurity.xcodeproj/xcshareddata/xcschemes/STSecurity.xcscheme +++ b/STSecurity.xcodeproj/xcshareddata/xcschemes/STSecurity.xcscheme @@ -26,7 +26,17 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - shouldUseLaunchSchemeArgsEnv = "YES"> + shouldUseLaunchSchemeArgsEnv = "YES" + codeCoverageEnabled = "YES"> + + + + @@ -39,21 +49,6 @@ - - - - - - - - - - - - - - - - diff --git a/STSecurity/STSecurityKeychainAccess.h b/STSecurity/STSecurityKeychainAccess.h index 98adf6e..67778f3 100644 --- a/STSecurity/STSecurityKeychainAccess.h +++ b/STSecurity/STSecurityKeychainAccess.h @@ -56,24 +56,24 @@ typedef NS_OPTIONS(NSInteger, STSecurityKeychainItemAccessControl) { #pragma mark - Password -+ (BOOL)containsPasswordForUsername:(NSString *)username service:(NSString *)service; ++ (BOOL)containsPasswordForUsername:(NSString *)username service:(NSString *)service NS_SWIFT_UNAVAILABLE(""); + (BOOL)containsPasswordForUsername:(NSString *)username service:(NSString *)service error:(NSError * __autoreleasing *)error; -+ (NSString *)passwordForUsername:(NSString *)username service:(NSString *)service; ++ (NSString *)passwordForUsername:(NSString *)username service:(NSString *)service NS_SWIFT_UNAVAILABLE(""); + (NSString *)passwordForUsername:(NSString *)username service:(NSString *)service error:(NSError * __autoreleasing *)error; + (NSString *)passwordForUsername:(NSString *)username service:(NSString *)service withOptions:(id)options error:(NSError * __autoreleasing *)error; -+ (BOOL)setPassword:(NSString *)password forUsername:(NSString *)username service:(NSString *)service; ++ (BOOL)setPassword:(NSString *)password forUsername:(NSString *)username service:(NSString *)service NS_SWIFT_UNAVAILABLE(""); + (BOOL)setPassword:(NSString *)password forUsername:(NSString *)username service:(NSString *)service error:(NSError * __autoreleasing *)error; -+ (BOOL)setPassword:(NSString *)password forUsername:(NSString *)username service:(NSString *)service overwriteExisting:(BOOL)overwriteExisting; ++ (BOOL)setPassword:(NSString *)password forUsername:(NSString *)username service:(NSString *)service overwriteExisting:(BOOL)overwriteExisting NS_SWIFT_UNAVAILABLE(""); + (BOOL)setPassword:(NSString *)password forUsername:(NSString *)username service:(NSString *)service overwriteExisting:(BOOL)overwriteExisting error:(NSError * __autoreleasing *)error; + (BOOL)setPassword:(NSString *)password forUsername:(NSString *)username service:(NSString *)service withOptions:(id)options error:(NSError * __autoreleasing *)error; -+ (BOOL)deletePasswordForUsername:(NSString *)username service:(NSString *)service; ++ (BOOL)deletePasswordForUsername:(NSString *)username service:(NSString *)service NS_SWIFT_UNAVAILABLE(""); + (BOOL)deletePasswordForUsername:(NSString *)username service:(NSString *)service error:(NSError * __autoreleasing *)error; + (BOOL)deletePasswordForUsername:(NSString *)username service:(NSString *)service withOptions:(id)options error:(NSError * __autoreleasing *)error; -+ (BOOL)deletePasswordsForService:(NSString *)service; ++ (BOOL)deletePasswordsForService:(NSString *)service NS_SWIFT_UNAVAILABLE(""); + (BOOL)deletePasswordsForService:(NSString *)service error:(NSError * __autoreleasing *)error; + (BOOL)deletePasswordsForService:(NSString *)service withOptions:(id)options error:(NSError * __autoreleasing *)error; diff --git a/STSecurity/Target.xcconfig b/STSecurity/Target.xcconfig index 009dad0..bcb7e67 100644 --- a/STSecurity/Target.xcconfig +++ b/STSecurity/Target.xcconfig @@ -1,5 +1,4 @@ // Copyright (c) 2013 Scott Talbot. All rights reserved. -//DSTROOT = /tmp/STSecurity.dst SKIP_INSTALL = YES PRODUCT_NAME = STSecurity diff --git a/STSecurityTests/STSecurityKeychainAccessRSATests.m b/STSecurityTests/STSecurityKeychainAccessRSATests.m index 825945c..8eb5411 100644 --- a/STSecurityTests/STSecurityKeychainAccessRSATests.m +++ b/STSecurityTests/STSecurityKeychainAccessRSATests.m @@ -1,309 +1,309 @@ -//// -//// STSecurityKeychainAccessRSATests.m -//// STSecurity -//// -//// Copyright (c) 2012 Scott Talbot. All rights reserved. -//// // -//@import XCTest; -// -//#import "STSecurity.h" -// -// -//@interface STSecurityKeychainAccessRSATests : XCTestCase -//@end -// -//@implementation STSecurityKeychainAccessRSATests -// -//- (void)testFetchNonexistent { -// { -// STSecurityRSAPublicKey *key = [STSecurityKeychainAccess fetchRSAPublicKeyForTag:@"STSecurityTest.nonexistent"]; -// XCTAssertNil(key, @"Keychain returned key for nonexistent tag"); -// } -// { -// NSError *error = nil; -// STSecurityRSAPublicKey *key = [STSecurityKeychainAccess fetchRSAPublicKeyForTag:@"STSecurityTest.nonexistent" error:&error]; -// XCTAssertNil(key, @"Keychain returned key for nonexistent tag"); -// XCTAssertNotNil(error, @"Keychain returned nil error"); -// } -//} -// -//- (void)testDeleteNonexistent { -// { -// NSError *error = nil; -// BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:@"STSecurityTest.nonexistent" error:&error]; -// XCTAssertFalse(status, @"Keychain returned success deleting nonexistent key"); -// XCTAssertNotNil(error, @"Keychain returned nil error"); -// XCTAssertEqual(error.code, errSecItemNotFound, @"Keychain returned error.code not ItemNotFound: %ld", (long)error.code); -// } -//} -// -// -//#if !defined(TRAVIS) || !(TRAVIS + 0) -// -//- (void)_st_testGenerationOfSize:(NSUInteger)keySize { -// NSString * const keyTag = @"STSecurityTest.testGeneration"; -// STSecurityRSAPublicKey *publicKey = nil; -// STSecurityRSAPrivateKey *privateKey = nil; -// -// { -// NSError *error = nil; -// BOOL status = [STSecurityKeychainAccess generateRSAKeypairOfSize:keySize insertedIntoKeychainWithTag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; -// XCTAssertTrue(status, @"Keychain could not generate key pair"); -// XCTAssertNil(error, @"Key generation returned error: %@", error); -// } -// XCTAssertNotNil(publicKey, @"Key generation resulted in no public key"); -// XCTAssertNotNil(privateKey, @"Key generation resulted in no private key"); -// -// { -// NSError *error = nil; -// BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:&error]; -// XCTAssertTrue(status, @"Keychain could not delete public key"); -// XCTAssertNil(error, @"Public key deletion returned error: %@", error); -// } -//} -// -////- (void)testGenerationSize384 { [self _st_testGenerationOfSize:384]; } -//- (void)testGenerationSize512 { [self _st_testGenerationOfSize:512]; } -//- (void)testGenerationSize768 { [self _st_testGenerationOfSize:768]; } -//- (void)testGenerationSize1024 { [self _st_testGenerationOfSize:1024]; } -//- (void)testGenerationSize1536 { [self _st_testGenerationOfSize:1536]; } -////- (void)testGenerationSize2048 { [self _st_testGenerationOfSize:2048]; } -////- (void)testGenerationSize3072 { [self _st_testGenerationOfSize:3072]; } -////- (void)testGenerationSize4096 { [self _st_testGenerationOfSize:4096]; } -// -// -//- (void)testGenerationAnonymous { -// STSecurityRSAPublicKey *publicKey = nil; -// STSecurityRSAPrivateKey *privateKey = nil; -// -// { -// NSError *error = nil; -// BOOL status = [STSecurityKeychainAccess generateRSAKeypairOfSize:1024 insertedIntoKeychainWithTag:nil publicKey:&publicKey privateKey:&privateKey error:&error]; -// XCTAssertFalse(status, @"Keychain generated key pair without tags"); -// XCTAssertNotNil(error, @"Key generation returned nil error"); -// } -// XCTAssertNil(publicKey, @"Key generation resulted in no public key"); -// XCTAssertNil(privateKey, @"Key generation resulted in no private key"); -//} -// -//- (void)testGenerationAndFetch { -// NSString * const keyTag = @"STSecurityTest.testGenerationAndFetch"; -// STSecurityRSAPublicKey *publicKey = nil; -// STSecurityRSAPrivateKey *privateKey = nil; -// NSUInteger keySize = 1024; -// -// { -// NSError *error = nil; -// BOOL status = [STSecurityKeychainAccess generateRSAKeypairOfSize:keySize insertedIntoKeychainWithTag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; -// XCTAssertTrue(status, @"Keychain could not generate key pair"); -// XCTAssertNil(error, @"Key generation returned error: %@", error); -// } -// XCTAssertNotNil(publicKey, @"Key generation resulted in no public key"); -// XCTAssertNotNil(privateKey, @"Key generation resulted in no private key"); -// -// NSData *privateKeyData = nil; -// { -// NSError *error = nil; -// privateKeyData = [STSecurityKeychainAccess fetchKeyDataForRSAPrivateKey:privateKey error:&error]; -// XCTAssertNotNil(privateKeyData, @"Could not fetch private key data"); -// XCTAssertNil(error, @"Private key data fetch returned error: %@", error); -// } -// -// STSecurityRSAPublicKey *fetchedPublicKey = nil; -// { -// NSError *error = nil; -// fetchedPublicKey = [STSecurityKeychainAccess fetchRSAPublicKeyForTag:keyTag error:&error]; -// XCTAssertNotNil(fetchedPublicKey, @"Keychain could not find public key"); -// XCTAssertNil(error, @"Keychain fetch returned error: %@", error); -// } -// -// STSecurityRSAPrivateKey *fetchedPrivateKey = nil; -// { -// NSError *error = nil; -// fetchedPrivateKey = [STSecurityKeychainAccess fetchRSAPrivateKeyForTag:keyTag error:&error]; -// XCTAssertNotNil(fetchedPrivateKey, @"Keychain could not find private key"); -// XCTAssertNil(error, @"Keychain fetch returned error: %@", error); -// } -// -// NSData *fetchedPrivateKeyData = nil; -// { -// NSError *error = nil; -// fetchedPrivateKeyData = [STSecurityKeychainAccess fetchKeyDataForRSAPrivateKey:fetchedPrivateKey error:&error]; -// XCTAssertNotNil(fetchedPrivateKeyData, @"Could not fetch private key data"); -// XCTAssertNil(error, @"Private key data fetch returned error: %@", error); -// } -// -// XCTAssertEqualObjects(publicKey.keyData, fetchedPublicKey.keyData, @"Fetched public key doesn't equal original"); -// XCTAssertEqualObjects(privateKeyData, fetchedPrivateKeyData, @"Fetched private key doesn't equal original"); -// -// { -// NSError *error = nil; -// BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:&error]; -// XCTAssertTrue(status, @"Keychain could not delete public key"); -// XCTAssertNil(error, @"Public key deletion returned error: %@", error); -// } -//} -// -//- (void)testConflictingGeneration { -// NSString * const keyTag = @"STSecurityTest.testConflictingGeneration"; -// STSecurityRSAPublicKey *publicKey = nil; -// STSecurityRSAPrivateKey *privateKey = nil; -// NSUInteger keySize = 1024; -// -// { -// NSError *error = nil; -// BOOL status = [STSecurityKeychainAccess generateRSAKeypairOfSize:keySize insertedIntoKeychainWithTag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; -// XCTAssertTrue(status, @"Keychain could not generate key pair"); -// XCTAssertNil(error, @"Key generation returned error: %@", error); -// } -// XCTAssertNotNil(publicKey, @"Key generation resulted in no public key"); -// XCTAssertNotNil(privateKey, @"Key generation resulted in no private key"); -// -// { -// NSError *error = nil; -// BOOL status = [STSecurityKeychainAccess generateRSAKeypairOfSize:keySize insertedIntoKeychainWithTag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; -// XCTAssertFalse(status, @"Keychain generated conflicting key pair"); -// XCTAssertNotNil(error, @"Key generation returned no error"); -// } -// -// { -// NSError *error = nil; -// BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:&error]; -// XCTAssertTrue(status, @"Keychain could not delete public key"); -// XCTAssertNil(error, @"Public key deletion returned error: %@", error); -// } -//} -//#endif -// -//- (void)testInsertion { -// unsigned char const pub_bytes[] = { -// 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, -// 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, -// 0x00, 0xb6, 0x63, 0x51, 0x02, 0xee, 0xd9, 0x71, 0x5e, 0x2e, 0x88, 0x6a, 0x61, 0xd1, 0x6a, 0x22, -// 0xb6, 0x7d, 0x3e, 0xae, 0xb3, 0xf1, 0x2c, 0x7f, 0xa7, 0xb3, 0xd7, 0xe1, 0x1e, 0x25, 0x41, 0x38, -// 0xc4, 0xab, 0xef, 0x43, 0xd8, 0x93, 0x55, 0xff, 0x42, 0x89, 0xda, 0x54, 0x46, 0x8b, 0xce, 0x54, -// 0x06, 0x28, 0x9d, 0xae, 0x42, 0x12, 0xf3, 0x3f, 0x26, 0x70, 0x31, 0x03, 0x6f, 0xa5, 0x61, 0x08, -// 0x48, 0x73, 0xd7, 0xdf, 0x74, 0x65, 0x01, 0xec, 0xb8, 0x48, 0x11, 0xdf, 0x45, 0x8d, 0x2c, 0x98, -// 0x08, 0xd9, 0x49, 0xbd, 0xfb, 0x71, 0x52, 0x21, 0xd6, 0x15, 0x84, 0xf8, 0xde, 0xfa, 0xcc, 0xdd, -// 0x12, 0xbc, 0xad, 0xd5, 0x7e, 0xac, 0x7b, 0x6e, 0xcf, 0x52, 0xdb, 0xf6, 0x6e, 0x22, 0x65, 0xd0, -// 0xa5, 0xfd, 0x39, 0xc6, 0xbc, 0xbb, 0x4a, 0x3a, 0x55, 0xfd, 0xd5, 0x2a, 0xe7, 0xee, 0x7e, 0xaf, -// 0x6f, 0xc3, 0x7c, 0x8b, 0x0e, 0x6c, 0xb4, 0xfb, 0x51, 0xb9, 0x22, 0xa1, 0x4a, 0xb0, 0x6d, 0x21, -// 0x6d, 0xe4, 0xc4, 0x9c, 0x72, 0x26, 0xe7, 0xef, 0x76, 0xa6, 0xaf, 0x84, 0x5e, 0xff, 0x4a, 0x90, -// 0x93, 0x49, 0xfb, 0x4c, 0xee, 0xdc, 0x87, 0x5f, 0x9a, 0xfa, 0x8b, 0x07, 0xaa, 0x96, 0x5c, 0xe9, -// 0x34, 0x51, 0x5e, 0x8c, 0x14, 0xc5, 0x48, 0x1e, 0x42, 0x7d, 0x10, 0xfb, 0xbd, 0x62, 0x4a, 0xfc, -// 0x96, 0x57, 0xea, 0x4c, 0x0c, 0x7d, 0xd1, 0x18, 0x3e, 0xd2, 0xea, 0xd7, 0x0d, 0xad, 0x5d, 0xfd, -// 0x3a, 0xc6, 0xb9, 0xed, 0x78, 0x22, 0xf3, 0x7f, 0x69, 0xe6, 0xb8, 0x0c, 0x09, 0xe4, 0xf0, 0x7f, -// 0x8a, 0xc6, 0x1b, 0xe3, 0x63, 0xae, 0x57, 0xe7, 0x6c, 0xe7, 0x92, 0xb7, 0x7b, 0xab, 0x74, 0xdb, -// 0x1f, 0x69, 0x3c, 0x45, 0x41, 0x8d, 0x29, 0xd0, 0xda, 0xe7, 0x99, 0xd4, 0xc7, 0x40, 0x58, 0xce, -// 0x23, 0x02, 0x03, 0x01, 0x00, 0x01 -// }; -// unsigned int const pub_bytes_len = 294; -// -// unsigned char const prv_bytes[] = { -// 0x30, 0x82, 0x04, 0xa5, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, 0xb6, 0x63, 0x51, 0x02, -// 0xee, 0xd9, 0x71, 0x5e, 0x2e, 0x88, 0x6a, 0x61, 0xd1, 0x6a, 0x22, 0xb6, 0x7d, 0x3e, 0xae, 0xb3, -// 0xf1, 0x2c, 0x7f, 0xa7, 0xb3, 0xd7, 0xe1, 0x1e, 0x25, 0x41, 0x38, 0xc4, 0xab, 0xef, 0x43, 0xd8, -// 0x93, 0x55, 0xff, 0x42, 0x89, 0xda, 0x54, 0x46, 0x8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 0xc6, 0x1b, 0xe3, 0x63, -// 0xae, 0x57, 0xe7, 0x6c, 0xe7, 0x92, 0xb7, 0x7b, 0xab, 0x74, 0xdb, 0x1f, 0x69, 0x3c, 0x45, 0x41, -// 0x8d, 0x29, 0xd0, 0xda, 0xe7, 0x99, 0xd4, 0xc7, 0x40, 0x58, 0xce, 0x23, 0x02, 0x03, 0x01, 0x00, -// 0x01, 0x02, 0x82, 0x01, 0x00, 0x08, 0xce, 0x2a, 0xaf, 0x15, 0x90, 0xf1, 0xe4, 0x36, 0x22, 0xe7, -// 0xdf, 0xe9, 0x18, 0x52, 0xac, 0xb4, 0xc7, 0x3d, 0xef, 0xfa, 0x08, 0xc7, 0xf0, 0xf4, 0xc1, 0xcb, -// 0x60, 0x85, 0x33, 0xec, 0xe5, 0xb1, 0xd7, 0x4f, 0x53, 0x39, 0x69, 0xc1, 0x75, 0x18, 0xea, 0xad, -// 0x7e, 0xea, 0x68, 0xff, 0xad, 0x7c, 0x70, 0x80, 0x65, 0x38, 0x3c, 0xfe, 0x23, 0x80, 0xef, 0x1c, -// 0xd7, 0x5b, 0x08, 0xa0, 0x39, 0xbf, 0x3e, 0x00, 0xcf, 0xc1, 0xc0, 0xa2, 0x09, 0x13, 0x91, 0xa9, -// 0x51, 0xd6, 0x4a, 0xfc, 0xdc, 0x10, 0x81, 0x7a, 0xe6, 0x94, 0xc5, 0xfe, 0x54, 0x33, 0x9d, 0xc3, -// 0xd6, 0x20, 0x0d, 0x9b, 0xee, 0xb7, 0xa5, 0x3c, 0xd5, 0x6c, 0xc6, 0x58, 0xc7, 0x31, 0x9c, 0xe4, -// 0xfc, 0xd4, 0x34, 0x4e, 0x2a, 0x75, 0x5b, 0x40, 0xb9, 0x03, 0xe1, 0xc5, 0x87, 0x39, 0x45, 0xfd, -// 0x58, 0x4d, 0x2f, 0x58, 0x90, 0xdb, 0xdf, 0x00, 0x3e, 0xc2, 0xc5, 0x0b, 0x80, 0x7e, 0xbb, 0xbc, -// 0xdc,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xa7, 0x1c, 0x7b, 0xb3, 0x1f, 0x68, 0xf1, 0x20, 0xd3, 0x36, 0xbe, 0xa3, -// 0x1f, 0x26, 0x43, 0x62, 0x4e, 0x3d, 0xc8, 0xde, 0x87, 0x41, 0x3b, 0x4e, 0x60, 0x30, 0xc2, 0x9b, -// 0xda, 0xd6, 0xf1, 0xe6, 0xda, 0xa9, 0x85, 0xd4, 0x47, 0xa8, 0xe3, 0x51, 0x99, 0x85, 0x77, 0xd9, -// 0x70, 0x09, 0xfd, 0x0b, 0x88, 0x20, 0xac, 0x1f, 0x2f, 0x19, 0xf8, 0x47, 0x31, 0xa7, 0xf7, 0x73, -// 0xa0, 0x41, 0x4b, 0xfd, 0x6d, 0xe2, 0xc0, 0xef, 0x65, 0x02, 0x81, 0x81, 0x00, 0xcd, 0x54, 0x03, -// 0x67, 0x7c, 0x4a, 0x3b, 0x47, 0x7f, 0x90, 0x66, 0x0f, 0xfe, 0xe2, 0xdf, 0xaa, 0xcd, 0xa3, 0x1a, -// 0xdb, 0xc1, 0x7f, 0xf3, 0x56, 0xa3, 0x5d, 0x7c, 0x82, 0xfd, 0xf4, 0x07, 0x28, 0x24, 0x0e, 0xaa, -// 0x23, 0xf6, 0x0c, 0x92, 0x59, 0x17, 0xe4, 0x49, 0x27, 0x51, 0xdc, 0x40, 0x47, 0x80, 0x83, 0x20, -// 0x1e, 0x70, 0x99, 0x41, 0xac, 0x59, 0xc8, 0xe6, 0xaf, 0x31, 0x23, 0x95, 0x57, 0xbc, 0xdc, 0xbd, -// 0xe9, 0x8e, 0x66, 0xb7, 0xcc, 0xc1, 0xf5, 0xd5, 0x4d, 0x01, 0x01, 0x71, 0x5a, 0xb3, 0x80, 0x6a, -// 0x8c, 0x6a, 0xeb, 0xf5, 0x31, 0xd9, 0xe3, 0x86, 0x27, 0x2d, 0xef, 0xc6, 0x41, 0x77, 0xf0, 0x1a, -// 0x99, 0x16, 0x17, 0x5f, 0x2a, 0x43, 0x9b, 0xe8, 0x01, 0x9a, 0xcc, 0x24, 0x06, 0x7d, 0xc4, 0xe5, -// 0xf7, 0xc3, 0xa1, 0xea, 0xc9, 0xc5, 0x4b, 0x3c, 0x2f, 0xb7, 0xba, 0x02, 0xe7, 0x02, 0x81, 0x81, -// 0x00, 0xa9, 0x3b, 0x31, 0x19, 0x1d, 0xfb, 0xa6, 0x54, 0xaa, 0x42, 0x6f, 0xc3, 0x71, 0x67, 0x3a, -// 0xd5, 0x95, 0x35, 0x26, 0x3e, 0x59, 0x1f, 0xf7, 0x1a, 0x34, 0xac, 0xea, 0x23, 0xdc, 0x34, 0x03, -// 0xe6, 0x33, 0xb4, 0x95, 0x0b, 0x62, 0x03, 0xd4, 0x53, 0x98, 0xa2, 0xa5, 0xaa, 0x75, 0xa1, 0x4b, -// 0x9c, 0x12, 0x0e, 0xcc, 0x03, 0x5a, 0xb0, 0x02, 0xf1, 0x19, 0xf2, 0xb1, 0x7c, 0x27, 0x79, 0x73, -// 0xbb, 0xeb, 0x78, 0x90, 0x2a, 0x40, 0x32, 0xad, 0xe9, 0x2f, 0xab, 0xb4, 0x4c, 0x70, 0x34, 0xbe, -// 0x4f, 0x40, 0x5f, 0xa7, 0x9b, 0x74, 0x8e, 0x50, 0x39, 0x14, 0x00, 0x21, 0x03, 0x18, 0x68, 0x4d, -// 0xac, 0x2a, 0xe7, 0x49, 0xc2, 0x0c, 0x0f, 0x3e, 0x95, 0xe0, 0x09, 0x1e, 0xfc, 0xe6, 0xfb, 0xd1, -// 0x95, 0x57, 0x29, 0x6b, 0xaa, 0x6b, 0xcb, 0x7f, 0x94, 0x83, 0x23, 0xcf, 0x6e, 0x68, 0xf3, 0x96, -// 0xf5, 0x02, 0x81, 0x81, 0x00, 0xb6, 0xa5, 0x2a, 0x16, 0x0e, 0xe8, 0x95, 0x4c, 0xa7, 0x7b, 0x92, -// 0x5e, 0x5e, 0x34, 0x00, 0x14, 0x16, 0xb2, 0x24, 0xfd, 0x20, 0x66, 0x29, 0xd6, 0x82, 0xa1, 0x71, -// 0x55, 0xb0, 0x83, 0x37, 0x2e, 0x8c, 0xcc, 0x82, 0xaa, 0x54, 0x7f, 0xa0, 0x5b, 0x22, 0x36, 0x8e, -// 0xa0, 0x2c, 0x60, 0x48, 0xc9, 0x91, 0xd6, 0x92, 0x66, 0xa1, 0x70, 0xa2, 0x8b, 0xa6, 0x9e, 0x60, -// 0x1d, 0xad, 0x0f, 0x63, 0x14, 0x55, 0xca, 0xe2, 0x20, 0x74, 0xec, 0x88, 0x48, 0xda, 0xac, 0x4c, -// 0x1e, 0x20, 0x6b, 0xe1, 0x22, 0x76, 0x94, 0x1f, 0xb3, 0x62, 0x95, 0x1c, 0x5a, 0x48, 0xe0, 0xec, -// 0x7f, 0xc3, 0x8c, 0x0b, 0x86, 0x47, 0x23, 0x4c, 0xf5, 0xaa, 0x42, 0x06, 0x04, 0x39, 0x79, 0xe0, -// 0xea, 0x34, 0x81, 0xac, 0xf6, 0x1d, 0x40, 0x5d, 0xf4, 0x84, 0x90, 0x6e, 0xa3, 0x27, 0x1e, 0x22, -// 0x9e, 0xab, 0xc7, 0x0a, 0x37, 0x02, 0x81, 0x81, 0x00, 0x85, 0xee, 0x09, 0x5e, 0x36, 0x6f, 0x0f, -// 0x95, 0x03, 0x80, 0x3e, 0x08, 0xa4, 0x8a, 0x91, 0x06, 0xb3, 0xff, 0x79, 0x06, 0x31, 0x5b, 0x18, -// 0xeb, 0xfd, 0x2f, 0xa9, 0x0d, 0x19, 0x9d, 0xc4, 0xf0, 0x02, 0xf7, 0x4d, 0x77, 0x23, 0xd7, 0x68, -// 0xbf, 0xef, 0x15, 0x43, 0x33, 0xa1, 0x79, 0x7f, 0xc5, 0xc1, 0xfd, 0xc7, 0xa7, 0xba, 0xfb, 0xac, -// 0x24, 0xb1, 0x82, 0x0c, 0xe1, 0x17, 0xb5, 0xda, 0x05, 0x4c, 0x90, 0x80, 0xd8, 0x82, 0x62, 0x2c, -// 0x6d, 0xc8, 0x65, 0xac, 0xa1, 0xb6, 0x6f, 0x82, 0xbd, 0xfd, 0x5f, 0x06, 0x65, 0x7f, 0xda, 0x8b, -// 0xee, 0xb8, 0x8a, 0x4e, 0x59, 0x8b, 0xb3, 0x5e, 0xfc, 0xf0, 0x6d, 0x2f, 0xbc, 0x31, 0x2b, 0xb6, -// 0x97, 0x84, 0x88, 0x0e, 0x51, 0x9b, 0x03, 0x38, 0x56, 0x34, 0x8a, 0x80, 0x7f, 0x67, 0x85, 0x3f, -// 0x70, 0xad, 0x99, 0x20, 0x5e, 0x2a, 0xf2, 0x97, 0x38 -// }; -// unsigned int const prv_bytes_len = 1193; -// -//#pragma clang diagnostic push -//#pragma clang diagnostic ignored "-Wcast-qual" -// NSData * const publicKeyData = [NSData dataWithBytesNoCopy:(void *)pub_bytes length:pub_bytes_len freeWhenDone:NO]; -// NSData * const privateKeyData = [NSData dataWithBytesNoCopy:(void *)prv_bytes length:prv_bytes_len freeWhenDone:NO]; -//#pragma clang diagnostic pop -// -// NSString * const keyTag = @"STSecurityTest.testInsertion"; -// STSecurityRSAPublicKey *publicKey = nil; -// STSecurityRSAPrivateKey *privateKey = nil; -// -// { -// NSError *error = nil; -// BOOL status = [STSecurityKeychainAccess insertRSAKeypairWithPublicKeyData:publicKeyData privateKeyData:privateKeyData intoKeychainWithAccessibility:STSecurityKeychainItemAccessibleAlways tag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; -// XCTAssertTrue(status, @"Keychain could not insertion key pair"); -// XCTAssertNil(error, @"Key insertion returned error: %@", error); -// } -// XCTAssertNotNil(publicKey, @"Key insertion resulted in no public key"); -// XCTAssertNotNil(privateKey, @"Key insertion resulted in no private key"); -// -// { -// NSError *error = nil; -// BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:&error]; -// XCTAssertTrue(status, @"Keychain could not delete public key"); -// XCTAssertNil(error, @"Public key deletion returned error: %@", error); -// } -//} -// -//@end +// STSecurityKeychainAccessRSATests.m +// STSecurity +// +// Copyright (c) 2012 Scott Talbot. All rights reserved. +// + +@import XCTest; + +#import "STSecurity.h" + + +@interface STSecurityKeychainAccessRSATests : XCTestCase +@end + +@implementation STSecurityKeychainAccessRSATests + +- (void)testFetchNonexistent { + { + STSecurityRSAPublicKey *key = [STSecurityKeychainAccess fetchRSAPublicKeyForTag:@"STSecurityTest.nonexistent"]; + XCTAssertNil(key, @"Keychain returned key for nonexistent tag"); + } + { + NSError *error = nil; + STSecurityRSAPublicKey *key = [STSecurityKeychainAccess fetchRSAPublicKeyForTag:@"STSecurityTest.nonexistent" error:&error]; + XCTAssertNil(key, @"Keychain returned key for nonexistent tag"); + XCTAssertNotNil(error, @"Keychain returned nil error"); + } +} + +- (void)testDeleteNonexistent { + { + NSError *error = nil; + BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:@"STSecurityTest.nonexistent" error:&error]; + XCTAssertFalse(status, @"Keychain returned success deleting nonexistent key"); + XCTAssertNotNil(error, @"Keychain returned nil error"); + XCTAssertEqual(error.code, errSecItemNotFound, @"Keychain returned error.code not ItemNotFound: %ld", (long)error.code); + } +} + + +#if !defined(TRAVIS) || !(TRAVIS + 0) + +- (void)_st_testGenerationOfSize:(NSUInteger)keySize { + NSString * const keyTag = @"STSecurityTest.testGeneration"; + STSecurityRSAPublicKey *publicKey = nil; + STSecurityRSAPrivateKey *privateKey = nil; + + { + NSError *error = nil; + BOOL status = [STSecurityKeychainAccess generateRSAKeypairOfSize:keySize insertedIntoKeychainWithTag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; + XCTAssertTrue(status, @"Keychain could not generate key pair"); + XCTAssertNil(error, @"Key generation returned error: %@", error); + } + XCTAssertNotNil(publicKey, @"Key generation resulted in no public key"); + XCTAssertNotNil(privateKey, @"Key generation resulted in no private key"); + + { + NSError *error = nil; + BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:&error]; + XCTAssertTrue(status, @"Keychain could not delete public key"); + XCTAssertNil(error, @"Public key deletion returned error: %@", error); + } +} + +//- (void)testGenerationSize384 { [self _st_testGenerationOfSize:384]; } +- (void)testGenerationSize512 { [self _st_testGenerationOfSize:512]; } +- (void)testGenerationSize768 { [self _st_testGenerationOfSize:768]; } +- (void)testGenerationSize1024 { [self _st_testGenerationOfSize:1024]; } +- (void)testGenerationSize1536 { [self _st_testGenerationOfSize:1536]; } +//- (void)testGenerationSize2048 { [self _st_testGenerationOfSize:2048]; } +//- (void)testGenerationSize3072 { [self _st_testGenerationOfSize:3072]; } +//- (void)testGenerationSize4096 { [self _st_testGenerationOfSize:4096]; } + + +- (void)testGenerationAnonymous { + STSecurityRSAPublicKey *publicKey = nil; + STSecurityRSAPrivateKey *privateKey = nil; + + { + NSError *error = nil; + BOOL status = [STSecurityKeychainAccess generateRSAKeypairOfSize:1024 insertedIntoKeychainWithTag:nil publicKey:&publicKey privateKey:&privateKey error:&error]; + XCTAssertFalse(status, @"Keychain generated key pair without tags"); + XCTAssertNotNil(error, @"Key generation returned nil error"); + } + XCTAssertNil(publicKey, @"Key generation resulted in no public key"); + XCTAssertNil(privateKey, @"Key generation resulted in no private key"); +} + +- (void)testGenerationAndFetch { + NSString * const keyTag = @"STSecurityTest.testGenerationAndFetch"; + STSecurityRSAPublicKey *publicKey = nil; + STSecurityRSAPrivateKey *privateKey = nil; + NSUInteger keySize = 1024; + + { + NSError *error = nil; + BOOL status = [STSecurityKeychainAccess generateRSAKeypairOfSize:keySize insertedIntoKeychainWithTag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; + XCTAssertTrue(status, @"Keychain could not generate key pair"); + XCTAssertNil(error, @"Key generation returned error: %@", error); + } + XCTAssertNotNil(publicKey, @"Key generation resulted in no public key"); + XCTAssertNotNil(privateKey, @"Key generation resulted in no private key"); + + NSData *privateKeyData = nil; + { + NSError *error = nil; + privateKeyData = [STSecurityKeychainAccess fetchKeyDataForRSAPrivateKey:privateKey error:&error]; + XCTAssertNotNil(privateKeyData, @"Could not fetch private key data"); + XCTAssertNil(error, @"Private key data fetch returned error: %@", error); + } + + STSecurityRSAPublicKey *fetchedPublicKey = nil; + { + NSError *error = nil; + fetchedPublicKey = [STSecurityKeychainAccess fetchRSAPublicKeyForTag:keyTag error:&error]; + XCTAssertNotNil(fetchedPublicKey, @"Keychain could not find public key"); + XCTAssertNil(error, @"Keychain fetch returned error: %@", error); + } + + STSecurityRSAPrivateKey *fetchedPrivateKey = nil; + { + NSError *error = nil; + fetchedPrivateKey = [STSecurityKeychainAccess fetchRSAPrivateKeyForTag:keyTag error:&error]; + XCTAssertNotNil(fetchedPrivateKey, @"Keychain could not find private key"); + XCTAssertNil(error, @"Keychain fetch returned error: %@", error); + } + + NSData *fetchedPrivateKeyData = nil; + { + NSError *error = nil; + fetchedPrivateKeyData = [STSecurityKeychainAccess fetchKeyDataForRSAPrivateKey:fetchedPrivateKey error:&error]; + XCTAssertNotNil(fetchedPrivateKeyData, @"Could not fetch private key data"); + XCTAssertNil(error, @"Private key data fetch returned error: %@", error); + } + + XCTAssertEqualObjects(publicKey.keyData, fetchedPublicKey.keyData, @"Fetched public key doesn't equal original"); + XCTAssertEqualObjects(privateKeyData, fetchedPrivateKeyData, @"Fetched private key doesn't equal original"); + + { + NSError *error = nil; + BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:&error]; + XCTAssertTrue(status, @"Keychain could not delete public key"); + XCTAssertNil(error, @"Public key deletion returned error: %@", error); + } +} + +- (void)testConflictingGeneration { + NSString * const keyTag = @"STSecurityTest.testConflictingGeneration"; + STSecurityRSAPublicKey *publicKey = nil; + STSecurityRSAPrivateKey *privateKey = nil; + NSUInteger keySize = 1024; + + { + NSError *error = nil; + BOOL status = [STSecurityKeychainAccess generateRSAKeypairOfSize:keySize insertedIntoKeychainWithTag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; + XCTAssertTrue(status, @"Keychain could not generate key pair"); + XCTAssertNil(error, @"Key generation returned error: %@", error); + } + XCTAssertNotNil(publicKey, @"Key generation resulted in no public key"); + XCTAssertNotNil(privateKey, @"Key generation resulted in no private key"); + + { + NSError *error = nil; + BOOL status = [STSecurityKeychainAccess generateRSAKeypairOfSize:keySize insertedIntoKeychainWithTag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; + XCTAssertFalse(status, @"Keychain generated conflicting key pair"); + XCTAssertNotNil(error, @"Key generation returned no error"); + } + + { + NSError *error = nil; + BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:&error]; + XCTAssertTrue(status, @"Keychain could not delete public key"); + XCTAssertNil(error, @"Public key deletion returned error: %@", error); + } +} +#endif + +- (void)testInsertion { + unsigned char const pub_bytes[] = { + 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, + 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, + 0x00, 0xb6, 0x63, 0x51, 0x02, 0xee, 0xd9, 0x71, 0x5e, 0x2e, 0x88, 0x6a, 0x61, 0xd1, 0x6a, 0x22, + 0xb6, 0x7d, 0x3e, 0xae, 0xb3, 0xf1, 0x2c, 0x7f, 0xa7, 0xb3, 0xd7, 0xe1, 0x1e, 0x25, 0x41, 0x38, + 0xc4, 0xab, 0xef, 0x43, 0xd8, 0x93, 0x55, 0xff, 0x42, 0x89, 0xda, 0x54, 0x46, 0x8b, 0xce, 0x54, + 0x06, 0x28, 0x9d, 0xae, 0x42, 0x12, 0xf3, 0x3f, 0x26, 0x70, 0x31, 0x03, 0x6f, 0xa5, 0x61, 0x08, + 0x48, 0x73, 0xd7, 0xdf, 0x74, 0x65, 0x01, 0xec, 0xb8, 0x48, 0x11, 0xdf, 0x45, 0x8d, 0x2c, 0x98, + 0x08, 0xd9, 0x49, 0xbd, 0xfb, 0x71, 0x52, 0x21, 0xd6, 0x15, 0x84, 0xf8, 0xde, 0xfa, 0xcc, 0xdd, + 0x12, 0xbc, 0xad, 0xd5, 0x7e, 0xac, 0x7b, 0x6e, 0xcf, 0x52, 0xdb, 0xf6, 0x6e, 0x22, 0x65, 0xd0, + 0xa5, 0xfd, 0x39, 0xc6, 0xbc, 0xbb, 0x4a, 0x3a, 0x55, 0xfd, 0xd5, 0x2a, 0xe7, 0xee, 0x7e, 0xaf, + 0x6f, 0xc3, 0x7c, 0x8b, 0x0e, 0x6c, 0xb4, 0xfb, 0x51, 0xb9, 0x22, 0xa1, 0x4a, 0xb0, 0x6d, 0x21, + 0x6d, 0xe4, 0xc4, 0x9c, 0x72, 0x26, 0xe7, 0xef, 0x76, 0xa6, 0xaf, 0x84, 0x5e, 0xff, 0x4a, 0x90, + 0x93, 0x49, 0xfb, 0x4c, 0xee, 0xdc, 0x87, 0x5f, 0x9a, 0xfa, 0x8b, 0x07, 0xaa, 0x96, 0x5c, 0xe9, + 0x34, 0x51, 0x5e, 0x8c, 0x14, 0xc5, 0x48, 0x1e, 0x42, 0x7d, 0x10, 0xfb, 0xbd, 0x62, 0x4a, 0xfc, + 0x96, 0x57, 0xea, 0x4c, 0x0c, 0x7d, 0xd1, 0x18, 0x3e, 0xd2, 0xea, 0xd7, 0x0d, 0xad, 0x5d, 0xfd, + 0x3a, 0xc6, 0xb9, 0xed, 0x78, 0x22, 0xf3, 0x7f, 0x69, 0xe6, 0xb8, 0x0c, 0x09, 0xe4, 0xf0, 0x7f, + 0x8a, 0xc6, 0x1b, 0xe3, 0x63, 0xae, 0x57, 0xe7, 0x6c, 0xe7, 0x92, 0xb7, 0x7b, 0xab, 0x74, 0xdb, + 0x1f, 0x69, 0x3c, 0x45, 0x41, 0x8d, 0x29, 0xd0, 0xda, 0xe7, 0x99, 0xd4, 0xc7, 0x40, 0x58, 0xce, + 0x23, 0x02, 0x03, 0x01, 0x00, 0x01 + }; + unsigned int const pub_bytes_len = 294; + + unsigned char const prv_bytes[] = { + 0x30, 0x82, 0x04, 0xa5, 0x02, 0x01, 0x00, 0x02, 0x82, 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 0x83, 0x23, 0xcf, 0x6e, 0x68, 0xf3, 0x96, + 0xf5, 0x02, 0x81, 0x81, 0x00, 0xb6, 0xa5, 0x2a, 0x16, 0x0e, 0xe8, 0x95, 0x4c, 0xa7, 0x7b, 0x92, + 0x5e, 0x5e, 0x34, 0x00, 0x14, 0x16, 0xb2, 0x24, 0xfd, 0x20, 0x66, 0x29, 0xd6, 0x82, 0xa1, 0x71, + 0x55, 0xb0, 0x83, 0x37, 0x2e, 0x8c, 0xcc, 0x82, 0xaa, 0x54, 0x7f, 0xa0, 0x5b, 0x22, 0x36, 0x8e, + 0xa0, 0x2c, 0x60, 0x48, 0xc9, 0x91, 0xd6, 0x92, 0x66, 0xa1, 0x70, 0xa2, 0x8b, 0xa6, 0x9e, 0x60, + 0x1d, 0xad, 0x0f, 0x63, 0x14, 0x55, 0xca, 0xe2, 0x20, 0x74, 0xec, 0x88, 0x48, 0xda, 0xac, 0x4c, + 0x1e, 0x20, 0x6b, 0xe1, 0x22, 0x76, 0x94, 0x1f, 0xb3, 0x62, 0x95, 0x1c, 0x5a, 0x48, 0xe0, 0xec, + 0x7f, 0xc3, 0x8c, 0x0b, 0x86, 0x47, 0x23, 0x4c, 0xf5, 0xaa, 0x42, 0x06, 0x04, 0x39, 0x79, 0xe0, + 0xea, 0x34, 0x81, 0xac, 0xf6, 0x1d, 0x40, 0x5d, 0xf4, 0x84, 0x90, 0x6e, 0xa3, 0x27, 0x1e, 0x22, + 0x9e, 0xab, 0xc7, 0x0a, 0x37, 0x02, 0x81, 0x81, 0x00, 0x85, 0xee, 0x09, 0x5e, 0x36, 0x6f, 0x0f, + 0x95, 0x03, 0x80, 0x3e, 0x08, 0xa4, 0x8a, 0x91, 0x06, 0xb3, 0xff, 0x79, 0x06, 0x31, 0x5b, 0x18, + 0xeb, 0xfd, 0x2f, 0xa9, 0x0d, 0x19, 0x9d, 0xc4, 0xf0, 0x02, 0xf7, 0x4d, 0x77, 0x23, 0xd7, 0x68, + 0xbf, 0xef, 0x15, 0x43, 0x33, 0xa1, 0x79, 0x7f, 0xc5, 0xc1, 0xfd, 0xc7, 0xa7, 0xba, 0xfb, 0xac, + 0x24, 0xb1, 0x82, 0x0c, 0xe1, 0x17, 0xb5, 0xda, 0x05, 0x4c, 0x90, 0x80, 0xd8, 0x82, 0x62, 0x2c, + 0x6d, 0xc8, 0x65, 0xac, 0xa1, 0xb6, 0x6f, 0x82, 0xbd, 0xfd, 0x5f, 0x06, 0x65, 0x7f, 0xda, 0x8b, + 0xee, 0xb8, 0x8a, 0x4e, 0x59, 0x8b, 0xb3, 0x5e, 0xfc, 0xf0, 0x6d, 0x2f, 0xbc, 0x31, 0x2b, 0xb6, + 0x97, 0x84, 0x88, 0x0e, 0x51, 0x9b, 0x03, 0x38, 0x56, 0x34, 0x8a, 0x80, 0x7f, 0x67, 0x85, 0x3f, + 0x70, 0xad, 0x99, 0x20, 0x5e, 0x2a, 0xf2, 0x97, 0x38 + }; + unsigned int const prv_bytes_len = 1193; + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcast-qual" + NSData * const publicKeyData = [NSData dataWithBytesNoCopy:(void *)pub_bytes length:pub_bytes_len freeWhenDone:NO]; + NSData * const privateKeyData = [NSData dataWithBytesNoCopy:(void *)prv_bytes length:prv_bytes_len freeWhenDone:NO]; +#pragma clang diagnostic pop + + NSString * const keyTag = @"STSecurityTest.testInsertion"; + STSecurityRSAPublicKey *publicKey = nil; + STSecurityRSAPrivateKey *privateKey = nil; + + { + NSError *error = nil; + BOOL status = [STSecurityKeychainAccess insertRSAKeypairWithPublicKeyData:publicKeyData privateKeyData:privateKeyData intoKeychainWithAccessibility:STSecurityKeychainItemAccessibleAlways tag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; + XCTAssertTrue(status, @"Keychain could not insertion key pair"); + XCTAssertNil(error, @"Key insertion returned error: %@", error); + } + XCTAssertNotNil(publicKey, @"Key insertion resulted in no public key"); + XCTAssertNotNil(privateKey, @"Key insertion resulted in no private key"); + + { + NSError *error = nil; + BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:&error]; + XCTAssertTrue(status, @"Keychain could not delete public key"); + XCTAssertNil(error, @"Public key deletion returned error: %@", error); + } +} + +@end diff --git a/STSecurityTests/STSecurityRSAEncryptionTests.m b/STSecurityTests/STSecurityRSAEncryptionTests.m index e1ee4ee..e344d01 100644 --- a/STSecurityTests/STSecurityRSAEncryptionTests.m +++ b/STSecurityTests/STSecurityRSAEncryptionTests.m @@ -1,296 +1,296 @@ -//// -//// STSecurityRSAEncryptionTests.m -//// STSecurity -//// -//// Copyright (c) 2012 Scott Talbot. All rights reserved. -//// // -//@import XCTest; -// -//#import "STSecurity.h" -// -// -//@interface STSecurityRSAEncryptionTests : XCTestCase -//@end -// -//@implementation STSecurityRSAEncryptionTests -// -//#if !defined(TRAVIS) || !(TRAVIS + 0) -// -//- (void)testEncryptionInvalid { -// NSString * const keyTag = @"STSecurityTest.testEncryptionInvalid"; -// STSecurityRSAPublicKey *publicKey = nil; -// STSecurityRSAPrivateKey *privateKey = nil; -// NSUInteger keySize = 512; -// -// [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:NULL]; -// -// { -// NSError *error = nil; -// BOOL status = [STSecurityKeychainAccess generateRSAKeypairOfSize:keySize insertedIntoKeychainWithTag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; -// XCTAssertTrue(status, @"Keychain could not generate key pair"); -// XCTAssertNil(error, @"Key generation returned error: %@", error); -// } -// XCTAssertNotNil(publicKey, @"Key generation resulted in no public key"); -// XCTAssertNotNil(privateKey, @"Key generation resulted in no private key"); -// -// { -// NSError *error = nil; -// NSData *data = [STSecurityRSAEncryption dataByEncryptingData:nil withPublicKey:publicKey padding:STSecurityRSAPaddingPKCS1 error:&error]; -// XCTAssertNil(data); -// XCTAssertNil(error); -// } -// -// { -// NSError *error = nil; -// NSData *data = [STSecurityRSAEncryption dataByEncryptingData:[NSData data] withPublicKey:publicKey padding:STSecurityRSAPaddingPKCS1 error:&error]; -// XCTAssertNotNil(data); -// XCTAssertNil(error); -// } -// -// { -// NSError *error = nil; -// BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:&error]; -// XCTAssertTrue(status, @"Keychain could not delete public key"); -// XCTAssertNil(error, @"Public key deletion returned error: %@", error); -// } -//} -// -//- (void)_st_testEncryptionRoundtripWithData:(NSData *)data keySize:(NSUInteger)keySize padding:(enum STSecurityRSAPadding)padding { -// NSString * const keyTag = @"STSecurityTest.testEncryption"; -// STSecurityRSAPublicKey *publicKey = nil; -// STSecurityRSAPrivateKey *privateKey = nil; -// -// { -// NSError *error = nil; -// BOOL status = [STSecurityKeychainAccess generateRSAKeypairOfSize:keySize insertedIntoKeychainWithTag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; -// XCTAssertTrue(status, @"Keychain could not generate key pair"); -// XCTAssertNil(error, @"Key generation returned error: %@", error); -// } -// XCTAssertNotNil(publicKey, @"Key generation resulted in no public key"); -// XCTAssertNotNil(privateKey, @"Key generation resulted in no private key"); -// -// NSData *dataEncrypted = nil; -// { -// NSError *error = nil; -// dataEncrypted = [STSecurityRSAEncryption dataByEncryptingData:data withPublicKey:publicKey padding:padding error:&error]; -// XCTAssertNotNil(dataEncrypted, @"Encryption returned nil data"); -// XCTAssertNil(error, @"Encryption returned error: %@", error); -// } -// XCTAssertFalse([data isEqualToData:dataEncrypted], @"Encrypted data isEqual: initial"); -// -// NSData *dataDecrypted = nil; -// { -// NSError *error = nil; -// dataDecrypted = [STSecurityRSAEncryption dataByDecryptingData:dataEncrypted withPrivateKey:privateKey padding:padding error:&error]; -// XCTAssertNotNil(dataDecrypted, @"Decryption returned nil data"); -// XCTAssertNil(error, @"Decryption returned error: %@", error); -// } -// XCTAssertEqualObjects(data, dataDecrypted, @"Decrypted data doesn't match input"); -// -// { -// NSError *error = nil; -// BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:&error]; -// XCTAssertTrue(status, @"Keychain could not delete public key"); -// XCTAssertNil(error, @"Public key deletion returned error: %@", error); -// } -//} -// -//- (void)testEncryptionRoundtrip0 { -// [self _st_testEncryptionRoundtripWithData:[@"plaintext" dataUsingEncoding:NSUTF8StringEncoding] keySize:1024 padding:STSecurityRSAPaddingPKCS1]; -//} -// -//- (void)testEncryptionRoundtrip1 { -// NSData *randomData = [STSecurityRandomization dataWithRandomBytesOfLength:16]; -// NSMutableData *data = [NSMutableData dataWithCapacity:128]; -// while ([data length] < 128) { -// [data appendData:randomData]; -// } -// [data setLength:128 - 11]; -// [self _st_testEncryptionRoundtripWithData:data keySize:1024 padding:STSecurityRSAPaddingPKCS1]; -//} -// -//- (void)testEncryptionRoundtrip2 { -// NSData *randomData = [STSecurityRandomization dataWithRandomBytesOfLength:16]; -// NSMutableData *data = [NSMutableData dataWithCapacity:64]; -// for (int i = 0; i < 4; ++i) { -// [data appendData:randomData]; -// } -// [data setLength:64]; -// [self _st_testEncryptionRoundtripWithData:data keySize:1024 padding:STSecurityRSAPaddingOAEP]; -//} -//#endif -// -//- (void)testEncryptionInserted { -// NSString * const keyTag = @"STSecurityTest.testInsertion"; -// STSecurityRSAPublicKey *publicKey = nil; -// STSecurityRSAPrivateKey *privateKey = nil; -// -// unsigned char const pub_bytes[] = { -// 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, -// 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, -// 0x00, 0xb6, 0x63, 0x51, 0x02, 0xee, 0xd9, 0x71, 0x5e, 0x2e, 0x88, 0x6a, 0x61, 0xd1, 0x6a, 0x22, -// 0xb6, 0x7d, 0x3e, 0xae, 0xb3, 0xf1, 0x2c, 0x7f, 0xa7, 0xb3, 0xd7, 0xe1, 0x1e, 0x25, 0x41, 0x38, -// 0xc4, 0xab, 0xef, 0x43, 0xd8, 0x93, 0x55, 0xff, 0x42, 0x89, 0xda, 0x54, 0x46, 0x8b, 0xce, 0x54, -// 0x06, 0x28, 0x9d, 0xae, 0x42, 0x12, 0xf3, 0x3f, 0x26, 0x70, 0x31, 0x03, 0x6f, 0xa5, 0x61, 0x08, -// 0x48, 0x73, 0xd7, 0xdf, 0x74, 0x65, 0x01, 0xec, 0xb8, 0x48, 0x11, 0xdf, 0x45, 0x8d, 0x2c, 0x98, -// 0x08, 0xd9, 0x49, 0xbd, 0xfb, 0x71, 0x52, 0x21, 0xd6, 0x15, 0x84, 0xf8, 0xde, 0xfa, 0xcc, 0xdd, -// 0x12, 0xbc, 0xad, 0xd5, 0x7e, 0xac, 0x7b, 0x6e, 0xcf, 0x52, 0xdb, 0xf6, 0x6e, 0x22, 0x65, 0xd0, -// 0xa5, 0xfd, 0x39, 0xc6, 0xbc, 0xbb, 0x4a, 0x3a, 0x55, 0xfd, 0xd5, 0x2a, 0xe7, 0xee, 0x7e, 0xaf, -// 0x6f, 0xc3, 0x7c, 0x8b, 0x0e, 0x6c, 0xb4, 0xfb, 0x51, 0xb9, 0x22, 0xa1, 0x4a, 0xb0, 0x6d, 0x21, -// 0x6d, 0xe4, 0xc4, 0x9c, 0x72, 0x26, 0xe7, 0xef, 0x76, 0xa6, 0xaf, 0x84, 0x5e, 0xff, 0x4a, 0x90, -// 0x93, 0x49, 0xfb, 0x4c, 0xee, 0xdc, 0x87, 0x5f, 0x9a, 0xfa, 0x8b, 0x07, 0xaa, 0x96, 0x5c, 0xe9, -// 0x34, 0x51, 0x5e, 0x8c, 0x14, 0xc5, 0x48, 0x1e, 0x42, 0x7d, 0x10, 0xfb, 0xbd, 0x62, 0x4a, 0xfc, -// 0x96, 0x57, 0xea, 0x4c, 0x0c, 0x7d, 0xd1, 0x18, 0x3e, 0xd2, 0xea, 0xd7, 0x0d, 0xad, 0x5d, 0xfd, -// 0x3a, 0xc6, 0xb9, 0xed, 0x78, 0x22, 0xf3, 0x7f, 0x69, 0xe6, 0xb8, 0x0c, 0x09, 0xe4, 0xf0, 0x7f, -// 0x8a, 0xc6, 0x1b, 0xe3, 0x63, 0xae, 0x57, 0xe7, 0x6c, 0xe7, 0x92, 0xb7, 0x7b, 0xab, 0x74, 0xdb, -// 0x1f, 0x69, 0x3c, 0x45, 0x41, 0x8d, 0x29, 0xd0, 0xda, 0xe7, 0x99, 0xd4, 0xc7, 0x40, 0x58, 0xce, -// 0x23, 0x02, 0x03, 0x01, 0x00, 0x01 -// }; -// unsigned int const pub_bytes_len = 294; -// -// unsigned char const prv_bytes[] = { -// 0x30, 0x82, 0x04, 0xa5, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, 0xb6, 0x63, 0x51, 0x02, -// 0xee, 0xd9, 0x71, 0x5e, 0x2e, 0x88, 0x6a, 0x61, 0xd1, 0x6a, 0x22, 0xb6, 0x7d, 0x3e, 0xae, 0xb3, -// 0xf1, 0x2c, 0x7f, 0xa7, 0xb3, 0xd7, 0xe1, 0x1e, 0x25, 0x41, 0x38, 0xc4, 0xab, 0xef, 0x43, 0xd8, -// 0x93, 0x55, 0xff, 0x42, 0x89, 0xda, 0x54, 0x46, 0x8b, 0xce, 0x54, 0x06, 0x28, 0x9d, 0xae, 0x42, -// 0x12, 0xf3, 0x3f, 0x26, 0x70, 0x31, 0x03, 0x6f, 0xa5, 0x61, 0x08, 0x48, 0x73, 0xd7, 0xdf, 0x74, -// 0x65, 0x01, 0xec, 0xb8, 0x48, 0x11, 0xdf, 0x45, 0x8d, 0x2c, 0x98, 0x08, 0xd9, 0x49, 0xbd, 0xfb, -// 0x71, 0x52, 0x21, 0xd6, 0x15, 0x84, 0xf8, 0xde, 0xfa, 0xcc, 0xdd, 0x12, 0xbc, 0xad, 0xd5, 0x7e, -// 0xac, 0x7b, 0x6e, 0xcf, 0x52, 0xdb, 0xf6, 0x6e, 0x22, 0x65, 0xd0, 0xa5, 0xfd, 0x39, 0xc6, 0xbc, -// 0xb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, 0xf8, 0xb6, 0x73, 0xc5, 0x64, 0x2c, 0xa3, 0xd9, 0x59, -// 0x0c, 0x2e, 0x7a, 0x6c, 0x6b, 0xf3, 0xea, 0xd7, 0xb6, 0x4a, 0xcd, 0xdd, 0x82, 0xd5, 0x64, 0x35, -// 0x8d, 0x8c, 0xa4, 0x89, 0x41, 0x04, 0x98, 0x3a, 0x35, 0x90, 0x09, 0x45, 0x3d, 0x25, 0xdf, 0xd6, -// 0x55, 0xe0, 0x68, 0x21, 0xa1, 0x02, 0x81, 0x81, 0x00, 0xe3, 0x66, 0x03, 0x23, 0xf1, 0xba, 0x2e, -// 0x99, 0xbd, 0x99, 0x0f, 0x7f, 0xc4, 0x6d, 0xf9, 0x66, 0xb9, 0x7f, 0x23, 0x91, 0x8a, 0x73, 0x0b, -// 0x65, 0x63, 0xd7, 0xe9, 0xf5, 0x86, 0x72, 0x8f, 0x9b, 0xc4, 0x48, 0x80, 0x1c, 0xd7, 0xae, 0x06, -// 0xa4, 0x58, 0x5c, 0x13, 0x7d, 0x47, 0xb1, 0x30, 0xc0, 0xb9, 0x51, 0xa2, 0x92, 0x72, 0x02, 0xdf, -// 0xd8, 0xae, 0x3c, 0xff, 0xa7, 0x1c, 0x7b, 0xb3, 0x1f, 0x68, 0xf1, 0x20, 0xd3, 0x36, 0xbe, 0xa3, -// 0x1f, 0x26, 0x43, 0x62, 0x4e, 0x3d, 0xc8, 0xde, 0x87, 0x41, 0x3b, 0x4e, 0x60, 0x30, 0xc2, 0x9b, -// 0xda, 0xd6, 0xf1, 0xe6, 0xda, 0xa9, 0x85, 0xd4, 0x47, 0xa8, 0xe3, 0x51, 0x99, 0x85, 0x77, 0xd9, -// 0x70, 0x09, 0xfd, 0x0b, 0x88, 0x20, 0xac, 0x1f, 0x2f, 0x19, 0xf8, 0x47, 0x31, 0xa7, 0xf7, 0x73, -// 0xa0, 0x41, 0x4b, 0xfd, 0x6d, 0xe2, 0xc0, 0xef, 0x65, 0x02, 0x81, 0x81, 0x00, 0xcd, 0x54, 0x03, -// 0x67, 0x7c, 0x4a, 0x3b, 0x47, 0x7f, 0x90, 0x66, 0x0f, 0xfe, 0xe2, 0xdf, 0xaa, 0xcd, 0xa3, 0x1a, -// 0xdb, 0xc1, 0x7f, 0xf3, 0x56, 0xa3, 0x5d, 0x7c, 0x82, 0xfd, 0xf4, 0x07, 0x28, 0x24, 0x0e, 0xaa, -// 0x23, 0xf6, 0x0c, 0x92, 0x59, 0x17, 0xe4, 0x49, 0x27, 0x51, 0xdc, 0x40, 0x47, 0x80, 0x83, 0x20, -// 0x1e, 0x70, 0x99, 0x41, 0xac, 0x59, 0xc8, 0xe6, 0xaf, 0x31, 0x23, 0x95, 0x57, 0xbc, 0xdc, 0xbd, -// 0xe9, 0x8e, 0x66, 0xb7, 0xcc, 0xc1, 0xf5, 0xd5, 0x4d, 0x01, 0x01, 0x71, 0x5a, 0xb3, 0x80, 0x6a, -// 0x8c, 0x6a, 0xeb, 0xf5, 0x31, 0xd9, 0xe3, 0x86, 0x27, 0x2d, 0xef, 0xc6, 0x41, 0x77, 0xf0, 0x1a, -// 0x99, 0x16, 0x17, 0x5f, 0x2a, 0x43, 0x9b, 0xe8, 0x01, 0x9a, 0xcc, 0x24, 0x06, 0x7d, 0xc4, 0xe5, -// 0xf7, 0xc3, 0xa1, 0xea, 0xc9, 0xc5, 0x4b, 0x3c, 0x2f, 0xb7, 0xba, 0x02, 0xe7, 0x02, 0x81, 0x81, -// 0x00, 0xa9, 0x3b, 0x31, 0x19, 0x1d, 0xfb, 0xa6, 0x54, 0xaa, 0x42, 0x6f, 0xc3, 0x71, 0x67, 0x3a, -// 0xd5, 0x95, 0x35, 0x26, 0x3e, 0x59, 0x1f, 0xf7, 0x1a, 0x34, 0xac, 0xea, 0x23, 0xdc, 0x34, 0x03, -// 0xe6, 0x33, 0xb4, 0x95, 0x0b, 0x62, 0x03, 0xd4, 0x53, 0x98, 0xa2, 0xa5, 0xaa, 0x75, 0xa1, 0x4b, -// 0x9c, 0x12, 0x0e, 0xcc, 0x03, 0x5a, 0xb0, 0x02, 0xf1, 0x19, 0xf2, 0xb1, 0x7c, 0x27, 0x79, 0x73, -// 0xbb, 0xeb, 0x78, 0x90, 0x2a, 0x40, 0x32, 0xad, 0xe9, 0x2f, 0xab, 0xb4, 0x4c, 0x70, 0x34, 0xbe, -// 0x4f, 0x40, 0x5f, 0xa7, 0x9b, 0x74, 0x8e, 0x50, 0x39, 0x14, 0x00, 0x21, 0x03, 0x18, 0x68, 0x4d, -// 0xac, 0x2a, 0xe7, 0x49, 0xc2, 0x0c, 0x0f, 0x3e, 0x95, 0xe0, 0x09, 0x1e, 0xfc, 0xe6, 0xfb, 0xd1, -// 0x95, 0x57, 0x29, 0x6b, 0xaa, 0x6b, 0xcb, 0x7f, 0x94, 0x83, 0x23, 0xcf, 0x6e, 0x68, 0xf3, 0x96, -// 0xf5, 0x02, 0x81, 0x81, 0x00, 0xb6, 0xa5, 0x2a, 0x16, 0x0e, 0xe8, 0x95, 0x4c, 0xa7, 0x7b, 0x92, -// 0x5e, 0x5e, 0x34, 0x00, 0x14, 0x16, 0xb2, 0x24, 0xfd, 0x20, 0x66, 0x29, 0xd6, 0x82, 0xa1, 0x71, -// 0x55, 0xb0, 0x83, 0x37, 0x2e, 0x8c, 0xcc, 0x82, 0xaa, 0x54, 0x7f, 0xa0, 0x5b, 0x22, 0x36, 0x8e, -// 0xa0, 0x2c, 0x60, 0x48, 0xc9, 0x91, 0xd6, 0x92, 0x66, 0xa1, 0x70, 0xa2, 0x8b, 0xa6, 0x9e, 0x60, -// 0x1d, 0xad, 0x0f, 0x63, 0x14, 0x55, 0xca, 0xe2, 0x20, 0x74, 0xec, 0x88, 0x48, 0xda, 0xac, 0x4c, -// 0x1e, 0x20, 0x6b, 0xe1, 0x22, 0x76, 0x94, 0x1f, 0xb3, 0x62, 0x95, 0x1c, 0x5a, 0x48, 0xe0, 0xec, -// 0x7f, 0xc3, 0x8c, 0x0b, 0x86, 0x47, 0x23, 0x4c, 0xf5, 0xaa, 0x42, 0x06, 0x04, 0x39, 0x79, 0xe0, -// 0xea, 0x34, 0x81, 0xac, 0xf6, 0x1d, 0x40, 0x5d, 0xf4, 0x84, 0x90, 0x6e, 0xa3, 0x27, 0x1e, 0x22, -// 0x9e, 0xab, 0xc7, 0x0a, 0x37, 0x02, 0x81, 0x81, 0x00, 0x85, 0xee, 0x09, 0x5e, 0x36, 0x6f, 0x0f, -// 0x95, 0x03, 0x80, 0x3e, 0x08, 0xa4, 0x8a, 0x91, 0x06, 0xb3, 0xff, 0x79, 0x06, 0x31, 0x5b, 0x18, -// 0xeb, 0xfd, 0x2f, 0xa9, 0x0d, 0x19, 0x9d, 0xc4, 0xf0, 0x02, 0xf7, 0x4d, 0x77, 0x23, 0xd7, 0x68, -// 0xbf, 0xef, 0x15, 0x43, 0x33, 0xa1, 0x79, 0x7f, 0xc5, 0xc1, 0xfd, 0xc7, 0xa7, 0xba, 0xfb, 0xac, -// 0x24, 0xb1, 0x82, 0x0c, 0xe1, 0x17, 0xb5, 0xda, 0x05, 0x4c, 0x90, 0x80, 0xd8, 0x82, 0x62, 0x2c, -// 0x6d, 0xc8, 0x65, 0xac, 0xa1, 0xb6, 0x6f, 0x82, 0xbd, 0xfd, 0x5f, 0x06, 0x65, 0x7f, 0xda, 0x8b, -// 0xee, 0xb8, 0x8a, 0x4e, 0x59, 0x8b, 0xb3, 0x5e, 0xfc, 0xf0, 0x6d, 0x2f, 0xbc, 0x31, 0x2b, 0xb6, -// 0x97, 0x84, 0x88, 0x0e, 0x51, 0x9b, 0x03, 0x38, 0x56, 0x34, 0x8a, 0x80, 0x7f, 0x67, 0x85, 0x3f, -// 0x70, 0xad, 0x99, 0x20, 0x5e, 0x2a, 0xf2, 0x97, 0x38 -// }; -// unsigned int const prv_bytes_len = 1193; -// -//#pragma clang diagnostic push -//#pragma clang diagnostic ignored "-Wcast-qual" -// NSData * const publicKeyData = [NSData dataWithBytesNoCopy:(void *)pub_bytes length:pub_bytes_len freeWhenDone:NO]; -// NSData * const privateKeyData = [NSData dataWithBytesNoCopy:(void *)prv_bytes length:prv_bytes_len freeWhenDone:NO]; -//#pragma clang diagnostic pop -// -// unsigned char const plaintext_bytes[] = { -// 0x70, 0x6c, 0x61, 0x69, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x0a -// }; -// unsigned int const plaintext_bytes_len = 10; -// -// unsigned char const ciphertext_bytes[] = { -// 0x7e, 0x7f, 0x35, 0xf0, 0x10, 0x3b, 0xf5, 0x8b, 0x72, 0xb1, 0xad, 0xea, 0x4d, 0x50, 0xca, 0xfb, -// 0xb9, 0xb8, 0x9c, 0x01, 0xe4, 0xbd, 0x63, 0x7a, 0xd5, 0x73, 0x80, 0x23, 0x9f, 0x9a, 0xf1, 0xff, -// 0x63, 0xc4, 0x3a, 0xd6, 0xa3, 0xe4, 0xbb, 0x47, 0xd1, 0x64, 0x1e, 0x4f, 0xda, 0xf0, 0xe2, 0x1f, -// 0x7e, 0x7e, 0x1e, 0x82, 0x25, 0xa5, 0xf9, 0x72, 0x17, 0x0c, 0x94, 0x27, 0xdb, 0x58, 0x94, 0x21, -// 0xd0, 0x5c, 0xf4, 0x13, 0x41, 0xc4, 0x8c, 0x82, 0xcf, 0x41, 0xa4, 0xcf, 0x61, 0x9b, 0x14, 0x0e, -// 0xd3, 0xbf, 0x7e, 0xcd, 0x2e, 0xbf, 0x76, 0x9b, 0x19, 0xc0, 0x56, 0x0a, 0x03, 0x58, 0x41, 0xb4, -// 0x0f, 0xdf, 0xaf, 0x0b, 0x29, 0xe6, 0xe7, 0x89, 0x46, 0x6d, 0x35, 0x74, 0xd5, 0x16, 0x89, 0xe2, -// 0xce, 0x6a, 0x8e, 0xc6, 0x14, 0x80, 0xfc, 0xf7, 0x22, 0x05, 0x43, 0x3d, 0x57, 0x97, 0x5f, 0x21, -// 0xed, 0xbc, 0x32, 0x32, 0x16, 0x86, 0x7b, 0x8c, 0x89, 0xcd, 0xf9, 0x43, 0x47, 0x4a, 0x04, 0x7d, -// 0x5d, 0xa1, 0x86, 0x0a, 0x72, 0x9f, 0x64, 0x4c, 0x23, 0xab, 0x5f, 0xe8, 0xac, 0x8a, 0x93, 0xf8, -// 0x15, 0x22, 0x05, 0x82, 0xd0, 0x60, 0xb8, 0x8e, 0x88, 0x54, 0xa8, 0x1c, 0x99, 0xad, 0xc2, 0x62, -// 0x86, 0x91, 0x8f, 0x2e, 0x66, 0x8d, 0x16, 0xb7, 0xe0, 0x3b, 0xe1, 0x8a, 0x2c, 0x6a, 0xa2, 0xe4, -// 0x60, 0xf6, 0x05, 0x0c, 0x5b, 0x2c, 0xe2, 0x2b, 0xd4, 0xf8, 0x5d, 0xf6, 0x95, 0xcc, 0x5c, 0xb0, -// 0x8f, 0xbf, 0x5d, 0xdb, 0xfa, 0x94, 0xf4, 0xff, 0x36, 0x65, 0x6b, 0x34, 0x75, 0x96, 0xaa, 0x59, -// 0xf1, 0x81, 0x74, 0x71, 0x38, 0xeb, 0xe7, 0x9f, 0x50, 0xfb, 0x14, 0x24, 0xbe, 0x40, 0xc5, 0x9c, -// 0xfd, 0x96, 0x9e, 0x66, 0x73, 0x3c, 0x20, 0xff, 0xa6, 0x64, 0xe4, 0x93, 0xe9, 0xa4, 0x44, 0x20 -// }; -// unsigned int const ciphertext_bytes_len = 256; -// -//#pragma clang diagnostic push -//#pragma clang diagnostic ignored "-Wcast-qual" -// NSData * const plaintextDataExpected = [NSData dataWithBytesNoCopy:(void *)plaintext_bytes length:plaintext_bytes_len freeWhenDone:NO]; -// NSData * const ciphertextData = [NSData dataWithBytesNoCopy:(void *)ciphertext_bytes length:ciphertext_bytes_len freeWhenDone:NO]; -//#pragma clang diagnostic pop -// -// [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:NULL]; -// -// { -// NSError *error = nil; -// BOOL status = [STSecurityKeychainAccess insertRSAKeypairWithPublicKeyData:publicKeyData privateKeyData:privateKeyData intoKeychainWithAccessibility:STSecurityKeychainItemAccessibleAlways tag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; -// XCTAssertTrue(status, @"Keychain could not insertion key pair"); -// XCTAssertNil(error, @"Key insertion returned error: %@", error); -// } -// XCTAssertNotNil(publicKey, @"Key insertion resulted in no public key"); -// XCTAssertNotNil(privateKey, @"Key insertion resulted in no private key"); -// -// NSData *ciphertextDataDecrypted = nil; -// { -// NSError *error = nil; -// ciphertextDataDecrypted = [STSecurityRSAEncryption dataByDecryptingData:ciphertextData withPrivateKey:privateKey padding:STSecurityRSAPaddingPKCS1 error:&error]; -// XCTAssertNotNil(ciphertextDataDecrypted); -// XCTAssertNil(error, @"error: %@", error); -// } -// XCTAssertEqualObjects(ciphertextDataDecrypted, plaintextDataExpected); -// -// { -// NSError *error = nil; -// BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:&error]; -// XCTAssertTrue(status, @"Keychain could not delete public key"); -// XCTAssertNil(error, @"Public key deletion returned error: %@", error); -// } -//} -// -//@end +// STSecurityRSAEncryptionTests.m +// STSecurity +// +// Copyright (c) 2012 Scott Talbot. All rights reserved. +// + +@import XCTest; + +#import "STSecurity.h" + + +@interface STSecurityRSAEncryptionTests : XCTestCase +@end + +@implementation STSecurityRSAEncryptionTests + +#if !defined(TRAVIS) || !(TRAVIS + 0) + +- (void)testEncryptionInvalid { + NSString * const keyTag = @"STSecurityTest.testEncryptionInvalid"; + STSecurityRSAPublicKey *publicKey = nil; + STSecurityRSAPrivateKey *privateKey = nil; + NSUInteger keySize = 512; + + [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:NULL]; + + { + NSError *error = nil; + BOOL status = [STSecurityKeychainAccess generateRSAKeypairOfSize:keySize insertedIntoKeychainWithTag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; + XCTAssertTrue(status, @"Keychain could not generate key pair"); + XCTAssertNil(error, @"Key generation returned error: %@", error); + } + XCTAssertNotNil(publicKey, @"Key generation resulted in no public key"); + XCTAssertNotNil(privateKey, @"Key generation resulted in no private key"); + + { + NSError *error = nil; + NSData *data = [STSecurityRSAEncryption dataByEncryptingData:nil withPublicKey:publicKey padding:STSecurityRSAPaddingPKCS1 error:&error]; + XCTAssertNil(data); + XCTAssertNil(error); + } + + { + NSError *error = nil; + NSData *data = [STSecurityRSAEncryption dataByEncryptingData:[NSData data] withPublicKey:publicKey padding:STSecurityRSAPaddingPKCS1 error:&error]; + XCTAssertNotNil(data); + XCTAssertNil(error); + } + + { + NSError *error = nil; + BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:&error]; + XCTAssertTrue(status, @"Keychain could not delete public key"); + XCTAssertNil(error, @"Public key deletion returned error: %@", error); + } +} + +- (void)_st_testEncryptionRoundtripWithData:(NSData *)data keySize:(NSUInteger)keySize padding:(enum STSecurityRSAPadding)padding { + NSString * const keyTag = @"STSecurityTest.testEncryption"; + STSecurityRSAPublicKey *publicKey = nil; + STSecurityRSAPrivateKey *privateKey = nil; + + { + NSError *error = nil; + BOOL status = [STSecurityKeychainAccess generateRSAKeypairOfSize:keySize insertedIntoKeychainWithTag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; + XCTAssertTrue(status, @"Keychain could not generate key pair"); + XCTAssertNil(error, @"Key generation returned error: %@", error); + } + XCTAssertNotNil(publicKey, @"Key generation resulted in no public key"); + XCTAssertNotNil(privateKey, @"Key generation resulted in no private key"); + + NSData *dataEncrypted = nil; + { + NSError *error = nil; + dataEncrypted = [STSecurityRSAEncryption dataByEncryptingData:data withPublicKey:publicKey padding:padding error:&error]; + XCTAssertNotNil(dataEncrypted, @"Encryption returned nil data"); + XCTAssertNil(error, @"Encryption returned error: %@", error); + } + XCTAssertFalse([data isEqualToData:dataEncrypted], @"Encrypted data isEqual: initial"); + + NSData *dataDecrypted = nil; + { + NSError *error = nil; + dataDecrypted = [STSecurityRSAEncryption dataByDecryptingData:dataEncrypted withPrivateKey:privateKey padding:padding error:&error]; + XCTAssertNotNil(dataDecrypted, @"Decryption returned nil data"); + XCTAssertNil(error, @"Decryption returned error: %@", error); + } + XCTAssertEqualObjects(data, dataDecrypted, @"Decrypted data doesn't match input"); + + { + NSError *error = nil; + BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:&error]; + XCTAssertTrue(status, @"Keychain could not delete public key"); + XCTAssertNil(error, @"Public key deletion returned error: %@", error); + } +} + +- (void)testEncryptionRoundtrip0 { + [self _st_testEncryptionRoundtripWithData:[@"plaintext" dataUsingEncoding:NSUTF8StringEncoding] keySize:1024 padding:STSecurityRSAPaddingPKCS1]; +} + +- (void)testEncryptionRoundtrip1 { + NSData *randomData = [STSecurityRandomization dataWithRandomBytesOfLength:16]; + NSMutableData *data = [NSMutableData dataWithCapacity:128]; + while ([data length] < 128) { + [data appendData:randomData]; + } + [data setLength:128 - 11]; + [self _st_testEncryptionRoundtripWithData:data keySize:1024 padding:STSecurityRSAPaddingPKCS1]; +} + +- (void)testEncryptionRoundtrip2 { + NSData *randomData = [STSecurityRandomization dataWithRandomBytesOfLength:16]; + NSMutableData *data = [NSMutableData dataWithCapacity:64]; + for (int i = 0; i < 4; ++i) { + [data appendData:randomData]; + } + [data setLength:64]; + [self _st_testEncryptionRoundtripWithData:data keySize:1024 padding:STSecurityRSAPaddingOAEP]; +} +#endif + +- (void)testEncryptionInserted { + NSString * const keyTag = @"STSecurityTest.testInsertion"; + STSecurityRSAPublicKey *publicKey = nil; + STSecurityRSAPrivateKey *privateKey = nil; + + unsigned char const pub_bytes[] = { + 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, + 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, + 0x00, 0xb6, 0x63, 0x51, 0x02, 0xee, 0xd9, 0x71, 0x5e, 0x2e, 0x88, 0x6a, 0x61, 0xd1, 0x6a, 0x22, + 0xb6, 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18, 0x3e, 0xd2, 0xea, 0xd7, 0x0d, 0xad, 0x5d, 0xfd, + 0x3a, 0xc6, 0xb9, 0xed, 0x78, 0x22, 0xf3, 0x7f, 0x69, 0xe6, 0xb8, 0x0c, 0x09, 0xe4, 0xf0, 0x7f, + 0x8a, 0xc6, 0x1b, 0xe3, 0x63, 0xae, 0x57, 0xe7, 0x6c, 0xe7, 0x92, 0xb7, 0x7b, 0xab, 0x74, 0xdb, + 0x1f, 0x69, 0x3c, 0x45, 0x41, 0x8d, 0x29, 0xd0, 0xda, 0xe7, 0x99, 0xd4, 0xc7, 0x40, 0x58, 0xce, + 0x23, 0x02, 0x03, 0x01, 0x00, 0x01 + }; + unsigned int const pub_bytes_len = 294; + + unsigned char const prv_bytes[] = { + 0x30, 0x82, 0x04, 0xa5, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, 0xb6, 0x63, 0x51, 0x02, + 0xee, 0xd9, 0x71, 0x5e, 0x2e, 0x88, 0x6a, 0x61, 0xd1, 0x6a, 0x22, 0xb6, 0x7d, 0x3e, 0xae, 0xb3, + 0xf1, 0x2c, 0x7f, 0xa7, 0xb3, 0xd7, 0xe1, 0x1e, 0x25, 0x41, 0x38, 0xc4, 0xab, 0xef, 0x43, 0xd8, + 0x93, 0x55, 0xff, 0x42, 0x89, 0xda, 0x54, 0x46, 0x8b, 0xce, 0x54, 0x06, 0x28, 0x9d, 0xae, 0x42, + 0x12, 0xf3, 0x3f, 0x26, 0x70, 0x31, 0x03, 0x6f, 0xa5, 0x61, 0x08, 0x48, 0x73, 0xd7, 0xdf, 0x74, + 0x65, 0x01, 0xec, 0xb8, 0x48, 0x11, 0xdf, 0x45, 0x8d, 0x2c, 0x98, 0x08, 0xd9, 0x49, 0xbd, 0xfb, + 0x71, 0x52, 0x21, 0xd6, 0x15, 0x84, 0xf8, 0xde, 0xfa, 0xcc, 0xdd, 0x12, 0xbc, 0xad, 0xd5, 0x7e, + 0xac, 0x7b, 0x6e, 0xc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c, 0x0b, 0x86, 0x47, 0x23, 0x4c, 0xf5, 0xaa, 0x42, 0x06, 0x04, 0x39, 0x79, 0xe0, + 0xea, 0x34, 0x81, 0xac, 0xf6, 0x1d, 0x40, 0x5d, 0xf4, 0x84, 0x90, 0x6e, 0xa3, 0x27, 0x1e, 0x22, + 0x9e, 0xab, 0xc7, 0x0a, 0x37, 0x02, 0x81, 0x81, 0x00, 0x85, 0xee, 0x09, 0x5e, 0x36, 0x6f, 0x0f, + 0x95, 0x03, 0x80, 0x3e, 0x08, 0xa4, 0x8a, 0x91, 0x06, 0xb3, 0xff, 0x79, 0x06, 0x31, 0x5b, 0x18, + 0xeb, 0xfd, 0x2f, 0xa9, 0x0d, 0x19, 0x9d, 0xc4, 0xf0, 0x02, 0xf7, 0x4d, 0x77, 0x23, 0xd7, 0x68, + 0xbf, 0xef, 0x15, 0x43, 0x33, 0xa1, 0x79, 0x7f, 0xc5, 0xc1, 0xfd, 0xc7, 0xa7, 0xba, 0xfb, 0xac, + 0x24, 0xb1, 0x82, 0x0c, 0xe1, 0x17, 0xb5, 0xda, 0x05, 0x4c, 0x90, 0x80, 0xd8, 0x82, 0x62, 0x2c, + 0x6d, 0xc8, 0x65, 0xac, 0xa1, 0xb6, 0x6f, 0x82, 0xbd, 0xfd, 0x5f, 0x06, 0x65, 0x7f, 0xda, 0x8b, + 0xee, 0xb8, 0x8a, 0x4e, 0x59, 0x8b, 0xb3, 0x5e, 0xfc, 0xf0, 0x6d, 0x2f, 0xbc, 0x31, 0x2b, 0xb6, + 0x97, 0x84, 0x88, 0x0e, 0x51, 0x9b, 0x03, 0x38, 0x56, 0x34, 0x8a, 0x80, 0x7f, 0x67, 0x85, 0x3f, + 0x70, 0xad, 0x99, 0x20, 0x5e, 0x2a, 0xf2, 0x97, 0x38 + }; + unsigned int const prv_bytes_len = 1193; + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcast-qual" + NSData * const publicKeyData = [NSData dataWithBytesNoCopy:(void *)pub_bytes length:pub_bytes_len freeWhenDone:NO]; + NSData * const privateKeyData = [NSData dataWithBytesNoCopy:(void *)prv_bytes length:prv_bytes_len freeWhenDone:NO]; +#pragma clang diagnostic pop + + unsigned char const plaintext_bytes[] = { + 0x70, 0x6c, 0x61, 0x69, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x0a + }; + unsigned int const plaintext_bytes_len = 10; + + unsigned char const ciphertext_bytes[] = { + 0x7e, 0x7f, 0x35, 0xf0, 0x10, 0x3b, 0xf5, 0x8b, 0x72, 0xb1, 0xad, 0xea, 0x4d, 0x50, 0xca, 0xfb, + 0xb9, 0xb8, 0x9c, 0x01, 0xe4, 0xbd, 0x63, 0x7a, 0xd5, 0x73, 0x80, 0x23, 0x9f, 0x9a, 0xf1, 0xff, + 0x63, 0xc4, 0x3a, 0xd6, 0xa3, 0xe4, 0xbb, 0x47, 0xd1, 0x64, 0x1e, 0x4f, 0xda, 0xf0, 0xe2, 0x1f, + 0x7e, 0x7e, 0x1e, 0x82, 0x25, 0xa5, 0xf9, 0x72, 0x17, 0x0c, 0x94, 0x27, 0xdb, 0x58, 0x94, 0x21, + 0xd0, 0x5c, 0xf4, 0x13, 0x41, 0xc4, 0x8c, 0x82, 0xcf, 0x41, 0xa4, 0xcf, 0x61, 0x9b, 0x14, 0x0e, + 0xd3, 0xbf, 0x7e, 0xcd, 0x2e, 0xbf, 0x76, 0x9b, 0x19, 0xc0, 0x56, 0x0a, 0x03, 0x58, 0x41, 0xb4, + 0x0f, 0xdf, 0xaf, 0x0b, 0x29, 0xe6, 0xe7, 0x89, 0x46, 0x6d, 0x35, 0x74, 0xd5, 0x16, 0x89, 0xe2, + 0xce, 0x6a, 0x8e, 0xc6, 0x14, 0x80, 0xfc, 0xf7, 0x22, 0x05, 0x43, 0x3d, 0x57, 0x97, 0x5f, 0x21, + 0xed, 0xbc, 0x32, 0x32, 0x16, 0x86, 0x7b, 0x8c, 0x89, 0xcd, 0xf9, 0x43, 0x47, 0x4a, 0x04, 0x7d, + 0x5d, 0xa1, 0x86, 0x0a, 0x72, 0x9f, 0x64, 0x4c, 0x23, 0xab, 0x5f, 0xe8, 0xac, 0x8a, 0x93, 0xf8, + 0x15, 0x22, 0x05, 0x82, 0xd0, 0x60, 0xb8, 0x8e, 0x88, 0x54, 0xa8, 0x1c, 0x99, 0xad, 0xc2, 0x62, + 0x86, 0x91, 0x8f, 0x2e, 0x66, 0x8d, 0x16, 0xb7, 0xe0, 0x3b, 0xe1, 0x8a, 0x2c, 0x6a, 0xa2, 0xe4, + 0x60, 0xf6, 0x05, 0x0c, 0x5b, 0x2c, 0xe2, 0x2b, 0xd4, 0xf8, 0x5d, 0xf6, 0x95, 0xcc, 0x5c, 0xb0, + 0x8f, 0xbf, 0x5d, 0xdb, 0xfa, 0x94, 0xf4, 0xff, 0x36, 0x65, 0x6b, 0x34, 0x75, 0x96, 0xaa, 0x59, + 0xf1, 0x81, 0x74, 0x71, 0x38, 0xeb, 0xe7, 0x9f, 0x50, 0xfb, 0x14, 0x24, 0xbe, 0x40, 0xc5, 0x9c, + 0xfd, 0x96, 0x9e, 0x66, 0x73, 0x3c, 0x20, 0xff, 0xa6, 0x64, 0xe4, 0x93, 0xe9, 0xa4, 0x44, 0x20 + }; + unsigned int const ciphertext_bytes_len = 256; + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcast-qual" + NSData * const plaintextDataExpected = [NSData dataWithBytesNoCopy:(void *)plaintext_bytes length:plaintext_bytes_len freeWhenDone:NO]; + NSData * const ciphertextData = [NSData dataWithBytesNoCopy:(void *)ciphertext_bytes length:ciphertext_bytes_len freeWhenDone:NO]; +#pragma clang diagnostic pop + + [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:NULL]; + + { + NSError *error = nil; + BOOL status = [STSecurityKeychainAccess insertRSAKeypairWithPublicKeyData:publicKeyData privateKeyData:privateKeyData intoKeychainWithAccessibility:STSecurityKeychainItemAccessibleAlways tag:keyTag publicKey:&publicKey privateKey:&privateKey error:&error]; + XCTAssertTrue(status, @"Keychain could not insertion key pair"); + XCTAssertNil(error, @"Key insertion returned error: %@", error); + } + XCTAssertNotNil(publicKey, @"Key insertion resulted in no public key"); + XCTAssertNotNil(privateKey, @"Key insertion resulted in no private key"); + + NSData *ciphertextDataDecrypted = nil; + { + NSError *error = nil; + ciphertextDataDecrypted = [STSecurityRSAEncryption dataByDecryptingData:ciphertextData withPrivateKey:privateKey padding:STSecurityRSAPaddingPKCS1 error:&error]; + XCTAssertNotNil(ciphertextDataDecrypted); + XCTAssertNil(error, @"error: %@", error); + } + XCTAssertEqualObjects(ciphertextDataDecrypted, plaintextDataExpected); + + { + NSError *error = nil; + BOOL status = [STSecurityKeychainAccess deleteRSAKeysForTag:keyTag error:&error]; + XCTAssertTrue(status, @"Keychain could not delete public key"); + XCTAssertNil(error, @"Public key deletion returned error: %@", error); + } +} + +@end diff --git a/STSecurityTests/STSecurityRSAKeyTests.m b/STSecurityTests/STSecurityRSAKeyTests.m index 83c4868..ec9af9b 100644 --- a/STSecurityTests/STSecurityRSAKeyTests.m +++ b/STSecurityTests/STSecurityRSAKeyTests.m @@ -1,43 +1,43 @@ -//// -//// STSecurityRSAKeyTests.m -//// STSecurity -//// -//// Copyright (c) 2012 Scott Talbot. All rights reserved. -//// // -//@import XCTest; -// -//#import -//#import "STSecurityRSAKey+Internal.h" -// -// -//@interface STSecurityRSAKeyTests : XCTestCase -//@end -// -//@implementation STSecurityRSAKeyTests -// -//- (void)testPublicKeyInstantiation { -// { -// STSecurityRSAPublicKey *key; -//#if defined(NS_BLOCK_ASSERTIONS) -// key = [[STSecurityRSAPublicKey alloc] initWithKeyRef:NULL keyData:nil]; -//#else -// XCTAssertThrows(key = [[STSecurityRSAPublicKey alloc] initWithKeyRef:NULL keyData:nil], @"Creating public key with neither keyRef nor data didn't throw"); -//#endif -// XCTAssertNil(key, @"Created public key with neither keyRef nor keyData"); -// } -//} -// -//- (void)testPrivateKeyInstantiation { -// { -// STSecurityRSAPrivateKey *key; -//#if defined(NS_BLOCK_ASSERTIONS) -// key = [[STSecurityRSAPrivateKey alloc] initWithKeyRef:NULL]; -//#else -// XCTAssertThrows(key = [[STSecurityRSAPrivateKey alloc] initWithKeyRef:NULL], @"Creating private key with NULL keyRef"); -//#endif -// XCTAssertNil(key, @"Created private key with NULL keyRef"); -// } -//} -// -//@end +// STSecurityRSAKeyTests.m +// STSecurity +// +// Copyright (c) 2012 Scott Talbot. All rights reserved. +// + +@import XCTest; + +#import +#import "STSecurityRSAKey+Internal.h" + + +@interface STSecurityRSAKeyTests : XCTestCase +@end + +@implementation STSecurityRSAKeyTests + +- (void)testPublicKeyInstantiation { + { + STSecurityRSAPublicKey *key; +#if defined(NS_BLOCK_ASSERTIONS) + key = [[STSecurityRSAPublicKey alloc] initWithKeyRef:NULL keyData:nil]; +#else + XCTAssertThrows(key = [[STSecurityRSAPublicKey alloc] initWithKeyRef:NULL keyData:nil], @"Creating public key with neither keyRef nor data didn't throw"); +#endif + XCTAssertNil(key, @"Created public key with neither keyRef nor keyData"); + } +} + +- (void)testPrivateKeyInstantiation { + { + STSecurityRSAPrivateKey *key; +#if defined(NS_BLOCK_ASSERTIONS) + key = [[STSecurityRSAPrivateKey alloc] initWithKeyRef:NULL]; +#else + XCTAssertThrows(key = [[STSecurityRSAPrivateKey alloc] initWithKeyRef:NULL], @"Creating private key with NULL keyRef"); +#endif + XCTAssertNil(key, @"Created private key with NULL keyRef"); + } +} + +@end