├── .swift-version ├── Sources ├── Hash │ ├── Exports.swift │ └── Hasher.swift ├── Signature │ ├── Exports.swift │ ├── HMACKey.swift │ ├── Signer.swift │ └── AsymmetricKey.swift └── CryptoSupport │ ├── Hex.swift │ ├── CryptoProvider.swift │ ├── CryptoError.swift │ └── Protocols.swift ├── TestFixtures ├── ecdsa_p256_public.pem ├── ecdsa_p256k1_public.pem ├── ecdsa_p384_public.pem ├── rsa_1024_public.pem ├── ecdsa_p256k1_private_secure.pem ├── ecdsa_p256k1_private.pem ├── ecdsa_p256_private_secure.pem ├── ecdsa_p256_private.pem ├── ecdsa_p384_private_secure.pem ├── ecdsa_p384_private.pem ├── rsa_2048_public.pem ├── rsa_1024_private.pem └── rsa_2048_private.pem ├── ServerCrypto.xcodeproj ├── project.xcworkspace │ └── contents.xcworkspacedata ├── xcshareddata │ └── xcschemes │ │ ├── xcschememanagement.plist │ │ └── ServerCrypto.xcscheme ├── Hash_Info.plist ├── Signature_Info.plist ├── CryptoSupport_Info.plist ├── ServerCryptoTests_Info.plist ├── SwiftCryptoTests_Info.plist └── project.pbxproj ├── Tests ├── LinuxMain.swift └── ServerCryptoTests │ ├── CryptoSupport │ ├── CryptoErrorTests.swift │ └── HexTests.swift │ ├── Hash │ └── HashTests.swift │ └── Signature │ ├── ECDSA │ ├── ECDSATests.swift │ └── ECDSASignatures.swift │ ├── SignatureTestsCoordinator.swift │ ├── HMAC │ ├── HMACTests.swift │ └── HMACSignatures.swift │ └── RSA │ ├── RSATests.swift │ └── RSATestVectors.swift ├── Package.resolved ├── .travis.yml ├── .ci ├── install.sh └── test.sh ├── Package.swift ├── LICENSE ├── .gitignore └── README.md /.swift-version: -------------------------------------------------------------------------------- 1 | 4.0 2 | -------------------------------------------------------------------------------- /Sources/Hash/Exports.swift: -------------------------------------------------------------------------------- 1 | /** 2 | * ServerCrypto 3 | * Copyright (c) 2017 Alexis Aubry. Licensed under the MIT license. 4 | */ 5 | 6 | @_exported import CryptoSupport 7 | -------------------------------------------------------------------------------- /Sources/Signature/Exports.swift: -------------------------------------------------------------------------------- 1 | /** 2 | * ServerCrypto 3 | * Copyright (c) 2017 Alexis Aubry. Licensed under the MIT license. 4 | */ 5 | 6 | @_exported import CryptoSupport 7 | @_exported import Hash 8 | -------------------------------------------------------------------------------- /TestFixtures/ecdsa_p256_public.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEIRANy4z+0EzSzHE53kpB1QG+0ans 3 | GCA5Q1pFyz+vzBP+ZlZZ+0OlHFpXDoU+yAo87EcVuMML/h34d0Np2iXMPw== 4 | -----END PUBLIC KEY----- 5 | -------------------------------------------------------------------------------- /TestFixtures/ecdsa_p256k1_public.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEd03O3e34pyzR+W8F/fp7ehs6FJxka0yL 3 | PO6DQAsJiN37SkclMWQxQm/VKbZgnKfChru50f8NMr0OsrTVDhTmxw== 4 | -----END PUBLIC KEY----- 5 | -------------------------------------------------------------------------------- /TestFixtures/ecdsa_p384_public.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEii2KI6N8O257DEkQqhnOd3b8rzNbNiMx 3 | ujUJ+hyuTiqt/SVia6fPhFbzd3XiWK2FSpPvI5gedj1vW1VQpImAIRF7Vx7AoYnj 4 | t8kVDiK7ymrXSVvfF1uA1rqQtcafM8eJ 5 | -----END PUBLIC KEY----- 6 | -------------------------------------------------------------------------------- /ServerCrypto.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /TestFixtures/rsa_1024_public.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9zqSZaBCMMslWnQs7YPorK4dU 3 | Tsc/i7jqDGB+RTZ089Fxns6NVsYXbDNW68sB6zL/vo2y2PRPmXu/jApK3zlLozUg 4 | RPxqNp8VTZT2rAxNBx2xkt0nvvit3etqR/Yf9pXQ+PfsjPfamj3uD4q5amZHj5Fh 5 | Lix5UTl34W/obAZO/wIDAQAB 6 | -----END PUBLIC KEY----- 7 | -------------------------------------------------------------------------------- /Tests/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import ServerCryptoTests 3 | 4 | XCTMain([ 5 | testCase(HexTests.allTests), 6 | testCase(CryptoErrorTests.allTests), 7 | testCase(HashTests.allTests), 8 | testCase(HMACTests.allTests), 9 | testCase(ECDSATests.allTests), 10 | testCase(RSATests.allTests), 11 | ]) 12 | -------------------------------------------------------------------------------- /TestFixtures/ecdsa_p256k1_private_secure.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PRIVATE KEY----- 2 | Proc-Type: 4,ENCRYPTED 3 | DEK-Info: DES-CBC,581055E4790B6E06 4 | 5 | NK+9waxzEjbRaRuVnhJXNET7lp/pC+9ODvWkuP587RhE51TRSerTS7CqmJFPrhVf 6 | 36TBfimJZOWR8HFhM17o9riUOq79vGTAYLFnsbBSwDimLdPFYT/jK4F499Fiwr+5 7 | wJEtfn45YOcEK0lIDXmoeBoKM6tW7pYz 8 | -----END EC PRIVATE KEY----- 9 | -------------------------------------------------------------------------------- /TestFixtures/ecdsa_p256k1_private.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PARAMETERS----- 2 | BgUrgQQACg== 3 | -----END EC PARAMETERS----- 4 | -----BEGIN EC PRIVATE KEY----- 5 | MHQCAQEEIOfRoN9qzusR5TGh+Omm7MiWxd4Cvab/5sVwUuMF9bAPoAcGBSuBBAAK 6 | oUQDQgAEd03O3e34pyzR+W8F/fp7ehs6FJxka0yLPO6DQAsJiN37SkclMWQxQm/V 7 | KbZgnKfChru50f8NMr0OsrTVDhTmxw== 8 | -----END EC PRIVATE KEY----- 9 | -------------------------------------------------------------------------------- /TestFixtures/ecdsa_p256_private_secure.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PRIVATE KEY----- 2 | Proc-Type: 4,ENCRYPTED 3 | DEK-Info: DES-CBC,69D237798EB4E1AD 4 | 5 | 0oPN79AW5FViLmVZ3TBO2sWJeLI4zrjW4OhjAZ1fSXBFS3igvnGcb2lCDozsMqYq 6 | DmE4v4hCf1Dp5b6+xJSmwWf5EMRw8uUFcQ9Pn7UnNDHK+x4haxTP/iYKkNIBCBcJ 7 | Zaj9W9CUEpHpMyvXcygopJ3QncaQT7zRoJp/m8jufoY= 8 | -----END EC PRIVATE KEY----- 9 | -------------------------------------------------------------------------------- /TestFixtures/ecdsa_p256_private.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PARAMETERS----- 2 | BggqhkjOPQMBBw== 3 | -----END EC PARAMETERS----- 4 | -----BEGIN EC PRIVATE KEY----- 5 | MHcCAQEEINahSHFi15+LTUPNKDnMNBHU0CAQYyhdHLFSt59uFT71oAoGCCqGSM49 6 | AwEHoUQDQgAEIRANy4z+0EzSzHE53kpB1QG+0ansGCA5Q1pFyz+vzBP+ZlZZ+0Ol 7 | HFpXDoU+yAo87EcVuMML/h34d0Np2iXMPw== 8 | -----END EC PRIVATE KEY----- 9 | -------------------------------------------------------------------------------- /ServerCrypto.xcodeproj/xcshareddata/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SchemeUserState 5 | 6 | ServerCrypto-Package.xcscheme 7 | 8 | 9 | SuppressBuildableAutocreation 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Package.resolved: -------------------------------------------------------------------------------- 1 | { 2 | "object": { 3 | "pins": [ 4 | { 5 | "package": "CTLS", 6 | "repositoryURL": "https://github.com/vapor/ctls", 7 | "state": { 8 | "branch": null, 9 | "revision": "fddec6a4643d6e85b6bb6dc54b1b5cdbabd395d2", 10 | "version": "1.1.2" 11 | } 12 | } 13 | ] 14 | }, 15 | "version": 1 16 | } 17 | -------------------------------------------------------------------------------- /TestFixtures/ecdsa_p384_private_secure.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PRIVATE KEY----- 2 | Proc-Type: 4,ENCRYPTED 3 | DEK-Info: DES-CBC,AF9D5CD3FAE6DD55 4 | 5 | zB/L5IJnQhXbZZxqFJImnkooMNpnaSb1/cIpSZpFeRDwPH2XwBR5X+NVCDmFL6Pn 6 | w0BmHKkSLbiQnZgjRK2br+GZ7WcZfcTeoI8nzbd1zOaC0/PGmDzDD+weLrq2ptrf 7 | wpjd/YKqxLs2SRGXQ8ZsFdXSf4LSsYQXA6bk9nSpnPAUsuOTh/qZJXfjenHnyvRK 8 | SnVgOtXczQgRmx17Ars9dP7T+QB+J3kA 9 | -----END EC PRIVATE KEY----- 10 | -------------------------------------------------------------------------------- /TestFixtures/ecdsa_p384_private.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PARAMETERS----- 2 | BgUrgQQAIg== 3 | -----END EC PARAMETERS----- 4 | -----BEGIN EC PRIVATE KEY----- 5 | MIGkAgEBBDAV1pHzjd8+nZb8XAW3DQN7w+QTfdMgvPaEHNCJ1sRvsBVumKgftK8O 6 | M9fmrSCzTE+gBwYFK4EEACKhZANiAASKLYojo3w7bnsMSRCqGc53dvyvM1s2IzG6 7 | NQn6HK5OKq39JWJrp8+EVvN3deJYrYVKk+8jmB52PW9bVVCkiYAhEXtXHsChieO3 8 | yRUOIrvKatdJW98XW4DWupC1xp8zx4k= 9 | -----END EC PRIVATE KEY----- 10 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: generic 2 | 3 | matrix: 4 | include: 5 | - os: linux 6 | dist: trusty 7 | sudo: required 8 | env: LOCAL_SWIFT_BRANCH="swift-4.0-release" LOCAL_SWIFT_VERSION="swift-4.0-RELEASE" DEPLOY="false" 9 | - os: osx 10 | osx_image: xcode9 11 | language: objective-c 12 | 13 | install: 14 | - ./.ci/install.sh 15 | 16 | script: 17 | - ./.ci/test.sh -------------------------------------------------------------------------------- /TestFixtures/rsa_2048_public.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA+FXyQ55AVPWO6TFqGsHS 3 | /Jsem/FfeO4IUHw522Qwh+USE8F0ulvZxMd3q6yFd/qMDierBA9bIK0Iizd9IUG1 4 | JVyyRuT8u9p/1IdF1zC1IluwzutxLwrsbwrOo400qQ40dzGxqKsD+50nQjFpahfI 5 | mzFbg4dZtksuJt5Y3xNIcLOdMLQbyJM8hJAEhS47JKgvzX1ZVg95u3ulYXXYom6T 6 | KHHFbgJMRrcexr7+JfF1d/+tD0QAdH2KMPmA3m6AN1MB7bdRSWV/dnPpBGX5ueV9 7 | tYWGrDRHLk+XdHaBjpRemI1pDMDIjymXSUJETvBuFbmbUmrTD4GfP8VMUjpWASfv 8 | eQIDAQAB 9 | -----END PUBLIC KEY----- 10 | -------------------------------------------------------------------------------- /.ci/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | if [[ $TRAVIS_OS_NAME == 'osx' ]]; then 5 | echo "👉 Installing build dependencies" 6 | gem install xcpretty 7 | brew outdated openssl && brew install openssl 8 | fi 9 | 10 | if [[ $TRAVIS_OS_NAME == 'linux' ]]; then 11 | 12 | echo "👉 Installing build dependencies" 13 | sudo apt-get install libssl-dev 14 | 15 | echo "👉 Installing Swift" 16 | SWIFT_URL=https://swift.org/builds/$LOCAL_SWIFT_BRANCH/ubuntu1404/$LOCAL_SWIFT_VERSION/$LOCAL_SWIFT_VERSION-ubuntu14.04.tar.gz 17 | curl -L $SWIFT_URL -o swift.tar.gz 18 | sudo tar -xzf swift.tar.gz --directory /usr/local --strip-components=2 19 | 20 | echo "👉 Fixing CoreFoundation" 21 | sudo find /usr/local/lib/swift/CoreFoundation -type f -exec chmod 644 {} \; 22 | 23 | fi -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:4.0 2 | 3 | import PackageDescription 4 | 5 | let package = Package( 6 | name: "ServerCrypto", 7 | products: [ 8 | .library(name: "CryptoSupport", targets: ["CryptoSupport"]), 9 | .library(name: "Hash", targets: ["Hash"]), 10 | .library(name: "Signature", targets: ["Signature"]) 11 | ], 12 | dependencies: [ 13 | .package(url: "https://github.com/vapor/ctls", from: "1.1.0") 14 | ], 15 | targets: [ 16 | .target(name: "CryptoSupport", dependencies: []), 17 | .target(name: "Hash", dependencies: ["CryptoSupport"]), 18 | .target(name: "Signature", dependencies: ["CryptoSupport", "Hash"]), 19 | .testTarget(name: "ServerCryptoTests",dependencies: ["CryptoSupport", "Hash", "Signature"]) 20 | ] 21 | ) 22 | -------------------------------------------------------------------------------- /ServerCrypto.xcodeproj/Hash_Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CFBundleDevelopmentRegion 5 | en 6 | CFBundleExecutable 7 | $(EXECUTABLE_NAME) 8 | CFBundleIdentifier 9 | $(PRODUCT_BUNDLE_IDENTIFIER) 10 | CFBundleInfoDictionaryVersion 11 | 6.0 12 | CFBundleName 13 | $(PRODUCT_NAME) 14 | CFBundlePackageType 15 | FMWK 16 | CFBundleShortVersionString 17 | 1.0 18 | CFBundleSignature 19 | ???? 20 | CFBundleVersion 21 | $(CURRENT_PROJECT_VERSION) 22 | NSPrincipalClass 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /ServerCrypto.xcodeproj/Signature_Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CFBundleDevelopmentRegion 5 | en 6 | CFBundleExecutable 7 | $(EXECUTABLE_NAME) 8 | CFBundleIdentifier 9 | $(PRODUCT_BUNDLE_IDENTIFIER) 10 | CFBundleInfoDictionaryVersion 11 | 6.0 12 | CFBundleName 13 | $(PRODUCT_NAME) 14 | CFBundlePackageType 15 | FMWK 16 | CFBundleShortVersionString 17 | 1.0 18 | CFBundleSignature 19 | ???? 20 | CFBundleVersion 21 | $(CURRENT_PROJECT_VERSION) 22 | NSPrincipalClass 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /ServerCrypto.xcodeproj/CryptoSupport_Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CFBundleDevelopmentRegion 5 | en 6 | CFBundleExecutable 7 | $(EXECUTABLE_NAME) 8 | CFBundleIdentifier 9 | $(PRODUCT_BUNDLE_IDENTIFIER) 10 | CFBundleInfoDictionaryVersion 11 | 6.0 12 | CFBundleName 13 | $(PRODUCT_NAME) 14 | CFBundlePackageType 15 | FMWK 16 | CFBundleShortVersionString 17 | 1.0 18 | CFBundleSignature 19 | ???? 20 | CFBundleVersion 21 | $(CURRENT_PROJECT_VERSION) 22 | NSPrincipalClass 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /ServerCrypto.xcodeproj/ServerCryptoTests_Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CFBundleDevelopmentRegion 5 | en 6 | CFBundleExecutable 7 | $(EXECUTABLE_NAME) 8 | CFBundleIdentifier 9 | $(PRODUCT_BUNDLE_IDENTIFIER) 10 | CFBundleInfoDictionaryVersion 11 | 6.0 12 | CFBundleName 13 | $(PRODUCT_NAME) 14 | CFBundlePackageType 15 | BNDL 16 | CFBundleShortVersionString 17 | 1.0 18 | CFBundleSignature 19 | ???? 20 | CFBundleVersion 21 | $(CURRENT_PROJECT_VERSION) 22 | NSPrincipalClass 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /ServerCrypto.xcodeproj/SwiftCryptoTests_Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CFBundleDevelopmentRegion 5 | en 6 | CFBundleExecutable 7 | $(EXECUTABLE_NAME) 8 | CFBundleIdentifier 9 | $(PRODUCT_BUNDLE_IDENTIFIER) 10 | CFBundleInfoDictionaryVersion 11 | 6.0 12 | CFBundleName 13 | $(PRODUCT_NAME) 14 | CFBundlePackageType 15 | BNDL 16 | CFBundleShortVersionString 17 | 1.0 18 | CFBundleSignature 19 | ???? 20 | CFBundleVersion 21 | $(CURRENT_PROJECT_VERSION) 22 | NSPrincipalClass 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /TestFixtures/rsa_1024_private.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXQIBAAKBgQC9zqSZaBCMMslWnQs7YPorK4dUTsc/i7jqDGB+RTZ089Fxns6N 3 | VsYXbDNW68sB6zL/vo2y2PRPmXu/jApK3zlLozUgRPxqNp8VTZT2rAxNBx2xkt0n 4 | vvit3etqR/Yf9pXQ+PfsjPfamj3uD4q5amZHj5FhLix5UTl34W/obAZO/wIDAQAB 5 | AoGAbLy6jWwRts/NioIzkhPvndW1FLaA7UW1bNgkW5J5LS0VOvtYp54jo/2Ht+8j 6 | gPjmYZ8f/GrQI93xB/5JUzVo05Cb5FCQ7Gh+q7QKRFnKTZUP2+/YKqSWn+Q9P2eq 7 | RDILzUXxuz5rtmDCPB8d9erMKbHbArRDQLxofxcuKsjqu2ECQQDePPUWskNK2oU1 8 | mxj7xhqYkKhn8ixzLWSjFQuAM7FEviypSZjRTimdAR816bZ8oh0Rv6XTfsGt+YEK 9 | ptj0zERPAkEA2qRq8bSvKINet1Z+DxZslY50PYZboRkrmr0JAR5r6R6stN/Cgw5c 10 | YBuywWw6tKP1fAVtAEsFEFuP4dDhptmuUQJADa3u4CDE55yfynbriMPe6zksRImx 11 | lr1ajndDJ/cGmFakZR80mt2WziU9iJIEO5O2+lqzmFsbDNxoxwESJa9VHQJBANLA 12 | keWSyRRALViEItbgQqKWwi1cCY7r+EAb30YY0OPREaD330L84MYzbMdNT/k34jU9 13 | 9afGqIbv+20sL5bpVUECQQCuDats4wGC9TfUNBGIYLW9dWJXNEIcQovBxAluxEkM 14 | tndGB/VYppjrXNRb1aIbBzzqaKiKJ818AcsIj9GBpWtw 15 | -----END RSA PRIVATE KEY----- 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Alexis Aubry Radanovic 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.ci/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | if [[ $TRAVIS_OS_NAME == 'osx' ]]; then 5 | 6 | echo "👉 Building with Xcode" 7 | xcodebuild clean build -project ServerCrypto.xcodeproj -scheme ServerCrypto | xcpretty 8 | 9 | echo "👉 Building with SPM in Debug mode" 10 | swift package clean 11 | swift build -Xswiftc -I/usr/local/opt/openssl/include -Xlinker -L/usr/local/opt/openssl/lib 12 | 13 | echo "👉 Building with SPM in Release mode" 14 | swift package clean 15 | swift build -c release -Xswiftc -I/usr/local/opt/openssl/include -Xlinker -L/usr/local/opt/openssl/lib 16 | 17 | echo "👉 Testing with Xcode" 18 | xcodebuild clean test -project ServerCrypto.xcodeproj -scheme ServerCrypto | xcpretty 19 | 20 | echo "👉 Testing with SPM" 21 | swift package clean 22 | swift test -Xswiftc -I/usr/local/opt/openssl/include -Xlinker -L/usr/local/opt/openssl/lib 23 | 24 | echo "✅ Done" 25 | 26 | fi 27 | 28 | if [[ $TRAVIS_OS_NAME == 'linux' ]]; then 29 | 30 | echo "👉 Building with SPM in Debug mode" 31 | swift package clean 32 | swift build 33 | 34 | echo "👉 Building with SPM in Release mode" 35 | swift package clean 36 | swift build -c release 37 | 38 | echo "👉 Testing with SPM" 39 | swift package clean 40 | swift test 41 | 42 | echo "✅ Done" 43 | 44 | fi 45 | -------------------------------------------------------------------------------- /Tests/ServerCryptoTests/CryptoSupport/CryptoErrorTests.swift: -------------------------------------------------------------------------------- 1 | /** 2 | * ServerCrypto 3 | * Copyright (c) 2017 Alexis Aubry. Licensed under the MIT license. 4 | */ 5 | 6 | import XCTest 7 | import Foundation 8 | import CTLS 9 | import Signature 10 | @testable import CryptoSupport 11 | 12 | class CryptoErrorTests: XCTestCase { 13 | 14 | func testGetLatestError() throws { 15 | 16 | CryptoProvider.load(.digests, .cryptoErrorStrings) 17 | 18 | let hmacKey = try HMACKey(password: "secret") 19 | let messageDigest = EVP_sha256() 20 | let context = EVP_MD_CTX_create() 21 | 22 | defer { 23 | EVP_MD_CTX_destroy(context) 24 | } 25 | 26 | /* Invalid Code */ 27 | 28 | EVP_DigestVerifyInit(context, nil, messageDigest, nil, hmacKey.underlyingKeyPointer) 29 | let error = CryptoError.latest 30 | 31 | XCTAssertTrue(error.errorDescription.hasSuffix("operation not supported for this keytype")) 32 | XCTAssertTrue(error.localizedDescription.hasSuffix("operation not supported for this keytype")) 33 | 34 | } 35 | 36 | } 37 | 38 | extension CryptoErrorTests { 39 | 40 | static var allTests : [(String, (CryptoErrorTests) -> () throws -> Void)] { 41 | return [ 42 | ("testGetLatestError", testGetLatestError) 43 | ] 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /Sources/CryptoSupport/Hex.swift: -------------------------------------------------------------------------------- 1 | /** 2 | * ServerCrypto 3 | * Copyright (c) 2017 Alexis Aubry. Licensed under the MIT license. 4 | */ 5 | 6 | import Foundation 7 | 8 | // MARK: - Get Hex from Data 9 | 10 | extension Data { 11 | 12 | /** 13 | * The hexadecimal text representation of the data. 14 | * - note: The returned string is lowercased. 15 | */ 16 | 17 | public var hexString: String { 18 | 19 | return reduce("") { 20 | (string, nextByte) in 21 | return string + String(format: "%02x", nextByte) 22 | } 23 | 24 | } 25 | 26 | } 27 | 28 | // MARK: - Create Data from Hex 29 | 30 | extension Data { 31 | 32 | /** 33 | * Extracts the bytes of a hex string. 34 | * - parameter hexString: The string. 35 | */ 36 | 37 | public init?(hexString: String) { 38 | 39 | var itetator = hexString.makeIterator() 40 | 41 | var bytes = Data() 42 | 43 | while let h1 = itetator.next() { 44 | 45 | var hexSequence = String(h1) 46 | 47 | if let h2 = itetator.next() { 48 | hexSequence += String(h2) 49 | } else { 50 | hexSequence.insert("0", at: hexSequence.startIndex) 51 | } 52 | 53 | guard let byte = UInt8(hexSequence, radix: 16) else { 54 | return nil 55 | } 56 | 57 | bytes.append(byte) 58 | 59 | } 60 | 61 | self = bytes 62 | 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /Sources/CryptoSupport/CryptoProvider.swift: -------------------------------------------------------------------------------- 1 | /** 2 | * ServerCrypto 3 | * Copyright (c) 2017 Alexis Aubry. Licensed under the MIT license. 4 | */ 5 | 6 | import CTLS 7 | 8 | /** 9 | * An object that loads components from OpenSSL on demand. 10 | */ 11 | 12 | public class CryptoProvider { 13 | 14 | public enum Component: Int { 15 | 16 | /// The OpenSSL digests. 17 | case digests 18 | 19 | /// The OpenSSL ciphers. 20 | case ciphers 21 | 22 | /// The error descriptions for the Crypto APIs. 23 | case cryptoErrorStrings 24 | 25 | /// Loads the component. 26 | func load() { 27 | 28 | switch self { 29 | case .digests: OpenSSL_add_all_digests() 30 | case .ciphers: OpenSSL_add_all_ciphers() 31 | case .cryptoErrorStrings: ERR_load_crypto_strings() 32 | } 33 | 34 | } 35 | 36 | } 37 | 38 | private static var loadedComponents: Set = [] 39 | 40 | /** 41 | * Loads the specified OpenSSL components if they are not already loaded. 42 | * 43 | * - parameter components: The components to load. 44 | */ 45 | 46 | public static func load(_ components: Component...) { 47 | 48 | for component in components { 49 | 50 | guard !loadedComponents.contains(component) else { 51 | continue 52 | } 53 | 54 | component.load() 55 | loadedComponents.insert(component) 56 | 57 | } 58 | 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /Sources/Signature/HMACKey.swift: -------------------------------------------------------------------------------- 1 | /** 2 | * ServerCrypto 3 | * Copyright (c) 2017 Alexis Aubry. Licensed under the MIT license. 4 | */ 5 | 6 | import Foundation 7 | import CryptoSupport 8 | import CTLS 9 | 10 | /** 11 | * A key to sign and verify with the HMAC algorithm. 12 | */ 13 | 14 | public class HMACKey { 15 | 16 | public let underlyingKeyPointer: UnsafeMutablePointer 17 | 18 | /** 19 | * Create a HMAC key with a binary password. 20 | * - parameter password: The bytes making the password. 21 | * - throws: In case of failure, this initializer throws a `CryptoError` object. 22 | */ 23 | 24 | public init(password: Data) throws { 25 | 26 | CryptoProvider.load(.digests, .cryptoErrorStrings) 27 | 28 | let optionalKey = password.withUnsafeBytes { 29 | (buf: UnsafePointer) -> UnsafeMutablePointer! in 30 | return EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, nil, buf, Int32(password.count)) 31 | } 32 | 33 | guard let key = optionalKey else { 34 | throw CryptoError.latest 35 | } 36 | 37 | underlyingKeyPointer = key 38 | 39 | } 40 | 41 | /** 42 | * Create a HMAC key with a plain-text password. 43 | * - parameter password: The plain-text password. 44 | * - throws: In case of failure, this initializer throws a `CryptoError` object. 45 | */ 46 | 47 | public convenience init(password: String) throws { 48 | let passwordData = Data(password.utf8) 49 | try self.init(password: passwordData) 50 | } 51 | 52 | deinit { 53 | EVP_PKEY_free(underlyingKeyPointer) 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /Sources/CryptoSupport/CryptoError.swift: -------------------------------------------------------------------------------- 1 | /** 2 | * ServerCrypto 3 | * Copyright (c) 2017 Alexis Aubry. Licensed under the MIT license. 4 | */ 5 | 6 | import Foundation 7 | import CTLS 8 | 9 | /** 10 | * The structured representation of an OpenSSL error. 11 | */ 12 | 13 | public struct CryptoError: LocalizedError { 14 | 15 | // MARK: - Properties 16 | 17 | /// The code of the error. 18 | public let code: UInt 19 | 20 | /// The description of the error. 21 | private let errDescription: String 22 | 23 | public var errorDescription: String { 24 | return errDescription 25 | } 26 | 27 | public var localizedDescription: String { 28 | return errDescription 29 | } 30 | 31 | // MARK: - Lifecycle 32 | 33 | /** 34 | * Creates an error descriptor. 35 | * - parameter code: The code of the error. 36 | * - parameter localizedDescription: The description of the error. 37 | */ 38 | 39 | private init(code: UInt, errDescription: String) { 40 | self.code = code 41 | self.errDescription = errDescription 42 | } 43 | 44 | // MARK: - Getting the Latest Error 45 | 46 | /** 47 | * The latest error thrown by the OpenSSL library. 48 | * - returns: The object describing the latest error. 49 | */ 50 | 51 | public static var latest: CryptoError { 52 | 53 | let code = ERR_get_error() 54 | 55 | var errorStringBuffer = [Int8]() 56 | ERR_error_string(code, &errorStringBuffer) 57 | 58 | let errDescription = String(cString: &errorStringBuffer) 59 | return CryptoError(code: code, errDescription: errDescription) 60 | 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | **/.DS_Store 6 | 7 | ## Build generated 8 | build/ 9 | DerivedData/ 10 | 11 | ## Various settings 12 | *.pbxuser 13 | !default.pbxuser 14 | *.mode1v3 15 | !default.mode1v3 16 | *.mode2v3 17 | !default.mode2v3 18 | *.perspectivev3 19 | !default.perspectivev3 20 | xcuserdata/ 21 | 22 | ## Other 23 | *.moved-aside 24 | *.xccheckout 25 | *.xcscmblueprint 26 | 27 | ## Obj-C/Swift specific 28 | *.hmap 29 | *.ipa 30 | *.dSYM.zip 31 | *.dSYM 32 | 33 | ## Playgrounds 34 | timeline.xctimeline 35 | playground.xcworkspace 36 | 37 | # Swift Package Manager 38 | # 39 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 40 | # Packages/ 41 | # Package.pins 42 | .build/ 43 | 44 | # CocoaPods 45 | # 46 | # We recommend against adding the Pods directory to your .gitignore. However 47 | # you should judge for yourself, the pros and cons are mentioned at: 48 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 49 | # 50 | # Pods/ 51 | 52 | # Carthage 53 | # 54 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 55 | # Carthage/Checkouts 56 | 57 | Carthage/Build 58 | 59 | # fastlane 60 | # 61 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 62 | # screenshots whenever they are needed. 63 | # For more information about the recommended setup visit: 64 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 65 | 66 | fastlane/report.xml 67 | fastlane/Preview.html 68 | fastlane/screenshots 69 | fastlane/test_output 70 | -------------------------------------------------------------------------------- /TestFixtures/rsa_2048_private.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEpAIBAAKCAQEA+FXyQ55AVPWO6TFqGsHS/Jsem/FfeO4IUHw522Qwh+USE8F0 3 | ulvZxMd3q6yFd/qMDierBA9bIK0Iizd9IUG1JVyyRuT8u9p/1IdF1zC1Iluwzutx 4 | LwrsbwrOo400qQ40dzGxqKsD+50nQjFpahfImzFbg4dZtksuJt5Y3xNIcLOdMLQb 5 | yJM8hJAEhS47JKgvzX1ZVg95u3ulYXXYom6TKHHFbgJMRrcexr7+JfF1d/+tD0QA 6 | dH2KMPmA3m6AN1MB7bdRSWV/dnPpBGX5ueV9tYWGrDRHLk+XdHaBjpRemI1pDMDI 7 | jymXSUJETvBuFbmbUmrTD4GfP8VMUjpWASfveQIDAQABAoIBABWdJWDNPTwnwzB4 8 | pIt/oyVpOtjHwU99KCwZI8/8gFzTiyc9BzPRGrsNwVSnx1YR8G6q9S99RqkpZjz3 9 | r2Rdm66Mytdwxq5y7f1JaMK58onzAQiBZXB6uulPP3zspVCxc8+L+7J6b/ZOT0Rr 10 | mIkrWMJpIVXpSd2b3YB0ibegrgVg8MFrsXvDvSoEVWMgZRTSaWoINokUFxCJnaL5 11 | nq7QXPv0aaq/J3px3tBJCyKJdzXTLgLDgXYdNg805cYjs3cP+OvpIxM/GiRumgDx 12 | FZap2JIJwTBzkKI+sBi4cJn8Mof4tLdhfkSkJVbhQwqxghujefBrRMySwzfculCG 13 | vbo4rCECgYEA/TYxQ9dPxcFEnZ00x+HhAm8S5AuXO9P3nxZuAhXSMybwDj6E+tZV 14 | IFLgo7PQU+q63ejlJx1P7IhoR9oil6N/TWVAPUEWs4FepTt51MjdPVCIgtpW3zI5 15 | 8nIPwNyMbhE1XZZg4t1VE4GLYZ0KXayoRUs2xdO0Si60FVyV9EM3LzsCgYEA+xIC 16 | LLOh2fXaVEKNuh4tlabew4FJM0jJZweQM4XU7xJRtcl7yDYoIYram/2XibUEAjoM 17 | y/uuU38k7R8opmOPfLTk/e8Tq9f3iL4DMHE8tOkDVTlqdnHh1jmroVl9gQmITj25 18 | w6tCS0YpVcVxKJg2EUaFUi11u/7CIHZ+Cs8/GNsCgYEA6zn21kElOF7ssUcjizSJ 19 | ZUtuTy99VPT7Km0Z0RIYbbCUfYcS3jtSZW7YhPs8Y1jCM/hxOL8ASooF5gn87MXU 20 | M0AGR2E6B5P9Kp5v9X6MGLPBvV28KihssI/Jlq7MPkv6OXDDnL1klXRY2VucD52f 21 | zI+s2GZtLCTq4pVaMMpob5UCgYBWu7Hkn2maUkRKN3OeiC5XNH5gK5mODecFoKdA 22 | JUuaC0oO8rvAPnU+oSlEGibve4kW+9bP4PIoBhRLligE0wAOpK82yhCRnNn2cy3G 23 | 3leKZ7SvDFaq9EyAJQwVgUTJ/vEHlmtGHTOZrXM6HispSuviq+oCqZGykB+f908z 24 | jMTPYQKBgQDl7wS44XuiSiPF1nJxvUgqT9yNCcCCjZXKwiALfsE2l+b1DcBIbrF1 25 | yWt4Op/6KHzHfgzpq7i26CXRILvwJH94yiAntVlZnZUZ9r//mEpE/2sHomEmL5vr 26 | A8A1oxvK6lyWhQD78dglQn6Xo0MtuaOaK/NcIj+FApFm4BD8OFLZRQ== 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /Tests/ServerCryptoTests/CryptoSupport/HexTests.swift: -------------------------------------------------------------------------------- 1 | /** 2 | * ServerCrypto 3 | * Copyright (c) 2017 Alexis Aubry. Licensed under the MIT license. 4 | */ 5 | 6 | import XCTest 7 | import Foundation 8 | @testable import CryptoSupport 9 | 10 | class HexTests: XCTestCase { 11 | 12 | let data = Data(bytes: [0x1a, 0x2b, 0x3c, 0x4d, 0x5e, 0x6f]) 13 | 14 | func testDataToHexString() { 15 | let hexString = data.hexString 16 | XCTAssertEqual(hexString, "1a2b3c4d5e6f") 17 | } 18 | 19 | func testDataFromHexString() { 20 | 21 | let data = Data(hexString: "1a2b3c4d5e6f") 22 | XCTAssertNotNil(data) 23 | 24 | guard data != nil else { 25 | XCTFail("Could not decode hex string.") 26 | return 27 | } 28 | 29 | XCTAssertEqual(data!, Data(bytes: [0x1a, 0x2b, 0x3c, 0x4d, 0x5e, 0x6f])) 30 | 31 | } 32 | 33 | func testDataFromUppercaseHexString() { 34 | 35 | let data = Data(hexString: "1A2B3C4D5E6F") 36 | XCTAssertNotNil(data) 37 | 38 | guard data != nil else { 39 | XCTFail("Could not decode hex string.") 40 | return 41 | } 42 | 43 | XCTAssertEqual(data!, Data(bytes: [0x1a, 0x2b, 0x3c, 0x4d, 0x5e, 0x6f])) 44 | 45 | } 46 | 47 | func testDataFromOddHexString() { 48 | 49 | let data = Data(hexString: "a2a45") 50 | 51 | guard data != nil else { 52 | XCTFail("Could not decode hex string.") 53 | return 54 | } 55 | 56 | XCTAssertEqual(data, Data(bytes: [0xa2, 0xa4, 0x05])) 57 | 58 | } 59 | 60 | func testDataFromInvalidHexString() { 61 | let data = Data(hexString: "NOT_A_HEX") 62 | XCTAssertNil(data) 63 | } 64 | 65 | } 66 | 67 | extension HexTests { 68 | 69 | static var allTests : [(String, (HexTests) -> () throws -> Void)] { 70 | return [ 71 | ("testDataToHexString", testDataToHexString), 72 | ("testDataFromHexString", testDataFromHexString), 73 | ("testDataFromUppercaseHexString", testDataFromUppercaseHexString), 74 | ("testDataFromInvalidHexString", testDataFromInvalidHexString) 75 | ] 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /Sources/CryptoSupport/Protocols.swift: -------------------------------------------------------------------------------- 1 | /** 2 | * ServerCrypto 3 | * Copyright (c) 2017 Alexis Aubry. Licensed under the MIT license. 4 | */ 5 | 6 | import Foundation 7 | 8 | /// A sequence of bytes. 9 | public typealias Bytes = RandomAccessCollection & MutableCollection & RawBytesProviding 10 | 11 | /** 12 | * Provides a raw bytes-represented version of itself. 13 | */ 14 | 15 | public protocol RawBytesProviding { 16 | 17 | /** 18 | * Executes a closure against the raw bytes in the data's buffer. 19 | */ 20 | 21 | func withUnsafeRawBytes(_ body: (UnsafeRawPointer) throws -> ResultType) rethrows -> ResultType 22 | 23 | /** 24 | * Executes a closure against the raw bytes in the data's buffer. 25 | */ 26 | 27 | func withUnsafeRawBytes(_ body: (UnsafeMutableRawPointer) throws -> ResultType) rethrows -> ResultType 28 | 29 | } 30 | 31 | extension Data: RawBytesProviding { 32 | 33 | public func withUnsafeRawBytes(_ body: (UnsafeRawPointer) throws -> ResultType) rethrows -> ResultType { 34 | return try self.withUnsafeBytes { (bytes: UnsafePointer) in 35 | try body(UnsafeRawPointer(bytes)) 36 | } 37 | } 38 | 39 | public func withUnsafeRawBytes(_ body: (UnsafeMutableRawPointer) throws -> ResultType) rethrows -> ResultType { 40 | return try self.withUnsafeBytes { (bytes: UnsafePointer) in 41 | try body(UnsafeMutableRawPointer(mutating: bytes)) 42 | } 43 | } 44 | 45 | public func withAutomaticPointer(_ body: (UnsafePointer) throws -> ResultType) rethrows -> ResultType { 46 | return try self.withUnsafeBytes { 47 | try body($0) 48 | } 49 | } 50 | 51 | public func withAutomaticPointer(_ body: (UnsafeMutablePointer) throws -> ResultType) rethrows -> ResultType { 52 | 53 | var copy = self 54 | 55 | return try copy.withUnsafeMutableBytes { 56 | try body($0) 57 | } 58 | } 59 | 60 | } 61 | 62 | extension Array: RawBytesProviding { 63 | 64 | public func withUnsafeRawBytes(_ body: (UnsafeRawPointer) throws -> ResultType) rethrows -> ResultType { 65 | let rawPointer = UnsafeRawPointer(self) 66 | return try body(rawPointer) 67 | } 68 | 69 | public func withUnsafeRawBytes(_ body: (UnsafeMutableRawPointer) throws -> ResultType) rethrows -> ResultType { 70 | let rawPointer = UnsafeMutableRawPointer(mutating: self) 71 | return try body(rawPointer) 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /Tests/ServerCryptoTests/Hash/HashTests.swift: -------------------------------------------------------------------------------- 1 | /** 2 | * ServerCrypto 3 | * Copyright (c) 2017 Alexis Aubry. Licensed under the MIT license. 4 | */ 5 | 6 | import XCTest 7 | import Foundation 8 | @testable import Hash 9 | 10 | class HashTests: XCTestCase { 11 | 12 | func testMD4() throws { 13 | try performTest(with: md4Hashes) 14 | } 15 | 16 | func testMD5() throws { 17 | try performTest(with: md5Hashes) 18 | } 19 | 20 | func testSHA1() throws { 21 | try performTest(with: sha1Hashes) 22 | } 23 | 24 | func testSHA224() throws { 25 | try performTest(with: sha224Hashes) 26 | } 27 | 28 | func testSHA256() throws { 29 | try performTest(with: sha256Hashes) 30 | } 31 | 32 | func testSHA384() throws { 33 | try performTest(with: sha384Hashes) 34 | } 35 | 36 | func testSHA512() throws { 37 | try performTest(with: sha512Hashes) 38 | } 39 | 40 | func testRipeMd160() throws { 41 | try performTest(with: ripeMd160Hashes) 42 | } 43 | 44 | func testNull() throws { 45 | try performTest(with: nullHashes) 46 | } 47 | 48 | // MARK: - Utilities 49 | 50 | func performTest(with hashes: [MessageHash]) throws { 51 | 52 | for messageHash in hashes { 53 | 54 | let messageData: Data 55 | let messageArray: [UInt8] 56 | 57 | switch messageHash.message { 58 | case .hex(let string): 59 | 60 | guard let _messageData = Data(hexString: string) else { 61 | XCTFail("Invalid hex string") 62 | return 63 | } 64 | 65 | messageData = _messageData 66 | messageArray = [UInt8](messageData) 67 | 68 | case .text(let string): 69 | messageData = Data(string.utf8) 70 | messageArray = [UInt8](messageData) 71 | 72 | } 73 | 74 | let computedDataHash = try messageHash.hasher.makeHash(for: messageData) 75 | let computedArrayHash = try messageHash.hasher.makeHash(for: messageArray) 76 | 77 | XCTAssertEqual(computedDataHash.hexString, messageHash.expectedHash) 78 | XCTAssertEqual(computedArrayHash.hexString, messageHash.expectedHash) 79 | 80 | } 81 | 82 | } 83 | 84 | } 85 | 86 | extension HashTests { 87 | 88 | static var allTests : [(String, (HashTests) -> () throws -> Void)] { 89 | return [ 90 | ("testMD4", testMD4), 91 | ("testMD5", testMD5), 92 | ("testSHA1", testSHA1), 93 | ("testSHA224", testSHA224), 94 | ("testSHA256", testSHA256), 95 | ("testSHA384", testSHA384), 96 | ("testSHA512", testSHA512), 97 | ("testRipeMd160", testRipeMd160), 98 | ("testNull", testNull) 99 | ] 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /Sources/Hash/Hasher.swift: -------------------------------------------------------------------------------- 1 | /** 2 | * ServerCrypto 3 | * Copyright (c) 2017 Alexis Aubry. Licensed under the MIT license. 4 | */ 5 | 6 | import Foundation 7 | import CryptoSupport 8 | import CTLS 9 | 10 | /** 11 | * A data hasher. 12 | */ 13 | 14 | public enum Hasher { 15 | 16 | /// The MD4 hashing algorithm. 17 | case md4 18 | 19 | /// The MD5 hashing algorithm. 20 | case md5 21 | 22 | /// The SHA-1 hashing algorithm. 23 | case sha1 24 | 25 | /// The SHA-224 hashing algorithm. 26 | case sha224 27 | 28 | /// The SHA-256 hashing algorithm. 29 | case sha256 30 | 31 | /// The SHA-384 hashing algorithm. 32 | case sha384 33 | 34 | /// The SHA-512 hashing algorithm. 35 | case sha512 36 | 37 | /// The RIPEMD-160 hashing algorithm. 38 | case ripeMd160 39 | 40 | /// A hashing algorithm that always returns an empty hash. 41 | case null 42 | 43 | /// Creates a message digest description for the hash provider. 44 | public func makeMessageDigest() -> UnsafePointer? { 45 | 46 | switch self { 47 | case .md4: return EVP_md4() 48 | case .md5: return EVP_md5() 49 | case .sha1: return EVP_sha1() 50 | case .sha224: return EVP_sha224() 51 | case .sha256: return EVP_sha256() 52 | case .sha384: return EVP_sha384() 53 | case .sha512: return EVP_sha512() 54 | case .ripeMd160: return EVP_ripemd160() 55 | case .null: return EVP_md_null() 56 | } 57 | 58 | } 59 | 60 | } 61 | 62 | // MARK: - Hashing 63 | 64 | extension Hasher { 65 | 66 | /** 67 | * Compute the hash of bytes. 68 | * 69 | * - parameter bytes: The bytes to hash. 70 | * - throws: This method may throw a `CryptoError` object in case of a failure. 71 | * - returns: A `Data` object that contains the bytes of the hash. 72 | */ 73 | 74 | public func makeHash(for bytes: T) throws -> Data 75 | where T.Element == UInt8, T.IndexDistance == Int { 76 | 77 | CryptoProvider.load(.digests, .cryptoErrorStrings) 78 | 79 | guard let digestDescription = makeMessageDigest() else { 80 | throw CryptoError.latest 81 | } 82 | 83 | guard let context = EVP_MD_CTX_create() else { 84 | throw CryptoError.latest 85 | } 86 | 87 | defer { 88 | EVP_MD_CTX_destroy(context) 89 | } 90 | 91 | /* Properties */ 92 | 93 | var digestLength = UInt32(EVP_MD_size(digestDescription)) 94 | var digest = Data(count: Int(digestLength)) 95 | 96 | /* Hashing */ 97 | 98 | guard EVP_DigestInit(context, digestDescription) == 1 else { 99 | throw CryptoError.latest 100 | } 101 | 102 | let updateResult = bytes.withUnsafeRawBytes { 103 | return EVP_DigestUpdate(context, $0, bytes.count) 104 | } 105 | 106 | guard updateResult == 1 else { 107 | throw CryptoError.latest 108 | } 109 | 110 | /* Final */ 111 | 112 | let finalResult = digest.withUnsafeMutableBytes { 113 | (mutableBody: UnsafeMutablePointer) -> Int32 in 114 | return EVP_DigestFinal(context, mutableBody, &digestLength) 115 | } 116 | 117 | guard finalResult == 1 else { 118 | throw CryptoError.latest 119 | } 120 | 121 | return digest.prefix(upTo: Int(digestLength)) 122 | 123 | } 124 | 125 | } 126 | -------------------------------------------------------------------------------- /Tests/ServerCryptoTests/Signature/ECDSA/ECDSATests.swift: -------------------------------------------------------------------------------- 1 | /** 2 | * ServerCrypto 3 | * Copyright (c) 2017 Alexis Aubry. Licensed under the MIT license. 4 | */ 5 | 6 | import XCTest 7 | import Foundation 8 | @testable import Signature 9 | 10 | class ECDSATests: XCTestCase { 11 | 12 | /// Tests ECDSA with SHA1. 13 | func testES1() throws { 14 | 15 | try SignatureTestsCoordinator.testSignatures(ecdsaP256withSHA1Signatures) 16 | try SignatureTestsCoordinator.testSignatures(ecdsaP384withSHA1Signatures) 17 | try SignatureTestsCoordinator.testSignatures(ecdsaSECP256K1withSHA1Signatures) 18 | 19 | try SignatureTestsCoordinator.testSignatures(ecdsaFakeP256withSHA1Signatures, isValid: false) 20 | try SignatureTestsCoordinator.testSignatures(ecdsaFakeP384withSHA1Signatures, isValid: false) 21 | try SignatureTestsCoordinator.testSignatures(ecdsaFakeSECP256K1withSHA1Signatures, isValid: false) 22 | 23 | } 24 | 25 | /// Tests ECDSA with SHA224. 26 | func testES224() throws { 27 | 28 | try SignatureTestsCoordinator.testSignatures(ecdsaP256withSHA224Signatures) 29 | try SignatureTestsCoordinator.testSignatures(ecdsaP384withSHA224Signatures) 30 | try SignatureTestsCoordinator.testSignatures(ecdsaSECP256K1withSHA224Signatures) 31 | 32 | try SignatureTestsCoordinator.testSignatures(ecdsaFakeP256withSHA224Signatures, isValid: false) 33 | try SignatureTestsCoordinator.testSignatures(ecdsaFakeP384withSHA224Signatures, isValid: false) 34 | try SignatureTestsCoordinator.testSignatures(ecdsaFakeSECP256K1withSHA224Signatures, isValid: false) 35 | 36 | } 37 | 38 | /// Tests ECDSA with SHA256. 39 | func testES256() throws { 40 | 41 | try SignatureTestsCoordinator.testSignatures(ecdsaP256withSHA256Signatures) 42 | try SignatureTestsCoordinator.testSignatures(ecdsaP384withSHA256Signatures) 43 | try SignatureTestsCoordinator.testSignatures(ecdsaSECP256K1withSHA256Signatures) 44 | 45 | try SignatureTestsCoordinator.testSignatures(ecdsaFakeP256withSHA256Signatures, isValid: false) 46 | try SignatureTestsCoordinator.testSignatures(ecdsaFakeP384withSHA256Signatures, isValid: false) 47 | try SignatureTestsCoordinator.testSignatures(ecdsaFakeSECP256K1withSHA256Signatures, isValid: false) 48 | 49 | } 50 | 51 | /// Tests ECDSA with SHA384. 52 | func testES384() throws { 53 | 54 | try SignatureTestsCoordinator.testSignatures(ecdsaP256withSHA384Signatures) 55 | try SignatureTestsCoordinator.testSignatures(ecdsaP384withSHA384Signatures) 56 | try SignatureTestsCoordinator.testSignatures(ecdsaSECP256K1withSHA384Signatures) 57 | 58 | try SignatureTestsCoordinator.testSignatures(ecdsaFakeP256withSHA384Signatures, isValid: false) 59 | try SignatureTestsCoordinator.testSignatures(ecdsaFakeP384withSHA384Signatures, isValid: false) 60 | try SignatureTestsCoordinator.testSignatures(ecdsaFakeSECP256K1withSHA384Signatures, isValid: false) 61 | 62 | } 63 | 64 | /// Tests ECDSA with SHA512. 65 | func testES512() throws { 66 | 67 | try SignatureTestsCoordinator.testSignatures(ecdsaP256withSHA512Signatures) 68 | try SignatureTestsCoordinator.testSignatures(ecdsaP384withSHA512Signatures) 69 | try SignatureTestsCoordinator.testSignatures(ecdsaSECP256K1withSHA512Signatures) 70 | 71 | try SignatureTestsCoordinator.testSignatures(ecdsaFakeP256withSHA512Signatures, isValid: false) 72 | try SignatureTestsCoordinator.testSignatures(ecdsaFakeP384withSHA512Signatures, isValid: false) 73 | try SignatureTestsCoordinator.testSignatures(ecdsaFakeSECP256K1withSHA512Signatures, isValid: false) 74 | 75 | } 76 | 77 | } 78 | 79 | extension ECDSATests { 80 | 81 | static var allTests : [(String, (ECDSATests) -> () throws -> Void)] { 82 | return [ 83 | ("testES1", testES1), 84 | ("testES224", testES224), 85 | ("testES256", testES256), 86 | ("testES384", testES384), 87 | ("testES512", testES512) 88 | ] 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /Tests/ServerCryptoTests/Signature/SignatureTestsCoordinator.swift: -------------------------------------------------------------------------------- 1 | /** 2 | * ServerCrypto 3 | * Copyright (c) 2017 Alexis Aubry. Licensed under the MIT license. 4 | */ 5 | 6 | import XCTest 7 | import Foundation 8 | import Signature 9 | 10 | class SignatureTestsCoordinator {} 11 | 12 | // MARK: - Key Loading 13 | 14 | extension SignatureTestsCoordinator { 15 | 16 | static func path(ofKey keyName: String) -> String? { 17 | 18 | #if Xcode 19 | let bundle = Bundle(for: SignatureTestsCoordinator.self) 20 | return bundle.path(forResource: keyName, ofType: "pem", inDirectory: "TestFixtures") 21 | #else 22 | let cWorkingDirectory = getenv("PWD")! 23 | let fixturesPath = String(cString: cWorkingDirectory) + "/TestFixtures" 24 | let keyPath = fixturesPath + "/" + keyName + ".pem" 25 | return FileManager.default.fileExists(atPath: keyPath) ? keyPath : nil 26 | #endif 27 | 28 | } 29 | 30 | static func pemData(at path: String) -> Data? { 31 | let url = URL(fileURLWithPath: path) 32 | return try? Data(contentsOf: url, options: .uncached) 33 | } 34 | 35 | } 36 | 37 | // MARK: - Key Testing 38 | 39 | protocol AsymmetricSignature { 40 | 41 | var hasher: Hasher { get } 42 | var message: String { get } 43 | 44 | var publicKeyName: String { get } 45 | var privateKeyName: String { get } 46 | var privateKeyPassphrase: String? { get } 47 | 48 | var validSignature: String { get } 49 | 50 | } 51 | 52 | extension SignatureTestsCoordinator { 53 | 54 | static func testSignatures(_ signatures: [S], isValid: Bool = true) throws { 55 | 56 | let successRequirement = isValid ? true : false 57 | 58 | for signature in signatures { 59 | 60 | guard let publicKeyPath = SignatureTestsCoordinator.path(ofKey: signature.publicKeyName), 61 | let privateKeyPath = SignatureTestsCoordinator.path(ofKey: signature.privateKeyName) else { 62 | XCTFail("Cannot find keys on disk.") 63 | return 64 | } 65 | 66 | guard let publicKeyData = SignatureTestsCoordinator.pemData(at: publicKeyPath), 67 | let privateKeyData = SignatureTestsCoordinator.pemData(at: privateKeyPath) else { 68 | XCTFail("Cannot read data from keys.") 69 | return 70 | } 71 | 72 | // 1. Load the keys 73 | 74 | let publicDiskKey = try AsymmetricKey.makePublicKey(readingPEMAtPath: publicKeyPath) 75 | let privateDiskKey = try AsymmetricKey.makePrivateKey(readingPEMAtPath: privateKeyPath, passphrase: signature.privateKeyPassphrase) 76 | 77 | let publicMemoryKey = try AsymmetricKey.makePublicKey(readingPEMData: publicKeyData) 78 | let privateMemoryKey = try AsymmetricKey.makePrivateKey(readingPEMData: privateKeyData, passphrase: signature.privateKeyPassphrase) 79 | 80 | let testKeys = [(publicDiskKey, privateDiskKey), (publicMemoryKey, privateMemoryKey)] 81 | 82 | for (publicKey, privateKey) in testKeys { 83 | 84 | let privateSigner = Signer.asymmetric(privateKey) 85 | let publicSigner = Signer.asymmetric(publicKey) 86 | 87 | // 2. Compute the signature of the message 88 | 89 | let messageData = signature.message.data(using: .utf8)! 90 | let generatedSignature = try privateSigner.sign(message: messageData, with: signature.hasher) 91 | 92 | // 3. Assert that the computed signature is valid 93 | 94 | let isSignatureValid = try publicSigner.verify(signature: generatedSignature, for: messageData, with: signature.hasher) 95 | 96 | XCTAssertTrue(isSignatureValid) 97 | 98 | // 4. Verify that the library recognizes valid and invalid signatures 99 | 100 | let testSignature = Data(hexString: signature.validSignature)! 101 | let verificationResult = try publicSigner.verify(signature: testSignature, for: messageData, with: signature.hasher) 102 | 103 | XCTAssertTrue(verificationResult == successRequirement) 104 | 105 | } 106 | 107 | } 108 | 109 | } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /Tests/ServerCryptoTests/Signature/HMAC/HMACTests.swift: -------------------------------------------------------------------------------- 1 | /** 2 | * ServerCrypto 3 | * Copyright (c) 2017 Alexis Aubry. Licensed under the MIT license. 4 | */ 5 | 6 | import XCTest 7 | import Foundation 8 | @testable import Signature 9 | 10 | 11 | class HMACTests: XCTestCase { 12 | 13 | /// Tests HMAC with MD4. 14 | func testHMD4() throws { 15 | try testHMAC(signatures: hmd4Signatures) 16 | try testHMAC(signatures: hmd4FakeSignatures, isValid: false) 17 | } 18 | 19 | /// Tests HMAC with MD5. 20 | func testHMD5() throws { 21 | try testHMAC(signatures: hmd5Signatures) 22 | try testHMAC(signatures: hmd5FakeSignatures, isValid: false) 23 | } 24 | 25 | /// Tests HMAC with SHA1. 26 | func testHS1() throws { 27 | try testHMAC(signatures: hs1Signatures) 28 | try testHMAC(signatures: hs1FakeSignatures, isValid: false) 29 | } 30 | 31 | /// Tests HMAC with SHA224. 32 | func testHS224() throws { 33 | try testHMAC(signatures: hs224Signatures) 34 | try testHMAC(signatures: hs224FakeSignatures, isValid: false) 35 | } 36 | 37 | /// Tests HMAC with SHA256. 38 | func testHS256() throws { 39 | try testHMAC(signatures: hs256Signatures) 40 | try testHMAC(signatures: hs256FakeSignatures, isValid: false) 41 | } 42 | 43 | /// Tests HMAC with SHA384. 44 | func testHS384() throws { 45 | try testHMAC(signatures: hs384Signatures) 46 | try testHMAC(signatures: hs384FakeSignatures, isValid: false) 47 | } 48 | 49 | /// Tests HMAC with SHA512. 50 | func testHS512() throws { 51 | try testHMAC(signatures: hs512Signatures) 52 | try testHMAC(signatures: hs512FakeSignatures, isValid: false) 53 | } 54 | 55 | /// Tests HMAC with RIPEMD-160. 56 | func testHRMD160() throws { 57 | try testHMAC(signatures: hrmd160Signatures) 58 | try testHMAC(signatures: hrmd160FakeSignatures, isValid: false) 59 | } 60 | 61 | // MARK: - HMAC Helpers 62 | 63 | func testHMAC(signatures: [HMACSignature], isValid: Bool = true) throws { 64 | 65 | let successRequirement = isValid ? true : false 66 | 67 | for signature in signatures { 68 | 69 | // 1. Create the key with the passphrase in the vector 70 | 71 | let hmacKey = try HMACKey(password: signature.keyPassword) 72 | let signer = Signer.hmac(hmacKey) 73 | 74 | // 2. Sign the message with the key 75 | 76 | let computedSignature = try signer.sign(message: Data(signature.message.utf8), 77 | with: signature.hasher) 78 | 79 | // 3. Verify that the generated signature is valid 80 | 81 | let isSignatureValid = try signer.verify(signature: computedSignature, 82 | for: Data(signature.message.utf8), 83 | with: signature.hasher) 84 | 85 | XCTAssertTrue(isSignatureValid) 86 | 87 | // 4. Verify that the library recognizes valid and invalid signatures 88 | 89 | let verificationResult = try signer.verify(signature: Data(hexString: signature.expectedSignature)!, 90 | for: Data(signature.message.utf8), 91 | with: signature.hasher) 92 | 93 | XCTAssertTrue(verificationResult == successRequirement) 94 | 95 | // 5. Verify that the signature is equal to the expected signature (or not equal if the test vector is fake) 96 | 97 | XCTAssertTrue((computedSignature.hexString == signature.expectedSignature) == successRequirement) 98 | 99 | } 100 | 101 | } 102 | 103 | } 104 | 105 | extension HMACTests { 106 | 107 | static var allTests : [(String, (HMACTests) -> () throws -> Void)] { 108 | return [ 109 | ("testHMD4", testHMD4), 110 | ("testHMD5", testHMD5), 111 | ("testHS1", testHS1), 112 | ("testHS224", testHS224), 113 | ("testHS256", testHS256), 114 | ("testHS384", testHS384), 115 | ("testHS512", testHS512), 116 | ("testHRMD160", testHRMD160), 117 | ] 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /Tests/ServerCryptoTests/Signature/RSA/RSATests.swift: -------------------------------------------------------------------------------- 1 | /** 2 | * ServerCrypto 3 | * Copyright (c) 2017 Alexis Aubry. Licensed under the MIT license. 4 | */ 5 | 6 | import XCTest 7 | import Foundation 8 | @testable import Signature 9 | 10 | class RSATests: XCTestCase { 11 | 12 | /// Tests RSA with MD4. 13 | func testRMD4() throws { 14 | 15 | try SignatureTestsCoordinator.testSignatures(rsa1024withMD4Signatures) 16 | try SignatureTestsCoordinator.testSignatures(rsa2048withMD4Signatures) 17 | 18 | try SignatureTestsCoordinator.testSignatures(rsa1024withMD4FakeSignatures, isValid: false) 19 | try SignatureTestsCoordinator.testSignatures(rsa2048withMD4FakeSignatures, isValid: false) 20 | 21 | } 22 | 23 | /// Tests RSA with MD5. 24 | func testRMD5() throws { 25 | 26 | try SignatureTestsCoordinator.testSignatures(rsa1024withMD5Signatures) 27 | try SignatureTestsCoordinator.testSignatures(rsa2048withMD5Signatures) 28 | 29 | try SignatureTestsCoordinator.testSignatures(rsa1024withMD5FakeSignatures, isValid: false) 30 | try SignatureTestsCoordinator.testSignatures(rsa2048withMD5FakeSignatures, isValid: false) 31 | 32 | } 33 | 34 | /// Tests RSA with SHA1. 35 | func testRS1() throws { 36 | 37 | try SignatureTestsCoordinator.testSignatures(rsa1024withSHA1Signatures) 38 | try SignatureTestsCoordinator.testSignatures(rsa2048withSHA1Signatures) 39 | 40 | try SignatureTestsCoordinator.testSignatures(rsa1024withSHA1FakeSignatures, isValid: false) 41 | try SignatureTestsCoordinator.testSignatures(rsa2048withSHA1FakeSignatures, isValid: false) 42 | 43 | } 44 | 45 | /// Tests RSA with SHA224. 46 | func testRS224() throws { 47 | 48 | try SignatureTestsCoordinator.testSignatures(rsa1024withSHA224Signatures) 49 | try SignatureTestsCoordinator.testSignatures(rsa2048withSHA224Signatures) 50 | 51 | try SignatureTestsCoordinator.testSignatures(rsa1024withSHA224FakeSignatures, isValid: false) 52 | try SignatureTestsCoordinator.testSignatures(rsa2048withSHA224FakeSignatures, isValid: false) 53 | 54 | } 55 | 56 | /// Tests RSA with SHA256. 57 | func testRS256() throws { 58 | 59 | try SignatureTestsCoordinator.testSignatures(rsa1024withSHA256Signatures) 60 | try SignatureTestsCoordinator.testSignatures(rsa2048withSHA256Signatures) 61 | 62 | try SignatureTestsCoordinator.testSignatures(rsa1024withSHA256FakeSignatures, isValid: false) 63 | try SignatureTestsCoordinator.testSignatures(rsa2048withSHA256FakeSignatures, isValid: false) 64 | 65 | } 66 | 67 | /// Tests RSA with SHA384. 68 | func testRS384() throws { 69 | 70 | try SignatureTestsCoordinator.testSignatures(rsa1024withSHA384Signatures) 71 | try SignatureTestsCoordinator.testSignatures(rsa2048withSHA384Signatures) 72 | 73 | try SignatureTestsCoordinator.testSignatures(rsa1024withSHA384FakeSignatures, isValid: false) 74 | try SignatureTestsCoordinator.testSignatures(rsa2048withSHA384FakeSignatures, isValid: false) 75 | 76 | } 77 | 78 | /// Tests RSA with SHA512. 79 | func testRS512() throws { 80 | 81 | try SignatureTestsCoordinator.testSignatures(rsa1024withSHA512Signatures) 82 | try SignatureTestsCoordinator.testSignatures(rsa2048withSHA512Signatures) 83 | 84 | try SignatureTestsCoordinator.testSignatures(rsa1024withSHA512FakeSignatures, isValid: false) 85 | try SignatureTestsCoordinator.testSignatures(rsa2048withSHA512FakeSignatures, isValid: false) 86 | 87 | } 88 | 89 | /// Tests RSA with RIPEMD160. 90 | func testRRMD160() throws { 91 | 92 | try SignatureTestsCoordinator.testSignatures(rsa1024withRIPEMD160Signatures) 93 | try SignatureTestsCoordinator.testSignatures(rsa2048withRIPEMD160Signatures) 94 | 95 | try SignatureTestsCoordinator.testSignatures(rsa1024withRIPEMD160FakeSignatures, isValid: false) 96 | try SignatureTestsCoordinator.testSignatures(rsa2048withRIPEMD160FakeSignatures, isValid: false) 97 | 98 | } 99 | 100 | } 101 | 102 | extension RSATests { 103 | 104 | static var allTests : [(String, (RSATests) -> () throws -> Void)] { 105 | return [ 106 | ("testRMD4", testRMD4), 107 | ("testRMD5", testRMD5), 108 | ("testRS1", testRS1), 109 | ("testRS224", testRS224), 110 | ("testRS256", testRS256), 111 | ("testRS384", testRS384), 112 | ("testRS512", testRS512), 113 | ("testRRMD160", testRRMD160), 114 | ] 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /ServerCrypto.xcodeproj/xcshareddata/xcschemes/ServerCrypto.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 62 | 68 | 69 | 70 | 71 | 72 | 78 | 79 | 80 | 81 | 82 | 83 | 94 | 95 | 101 | 102 | 103 | 104 | 105 | 106 | 112 | 113 | 119 | 120 | 121 | 122 | 124 | 125 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /Sources/Signature/Signer.swift: -------------------------------------------------------------------------------- 1 | /** 2 | * ServerCrypto 3 | * Copyright (c) 2017 Alexis Aubry. Licensed under the MIT license. 4 | */ 5 | 6 | import Foundation 7 | import CryptoSupport 8 | import Hash 9 | import CTLS 10 | 11 | /** 12 | * An object that can sign messages. 13 | */ 14 | 15 | public enum Signer { 16 | 17 | /// An HMAC signer. 18 | case hmac(HMACKey) 19 | 20 | /// A key-pair based signer (RSA, ECDSA, ...). 21 | case asymmetric(AsymmetricKey) 22 | 23 | var rawKey: UnsafeMutablePointer { 24 | 25 | switch self { 26 | case .hmac(let key): 27 | return key.underlyingKeyPointer 28 | 29 | case .asymmetric(let key): 30 | return key.keyContainer.underlyingKeyPointer 31 | 32 | } 33 | 34 | } 35 | 36 | } 37 | 38 | // MARK: - Signature 39 | 40 | extension Signer { 41 | 42 | /** 43 | * Signs a message with the specified key and hasher. 44 | * - parameter message: The message to sign. 45 | * - parameter hasher: The hasher to use to generate the signature hash. 46 | * - returns: The bytes containing signature of the message. 47 | * - throws: A `CryptoError` on failure. 48 | */ 49 | 50 | public func sign(message: T, with hasher: Hasher) throws -> Data 51 | where T.Element == UInt8, T.IndexDistance == Int { 52 | 53 | CryptoProvider.load(.digests, .ciphers, .cryptoErrorStrings) 54 | 55 | /* Pointers */ 56 | 57 | guard let messageDigest = hasher.makeMessageDigest() else { 58 | throw CryptoError.latest 59 | } 60 | 61 | guard let context = EVP_MD_CTX_create() else { 62 | throw CryptoError.latest 63 | } 64 | 65 | defer { 66 | EVP_MD_CTX_destroy(context) 67 | } 68 | 69 | /* Signature */ 70 | 71 | guard EVP_DigestSignInit(context, nil, messageDigest, nil, rawKey) == 1 else { 72 | throw CryptoError.latest 73 | } 74 | 75 | let updateResult = message.withUnsafeRawBytes { 76 | EVP_DigestUpdate(context, $0, message.count) 77 | } 78 | 79 | guard updateResult == 1 else { 80 | throw CryptoError.latest 81 | } 82 | 83 | /* Final */ 84 | 85 | var signatureLength = 0 86 | 87 | guard EVP_DigestSignFinal(context, nil, &signatureLength) == 1 else { 88 | throw CryptoError.latest 89 | } 90 | 91 | var signature = Data(count: signatureLength) 92 | 93 | let signatureResult = signature.withUnsafeMutableBytes { 94 | (body: UnsafeMutablePointer) -> Int32 in 95 | EVP_DigestSignFinal(context, body, &signatureLength) 96 | } 97 | 98 | guard signatureResult == 1 else { 99 | throw CryptoError.latest 100 | } 101 | 102 | return signature.prefix(upTo: signatureLength) 103 | 104 | } 105 | 106 | /** 107 | * Verifies the signature for a given message and hasher. 108 | * - parameter signature: The signature to verify. 109 | * - parameter message: The message to match with the signature. 110 | * - parameter hasher: The hasher used to generate the signature hash. 111 | * - returns: Whether the signature is valid for the message. 112 | * - throws: A `CryptoError` on failure. 113 | */ 114 | 115 | public func verify(signature: Data, for message: T, with hasher: Hasher) throws -> Bool 116 | where T.Element == UInt8, T.IndexDistance == Int { 117 | 118 | CryptoProvider.load(.digests, .ciphers, .cryptoErrorStrings) 119 | 120 | switch self { 121 | case .asymmetric: 122 | return try verify_evp(signature: signature, for: message, with: hasher) 123 | 124 | case .hmac: 125 | return try verify_hmac(signature: signature, for: message, with: hasher) 126 | 127 | } 128 | 129 | 130 | } 131 | 132 | private func verify_evp(signature: Data, for message: T, with hasher: Hasher) throws -> Bool 133 | where T.Element == UInt8, T.IndexDistance == Int { 134 | 135 | var mutableSignature = signature 136 | 137 | guard let messageDigest = hasher.makeMessageDigest() else { 138 | throw CryptoError.latest 139 | } 140 | 141 | guard let context = EVP_MD_CTX_create() else { 142 | throw CryptoError.latest 143 | } 144 | 145 | defer { 146 | EVP_MD_CTX_destroy(context) 147 | } 148 | 149 | /* Verification */ 150 | 151 | guard EVP_DigestVerifyInit(context, nil, messageDigest, nil, rawKey) == 1 else { 152 | throw CryptoError.latest 153 | } 154 | 155 | let updateResult = message.withUnsafeRawBytes { 156 | EVP_DigestUpdate(context, $0, message.count) 157 | } 158 | 159 | guard updateResult == 1 else { 160 | throw CryptoError.latest 161 | } 162 | 163 | /* Final */ 164 | 165 | let verificationResult: Int32 = signature.withAutomaticPointer { 166 | return EVP_DigestVerifyFinal(context, $0, signature.count) 167 | } 168 | 169 | return verificationResult == 1 170 | 171 | } 172 | 173 | private func verify_hmac(signature: Data, for message: T, with hasher: Hasher) throws -> Bool 174 | where T.Element == UInt8, T.IndexDistance == Int { 175 | 176 | let expectedSignature = try self.sign(message: message, with: hasher) 177 | 178 | guard expectedSignature.count == signature.count else { 179 | return false 180 | } 181 | 182 | return expectedSignature.withUnsafeRawBytes { 183 | expectedPtr in 184 | 185 | signature.withUnsafeRawBytes { 186 | signaturePtr in 187 | return CRYPTO_memcmp(signaturePtr, expectedPtr, signature.count) == 0 188 | } 189 | 190 | } 191 | 192 | } 193 | 194 | } 195 | -------------------------------------------------------------------------------- /Sources/Signature/AsymmetricKey.swift: -------------------------------------------------------------------------------- 1 | /** 2 | * ServerCrypto 3 | * Copyright (c) 2017 Alexis Aubry. Licensed under the MIT license. 4 | */ 5 | 6 | import Foundation 7 | import CryptoSupport 8 | import CTLS 9 | 10 | /** 11 | * A key of an asymmetric signature key pair, such as an ECDSA or an RSA key pair. Can represent 12 | * either a public or a private key. 13 | */ 14 | 15 | public enum AsymmetricKey { 16 | 17 | /// A public key used for signature verification. 18 | case publicKey(EVPKeyContainer) 19 | 20 | /// A private key used for signing. 21 | case privateKey(EVPKeyContainer) 22 | 23 | /// The instance containing the raw EVP_PKEY pointer. 24 | public var keyContainer: EVPKeyContainer { 25 | 26 | switch self { 27 | case .publicKey(let container): 28 | return container 29 | case .privateKey(let container): 30 | return container 31 | } 32 | 33 | } 34 | 35 | } 36 | 37 | /** 38 | * An object that contains an EVP_PKEY pointer and deallocates it on disposal. 39 | */ 40 | 41 | public class EVPKeyContainer { 42 | 43 | /// The pointer to the raw EVP_PKEY wrapped by the instance. 44 | public let underlyingKeyPointer: UnsafeMutablePointer 45 | 46 | public init(wrapping underlyingKeyPointer: UnsafeMutablePointer) { 47 | self.underlyingKeyPointer = underlyingKeyPointer 48 | } 49 | 50 | deinit { 51 | EVP_PKEY_free(underlyingKeyPointer) 52 | } 53 | 54 | } 55 | 56 | // MARK: - Public Key Factories 57 | 58 | extension AsymmetricKey { 59 | 60 | /** 61 | * Create a public key by reading its PEM-encoded version on disk. 62 | * - parameter path: The path to the key to read. 63 | * - throws: In case of failure, this factory method throws a `CryptoError` object. 64 | * - returns: The public key associated with its OpenSSL representation. 65 | */ 66 | 67 | public static func makePublicKey(readingPEMAtPath path: String) throws -> AsymmetricKey { 68 | let keyBio = try self.readBio(at: path) 69 | return try makePublicKey(reading: keyBio) 70 | } 71 | 72 | /** 73 | * Create a public key by reading its PEM-encoded version in memory. 74 | * - parameter data: The data buffer containing the PEM key to read. 75 | * - throws: In case of failure, this factory method throws a `CryptoError` object. 76 | * - returns: The public key associated with its OpenSSL representation. 77 | */ 78 | 79 | public static func makePublicKey(readingPEMData data: Data) throws -> AsymmetricKey { 80 | let keyBio = try self.readBio(in: data) 81 | return try makePublicKey(reading: keyBio) 82 | } 83 | 84 | private static func makePublicKey(reading keyBio: UnsafeMutablePointer) throws -> AsymmetricKey { 85 | 86 | guard let pubKey = PEM_read_bio_PUBKEY(keyBio, nil, nil, nil) else { 87 | throw CryptoError.latest 88 | } 89 | 90 | let container = EVPKeyContainer(wrapping: pubKey) 91 | return .publicKey(container) 92 | 93 | } 94 | 95 | } 96 | 97 | // MARK: - Private Key Factories 98 | 99 | extension AsymmetricKey { 100 | 101 | /** 102 | * Create a private key by reading its PEM-encoded version on disk. 103 | * - parameter path: The path to the key to read. 104 | * - parameter passphrase: The passphrase of the key, if it is encrypted. 105 | * - throws: In case of failure, this factory method throws a `CryptoError` object. 106 | * - returns: The private key associated with its OpenSSL representation. 107 | */ 108 | 109 | public static func makePrivateKey(readingPEMAtPath path: String, passphrase: String?) throws -> AsymmetricKey { 110 | let keyBio = try self.readBio(at: path) 111 | return try makePrivateKey(reading: keyBio, passphrase: passphrase) 112 | } 113 | 114 | /** 115 | * Create a private key by reading its PEM-encoded version in memory. 116 | * - parameter data: The data buffer containing the PEM key to read. 117 | * - parameter passphrase: The passphrase of the key, if it is encrypted. 118 | * - throws: In case of failure, this factory method throws a `CryptoError` object. 119 | * - returns: The public key associated with its OpenSSL representation. 120 | */ 121 | 122 | public static func makePrivateKey(readingPEMData data: Data, passphrase: String?) throws -> AsymmetricKey { 123 | let keyBio = try self.readBio(in: data) 124 | return try makePrivateKey(reading: keyBio, passphrase: passphrase) 125 | } 126 | 127 | private static func makePrivateKey(reading keyBio: UnsafeMutablePointer, passphrase: String?) throws -> AsymmetricKey { 128 | 129 | let passphraseBytes = passphrase?.withCString { UnsafeMutableRawPointer(mutating: $0) } 130 | 131 | guard let pkey = PEM_read_bio_PrivateKey(keyBio, nil, { AsymmetricKey.password_cb($0, $1, $2, $3) }, passphraseBytes) else { 132 | throw CryptoError.latest 133 | } 134 | 135 | let container = EVPKeyContainer(wrapping: pkey) 136 | return .privateKey(container) 137 | 138 | } 139 | 140 | } 141 | 142 | // MARK: - Utilities 143 | 144 | extension AsymmetricKey { 145 | 146 | private static func readBio(at path: String) throws -> UnsafeMutablePointer { 147 | 148 | CryptoProvider.load(.digests, .ciphers, .cryptoErrorStrings) 149 | 150 | guard let bio = BIO_new_file(path, "r") else { 151 | throw CryptoError.latest 152 | } 153 | 154 | return bio 155 | 156 | } 157 | 158 | private static func readBio(in pemData: Data) throws -> UnsafeMutablePointer { 159 | 160 | CryptoProvider.load(.digests, .ciphers, .cryptoErrorStrings) 161 | 162 | let optionalBio = pemData.withUnsafeRawBytes { 163 | BIO_new_mem_buf($0, Int32(pemData.count)) 164 | } 165 | 166 | guard let bio = optionalBio else { 167 | throw CryptoError.latest 168 | } 169 | 170 | return bio 171 | 172 | } 173 | 174 | private static func password_cb(_ buf: UnsafeMutablePointer?, _ bufferSize: Int32, _ rwflag: Int32, _ password: UnsafeMutableRawPointer?) -> Int32 { 175 | 176 | guard buf != nil else { 177 | return 0 178 | } 179 | 180 | guard password != nil else { 181 | strcpy(buf!, "") 182 | return 0 183 | } 184 | 185 | let ptr = password!.assumingMemoryBound(to: Int8.self) 186 | 187 | var n = Int32(strlen(ptr)) 188 | 189 | if n >= bufferSize { 190 | n = bufferSize - 1 191 | } 192 | 193 | memcpy(buf!, password!, Int(n)) 194 | 195 | return n 196 | 197 | } 198 | 199 | } 200 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ServerCrypto 2 | 3 | [![Build Status](https://travis-ci.org/alexaubry/ServerCrypto.svg?branch=master)](https://travis-ci.org/alexaubry/ServerCrypto) 4 | [![Requires Swift 4.0](https://img.shields.io/badge/Swift-4.0-ee4f37.svg)]() 5 | [![Supports macOS and Linux](https://img.shields.io/badge/os-linux%20%7C%20macOS-lightgrey.svg)]() 6 | 7 | ServerCrypto is a library that makes server-side cryptography easy in Swift. 8 | 9 | ## Installation 10 | 11 | To use ServerCrypto in your project, add this line to your `Package.swift`: 12 | 13 | ~~~swift 14 | .package(url: "https://github.com/alexaubry/ServerCrypto", from: "1.0.0") 15 | ~~~ 16 | 17 | Make sure you have OpenSSL installed before using the library. 18 | 19 | On macOS, you need to provide the following flags to build or test from the command line: 20 | 21 | ~~~bash 22 | swift build -Xswiftc -I/usr/local/opt/openssl/include -Xlinker -L/usr/local/opt/openssl/lib 23 | ~~~ 24 | 25 | ## Features 26 | 27 | - [Hashing](#hashing) 28 | - [HMAC Signature](#hmac-signature) 29 | - [HMAC Verification](#hmac-verification) 30 | - [Asymmetric Signature](#asymmetric-signature) 31 | - [Asymmetric Signature Verification](#asymmetric-signature-verification) 32 | 33 | ## Hashing 34 | 35 | To compute the hash of a sequence of bytes, you use an instance of `Hasher`. 36 | 37 | `Hasher` can generate hashes for `Data`, `[UInt8]` ; and any type than conforms to the `Bytes` protocols. 38 | 39 | The following hashing algorithms are supported: 40 | 41 | ~~~ 42 | .md4 .md5 .sha1 .sha224 .sha256 .sha384 .sha512 .ripeMd160 43 | ~~~ 44 | 45 | #### Example 46 | 47 | To compute the SHA-256 hash of a String, write the following code: 48 | 49 | ~~~swift 50 | import Hash 51 | 52 | let hasher = Hasher.sha256 53 | 54 | let messageData = "Hello world".data(using: .utf8)! 55 | let hashData = try hasher.makeHash(for: messageData) // Returns a Data object 56 | let hashHexString = hashData.hexString 57 | ~~~ 58 | 59 | ## HMAC Signature 60 | 61 | To create an HMAC signature, you need: 62 | 63 | - A message digest / hashing algorithm 64 | - A key with a password 65 | - A message to sign 66 | 67 | You use an instance of `Signer` to generate an HMAC signature. Any type supported by [`Hasher`](#hashing) is also supported by `Signer`. 68 | 69 | #### Example 70 | 71 | To compute the SHA-256 HMAC of a String, you need to follow these steps: 72 | 73 | **1-** Create an HMAC key with a password 74 | 75 | ~~~swift 76 | import Signature 77 | 78 | let key = try HMACKey(password: "secret") 79 | ~~~ 80 | 81 | **2-** Create an HMAC signer 82 | 83 | ~~~swift 84 | let signer = Signer.hmac(key) 85 | ~~~ 86 | 87 | **3-** Get the HMAC for the message 88 | 89 | ~~~swift 90 | let messageData = "Hello world".data(using: .utf8)! 91 | let hmacData = signer.sign(messageData, with: .sha256) // Returns a Data object 92 | let hmacHexString = hmacData.hexString 93 | ~~~ 94 | 95 | ## HMAC Verification 96 | 97 | To verify that an HMAC signature is valid for the message you expect, you need: 98 | 99 | - A message digest / hashing algorithm 100 | - A key with an expected password 101 | - An expected message 102 | - A signature to verify 103 | 104 | You use an instance of `Signer` to verify an HMAC signature. The signature must be a `Data` object. The expected message can be any type supported by [`Hasher`](#hashing). 105 | 106 | #### Example 107 | 108 | To verify the SHA-256 HMAC of a String, you need to follow these steps: 109 | 110 | **1-** Create an HMAC key with the expected password 111 | 112 | ~~~swift 113 | import Signature 114 | 115 | let key = try HMACKey(password: "secret") 116 | ~~~ 117 | 118 | **2-** Create an HMAC signer 119 | 120 | ~~~swift 121 | let signer = Signer.hmac(key) 122 | ~~~ 123 | 124 | **3-** Verify the HMAC for the message 125 | 126 | ~~~swift 127 | let hmacData = ... 128 | let messageData = "Hello world".data(using: .utf8)! 129 | let isValid = signer.verify(signature: hmacData, for: messageData, with: .sha256) // Returns a Bool 130 | ~~~ 131 | 132 | ## Asymmetric Signature 133 | 134 | Signature.framework can generate signatures using private keys and algorithms like RSA and ECDSA. 135 | 136 | To create a signature, you need: 137 | 138 | - A message digest / hashing algorithm 139 | - A private PEM-encoded key 140 | - A message to sign 141 | 142 | You use an instance of `Signer` to generate a signature. Any type supported by [`Hasher`](#hashing) is also supported by `Signer`. 143 | 144 | #### Example 145 | 146 | To compute the SHA-256 ECDSA signature of a String, you need to follow these steps: 147 | 148 | **1-** Load a private key from a PEM file: 149 | 150 | ~~~swift 151 | import Signature 152 | 153 | let privateKey = try AsymmetricKey.makePrivateKey(readingPEMAtPath: "path/to/public/key.pem", passphrase: "...") 154 | ~~~ 155 | 156 | You can also load a PEM key from memory using `AsymmetricKey.makePrivateKey(readingPEMData: Data,passphrase: String?)`. 157 | 158 | **2-** Create an asymmetric signer 159 | 160 | ~~~swift 161 | let signer = Signer.asymmetric(privateKey) 162 | ~~~ 163 | 164 | **3-** Get the signature for the message 165 | 166 | ~~~swift 167 | let messageData = "Hello world".data(using: .utf8)! 168 | let hmacData = signer.sign(messageData, with: .sha256) // Returns a Data object 169 | let hmacHexString = hmacData.hexString 170 | ~~~ 171 | 172 | ## Asymmetric Signature Verification 173 | 174 | To verify that a signature is valid for the message you expect, you need: 175 | 176 | - A message digest / hashing algorithm 177 | - The public key associated with the expected private key 178 | - An expected message 179 | - A signature to verify 180 | 181 | You use an instance of `Signer` to verify a signature. The signature must be a `Data` object. The expected message can be any type supported by [`Hasher`](#hashing). 182 | 183 | #### Example 184 | 185 | To verify that a SHA-256 ECDSA signature of a String is valid for the public key, you need to follow these steps: 186 | 187 | **1-** Load the public key from a PEM file 188 | 189 | ~~~swift 190 | import Signature 191 | 192 | let publicKey = try AsymmetricKey.makePublicKey(readingPEMAtPath: "path/to/private/key.pem") 193 | ~~~ 194 | 195 | You can also load the key from memory using `AsymmetricKey.makePublicKey(readingPEMData: Data)`. 196 | 197 | **2-** Create an asymmetric signer 198 | 199 | ~~~swift 200 | let signer = Signer.asymmetric(publicKey) 201 | ~~~ 202 | 203 | **3-** Verify the signatrure for the message 204 | 205 | ~~~swift 206 | let hmacData = ... 207 | let messageData = "Hello world".data(using: .utf8)! 208 | let isValid = signer.verify(signature: hmacData, for: messageData, with: .sha256) // Returns a Bool 209 | ~~~ 210 | 211 | ## Author 212 | 213 | Alexis Aubry, me@alexaubry.fr 214 | 215 | You can find me on Twitter : [@_alexaubry](https://twitter.com/_alexaubry) 216 | 217 | ## License 218 | 219 | ServerCrypto is available under the MIT License. See the [LICENSE](LICENSE) file for more info. 220 | -------------------------------------------------------------------------------- /Tests/ServerCryptoTests/Signature/RSA/RSATestVectors.swift: -------------------------------------------------------------------------------- 1 | /** 2 | * ServerCrypto 3 | * Copyright (c) 2017 Alexis Aubry. Licensed under the MIT license. 4 | */ 5 | 6 | import Foundation 7 | import Hash 8 | import Signature 9 | 10 | struct RSASignature: AsymmetricSignature { 11 | 12 | let hasher: Hasher 13 | let privateKeyName: String 14 | let publicKeyName: String 15 | let privateKeyPassphrase: String? 16 | let message: String 17 | let validSignature: String 18 | 19 | init(_ hasher: Hasher, _ privateKeyName: String, _ publicKeyName: String, _ privateKeyPassphrase: String?, _ message: String, _ validSignature: String) { 20 | self.hasher = hasher 21 | self.privateKeyName = privateKeyName 22 | self.publicKeyName = publicKeyName 23 | self.privateKeyPassphrase = privateKeyPassphrase 24 | self.message = message 25 | self.validSignature = validSignature 26 | } 27 | 28 | } 29 | 30 | // MARK: - RSA1024 Signatures 31 | 32 | let rsa1024withMD4Signatures = [ 33 | RSASignature(.md4, "rsa_1024_private", "rsa_1024_public", nil, "Signature", "0ca6a9f76a7281a5c161ffbfe0cb83e9e47fe3a9a523dc6d9cb447e29f1e734d40ed4d78316430a70bbd985685ea537c68266007cadd6f07ba71c34b038bde8d4a5bc6bf7a2b869c3fc1cf58be77e3b99ba25db2b15ad34898728745c4c2a583e5fa2ee373ad84f7366ad2d851288f0a01aeb935805ce88c29565533aa4311e4"), 34 | ] 35 | 36 | let rsa1024withMD5Signatures = [ 37 | RSASignature(.md5, "rsa_1024_private", "rsa_1024_public", nil, "Signature", "094021c72863ae317b4e8a5a1fd742d539724c060669704ea3d807f962663f5b8e43b5f8a703b098d9e4c8203b88423b96c45060206ae8ee34ffd98b32948b356246a633e27360e790ad822773344e1d71a5e5e51ec288701e6d9c95df225cd6760642418f1a8af07498be4cc73b6f352545d34b4433dc0bfee468bd78891922"), 38 | ] 39 | 40 | let rsa1024withSHA1Signatures = [ 41 | RSASignature(.sha1, "rsa_1024_private", "rsa_1024_public", nil, "Signature", "837d0eca894ba4d793a23d87d209bd9f02b04201122de9ab4ad351b05104b562aa2522ca48ef984b2b0287cba0eda2764de82b05ed4d1388f418f6d96fa85ceb24ebed0c7b531a60c96f9d31773c025ce0b7ad126900dea582d9bca702ab26810387c2d25630f94bd0a10f530e069215872fe9fc01b7bccdce2f0844e5daf30d"), 42 | ] 43 | 44 | let rsa1024withSHA224Signatures = [ 45 | RSASignature(.sha224, "rsa_1024_private", "rsa_1024_public", nil, "Signature", "71a213d313382bb4a08e6f6c6ef24502bc97d52467c206287ee1e2c314ff452a6a63dc728758f17fed02d9f3af2b4a741203e78e9f636d16f234f902fe6944a3bb7a2e64d0d713ef41f9c890222116fe33f042bf788edf1904f948822c1e217c226a1b1a6c4bc11b08757830374a7377da255172e86bb633885d3442018f650c"), 46 | ] 47 | 48 | let rsa1024withSHA256Signatures = [ 49 | RSASignature(.sha256, "rsa_1024_private", "rsa_1024_public", nil, "Signature", "aa0af387f260e4c46ea6ec43cc11bb4ecfaded1f760b0c798b0c0a79f8f1088823c3fd37e5c9cc27e54f69ff3126e51a672d0f680c8845ed96b2c77b0d1574e8e03738d1330359c4ce916d66d611c1e987c56b64bf3f60ea2faa9c6211161352f803b4bec58ba23e1c8330d3c0b1697790b6d06d326e04db5e6ba32b7635bb62"), 50 | ] 51 | 52 | let rsa1024withSHA384Signatures = [ 53 | RSASignature(.sha384, "rsa_1024_private", "rsa_1024_public", nil, "Signature", "556a4044cabf81807ff815a7193d1771fbfb6beeacb708f120ff3968cb19717fe46a518e5d65ecef7d8fe4c95f3d7e4fa7152dc9d7e24ac069fb252b01f963ab3fdbdffdfa3fbf5993da9b96b4733f56c87158a4d3f3584047fd3531aee9a7758de7829e8160cfdc8dfb117481d9bb60e6b874296195489a1e6fe262bec9df49"), 54 | ] 55 | 56 | let rsa1024withSHA512Signatures = [ 57 | RSASignature(.sha512, "rsa_1024_private", "rsa_1024_public", nil, "Signature", "b28382110a15487ebbbd977e9c1e48b1f8043cd4ac58bab76fca41fd762f7c7175551519518b963011881252bcf890ac7e5cbf30dffc8921f1c8081a2bb674b773239cda1f71231236032c4c17e5f1299e8c598f51b20cd47384d807c16ef052048e4ce1850512fb7eb1685a405fe66d78cbb482a28c5680acf7de123ac7d531"), 58 | ] 59 | 60 | let rsa1024withRIPEMD160Signatures = [ 61 | RSASignature(.ripeMd160, "rsa_1024_private", "rsa_1024_public", nil, "Signature", "0839278c6da93ed1fa8c89c58e2e2c4b02e9fb7d920cfaa284a03ef2b33f647a7120aa2a81f2c22fced292e9ac7d5f8039e8a248cc8bf05b5c61d58b593b56a0b4775c37b6b0fefed5bf24273bd8bb0a5af0c08435715fa64f80c8a8e081092e667846fbc412407bd82dbff0f4d622713a7dd847b8d220b9755da67cf23f6684"), 62 | ] 63 | 64 | // MARK: - RSA1024 Fake Signatures 65 | 66 | let rsa1024withMD4FakeSignatures = [ 67 | RSASignature(.md4, "rsa_1024_private", "rsa_1024_public", nil, "Signature", "1ca6a9f76a7281a5c161ffbfe0cb83e9e47fe3a9a523dc6d9cb447e29f1e734d40ed4d78316430a70bbd985685ea537c68266007cadd6f07ba71c34b038bde8d4a5bc6bf7a2b869c3fc1cf58be77e3b99ba25db2b15ad34898728745c4c2a583e5fa2ee373ad84f7366ad2d851288f0a01aeb935805ce88c29565533aa4311e4"), 68 | ] 69 | 70 | let rsa1024withMD5FakeSignatures = [ 71 | RSASignature(.md5, "rsa_1024_private", "rsa_1024_public", nil, "Signature", "194021c72863ae317b4e8a5a1fd742d539724c060669704ea3d807f962663f5b8e43b5f8a703b098d9e4c8203b88423b96c45060206ae8ee34ffd98b32948b356246a633e27360e790ad822773344e1d71a5e5e51ec288701e6d9c95df225cd6760642418f1a8af07498be4cc73b6f352545d34b4433dc0bfee468bd78891922"), 72 | ] 73 | 74 | let rsa1024withSHA1FakeSignatures = [ 75 | RSASignature(.sha1, "rsa_1024_private", "rsa_1024_public", nil, "Signature", "937d0eca894ba4d793a23d87d209bd9f02b04201122de9ab4ad351b05104b562aa2522ca48ef984b2b0287cba0eda2764de82b05ed4d1388f418f6d96fa85ceb24ebed0c7b531a60c96f9d31773c025ce0b7ad126900dea582d9bca702ab26810387c2d25630f94bd0a10f530e069215872fe9fc01b7bccdce2f0844e5daf30d"), 76 | ] 77 | 78 | let rsa1024withSHA224FakeSignatures = [ 79 | RSASignature(.sha224, "rsa_1024_private", "rsa_1024_public", nil, "Signature", "81a213d313382bb4a08e6f6c6ef24502bc97d52467c206287ee1e2c314ff452a6a63dc728758f17fed02d9f3af2b4a741203e78e9f636d16f234f902fe6944a3bb7a2e64d0d713ef41f9c890222116fe33f042bf788edf1904f948822c1e217c226a1b1a6c4bc11b08757830374a7377da255172e86bb633885d3442018f650c"), 80 | ] 81 | 82 | let rsa1024withSHA256FakeSignatures = [ 83 | RSASignature(.sha256, "rsa_1024_private", "rsa_1024_public", nil, "Signature", "ba0af387f260e4c46ea6ec43cc11bb4ecfaded1f760b0c798b0c0a79f8f1088823c3fd37e5c9cc27e54f69ff3126e51a672d0f680c8845ed96b2c77b0d1574e8e03738d1330359c4ce916d66d611c1e987c56b64bf3f60ea2faa9c6211161352f803b4bec58ba23e1c8330d3c0b1697790b6d06d326e04db5e6ba32b7635bb62"), 84 | ] 85 | 86 | let rsa1024withSHA384FakeSignatures = [ 87 | RSASignature(.sha384, "rsa_1024_private", "rsa_1024_public", nil, "Signature", "656a4044cabf81807ff815a7193d1771fbfb6beeacb708f120ff3968cb19717fe46a518e5d65ecef7d8fe4c95f3d7e4fa7152dc9d7e24ac069fb252b01f963ab3fdbdffdfa3fbf5993da9b96b4733f56c87158a4d3f3584047fd3531aee9a7758de7829e8160cfdc8dfb117481d9bb60e6b874296195489a1e6fe262bec9df49"), 88 | ] 89 | 90 | let rsa1024withSHA512FakeSignatures = [ 91 | RSASignature(.sha512, "rsa_1024_private", "rsa_1024_public", nil, "Signature", "c28382110a15487ebbbd977e9c1e48b1f8043cd4ac58bab76fca41fd762f7c7175551519518b963011881252bcf890ac7e5cbf30dffc8921f1c8081a2bb674b773239cda1f71231236032c4c17e5f1299e8c598f51b20cd47384d807c16ef052048e4ce1850512fb7eb1685a405fe66d78cbb482a28c5680acf7de123ac7d531"), 92 | ] 93 | 94 | let rsa1024withRIPEMD160FakeSignatures = [ 95 | RSASignature(.ripeMd160, "rsa_1024_private", "rsa_1024_public", nil, "Signature", "1839278c6da93ed1fa8c89c58e2e2c4b02e9fb7d920cfaa284a03ef2b33f647a7120aa2a81f2c22fced292e9ac7d5f8039e8a248cc8bf05b5c61d58b593b56a0b4775c37b6b0fefed5bf24273bd8bb0a5af0c08435715fa64f80c8a8e081092e667846fbc412407bd82dbff0f4d622713a7dd847b8d220b9755da67cf23f6684"), 96 | ] 97 | 98 | // MARK: - RSA2048 Signatures 99 | 100 | let rsa2048withMD4Signatures = [ 101 | RSASignature(.md4, "rsa_2048_private", "rsa_2048_public", nil, "Signature", "a3e9b219e7cc5d3c0df024ae495c9deb14bcf26045143379d20f26a5df0d89c23fd441954a662639ad5d9030580a3fea7d711785e6971e408c8a0bf083edd9abadd09d0807e1790906990e1b779493f3e81d09eeed4773849a3ef82bb96a1dc290aa8a3874de8ceddbd44f577e000212b49b5705d8a406450f0a3c6bedf65083508b808bb259fa6918d01917d7ca6d0809798c291049df25a51622336f7deccbed7b10b8fd0b305c4810603c0a9c2e356a51a9aca1ae963a85b256525bdf2c75c70146d7c69d02c16a672252b347aec5fcfc4b5634a8208b92a8b02dadfd63d978ad1fcae90c34841decad1dc041c09377bfb3e1587948e77b1bd2c4afb4bca1"), 102 | ] 103 | 104 | let rsa2048withMD5Signatures = [ 105 | RSASignature(.md5, "rsa_2048_private", "rsa_2048_public", nil, "Signature", "70b96a945eb67a115e42406484772c233ac381cd1fb263217f03853cea12bf6a7df7137aae598abbbb325231e4bde8c4f784ec30ef617acfa77d37ad2568ccafc6337335e0e8e78e5af6c4019f6113930b999bfb9a91fefa1df71535d10ba799b2a95838bada8fd887be89c07f7ad9dd3ee68676d23d2792a458b88728f4a3c03a3b564d79a75517bfffbf3c7993cdb57ca8cd89270c003416bbaa28b67a74231652c9ef124e5d42f74c830d63e9cc1bc8682e9c4eed522c69cbe046133e803741dcb6407df9acca9e3835706d3680fb0b4c28f654e28746fd6461756d7fac8df3e5b0e60e709bc7fdd093c70d63bd633be48927e3abe90decce78b11f0ef1dd"), 106 | ] 107 | 108 | let rsa2048withSHA1Signatures = [ 109 | RSASignature(.sha1, "rsa_2048_private", "rsa_2048_public", nil, "Signature", "1887fdafdfcdd11ad5b311bfab44ef7d2669f6380eae66d1686e2630ae7d971b5a1133e9044ac38eedd5f3cf87f988d783f459daead96f03631ca1a538e769b9d82ecb4d5439864640c671eb9e62d40e3f1df95c0a61626ecbef328ed5c5e6341732b3ed0db551ac277ebe86129b85268b3afd529f311d1ad4007dead9d8c986ac78b5dfa719ae2eca64102943697fada9526ae2d736249af4bcf39735e9b72484cd88d876adaaf8e528efd19005f955c43eec0cf97e9a8693675d30770eade9690a7f113314bc332f6264978e4135905438d28821570cce43d055b72ed0eca4e61a703121a7492e7492cb53f4a977760e74243bf459680a0b3167110bb7b446"), 110 | ] 111 | 112 | let rsa2048withSHA224Signatures = [ 113 | RSASignature(.sha224, "rsa_2048_private", "rsa_2048_public", nil, "Signature", "1650edfa4e3a51a28c7a7b62360fb3fcd14da84f1a468f40db74d4da03474c93980caa6a9b3c74526887e56b86baa5a0d03618eda94dd7cb41feef2d783576c63d321a47f9ec2067e3c1253c11bb2b38588c12680bb134370405a4d51bdf4b0c30ad568b5cdf99928bc4e45ffe60fa9eccf705434a71054e5383b786871a8fad152af4f76a6e6caa7987f1bda15f7a89a313ad05556e2c68e65c79156540152b9e870a465411c8d922ae45e2720a49ce2dad28388f501a3762b08c0571ec45f94e3d6769831919c103b3a11c63b2801f1359209cd3ade647357a0921eac611149bc904fb16c2efdbe4a150bdbd24baf26ec40b1dbb1457433d06dd4d2e6614a6"), 114 | ] 115 | 116 | let rsa2048withSHA256Signatures = [ 117 | RSASignature(.sha256, "rsa_2048_private", "rsa_2048_public", nil, "Signature", "468028cc227102dd8a8e0583c4de5bd798d039203eba76a5e183bf4869128e1a513f192672dc5983c7dfe1b5fa150e2145a6b9792c08e24c0622433fb6d3ed97615bbce6f370551f51818cfc7f999489254886c200cec8b97540ab5afcb1e5b64670d3c6cce73e055d2767b3729140b9227672c2b4892dcb4023c49267099ba4e6d3359d69c02cc587fa2ac2d5b7e48d2176f6d16bda15569eb5a5c0cb02ba4f9b91fbf030a3c762e6ab5c5b80ebae88c0da9ea7b775a522ee788f4b60ab9841009b72a53764b9388fbcf7fee08e4d86ffd692ec7e5baff5d5a3b3f01b88779029cae2a61e46a4de6ea7cf739c66c46eaf5661889ba35b862331ae3209cfe30a"), 118 | ] 119 | 120 | let rsa2048withSHA384Signatures = [ 121 | RSASignature(.sha384, "rsa_2048_private", "rsa_2048_public", nil, "Signature", "c578a4b276e27871ac3084e2614ac60dfb57ffc9411352141dd48c301cdacd60c76656ef11d3097ef00f08a6d647805e72e7a581bf710fc75e9fc02489433000451156157145faf6127d4d3b9b7d749ca09e2319de29a400a49d0c699031c0efbf8905a99ef7a3b0bca8291570cd2b7e4fb3a94255e455ba7968ed21115b22e9675a889a63dab88341bf471cbb6731564a5146d3b89541496d06099afa602ffb63d45b0e6f79e522c3a10571bd446718651359b49d06c2fdde3c0d7f07401e62c24b48ab67d585c4c79d8f734fa3962893a57d004f0612847ef993404b5e2e2bb9fc175afa79652a43c126458cf6a9956ef8b6e53d7a4fee3374b8448c12bd27"), 122 | ] 123 | 124 | let rsa2048withSHA512Signatures = [ 125 | RSASignature(.sha512, "rsa_2048_private", "rsa_2048_public", nil, "Signature", "c399f823f0cb8bf669202e3d51988e4d05e930660a917228c887bf63e70bc2e45189cde905522e400ac5151f907abacb584aa817e4d2aabe8750179d6cb1bb630905c3cf1b6c2fbc2a9a8dbe75d17caff507f6e13e72078ea11e4adc6556b71f332b95795a4883897a359279da449c692b509ae2e980e58f1672ac9ff72c7bfa691c5803b9337cc3028df06b81d48d2a3c611ec4309d4257f78ec773c282af9a5886a4a9419887ff796615e7ca1ffe43df4f6360483352c182cc96fccd6827c052d55ab7b8315d2ad456455fa99f2c6837e31032c6ecf161e18146e4bc0a8321b5b1445cfbcce434f220593201a3a31f9abd477d4d795815d700c67c719212d0"), 126 | ] 127 | 128 | let rsa2048withRIPEMD160Signatures = [ 129 | RSASignature(.ripeMd160, "rsa_2048_private", "rsa_2048_public", nil, "Signature", "4063f3151edfe92112076a0724a5544828074d0559103e71c946a8891a3cef6bb467afb12e0a607ae6d3572d20e02bfeb85364347f02b9e69950b3ea661369db7af62cffba4f286ed8c31f1a68e811d351a20adeefaf106f17dc647487364a144f9782e6e1559d2def1bc27e61abad3a420999b40dd2a3ca8cff61e53584dd05657433c917036d58b689ada5dc3d759967d8e1fef2fac599d578d90cdef2e3acb73e202cdec6152a643e9f257dd6772f306aa48c2403a8c4d0556204d7bb434c987444753fa8ab325021b1f38c1728cb696f801e2d69eda493a41603d739dad6e462b53aaeae5e4ca23cca3f9de6e1cecb017e2c56abdb1028a7cbe0a5a17f69"), 130 | ] 131 | 132 | // MARK: - RSA2048 Fake Signatures 133 | 134 | let rsa2048withMD4FakeSignatures = [ 135 | RSASignature(.md4, "rsa_2048_private", "rsa_2048_public", nil, "Signature", "b3e9b219e7cc5d3c0df024ae495c9deb14bcf26045143379d20f26a5df0d89c23fd441954a662639ad5d9030580a3fea7d711785e6971e408c8a0bf083edd9abadd09d0807e1790906990e1b779493f3e81d09eeed4773849a3ef82bb96a1dc290aa8a3874de8ceddbd44f577e000212b49b5705d8a406450f0a3c6bedf65083508b808bb259fa6918d01917d7ca6d0809798c291049df25a51622336f7deccbed7b10b8fd0b305c4810603c0a9c2e356a51a9aca1ae963a85b256525bdf2c75c70146d7c69d02c16a672252b347aec5fcfc4b5634a8208b92a8b02dadfd63d978ad1fcae90c34841decad1dc041c09377bfb3e1587948e77b1bd2c4afb4bca1"), 136 | ] 137 | 138 | let rsa2048withMD5FakeSignatures = [ 139 | RSASignature(.md5, "rsa_2048_private", "rsa_2048_public", nil, "Signature", "80b96a945eb67a115e42406484772c233ac381cd1fb263217f03853cea12bf6a7df7137aae598abbbb325231e4bde8c4f784ec30ef617acfa77d37ad2568ccafc6337335e0e8e78e5af6c4019f6113930b999bfb9a91fefa1df71535d10ba799b2a95838bada8fd887be89c07f7ad9dd3ee68676d23d2792a458b88728f4a3c03a3b564d79a75517bfffbf3c7993cdb57ca8cd89270c003416bbaa28b67a74231652c9ef124e5d42f74c830d63e9cc1bc8682e9c4eed522c69cbe046133e803741dcb6407df9acca9e3835706d3680fb0b4c28f654e28746fd6461756d7fac8df3e5b0e60e709bc7fdd093c70d63bd633be48927e3abe90decce78b11f0ef1dd"), 140 | ] 141 | 142 | let rsa2048withSHA1FakeSignatures = [ 143 | RSASignature(.sha1, "rsa_2048_private", "rsa_2048_public", nil, "Signature", "2887fdafdfcdd11ad5b311bfab44ef7d2669f6380eae66d1686e2630ae7d971b5a1133e9044ac38eedd5f3cf87f988d783f459daead96f03631ca1a538e769b9d82ecb4d5439864640c671eb9e62d40e3f1df95c0a61626ecbef328ed5c5e6341732b3ed0db551ac277ebe86129b85268b3afd529f311d1ad4007dead9d8c986ac78b5dfa719ae2eca64102943697fada9526ae2d736249af4bcf39735e9b72484cd88d876adaaf8e528efd19005f955c43eec0cf97e9a8693675d30770eade9690a7f113314bc332f6264978e4135905438d28821570cce43d055b72ed0eca4e61a703121a7492e7492cb53f4a977760e74243bf459680a0b3167110bb7b446"), 144 | ] 145 | 146 | let rsa2048withSHA224FakeSignatures = [ 147 | RSASignature(.sha224, "rsa_2048_private", "rsa_2048_public", nil, "Signature", "2650edfa4e3a51a28c7a7b62360fb3fcd14da84f1a468f40db74d4da03474c93980caa6a9b3c74526887e56b86baa5a0d03618eda94dd7cb41feef2d783576c63d321a47f9ec2067e3c1253c11bb2b38588c12680bb134370405a4d51bdf4b0c30ad568b5cdf99928bc4e45ffe60fa9eccf705434a71054e5383b786871a8fad152af4f76a6e6caa7987f1bda15f7a89a313ad05556e2c68e65c79156540152b9e870a465411c8d922ae45e2720a49ce2dad28388f501a3762b08c0571ec45f94e3d6769831919c103b3a11c63b2801f1359209cd3ade647357a0921eac611149bc904fb16c2efdbe4a150bdbd24baf26ec40b1dbb1457433d06dd4d2e6614a6"), 148 | ] 149 | 150 | let rsa2048withSHA256FakeSignatures = [ 151 | RSASignature(.sha256, "rsa_2048_private", "rsa_2048_public", nil, "Signature", "568028cc227102dd8a8e0583c4de5bd798d039203eba76a5e183bf4869128e1a513f192672dc5983c7dfe1b5fa150e2145a6b9792c08e24c0622433fb6d3ed97615bbce6f370551f51818cfc7f999489254886c200cec8b97540ab5afcb1e5b64670d3c6cce73e055d2767b3729140b9227672c2b4892dcb4023c49267099ba4e6d3359d69c02cc587fa2ac2d5b7e48d2176f6d16bda15569eb5a5c0cb02ba4f9b91fbf030a3c762e6ab5c5b80ebae88c0da9ea7b775a522ee788f4b60ab9841009b72a53764b9388fbcf7fee08e4d86ffd692ec7e5baff5d5a3b3f01b88779029cae2a61e46a4de6ea7cf739c66c46eaf5661889ba35b862331ae3209cfe30a"), 152 | ] 153 | 154 | let rsa2048withSHA384FakeSignatures = [ 155 | RSASignature(.sha384, "rsa_2048_private", "rsa_2048_public", nil, "Signature", "d578a4b276e27871ac3084e2614ac60dfb57ffc9411352141dd48c301cdacd60c76656ef11d3097ef00f08a6d647805e72e7a581bf710fc75e9fc02489433000451156157145faf6127d4d3b9b7d749ca09e2319de29a400a49d0c699031c0efbf8905a99ef7a3b0bca8291570cd2b7e4fb3a94255e455ba7968ed21115b22e9675a889a63dab88341bf471cbb6731564a5146d3b89541496d06099afa602ffb63d45b0e6f79e522c3a10571bd446718651359b49d06c2fdde3c0d7f07401e62c24b48ab67d585c4c79d8f734fa3962893a57d004f0612847ef993404b5e2e2bb9fc175afa79652a43c126458cf6a9956ef8b6e53d7a4fee3374b8448c12bd27"), 156 | ] 157 | 158 | let rsa2048withSHA512FakeSignatures = [ 159 | RSASignature(.sha512, "rsa_2048_private", "rsa_2048_public", nil, "Signature", "d399f823f0cb8bf669202e3d51988e4d05e930660a917228c887bf63e70bc2e45189cde905522e400ac5151f907abacb584aa817e4d2aabe8750179d6cb1bb630905c3cf1b6c2fbc2a9a8dbe75d17caff507f6e13e72078ea11e4adc6556b71f332b95795a4883897a359279da449c692b509ae2e980e58f1672ac9ff72c7bfa691c5803b9337cc3028df06b81d48d2a3c611ec4309d4257f78ec773c282af9a5886a4a9419887ff796615e7ca1ffe43df4f6360483352c182cc96fccd6827c052d55ab7b8315d2ad456455fa99f2c6837e31032c6ecf161e18146e4bc0a8321b5b1445cfbcce434f220593201a3a31f9abd477d4d795815d700c67c719212d0"), 160 | ] 161 | 162 | let rsa2048withRIPEMD160FakeSignatures = [ 163 | RSASignature(.ripeMd160, "rsa_2048_private", "rsa_2048_public", nil, "Signature", "5063f3151edfe92112076a0724a5544828074d0559103e71c946a8891a3cef6bb467afb12e0a607ae6d3572d20e02bfeb85364347f02b9e69950b3ea661369db7af62cffba4f286ed8c31f1a68e811d351a20adeefaf106f17dc647487364a144f9782e6e1559d2def1bc27e61abad3a420999b40dd2a3ca8cff61e53584dd05657433c917036d58b689ada5dc3d759967d8e1fef2fac599d578d90cdef2e3acb73e202cdec6152a643e9f257dd6772f306aa48c2403a8c4d0556204d7bb434c987444753fa8ab325021b1f38c1728cb696f801e2d69eda493a41603d739dad6e462b53aaeae5e4ca23cca3f9de6e1cecb017e2c56abdb1028a7cbe0a5a17f69"), 164 | ] 165 | -------------------------------------------------------------------------------- /Tests/ServerCryptoTests/Signature/HMAC/HMACSignatures.swift: -------------------------------------------------------------------------------- 1 | /** 2 | * ServerCrypto 3 | * Copyright (c) 2017 Alexis Aubry. Licensed under the MIT license. 4 | */ 5 | 6 | import Foundation 7 | import Hash 8 | import Signature 9 | 10 | struct HMACSignature { 11 | 12 | let hasher: Hasher 13 | let keyPassword: String 14 | let message: String 15 | let expectedSignature: String 16 | 17 | init(_ hasher: Hasher, _ keyPassword: String, _ message: String, _ expectedSignature: String) { 18 | self.hasher = hasher 19 | self.keyPassword = keyPassword 20 | self.message = message 21 | self.expectedSignature = expectedSignature 22 | } 23 | 24 | } 25 | 26 | // MARK: - HMAC Signatures 27 | 28 | let hmd4Signatures = [ 29 | HMACSignature(.md4, "secret", "4869205468657265", "aa52213133eae9ae2adb86f01d79b098"), 30 | HMACSignature(.md4, "secret", "7768617420646f2079612077616e7420666f72206e6f7468696e673f", "896d9c033fcb197f1bd1993f716eea91"), 31 | HMACSignature(.md4, "secret", "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd", "87b258f40db19d2059736988801f7dd0"), 32 | HMACSignature(.md4, "secret", "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd", "5a06db78c30ed795057541289e87eb1a"), 33 | HMACSignature(.md4, "secret", "546573742057697468205472756e636174696f6e", "c2284a36b025d3dec59b32552b32a372"), 34 | HMACSignature(.md4, "secret", "54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374", "73847ea99388a189f50c5a0c552b76c1") 35 | ] 36 | 37 | let hmd5Signatures = [ 38 | HMACSignature(.md5, "secret", "4869205468657265", "1f337b759bb8c23e9f9ef1d28f6ac822"), 39 | HMACSignature(.md5, "secret", "7768617420646f2079612077616e7420666f72206e6f7468696e673f", "8d5b74cac41c45a0f22b7a353bdb27b7"), 40 | HMACSignature(.md5, "secret", "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd", "3bd09138f1c959fc9a85040f2613aa9c"), 41 | HMACSignature(.md5, "secret", "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd", "09a0fa300a224deaf01d6d9da640d188"), 42 | HMACSignature(.md5, "secret", "546573742057697468205472756e636174696f6e", "2443afbf1bcb5c01563365e447fa1ea9"), 43 | HMACSignature(.md5, "secret", "54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374", "731738a059b3f585bfdf5a810280101e") 44 | ] 45 | 46 | let hs1Signatures = [ 47 | HMACSignature(.sha1, "secret", "4869205468657265", "dd3c907046caa39e26428dd00afd66e7ba758fd0"), 48 | HMACSignature(.sha1, "secret", "7768617420646f2079612077616e7420666f72206e6f7468696e673f", "e65afa52fc891d188ded82a4a35ebe3cd04be9bc"), 49 | HMACSignature(.sha1, "secret", "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd", "6b9f8180b03d020da32941c757d9683cf1b43c19"), 50 | HMACSignature(.sha1, "secret", "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd", "b86c2818df18264ce27b33fb621647ec8f2271bf"), 51 | HMACSignature(.sha1, "secret", "546573742057697468205472756e636174696f6e", "64ee7f075ce9a063c863391b343c6512ba25a273"), 52 | HMACSignature(.sha1, "secret", "54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374", "582bc4f8dd7ab86337234ddb680aad33f9a77536") 53 | ] 54 | 55 | let hs224Signatures = [ 56 | HMACSignature(.sha224, "secret", "4869205468657265", "0109f3443e9dbdcd9b3c588ce3a284bd72a17ab9d01771a6aa901305"), 57 | HMACSignature(.sha224, "secret", "7768617420646f2079612077616e7420666f72206e6f7468696e673f", "c514a97333c41c9f76ba475560fe46d3a02665c560632cd7ba7ed11a"), 58 | HMACSignature(.sha224, "secret", "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd", "82f9b92da6cd4d349bfb6513fd8b211bcfc7c204d2682d8f6a60c728"), 59 | HMACSignature(.sha224, "secret", "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd", "4354aaf1c7ddd3a2691da13b9239e9679aef6ca319df810c34da527a"), 60 | HMACSignature(.sha224, "secret", "546573742057697468205472756e636174696f6e", "338931e05590f1143a6c80e3ac21e691e55e2932961ec930175d88d5"), 61 | HMACSignature(.sha224, "secret", "54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374", "ef373b7722c72be96f1f17b376814ef97f2da0db8abe962c61fff448") 62 | ] 63 | 64 | let hs256Signatures = [ 65 | HMACSignature(.sha256, "secret", "4869205468657265", "891972b1433ed6038585b2af44c757398e050d411ffcde118f271b5d2b637168"), 66 | HMACSignature(.sha256, "secret", "7768617420646f2079612077616e7420666f72206e6f7468696e673f", "ae974fb8f1d2f09aab9bcb0354946ace98a2976bd7204c43c0844ddbeae11977"), 67 | HMACSignature(.sha256, "secret", "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd", "245b32c433a7fbf112a7e1b61ad6caa8f53df23698f094a7c966c81a597c1653"), 68 | HMACSignature(.sha256, "secret", "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd", "74d02e25f0c3e0b5db5f8e720ae9905dac00e76e3d1b67e138a609efb4750817"), 69 | HMACSignature(.sha256, "secret", "546573742057697468205472756e636174696f6e", "b957fb9adee927335cd732e97ac3d74788ad62e642f2efc324856461667d4048"), 70 | HMACSignature(.sha256, "secret", "54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374", "ea5ae39f48fef23342b288e26305d4e359f961c741a85a2f5cdd9ebe02db5e3f") 71 | ] 72 | 73 | let hs384Signatures = [ 74 | HMACSignature(.sha384, "secret", "4869205468657265", "4f8435f1cfe3fe1342ea0961e1cf3fda4b2e061d16b69216f717e321fd2981298986e7f3ecfd178833f4500cfbcdb56d"), 75 | HMACSignature(.sha384, "secret", "7768617420646f2079612077616e7420666f72206e6f7468696e673f", "a149f16c4e2ba0eda01cfce43998b2ee71424ae6d1bc6e73fa63738c5faf2a196793379af11e2979b1e1994a1f8aa5b1"), 76 | HMACSignature(.sha384, "secret", "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd", "e54431ad21df0e8c28a080c334c158e826ba1e09746ed2eebfb9727418cf3f65f9758aaba33835b4fc9e75f3e50054bb"), 77 | HMACSignature(.sha384, "secret", "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd", "3045f925ade5f4abf40e93280bbc13e6b4a6e4a05d37594632d93abfbcca1d1f2dc9a309d6852515afdd96911acd5eb1"), 78 | HMACSignature(.sha384, "secret", "546573742057697468205472756e636174696f6e", "4919ab0d79a9a646bf8ef57bb015ee3173a332157dbcd4ccbad3d77bdf846937f8cf9f55506b6579e0f8465a37ad16cd"), 79 | HMACSignature(.sha384, "secret", "54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374", "a35407dab3248ab81f7451f9675e8b55af2de0c41f77634865b07ef0dbbdd10c018426aaa883b00c69868db802b58653") 80 | ] 81 | 82 | let hs512Signatures = [ 83 | HMACSignature(.sha512, "secret", "4869205468657265", "278dcfbdedead24e23633f1f7057dffbaf6ee8c706a4da19a6028c90ccf28708cdb3cbd224e4d12bbcb0a44a615622938509a20f8b3e4963cec715a211957b81"), 84 | HMACSignature(.sha512, "secret", "7768617420646f2079612077616e7420666f72206e6f7468696e673f", "f7047c2e9e2afb00865108fa062e9605b97e7a40652d3660624dd88acb2f5cb12daebdfc19c1472993fce4d3752a3b3dbd0e07c7c37bfcdbdc777d166c705a88"), 85 | HMACSignature(.sha512, "secret", "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd", "1e99362a14801505715619e10260ad124d36cff093dba67fb026e12a5f032707df9991db219d0d63e18f89df21bceac0bba085b521ec792fac38a9063c96d1cd"), 86 | HMACSignature(.sha512, "secret", "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd", "03960e8605dd3356546e39f5484d9907e4f9eb3d4a43135fd88ff4704f913a97f7f83e5fbd41d7facd1362c91daea26baa9e9e3f8175f4ef11f880e3a3bf4c0e"), 87 | HMACSignature(.sha512, "secret", "546573742057697468205472756e636174696f6e", "b97610d8d1df4093fcca0e3387d6ac553c6dd845ae8cd51e916b7a2087f02628ef66c4a6fbc9685b8445934eb9f567c35532b615e71f82779e1e19d89bfb99d5"), 88 | HMACSignature(.sha512, "secret", "54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374", "534ab2f3ac9fdfe41ca6c761c87def5dcd8e8aa6f14a676909014092ae3bf4fa0f36bedebe0842f52e89b29686822c577742d6873b5b551c86d960685a2bf2bf") 89 | ] 90 | 91 | let hrmd160Signatures = [ 92 | HMACSignature(.ripeMd160, "secret", "4869205468657265", "652483494188b83c0cf114c9ad78a732de26a220"), 93 | HMACSignature(.ripeMd160, "secret", "7768617420646f2079612077616e7420666f72206e6f7468696e673f", "23e73b856e4804300b1fbd40587d97ca36dfcbfb"), 94 | HMACSignature(.ripeMd160, "secret", "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd", "a356873991ac57e844bed4484b14469c744321d4"), 95 | HMACSignature(.ripeMd160, "secret", "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd", "b337e700692ca6dda4434db54e67a2ea65c03458"), 96 | HMACSignature(.ripeMd160, "secret", "546573742057697468205472756e636174696f6e", "e7183d8738b7ee472ce7817ebc9e3a2fa94ce707"), 97 | HMACSignature(.ripeMd160, "secret", "54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374", "ce9268e72624ae8f04408b12249f40aa33e795f8") 98 | ] 99 | 100 | // MARK: - Fake HMAC Signatures 101 | 102 | let hmd4FakeSignatures = [ 103 | HMACSignature(.md4, "secret", "4869205468657265", "aa52213133eae9ae2adb86f01d79b099"), 104 | HMACSignature(.md4, "secret", "7768617420646f2079612077616e7420666f72206e6f7468696e673f", "896d9c033fcb197f1bd1993f716eea92"), 105 | HMACSignature(.md4, "secret", "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd", "87b258f40db19d2059736988801f7dd1"), 106 | HMACSignature(.md4, "secret", "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd", "5a06db78c30ed795057541289e87eb1b"), 107 | HMACSignature(.md4, "secret", "546573742057697468205472756e636174696f6e", "c2284a36b025d3dec59b32552b32a373"), 108 | HMACSignature(.md4, "secret", "54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374", "73847ea99388a189f50c") 109 | ] 110 | 111 | let hmd5FakeSignatures = [ 112 | HMACSignature(.md5, "secret", "4869205468657265", "1f337b759bb8c23e9f9ef1d28f6ac823"), 113 | HMACSignature(.md5, "secret", "7768617420646f2079612077616e7420666f72206e6f7468696e673f", "8d5b74cac41c45a0f22b7a353bdb27b8"), 114 | HMACSignature(.md5, "secret", "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd", "3bd09138f1c959fc9a85040f2613aa9d"), 115 | HMACSignature(.md5, "secret", "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd", "09a0fa300a224deaf01d6d9da640d189"), 116 | HMACSignature(.md5, "secret", "546573742057697468205472756e636174696f6e", "2443afbf1bcb5c01563365e447fa1eaa"), 117 | HMACSignature(.md5, "secret", "54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374", "731738a059b10280101f") 118 | ] 119 | 120 | let hs1FakeSignatures = [ 121 | HMACSignature(.sha1, "secret", "4869205468657265", "dd3c907046caa39e26428dd00afd66e7ba758fd1"), 122 | HMACSignature(.sha1, "secret", "7768617420646f2079612077616e7420666f72206e6f7468696e673f", "e65afa52fc891d188ded82a4a35ebe3cd04be9bd"), 123 | HMACSignature(.sha1, "secret", "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd", "6b9f8180b03d020da32941c757d9683cf1b43c1a"), 124 | HMACSignature(.sha1, "secret", "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd", "b86c2818df18264ce27b33fb621647ec8f2271b0"), 125 | HMACSignature(.sha1, "secret", "546573742057697468205472756e636174696f6e", "64ee7f075ce9a063c863391b343c6512ba25a274"), 126 | HMACSignature(.sha1, "secret", "54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374", "582bc4f80aad33f9a77537") 127 | ] 128 | 129 | let hs224FakeSignatures = [ 130 | HMACSignature(.sha224, "secret", "4869205468657265", "0109f3443e9dbdcd9b3c588ce3a284bd72a17ab9d01771a6aa901306"), 131 | HMACSignature(.sha224, "secret", "7768617420646f2079612077616e7420666f72206e6f7468696e673f", "c514a97333c41c9f76ba475560fe46d3a02665c560632cd7ba7ed11b"), 132 | HMACSignature(.sha224, "secret", "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd", "82f9b92da6cd4d349bfb6513fd8b211bcfc7c204d2682d8f6a60c729"), 133 | HMACSignature(.sha224, "secret", "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd", "4354aaf1c7ddd3a2691da13b9239e9679aef6ca319df810c34da527b"), 134 | HMACSignature(.sha224, "secret", "546573742057697468205472756e636174696f6e", "338931e05590f1143a6c80e3ac21e691e55e2932961ec930175d88d6"), 135 | HMACSignature(.sha224, "secret", "54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374", "ef373b77b376814ef97f2da0db8abe962c61fff449") 136 | ] 137 | 138 | let hs256FakeSignatures = [ 139 | HMACSignature(.sha256, "secret", "4869205468657265", "891972b1433ed6038585b2af44c757398e050d411ffcde118f271b5d2b637169"), 140 | HMACSignature(.sha256, "secret", "7768617420646f2079612077616e7420666f72206e6f7468696e673f", "ae974fb8f1d2f09aab9bcb0354946ace98a2976bd7204c43c0844ddbeae11978"), 141 | HMACSignature(.sha256, "secret", "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd", "245b32c433a7fbf112a7e1b61ad6caa8f53df23698f094a7c966c81a597c1654"), 142 | HMACSignature(.sha256, "secret", "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd", "74d02e25f0c3e0b5db5f8e720ae9905dac00e76e3d1b67e138a609efb4750818"), 143 | HMACSignature(.sha256, "secret", "546573742057697468205472756e636174696f6e", "b957fb9adee927335cd732e97ac3d74788ad62e642f2efc324856461667d4049"), 144 | HMACSignature(.sha256, "secret", "54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374", "ea5a26305d4e359f961c741a85a2f5cdd9ebe02db5e30") 145 | ] 146 | 147 | let hs384FakeSignatures = [ 148 | HMACSignature(.sha384, "secret", "4869205468657265", "4f8435f1cfe3fe1342ea0961e1cf3fda4b2e061d16b69216f717e321fd2981298986e7f3ecfd178833f4500cfbcdb56e"), 149 | HMACSignature(.sha384, "secret", "7768617420646f2079612077616e7420666f72206e6f7468696e673f", "a149f16c4e2ba0eda01cfce43998b2ee71424ae6d1bc6e73fa63738c5faf2a196793379af11e2979b1e1994a1f8aa5b2"), 150 | HMACSignature(.sha384, "secret", "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd", "e54431ad21df0e8c28a080c334c158e826ba1e09746ed2eebfb9727418cf3f65f9758aaba33835b4fc9e75f3e50054bc"), 151 | HMACSignature(.sha384, "secret", "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd", "3045f925ade5f4abf40e93280bbc13e6b4a6e4a05d37594632d93abfbcca1d1f2dc9a309d6852515afdd96911acd5eb2"), 152 | HMACSignature(.sha384, "secret", "546573742057697468205472756e636174696f6e", "4919ab0d79a9a646bf8ef57bb015ee3173a332157dbcd4ccbad3d77bdf846937f8cf9f55506b6579e0f8465a37ad16ce"), 153 | HMACSignature(.sha384, "secret", "54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374", "a35407dab3248ab81f7451f9675e8b55af2de0c8426aaa883b00c69868db802b58654") 154 | ] 155 | 156 | let hs512FakeSignatures = [ 157 | HMACSignature(.sha512, "secret", "4869205468657265", "278dcfbdedead24e23633f1f7057dffbaf6ee8c706a4da19a6028c90ccf28708cdb3cbd224e4d12bbcb0a44a615622938509a20f8b3e4963cec715a211957b82"), 158 | HMACSignature(.sha512, "secret", "7768617420646f2079612077616e7420666f72206e6f7468696e673f", "f7047c2e9e2afb00865108fa062e9605b97e7a40652d3660624dd88acb2f5cb12daebdfc19c1472993fce4d3752a3b3dbd0e07c7c37bfcdbdc777d166c705a89"), 159 | HMACSignature(.sha512, "secret", "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd", "1e99362a14801505715619e10260ad124d36cff093dba67fb026e12a5f032707df9991db219d0d63e18f89df21bceac0bba085b521ec792fac38a9063c96d1ce"), 160 | HMACSignature(.sha512, "secret", "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd", "03960e8605dd3356546e39f5484d9907e4f9eb3d4a43135fd88ff4704f913a97f7f83e5fbd41d7facd1362c91daea26baa9e9e3f8175f4ef11f880e3a3bf4c0f"), 161 | HMACSignature(.sha512, "secret", "546573742057697468205472756e636174696f6e", "b97610d8d1df4093fcca0e3387d6ac553c6dd845ae8cd51e916b7a2087f02628ef66c4a6fbc9685b8445934eb9f567c35532b615e71f82779e1e19d89bfb99d6"), 162 | HMACSignature(.sha512, "secret", "54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374", "534ab2f3ac9fdfe41ca09014092ae3bf4fa0f36bedebe0842f52e89b29686822c577742d6873b5b551c86d960685a2bf2b0") 163 | ] 164 | 165 | let hrmd160FakeSignatures = [ 166 | HMACSignature(.ripeMd160, "secret", "4869205468657265", "652483494188b83c0cf114c9ad78a732de26a221"), 167 | HMACSignature(.ripeMd160, "secret", "7768617420646f2079612077616e7420666f72206e6f7468696e673f", "23e73b856e4804300b1fbd40587d97ca36dfcbfc"), 168 | HMACSignature(.ripeMd160, "secret", "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd", "a356873991ac57e844bed4484b14469c744321d5"), 169 | HMACSignature(.ripeMd160, "secret", "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd", "b337e700692ca6dda4434db54e67a2ea65c03459"), 170 | HMACSignature(.ripeMd160, "secret", "546573742057697468205472756e636174696f6e", "e7183d8738b7ee472ce7817ebc9e3a2fa94ce708"), 171 | HMACSignature(.ripeMd160, "secret", "54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374", "ce9268e72624aea33e795f9") 172 | ] 173 | -------------------------------------------------------------------------------- /Tests/ServerCryptoTests/Signature/ECDSA/ECDSASignatures.swift: -------------------------------------------------------------------------------- 1 | /** 2 | * ServerCrypto 3 | * Copyright (c) 2017 Alexis Aubry. Licensed under the MIT license. 4 | */ 5 | 6 | import Foundation 7 | import Hash 8 | import Signature 9 | 10 | struct ECDSASignature: AsymmetricSignature { 11 | 12 | let hasher: Hasher 13 | let privateKeyName: String 14 | let publicKeyName: String 15 | let privateKeyPassphrase: String? 16 | let message: String 17 | let validSignature: String 18 | 19 | init(_ hasher: Hasher, _ privateKeyName: String, _ publicKeyName: String, _ privateKeyPassphrase: String?, _ message: String, _ validSignature: String) { 20 | self.hasher = hasher 21 | self.privateKeyName = privateKeyName 22 | self.publicKeyName = publicKeyName 23 | self.privateKeyPassphrase = privateKeyPassphrase 24 | self.message = message 25 | self.validSignature = validSignature 26 | } 27 | 28 | } 29 | 30 | // MARK: - P-256 Signatures 31 | 32 | let ecdsaP256withSHA1Signatures = [ 33 | ECDSASignature(.sha1, "ecdsa_p256_private", "ecdsa_p256_public", nil, "Signature", "30440220142d2bf02bc162e09f9afe050cd4ab7b6d0c65d3976837d36d2c27524839e1bd0220787279af8e5b67f5760a118bd4ad7f0b5dc82798eb775a26fb1ac13c16b087ea"), 34 | ECDSASignature(.sha1, "ecdsa_p256_private_secure", "ecdsa_p256_public", "secret", "Signature", "30440220142d2bf02bc162e09f9afe050cd4ab7b6d0c65d3976837d36d2c27524839e1bd0220787279af8e5b67f5760a118bd4ad7f0b5dc82798eb775a26fb1ac13c16b087ea") 35 | ] 36 | 37 | let ecdsaP256withSHA224Signatures = [ 38 | ECDSASignature(.sha224, "ecdsa_p256_private", "ecdsa_p256_public", nil, "Signature", "304402203a35f5dbf44d9483390350743666e76719b60c6afbeaa59230c2aaadf0cc0c2b022037f0d41dcf3f6df4074856bd96010791e264a27f397809eb14ac734b0ab34325"), 39 | ECDSASignature(.sha224, "ecdsa_p256_private_secure", "ecdsa_p256_public", "secret", "Signature", "304402203a35f5dbf44d9483390350743666e76719b60c6afbeaa59230c2aaadf0cc0c2b022037f0d41dcf3f6df4074856bd96010791e264a27f397809eb14ac734b0ab34325") 40 | ] 41 | 42 | let ecdsaP256withSHA256Signatures = [ 43 | ECDSASignature(.sha256, "ecdsa_p256_private", "ecdsa_p256_public", nil, "Signature", "30440220696492055ba3dff587079215060159936836885f4b581992fe2f7442ff4aedd402201e5120aa9750715da8171f59ee7ada254c479fca2ac181cf3d34ec9902afcea6"), 44 | ECDSASignature(.sha256, "ecdsa_p256_private_secure", "ecdsa_p256_public", "secret", "Signature", "30440220696492055ba3dff587079215060159936836885f4b581992fe2f7442ff4aedd402201e5120aa9750715da8171f59ee7ada254c479fca2ac181cf3d34ec9902afcea6") 45 | ] 46 | 47 | let ecdsaP256withSHA384Signatures = [ 48 | ECDSASignature(.sha384, "ecdsa_p256_private", "ecdsa_p256_public", nil, "Signature", "3045022100b0f9d2af16e8de339a868c7e09c27885d265ffaa112fb59c6ed19c4dd90edd7102204955fa0cccdce5ab6736f7d35c768b8fb405a1f156d2545342480619da5ca5dd"), 49 | ECDSASignature(.sha384, "ecdsa_p256_private_secure", "ecdsa_p256_public", "secret", "Signature", "3045022100b0f9d2af16e8de339a868c7e09c27885d265ffaa112fb59c6ed19c4dd90edd7102204955fa0cccdce5ab6736f7d35c768b8fb405a1f156d2545342480619da5ca5dd") 50 | ] 51 | 52 | let ecdsaP256withSHA512Signatures = [ 53 | ECDSASignature(.sha512, "ecdsa_p256_private", "ecdsa_p256_public", nil, "Signature", "304602210088a32c22c712d2840e19548f3e4807c4ef2329c51bd2c3581f2586c6734df8d8022100c47c083a771d2696a7e5c94740eb7f5a4f7c0f9a0f8dde55dc9ae846a74de50e"), 54 | ECDSASignature(.sha512, "ecdsa_p256_private_secure", "ecdsa_p256_public", "secret", "Signature", "304602210088a32c22c712d2840e19548f3e4807c4ef2329c51bd2c3581f2586c6734df8d8022100c47c083a771d2696a7e5c94740eb7f5a4f7c0f9a0f8dde55dc9ae846a74de50e") 55 | ] 56 | 57 | // MARK: - P-256 Fake Signatures 58 | 59 | let ecdsaFakeP256withSHA1Signatures = [ 60 | ECDSASignature(.sha1, "ecdsa_p256_private", "ecdsa_p256_public", nil, "Signature", "40440220142d2bf02bc162e09f9afe050cd4ab7b6d0c65d3976837d36d2c27524839e1bd0220787279af8e5b67f5760a118bd4ad7f0b5dc82798eb775a26fb1ac13c16b087ea"), 61 | ECDSASignature(.sha1, "ecdsa_p256_private_secure", "ecdsa_p256_public", "secret", "Signature", "40440220142d2bf02bc162e09f9afe050cd4ab7b6d0c65d3976837d36d2c27524839e1bd0220787279af8e5b67f5760a118bd4ad7f0b5dc82798eb775a26fb1ac13c16b087ea") 62 | ] 63 | 64 | let ecdsaFakeP256withSHA224Signatures = [ 65 | ECDSASignature(.sha224, "ecdsa_p256_private", "ecdsa_p256_public", nil, "Signature", "404402203a35f5dbf44d9483390350743666e76719b60c6afbeaa59230c2aaadf0cc0c2b022037f0d41dcf3f6df4074856bd96010791e264a27f397809eb14ac734b0ab34325"), 66 | ECDSASignature(.sha224, "ecdsa_p256_private_secure", "ecdsa_p256_public", "secret", "Signature", "404402203a35f5dbf44d9483390350743666e76719b60c6afbeaa59230c2aaadf0cc0c2b022037f0d41dcf3f6df4074856bd96010791e264a27f397809eb14ac734b0ab34325") 67 | ] 68 | 69 | let ecdsaFakeP256withSHA256Signatures = [ 70 | ECDSASignature(.sha256, "ecdsa_p256_private", "ecdsa_p256_public", nil, "Signature", "40440220696492055ba3dff587079215060159936836885f4b581992fe2f7442ff4aedd402201e5120aa9750715da8171f59ee7ada254c479fca2ac181cf3d34ec9902afcea6"), 71 | ECDSASignature(.sha256, "ecdsa_p256_private_secure", "ecdsa_p256_public", "secret", "Signature", "40440220696492055ba3dff587079215060159936836885f4b581992fe2f7442ff4aedd402201e5120aa9750715da8171f59ee7ada254c479fca2ac181cf3d34ec9902afcea6") 72 | ] 73 | 74 | let ecdsaFakeP256withSHA384Signatures = [ 75 | ECDSASignature(.sha384, "ecdsa_p256_private", "ecdsa_p256_public", nil, "Signature", "4045022100b0f9d2af16e8de339a868c7e09c27885d265ffaa112fb59c6ed19c4dd90edd7102204955fa0cccdce5ab6736f7d35c768b8fb405a1f156d2545342480619da5ca5dd"), 76 | ECDSASignature(.sha384, "ecdsa_p256_private_secure", "ecdsa_p256_public", "secret", "Signature", "4045022100b0f9d2af16e8de339a868c7e09c27885d265ffaa112fb59c6ed19c4dd90edd7102204955fa0cccdce5ab6736f7d35c768b8fb405a1f156d2545342480619da5ca5dd") 77 | ] 78 | 79 | let ecdsaFakeP256withSHA512Signatures = [ 80 | ECDSASignature(.sha512, "ecdsa_p256_private", "ecdsa_p256_public", nil, "Signature", "404602210088a32c22c712d2840e19548f3e4807c4ef2329c51bd2c3581f2586c6734df8d8022100c47c083a771d2696a7e5c94740eb7f5a4f7c0f9a0f8dde55dc9ae846a74de50e"), 81 | ECDSASignature(.sha512, "ecdsa_p256_private_secure", "ecdsa_p256_public", "secret", "Signature", "404602210088a32c22c712d2840e19548f3e4807c4ef2329c51bd2c3581f2586c6734df8d8022100c47c083a771d2696a7e5c94740eb7f5a4f7c0f9a0f8dde55dc9ae846a74de50e") 82 | ] 83 | 84 | // MARK: - SECP256K1 Signatures 85 | 86 | let ecdsaSECP256K1withSHA1Signatures = [ 87 | ECDSASignature(.sha1, "ecdsa_p256k1_private", "ecdsa_p256k1_public", nil, "Signature", "30440220223af119d5501f5b8ab3f6f5af7d771975cbe6abc191f23d58fae8e26d87d0530220587d078ab8d92282bccf59dcdee45417353c229755c56cc9fa0e596d4c3d6ba0"), 88 | ECDSASignature(.sha1, "ecdsa_p256k1_private_secure", "ecdsa_p256k1_public", "secret", "Signature", "30440220223af119d5501f5b8ab3f6f5af7d771975cbe6abc191f23d58fae8e26d87d0530220587d078ab8d92282bccf59dcdee45417353c229755c56cc9fa0e596d4c3d6ba0") 89 | ] 90 | 91 | let ecdsaSECP256K1withSHA224Signatures = [ 92 | ECDSASignature(.sha224, "ecdsa_p256k1_private", "ecdsa_p256k1_public", nil, "Signature", "304502204820c26d0e8241ac9a0387a4c31c5f17239cb3e0417c34f6be76355c53137a4a022100abecf3e33f6fee4650c491f9c295351382f95ecaec01b9b73505711af03d3e1b"), 93 | ECDSASignature(.sha224, "ecdsa_p256k1_private_secure", "ecdsa_p256k1_public", "secret", "Signature", "304502204820c26d0e8241ac9a0387a4c31c5f17239cb3e0417c34f6be76355c53137a4a022100abecf3e33f6fee4650c491f9c295351382f95ecaec01b9b73505711af03d3e1b") 94 | ] 95 | 96 | let ecdsaSECP256K1withSHA256Signatures = [ 97 | ECDSASignature(.sha256, "ecdsa_p256k1_private", "ecdsa_p256k1_public", nil, "Signature", "304502200fc7b74e34192a018649422ef4ea7663ee195ae2f104bf02cecaafc5c1d43a1d0221009ab13bb52d2f980a9eab42033f246e1495236898d613e484e81671578ad58bad"), 98 | ECDSASignature(.sha256, "ecdsa_p256k1_private_secure", "ecdsa_p256k1_public", "secret", "Signature", "304502200fc7b74e34192a018649422ef4ea7663ee195ae2f104bf02cecaafc5c1d43a1d0221009ab13bb52d2f980a9eab42033f246e1495236898d613e484e81671578ad58bad") 99 | ] 100 | 101 | let ecdsaSECP256K1withSHA384Signatures = [ 102 | ECDSASignature(.sha384, "ecdsa_p256k1_private", "ecdsa_p256k1_public", nil, "Signature", "304402207b0d6dc6a1aa3bd9ec28dca80fcb265fb8bb92c4dc58f1892e0cab3dfd8e4fd0022056a280b4e8c3c1940a88048ba10cb693ec99d057a88e9365f1ab0b675d7706f5"), 103 | ECDSASignature(.sha384, "ecdsa_p256k1_private_secure", "ecdsa_p256k1_public", "secret", "Signature", "304402207b0d6dc6a1aa3bd9ec28dca80fcb265fb8bb92c4dc58f1892e0cab3dfd8e4fd0022056a280b4e8c3c1940a88048ba10cb693ec99d057a88e9365f1ab0b675d7706f5") 104 | ] 105 | 106 | let ecdsaSECP256K1withSHA512Signatures = [ 107 | ECDSASignature(.sha512, "ecdsa_p256k1_private", "ecdsa_p256k1_public", nil, "Signature", "3044022000f851e1d80ce3820f6dfa2895f1c759fa12dbac3f6386cb409043c3bc4b3fd202206d3d300404c7af7ac5fb30576dc65997af24a0adb4f40da60d762362c747c67b"), 108 | ECDSASignature(.sha512, "ecdsa_p256k1_private_secure", "ecdsa_p256k1_public", "secret", "Signature", "3044022000f851e1d80ce3820f6dfa2895f1c759fa12dbac3f6386cb409043c3bc4b3fd202206d3d300404c7af7ac5fb30576dc65997af24a0adb4f40da60d762362c747c67b") 109 | ] 110 | 111 | // MARK: - SECP256K1 Fake Signatures 112 | 113 | let ecdsaFakeSECP256K1withSHA1Signatures = [ 114 | ECDSASignature(.sha1, "ecdsa_p256k1_private", "ecdsa_p256k1_public", nil, "Signature", "40440220223af119d5501f5b8ab3f6f5af7d771975cbe6abc191f23d58fae8e26d87d0530220587d078ab8d92282bccf59dcdee45417353c229755c56cc9fa0e596d4c3d6ba0"), 115 | ECDSASignature(.sha1, "ecdsa_p256k1_private_secure", "ecdsa_p256k1_public", "secret", "Signature", "40440220223af119d5501f5b8ab3f6f5af7d771975cbe6abc191f23d58fae8e26d87d0530220587d078ab8d92282bccf59dcdee45417353c229755c56cc9fa0e596d4c3d6ba0") 116 | ] 117 | 118 | let ecdsaFakeSECP256K1withSHA224Signatures = [ 119 | ECDSASignature(.sha224, "ecdsa_p256k1_private", "ecdsa_p256k1_public", nil, "Signature", "404502204820c26d0e8241ac9a0387a4c31c5f17239cb3e0417c34f6be76355c53137a4a022100abecf3e33f6fee4650c491f9c295351382f95ecaec01b9b73505711af03d3e1b"), 120 | ECDSASignature(.sha224, "ecdsa_p256k1_private_secure", "ecdsa_p256k1_public", "secret", "Signature", "404502204820c26d0e8241ac9a0387a4c31c5f17239cb3e0417c34f6be76355c53137a4a022100abecf3e33f6fee4650c491f9c295351382f95ecaec01b9b73505711af03d3e1b") 121 | ] 122 | 123 | let ecdsaFakeSECP256K1withSHA256Signatures = [ 124 | ECDSASignature(.sha256, "ecdsa_p256k1_private", "ecdsa_p256k1_public", nil, "Signature", "404502200fc7b74e34192a018649422ef4ea7663ee195ae2f104bf02cecaafc5c1d43a1d0221009ab13bb52d2f980a9eab42033f246e1495236898d613e484e81671578ad58bad"), 125 | ECDSASignature(.sha256, "ecdsa_p256k1_private_secure", "ecdsa_p256k1_public", "secret", "Signature", "404502200fc7b74e34192a018649422ef4ea7663ee195ae2f104bf02cecaafc5c1d43a1d0221009ab13bb52d2f980a9eab42033f246e1495236898d613e484e81671578ad58bad") 126 | ] 127 | 128 | let ecdsaFakeSECP256K1withSHA384Signatures = [ 129 | ECDSASignature(.sha384, "ecdsa_p256k1_private", "ecdsa_p256k1_public", nil, "Signature", "404402207b0d6dc6a1aa3bd9ec28dca80fcb265fb8bb92c4dc58f1892e0cab3dfd8e4fd0022056a280b4e8c3c1940a88048ba10cb693ec99d057a88e9365f1ab0b675d7706f5"), 130 | ECDSASignature(.sha384, "ecdsa_p256k1_private_secure", "ecdsa_p256k1_public", "secret", "Signature", "404402207b0d6dc6a1aa3bd9ec28dca80fcb265fb8bb92c4dc58f1892e0cab3dfd8e4fd0022056a280b4e8c3c1940a88048ba10cb693ec99d057a88e9365f1ab0b675d7706f5") 131 | ] 132 | 133 | let ecdsaFakeSECP256K1withSHA512Signatures = [ 134 | ECDSASignature(.sha512, "ecdsa_p256k1_private", "ecdsa_p256k1_public", nil, "Signature", "4044022000f851e1d80ce3820f6dfa2895f1c759fa12dbac3f6386cb409043c3bc4b3fd202206d3d300404c7af7ac5fb30576dc65997af24a0adb4f40da60d762362c747c67b"), 135 | ECDSASignature(.sha512, "ecdsa_p256k1_private_secure", "ecdsa_p256k1_public", "secret", "Signature", "4044022000f851e1d80ce3820f6dfa2895f1c759fa12dbac3f6386cb409043c3bc4b3fd202206d3d300404c7af7ac5fb30576dc65997af24a0adb4f40da60d762362c747c67b") 136 | ] 137 | 138 | // MARK: - P-384 Signatures 139 | 140 | let ecdsaP384withSHA1Signatures = [ 141 | ECDSASignature(.sha1, "ecdsa_p384_private", "ecdsa_p384_public", nil, "Signature", "30660231009a7b01956f59e56de1ec906b2b6e05871fac65fb3a5084cca973f8378f010f15ae3b36026eb7f71e1a1d3c87c5a33f69023100e8a6564376e4a614cb3a9df5fa26725a1cd53052fe3be91a000e23f7e5d0775b73463a5b7334b078b069e5775ed39a13"), 142 | ECDSASignature(.sha1, "ecdsa_p384_private_secure", "ecdsa_p384_public", "secret", "Signature", "30660231009a7b01956f59e56de1ec906b2b6e05871fac65fb3a5084cca973f8378f010f15ae3b36026eb7f71e1a1d3c87c5a33f69023100e8a6564376e4a614cb3a9df5fa26725a1cd53052fe3be91a000e23f7e5d0775b73463a5b7334b078b069e5775ed39a13") 143 | ] 144 | 145 | let ecdsaP384withSHA224Signatures = [ 146 | ECDSASignature(.sha224, "ecdsa_p384_private", "ecdsa_p384_public", nil, "Signature", "306402300d6a2f3636989a489b4d89b21f314d86620e4db7a0938512439a5e51d91a48d9512fda486d11d29ed8cd526a8f4cb8b5023071d271b4b74285809bb134aea6bf904d72013acd094a0dadb7d8db687a3b1abe045f571cbebe0793c1991c57334fb51d"), 147 | ECDSASignature(.sha224, "ecdsa_p384_private_secure", "ecdsa_p384_public", "secret", "Signature", "306402300d6a2f3636989a489b4d89b21f314d86620e4db7a0938512439a5e51d91a48d9512fda486d11d29ed8cd526a8f4cb8b5023071d271b4b74285809bb134aea6bf904d72013acd094a0dadb7d8db687a3b1abe045f571cbebe0793c1991c57334fb51d") 148 | ] 149 | 150 | let ecdsaP384withSHA256Signatures = [ 151 | ECDSASignature(.sha256, "ecdsa_p384_private", "ecdsa_p384_public", nil, "Signature", "306502302e599b6bdf333b5eaa8e8edebfd476bb279bdd573f551c8db48b15a4734d865d1d9a9a15fbf3af67ce9034d6208efbf9023100fd02c1312797d5181fbe78da5da71172b8e6f395a5c67934c4a242077969982e0de7244836444b289b56a13e963b0282"), 152 | ECDSASignature(.sha256, "ecdsa_p384_private_secure", "ecdsa_p384_public", "secret", "Signature", "306502302e599b6bdf333b5eaa8e8edebfd476bb279bdd573f551c8db48b15a4734d865d1d9a9a15fbf3af67ce9034d6208efbf9023100fd02c1312797d5181fbe78da5da71172b8e6f395a5c67934c4a242077969982e0de7244836444b289b56a13e963b0282") 153 | ] 154 | 155 | let ecdsaP384withSHA384Signatures = [ 156 | ECDSASignature(.sha384, "ecdsa_p384_private", "ecdsa_p384_public", nil, "Signature", "3065023100e9c98f98173349ecebeebfab349fa1831bea133355dd06f1e62e02052d960ad78547210934cbd4897ac254ead80e323e02304add0ca8fa2a6fbd7021095c6da8acd84d1339c9e6d939df107514eb2786e0b0cd113380e4d99dfb36b6f5808401c1c6"), 157 | ECDSASignature(.sha384, "ecdsa_p384_private_secure", "ecdsa_p384_public", "secret", "Signature", "3065023100e9c98f98173349ecebeebfab349fa1831bea133355dd06f1e62e02052d960ad78547210934cbd4897ac254ead80e323e02304add0ca8fa2a6fbd7021095c6da8acd84d1339c9e6d939df107514eb2786e0b0cd113380e4d99dfb36b6f5808401c1c6") 158 | ] 159 | 160 | let ecdsaP384withSHA512Signatures = [ 161 | ECDSASignature(.sha512, "ecdsa_p384_private", "ecdsa_p384_public", nil, "Signature", "3065023053e18a3d2fcde03585522e7ede736b50b8ab38c91cc6779ffc4f5e386463e9c3df34b9a8634900442af309f5d7d65d1f023100a31f00e3fc50a9b1f869b8d9c82fa66305343dbffb15a5a44163a117c86d9f1eb3cb9971fb1264a56e3c215181ecc01f"), 162 | ECDSASignature(.sha512, "ecdsa_p384_private_secure", "ecdsa_p384_public", "secret", "Signature", "3065023053e18a3d2fcde03585522e7ede736b50b8ab38c91cc6779ffc4f5e386463e9c3df34b9a8634900442af309f5d7d65d1f023100a31f00e3fc50a9b1f869b8d9c82fa66305343dbffb15a5a44163a117c86d9f1eb3cb9971fb1264a56e3c215181ecc01f") 163 | ] 164 | 165 | // MARK: - P-384 Fake Signatures 166 | 167 | let ecdsaFakeP384withSHA1Signatures = [ 168 | ECDSASignature(.sha1, "ecdsa_p384_private", "ecdsa_p384_public", nil, "Signature", "40660231009a7b01956f59e56de1ec906b2b6e05871fac65fb3a5084cca973f8378f010f15ae3b36026eb7f71e1a1d3c87c5a33f69023100e8a6564376e4a614cb3a9df5fa26725a1cd53052fe3be91a000e23f7e5d0775b73463a5b7334b078b069e5775ed39a13"), 169 | ECDSASignature(.sha1, "ecdsa_p384_private_secure", "ecdsa_p384_public", "secret", "Signature", "40660231009a7b01956f59e56de1ec906b2b6e05871fac65fb3a5084cca973f8378f010f15ae3b36026eb7f71e1a1d3c87c5a33f69023100e8a6564376e4a614cb3a9df5fa26725a1cd53052fe3be91a000e23f7e5d0775b73463a5b7334b078b069e5775ed39a13") 170 | ] 171 | 172 | let ecdsaFakeP384withSHA224Signatures = [ 173 | ECDSASignature(.sha224, "ecdsa_p384_private", "ecdsa_p384_public", nil, "Signature", "406402300d6a2f3636989a489b4d89b21f314d86620e4db7a0938512439a5e51d91a48d9512fda486d11d29ed8cd526a8f4cb8b5023071d271b4b74285809bb134aea6bf904d72013acd094a0dadb7d8db687a3b1abe045f571cbebe0793c1991c57334fb51d"), 174 | ECDSASignature(.sha224, "ecdsa_p384_private_secure", "ecdsa_p384_public", "secret", "Signature", "406402300d6a2f3636989a489b4d89b21f314d86620e4db7a0938512439a5e51d91a48d9512fda486d11d29ed8cd526a8f4cb8b5023071d271b4b74285809bb134aea6bf904d72013acd094a0dadb7d8db687a3b1abe045f571cbebe0793c1991c57334fb51d") 175 | ] 176 | 177 | let ecdsaFakeP384withSHA256Signatures = [ 178 | ECDSASignature(.sha256, "ecdsa_p384_private", "ecdsa_p384_public", nil, "Signature", "406502302e599b6bdf333b5eaa8e8edebfd476bb279bdd573f551c8db48b15a4734d865d1d9a9a15fbf3af67ce9034d6208efbf9023100fd02c1312797d5181fbe78da5da71172b8e6f395a5c67934c4a242077969982e0de7244836444b289b56a13e963b0282"), 179 | ECDSASignature(.sha256, "ecdsa_p384_private_secure", "ecdsa_p384_public", "secret", "Signature", "406502302e599b6bdf333b5eaa8e8edebfd476bb279bdd573f551c8db48b15a4734d865d1d9a9a15fbf3af67ce9034d6208efbf9023100fd02c1312797d5181fbe78da5da71172b8e6f395a5c67934c4a242077969982e0de7244836444b289b56a13e963b0282") 180 | ] 181 | 182 | let ecdsaFakeP384withSHA384Signatures = [ 183 | ECDSASignature(.sha384, "ecdsa_p384_private", "ecdsa_p384_public", nil, "Signature", "4065023100e9c98f98173349ecebeebfab349fa1831bea133355dd06f1e62e02052d960ad78547210934cbd4897ac254ead80e323e02304add0ca8fa2a6fbd7021095c6da8acd84d1339c9e6d939df107514eb2786e0b0cd113380e4d99dfb36b6f5808401c1c6"), 184 | ECDSASignature(.sha384, "ecdsa_p384_private_secure", "ecdsa_p384_public", "secret", "Signature", "4065023100e9c98f98173349ecebeebfab349fa1831bea133355dd06f1e62e02052d960ad78547210934cbd4897ac254ead80e323e02304add0ca8fa2a6fbd7021095c6da8acd84d1339c9e6d939df107514eb2786e0b0cd113380e4d99dfb36b6f5808401c1c6") 185 | ] 186 | 187 | let ecdsaFakeP384withSHA512Signatures = [ 188 | ECDSASignature(.sha512, "ecdsa_p384_private", "ecdsa_p384_public", nil, "Signature", "4065023053e18a3d2fcde03585522e7ede736b50b8ab38c91cc6779ffc4f5e386463e9c3df34b9a8634900442af309f5d7d65d1f023100a31f00e3fc50a9b1f869b8d9c82fa66305343dbffb15a5a44163a117c86d9f1eb3cb9971fb1264a56e3c215181ecc01f"), 189 | ECDSASignature(.sha512, "ecdsa_p384_private_secure", "ecdsa_p384_public", "secret", "Signature", "4065023053e18a3d2fcde03585522e7ede736b50b8ab38c91cc6779ffc4f5e386463e9c3df34b9a8634900442af309f5d7d65d1f023100a31f00e3fc50a9b1f869b8d9c82fa66305343dbffb15a5a44163a117c86d9f1eb3cb9971fb1264a56e3c215181ecc01f") 190 | ] 191 | -------------------------------------------------------------------------------- /ServerCrypto.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXAggregateTarget section */ 10 | "ServerCrypto::ServerCryptoPackageTests::ProductTarget" /* ServerCryptoPackageTests */ = { 11 | isa = PBXAggregateTarget; 12 | buildConfigurationList = OBJ_111 /* Build configuration list for PBXAggregateTarget "ServerCryptoPackageTests" */; 13 | buildPhases = ( 14 | ); 15 | dependencies = ( 16 | OBJ_114 /* PBXTargetDependency */, 17 | ); 18 | name = ServerCryptoPackageTests; 19 | productName = ServerCryptoPackageTests; 20 | }; 21 | /* End PBXAggregateTarget section */ 22 | 23 | /* Begin PBXBuildFile section */ 24 | 55B463121F7996CF00D3F0AA /* TestFixtures in Resources */ = {isa = PBXBuildFile; fileRef = OBJ_40 /* TestFixtures */; }; 25 | OBJ_105 /* CryptoError.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_9 /* CryptoError.swift */; }; 26 | OBJ_106 /* CryptoProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_10 /* CryptoProvider.swift */; }; 27 | OBJ_107 /* Hex.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_11 /* Hex.swift */; }; 28 | OBJ_108 /* Protocols.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_12 /* Protocols.swift */; }; 29 | OBJ_52 /* Package.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_6 /* Package.swift */; }; 30 | OBJ_58 /* CryptoErrorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_24 /* CryptoErrorTests.swift */; }; 31 | OBJ_59 /* HexTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_25 /* HexTests.swift */; }; 32 | OBJ_60 /* HashTestData.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_27 /* HashTestData.swift */; }; 33 | OBJ_61 /* HashTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_28 /* HashTests.swift */; }; 34 | OBJ_62 /* ECDSASignatures.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_31 /* ECDSASignatures.swift */; }; 35 | OBJ_63 /* ECDSATests.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_32 /* ECDSATests.swift */; }; 36 | OBJ_64 /* HMACSignatures.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_34 /* HMACSignatures.swift */; }; 37 | OBJ_65 /* HMACTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_35 /* HMACTests.swift */; }; 38 | OBJ_66 /* RSATestVectors.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_37 /* RSATestVectors.swift */; }; 39 | OBJ_67 /* RSATests.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_38 /* RSATests.swift */; }; 40 | OBJ_68 /* SignatureTestsCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_39 /* SignatureTestsCoordinator.swift */; }; 41 | OBJ_70 /* Signature.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = "ServerCrypto::Signature::Product" /* Signature.framework */; }; 42 | OBJ_71 /* Hash.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = "ServerCrypto::Hash::Product" /* Hash.framework */; }; 43 | OBJ_72 /* CryptoSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = "ServerCrypto::CryptoSupport::Product" /* CryptoSupport.framework */; }; 44 | OBJ_83 /* AsymmetricKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_17 /* AsymmetricKey.swift */; }; 45 | OBJ_84 /* Exports.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_18 /* Exports.swift */; }; 46 | OBJ_85 /* HMACKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_19 /* HMACKey.swift */; }; 47 | OBJ_86 /* Signer.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_20 /* Signer.swift */; }; 48 | OBJ_88 /* Hash.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = "ServerCrypto::Hash::Product" /* Hash.framework */; }; 49 | OBJ_89 /* CryptoSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = "ServerCrypto::CryptoSupport::Product" /* CryptoSupport.framework */; }; 50 | OBJ_96 /* Exports.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_14 /* Exports.swift */; }; 51 | OBJ_97 /* Hasher.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_15 /* Hasher.swift */; }; 52 | OBJ_99 /* CryptoSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = "ServerCrypto::CryptoSupport::Product" /* CryptoSupport.framework */; }; 53 | /* End PBXBuildFile section */ 54 | 55 | /* Begin PBXContainerItemProxy section */ 56 | 55B4630A1F79965000D3F0AA /* PBXContainerItemProxy */ = { 57 | isa = PBXContainerItemProxy; 58 | containerPortal = OBJ_1 /* Project object */; 59 | proxyType = 1; 60 | remoteGlobalIDString = "ServerCrypto::CryptoSupport"; 61 | remoteInfo = CryptoSupport; 62 | }; 63 | 55B4630B1F79965000D3F0AA /* PBXContainerItemProxy */ = { 64 | isa = PBXContainerItemProxy; 65 | containerPortal = OBJ_1 /* Project object */; 66 | proxyType = 1; 67 | remoteGlobalIDString = "ServerCrypto::Hash"; 68 | remoteInfo = Hash; 69 | }; 70 | 55B4630C1F79965000D3F0AA /* PBXContainerItemProxy */ = { 71 | isa = PBXContainerItemProxy; 72 | containerPortal = OBJ_1 /* Project object */; 73 | proxyType = 1; 74 | remoteGlobalIDString = "ServerCrypto::CryptoSupport"; 75 | remoteInfo = CryptoSupport; 76 | }; 77 | 55B4630D1F79965000D3F0AA /* PBXContainerItemProxy */ = { 78 | isa = PBXContainerItemProxy; 79 | containerPortal = OBJ_1 /* Project object */; 80 | proxyType = 1; 81 | remoteGlobalIDString = "ServerCrypto::Signature"; 82 | remoteInfo = Signature; 83 | }; 84 | 55B4630E1F79965000D3F0AA /* PBXContainerItemProxy */ = { 85 | isa = PBXContainerItemProxy; 86 | containerPortal = OBJ_1 /* Project object */; 87 | proxyType = 1; 88 | remoteGlobalIDString = "ServerCrypto::Hash"; 89 | remoteInfo = Hash; 90 | }; 91 | 55B4630F1F79965000D3F0AA /* PBXContainerItemProxy */ = { 92 | isa = PBXContainerItemProxy; 93 | containerPortal = OBJ_1 /* Project object */; 94 | proxyType = 1; 95 | remoteGlobalIDString = "ServerCrypto::CryptoSupport"; 96 | remoteInfo = CryptoSupport; 97 | }; 98 | 55B463101F79965100D3F0AA /* PBXContainerItemProxy */ = { 99 | isa = PBXContainerItemProxy; 100 | containerPortal = OBJ_1 /* Project object */; 101 | proxyType = 1; 102 | remoteGlobalIDString = "ServerCrypto::ServerCryptoTests"; 103 | remoteInfo = ServerCryptoTests; 104 | }; 105 | /* End PBXContainerItemProxy section */ 106 | 107 | /* Begin PBXFileReference section */ 108 | OBJ_10 /* CryptoProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CryptoProvider.swift; sourceTree = ""; }; 109 | OBJ_11 /* Hex.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Hex.swift; sourceTree = ""; }; 110 | OBJ_12 /* Protocols.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Protocols.swift; sourceTree = ""; }; 111 | OBJ_14 /* Exports.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Exports.swift; sourceTree = ""; }; 112 | OBJ_15 /* Hasher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Hasher.swift; sourceTree = ""; }; 113 | OBJ_17 /* AsymmetricKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AsymmetricKey.swift; sourceTree = ""; }; 114 | OBJ_18 /* Exports.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Exports.swift; sourceTree = ""; }; 115 | OBJ_19 /* HMACKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMACKey.swift; sourceTree = ""; }; 116 | OBJ_20 /* Signer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Signer.swift; sourceTree = ""; }; 117 | OBJ_24 /* CryptoErrorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CryptoErrorTests.swift; sourceTree = ""; }; 118 | OBJ_25 /* HexTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HexTests.swift; sourceTree = ""; }; 119 | OBJ_27 /* HashTestData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HashTestData.swift; sourceTree = ""; }; 120 | OBJ_28 /* HashTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HashTests.swift; sourceTree = ""; }; 121 | OBJ_31 /* ECDSASignatures.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ECDSASignatures.swift; sourceTree = ""; }; 122 | OBJ_32 /* ECDSATests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ECDSATests.swift; sourceTree = ""; }; 123 | OBJ_34 /* HMACSignatures.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMACSignatures.swift; sourceTree = ""; }; 124 | OBJ_35 /* HMACTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HMACTests.swift; sourceTree = ""; }; 125 | OBJ_37 /* RSATestVectors.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RSATestVectors.swift; sourceTree = ""; }; 126 | OBJ_38 /* RSATests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RSATests.swift; sourceTree = ""; }; 127 | OBJ_39 /* SignatureTestsCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignatureTestsCoordinator.swift; sourceTree = ""; }; 128 | OBJ_40 /* TestFixtures */ = {isa = PBXFileReference; lastKnownFileType = folder; path = TestFixtures; sourceTree = SOURCE_ROOT; }; 129 | OBJ_6 /* Package.swift */ = {isa = PBXFileReference; explicitFileType = sourcecode.swift; path = Package.swift; sourceTree = ""; }; 130 | OBJ_9 /* CryptoError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CryptoError.swift; sourceTree = ""; }; 131 | "ServerCrypto::CryptoSupport::Product" /* CryptoSupport.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = CryptoSupport.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 132 | "ServerCrypto::Hash::Product" /* Hash.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Hash.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 133 | "ServerCrypto::ServerCryptoTests::Product" /* ServerCryptoTests.xctest */ = {isa = PBXFileReference; lastKnownFileType = file; path = ServerCryptoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 134 | "ServerCrypto::Signature::Product" /* Signature.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Signature.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 135 | /* End PBXFileReference section */ 136 | 137 | /* Begin PBXFrameworksBuildPhase section */ 138 | OBJ_109 /* Frameworks */ = { 139 | isa = PBXFrameworksBuildPhase; 140 | buildActionMask = 0; 141 | files = ( 142 | ); 143 | runOnlyForDeploymentPostprocessing = 0; 144 | }; 145 | OBJ_69 /* Frameworks */ = { 146 | isa = PBXFrameworksBuildPhase; 147 | buildActionMask = 0; 148 | files = ( 149 | OBJ_70 /* Signature.framework in Frameworks */, 150 | OBJ_71 /* Hash.framework in Frameworks */, 151 | OBJ_72 /* CryptoSupport.framework in Frameworks */, 152 | ); 153 | runOnlyForDeploymentPostprocessing = 0; 154 | }; 155 | OBJ_87 /* Frameworks */ = { 156 | isa = PBXFrameworksBuildPhase; 157 | buildActionMask = 0; 158 | files = ( 159 | OBJ_88 /* Hash.framework in Frameworks */, 160 | OBJ_89 /* CryptoSupport.framework in Frameworks */, 161 | ); 162 | runOnlyForDeploymentPostprocessing = 0; 163 | }; 164 | OBJ_98 /* Frameworks */ = { 165 | isa = PBXFrameworksBuildPhase; 166 | buildActionMask = 0; 167 | files = ( 168 | OBJ_99 /* CryptoSupport.framework in Frameworks */, 169 | ); 170 | runOnlyForDeploymentPostprocessing = 0; 171 | }; 172 | /* End PBXFrameworksBuildPhase section */ 173 | 174 | /* Begin PBXGroup section */ 175 | OBJ_13 /* Hash */ = { 176 | isa = PBXGroup; 177 | children = ( 178 | OBJ_14 /* Exports.swift */, 179 | OBJ_15 /* Hasher.swift */, 180 | ); 181 | name = Hash; 182 | path = Sources/Hash; 183 | sourceTree = SOURCE_ROOT; 184 | }; 185 | OBJ_16 /* Signature */ = { 186 | isa = PBXGroup; 187 | children = ( 188 | OBJ_17 /* AsymmetricKey.swift */, 189 | OBJ_18 /* Exports.swift */, 190 | OBJ_19 /* HMACKey.swift */, 191 | OBJ_20 /* Signer.swift */, 192 | ); 193 | name = Signature; 194 | path = Sources/Signature; 195 | sourceTree = SOURCE_ROOT; 196 | }; 197 | OBJ_21 /* Tests */ = { 198 | isa = PBXGroup; 199 | children = ( 200 | OBJ_22 /* ServerCryptoTests */, 201 | ); 202 | name = Tests; 203 | sourceTree = SOURCE_ROOT; 204 | }; 205 | OBJ_22 /* ServerCryptoTests */ = { 206 | isa = PBXGroup; 207 | children = ( 208 | OBJ_23 /* CryptoSupport */, 209 | OBJ_26 /* Hash */, 210 | OBJ_29 /* Signature */, 211 | ); 212 | name = ServerCryptoTests; 213 | path = Tests/ServerCryptoTests; 214 | sourceTree = SOURCE_ROOT; 215 | }; 216 | OBJ_23 /* CryptoSupport */ = { 217 | isa = PBXGroup; 218 | children = ( 219 | OBJ_24 /* CryptoErrorTests.swift */, 220 | OBJ_25 /* HexTests.swift */, 221 | ); 222 | path = CryptoSupport; 223 | sourceTree = ""; 224 | }; 225 | OBJ_26 /* Hash */ = { 226 | isa = PBXGroup; 227 | children = ( 228 | OBJ_27 /* HashTestData.swift */, 229 | OBJ_28 /* HashTests.swift */, 230 | ); 231 | path = Hash; 232 | sourceTree = ""; 233 | }; 234 | OBJ_29 /* Signature */ = { 235 | isa = PBXGroup; 236 | children = ( 237 | OBJ_30 /* ECDSA */, 238 | OBJ_33 /* HMAC */, 239 | OBJ_36 /* RSA */, 240 | OBJ_39 /* SignatureTestsCoordinator.swift */, 241 | ); 242 | path = Signature; 243 | sourceTree = ""; 244 | }; 245 | OBJ_30 /* ECDSA */ = { 246 | isa = PBXGroup; 247 | children = ( 248 | OBJ_31 /* ECDSASignatures.swift */, 249 | OBJ_32 /* ECDSATests.swift */, 250 | ); 251 | path = ECDSA; 252 | sourceTree = ""; 253 | }; 254 | OBJ_33 /* HMAC */ = { 255 | isa = PBXGroup; 256 | children = ( 257 | OBJ_34 /* HMACSignatures.swift */, 258 | OBJ_35 /* HMACTests.swift */, 259 | ); 260 | path = HMAC; 261 | sourceTree = ""; 262 | }; 263 | OBJ_36 /* RSA */ = { 264 | isa = PBXGroup; 265 | children = ( 266 | OBJ_37 /* RSATestVectors.swift */, 267 | OBJ_38 /* RSATests.swift */, 268 | ); 269 | path = RSA; 270 | sourceTree = ""; 271 | }; 272 | OBJ_41 /* Dependencies */ = { 273 | isa = PBXGroup; 274 | children = ( 275 | ); 276 | name = Dependencies; 277 | sourceTree = ""; 278 | }; 279 | OBJ_42 /* Products */ = { 280 | isa = PBXGroup; 281 | children = ( 282 | "ServerCrypto::ServerCryptoTests::Product" /* ServerCryptoTests.xctest */, 283 | "ServerCrypto::Signature::Product" /* Signature.framework */, 284 | "ServerCrypto::Hash::Product" /* Hash.framework */, 285 | "ServerCrypto::CryptoSupport::Product" /* CryptoSupport.framework */, 286 | ); 287 | name = Products; 288 | sourceTree = BUILT_PRODUCTS_DIR; 289 | }; 290 | OBJ_5 /* */ = { 291 | isa = PBXGroup; 292 | children = ( 293 | OBJ_6 /* Package.swift */, 294 | OBJ_7 /* Sources */, 295 | OBJ_21 /* Tests */, 296 | OBJ_40 /* TestFixtures */, 297 | OBJ_41 /* Dependencies */, 298 | OBJ_42 /* Products */, 299 | ); 300 | name = ""; 301 | sourceTree = ""; 302 | }; 303 | OBJ_7 /* Sources */ = { 304 | isa = PBXGroup; 305 | children = ( 306 | OBJ_8 /* CryptoSupport */, 307 | OBJ_13 /* Hash */, 308 | OBJ_16 /* Signature */, 309 | ); 310 | name = Sources; 311 | sourceTree = SOURCE_ROOT; 312 | }; 313 | OBJ_8 /* CryptoSupport */ = { 314 | isa = PBXGroup; 315 | children = ( 316 | OBJ_9 /* CryptoError.swift */, 317 | OBJ_10 /* CryptoProvider.swift */, 318 | OBJ_11 /* Hex.swift */, 319 | OBJ_12 /* Protocols.swift */, 320 | ); 321 | name = CryptoSupport; 322 | path = Sources/CryptoSupport; 323 | sourceTree = SOURCE_ROOT; 324 | }; 325 | /* End PBXGroup section */ 326 | 327 | /* Begin PBXNativeTarget section */ 328 | "ServerCrypto::CryptoSupport" /* CryptoSupport */ = { 329 | isa = PBXNativeTarget; 330 | buildConfigurationList = OBJ_101 /* Build configuration list for PBXNativeTarget "CryptoSupport" */; 331 | buildPhases = ( 332 | OBJ_104 /* Sources */, 333 | OBJ_109 /* Frameworks */, 334 | ); 335 | buildRules = ( 336 | ); 337 | dependencies = ( 338 | ); 339 | name = CryptoSupport; 340 | productName = CryptoSupport; 341 | productReference = "ServerCrypto::CryptoSupport::Product" /* CryptoSupport.framework */; 342 | productType = "com.apple.product-type.framework"; 343 | }; 344 | "ServerCrypto::Hash" /* Hash */ = { 345 | isa = PBXNativeTarget; 346 | buildConfigurationList = OBJ_92 /* Build configuration list for PBXNativeTarget "Hash" */; 347 | buildPhases = ( 348 | OBJ_95 /* Sources */, 349 | OBJ_98 /* Frameworks */, 350 | ); 351 | buildRules = ( 352 | ); 353 | dependencies = ( 354 | OBJ_100 /* PBXTargetDependency */, 355 | ); 356 | name = Hash; 357 | productName = Hash; 358 | productReference = "ServerCrypto::Hash::Product" /* Hash.framework */; 359 | productType = "com.apple.product-type.framework"; 360 | }; 361 | "ServerCrypto::ServerCryptoTests" /* ServerCryptoTests */ = { 362 | isa = PBXNativeTarget; 363 | buildConfigurationList = OBJ_54 /* Build configuration list for PBXNativeTarget "ServerCryptoTests" */; 364 | buildPhases = ( 365 | OBJ_57 /* Sources */, 366 | OBJ_69 /* Frameworks */, 367 | 55B463111F7996CA00D3F0AA /* Resources */, 368 | ); 369 | buildRules = ( 370 | ); 371 | dependencies = ( 372 | OBJ_73 /* PBXTargetDependency */, 373 | OBJ_75 /* PBXTargetDependency */, 374 | OBJ_77 /* PBXTargetDependency */, 375 | ); 376 | name = ServerCryptoTests; 377 | productName = ServerCryptoTests; 378 | productReference = "ServerCrypto::ServerCryptoTests::Product" /* ServerCryptoTests.xctest */; 379 | productType = "com.apple.product-type.bundle.unit-test"; 380 | }; 381 | "ServerCrypto::Signature" /* Signature */ = { 382 | isa = PBXNativeTarget; 383 | buildConfigurationList = OBJ_79 /* Build configuration list for PBXNativeTarget "Signature" */; 384 | buildPhases = ( 385 | OBJ_82 /* Sources */, 386 | OBJ_87 /* Frameworks */, 387 | ); 388 | buildRules = ( 389 | ); 390 | dependencies = ( 391 | OBJ_90 /* PBXTargetDependency */, 392 | OBJ_91 /* PBXTargetDependency */, 393 | ); 394 | name = Signature; 395 | productName = Signature; 396 | productReference = "ServerCrypto::Signature::Product" /* Signature.framework */; 397 | productType = "com.apple.product-type.framework"; 398 | }; 399 | "ServerCrypto::SwiftPMPackageDescription" /* ServerCryptoPackageDescription */ = { 400 | isa = PBXNativeTarget; 401 | buildConfigurationList = OBJ_48 /* Build configuration list for PBXNativeTarget "ServerCryptoPackageDescription" */; 402 | buildPhases = ( 403 | OBJ_51 /* Sources */, 404 | ); 405 | buildRules = ( 406 | ); 407 | dependencies = ( 408 | ); 409 | name = ServerCryptoPackageDescription; 410 | productName = ServerCryptoPackageDescription; 411 | productType = "com.apple.product-type.framework"; 412 | }; 413 | /* End PBXNativeTarget section */ 414 | 415 | /* Begin PBXProject section */ 416 | OBJ_1 /* Project object */ = { 417 | isa = PBXProject; 418 | attributes = { 419 | LastUpgradeCheck = 9999; 420 | }; 421 | buildConfigurationList = OBJ_2 /* Build configuration list for PBXProject "ServerCrypto" */; 422 | compatibilityVersion = "Xcode 3.2"; 423 | developmentRegion = English; 424 | hasScannedForEncodings = 0; 425 | knownRegions = ( 426 | en, 427 | ); 428 | mainGroup = OBJ_5 /* */; 429 | productRefGroup = OBJ_42 /* Products */; 430 | projectDirPath = ""; 431 | projectRoot = ""; 432 | targets = ( 433 | "ServerCrypto::SwiftPMPackageDescription" /* ServerCryptoPackageDescription */, 434 | "ServerCrypto::ServerCryptoTests" /* ServerCryptoTests */, 435 | "ServerCrypto::Signature" /* Signature */, 436 | "ServerCrypto::Hash" /* Hash */, 437 | "ServerCrypto::CryptoSupport" /* CryptoSupport */, 438 | "ServerCrypto::ServerCryptoPackageTests::ProductTarget" /* ServerCryptoPackageTests */, 439 | ); 440 | }; 441 | /* End PBXProject section */ 442 | 443 | /* Begin PBXResourcesBuildPhase section */ 444 | 55B463111F7996CA00D3F0AA /* Resources */ = { 445 | isa = PBXResourcesBuildPhase; 446 | buildActionMask = 2147483647; 447 | files = ( 448 | 55B463121F7996CF00D3F0AA /* TestFixtures in Resources */, 449 | ); 450 | runOnlyForDeploymentPostprocessing = 0; 451 | }; 452 | /* End PBXResourcesBuildPhase section */ 453 | 454 | /* Begin PBXSourcesBuildPhase section */ 455 | OBJ_104 /* Sources */ = { 456 | isa = PBXSourcesBuildPhase; 457 | buildActionMask = 0; 458 | files = ( 459 | OBJ_105 /* CryptoError.swift in Sources */, 460 | OBJ_106 /* CryptoProvider.swift in Sources */, 461 | OBJ_107 /* Hex.swift in Sources */, 462 | OBJ_108 /* Protocols.swift in Sources */, 463 | ); 464 | runOnlyForDeploymentPostprocessing = 0; 465 | }; 466 | OBJ_51 /* Sources */ = { 467 | isa = PBXSourcesBuildPhase; 468 | buildActionMask = 0; 469 | files = ( 470 | OBJ_52 /* Package.swift in Sources */, 471 | ); 472 | runOnlyForDeploymentPostprocessing = 0; 473 | }; 474 | OBJ_57 /* Sources */ = { 475 | isa = PBXSourcesBuildPhase; 476 | buildActionMask = 0; 477 | files = ( 478 | OBJ_58 /* CryptoErrorTests.swift in Sources */, 479 | OBJ_59 /* HexTests.swift in Sources */, 480 | OBJ_60 /* HashTestData.swift in Sources */, 481 | OBJ_61 /* HashTests.swift in Sources */, 482 | OBJ_62 /* ECDSASignatures.swift in Sources */, 483 | OBJ_63 /* ECDSATests.swift in Sources */, 484 | OBJ_64 /* HMACSignatures.swift in Sources */, 485 | OBJ_65 /* HMACTests.swift in Sources */, 486 | OBJ_66 /* RSATestVectors.swift in Sources */, 487 | OBJ_67 /* RSATests.swift in Sources */, 488 | OBJ_68 /* SignatureTestsCoordinator.swift in Sources */, 489 | ); 490 | runOnlyForDeploymentPostprocessing = 0; 491 | }; 492 | OBJ_82 /* Sources */ = { 493 | isa = PBXSourcesBuildPhase; 494 | buildActionMask = 0; 495 | files = ( 496 | OBJ_83 /* AsymmetricKey.swift in Sources */, 497 | OBJ_84 /* Exports.swift in Sources */, 498 | OBJ_85 /* HMACKey.swift in Sources */, 499 | OBJ_86 /* Signer.swift in Sources */, 500 | ); 501 | runOnlyForDeploymentPostprocessing = 0; 502 | }; 503 | OBJ_95 /* Sources */ = { 504 | isa = PBXSourcesBuildPhase; 505 | buildActionMask = 0; 506 | files = ( 507 | OBJ_96 /* Exports.swift in Sources */, 508 | OBJ_97 /* Hasher.swift in Sources */, 509 | ); 510 | runOnlyForDeploymentPostprocessing = 0; 511 | }; 512 | /* End PBXSourcesBuildPhase section */ 513 | 514 | /* Begin PBXTargetDependency section */ 515 | OBJ_100 /* PBXTargetDependency */ = { 516 | isa = PBXTargetDependency; 517 | target = "ServerCrypto::CryptoSupport" /* CryptoSupport */; 518 | targetProxy = 55B4630A1F79965000D3F0AA /* PBXContainerItemProxy */; 519 | }; 520 | OBJ_114 /* PBXTargetDependency */ = { 521 | isa = PBXTargetDependency; 522 | target = "ServerCrypto::ServerCryptoTests" /* ServerCryptoTests */; 523 | targetProxy = 55B463101F79965100D3F0AA /* PBXContainerItemProxy */; 524 | }; 525 | OBJ_73 /* PBXTargetDependency */ = { 526 | isa = PBXTargetDependency; 527 | target = "ServerCrypto::Signature" /* Signature */; 528 | targetProxy = 55B4630D1F79965000D3F0AA /* PBXContainerItemProxy */; 529 | }; 530 | OBJ_75 /* PBXTargetDependency */ = { 531 | isa = PBXTargetDependency; 532 | target = "ServerCrypto::Hash" /* Hash */; 533 | targetProxy = 55B4630E1F79965000D3F0AA /* PBXContainerItemProxy */; 534 | }; 535 | OBJ_77 /* PBXTargetDependency */ = { 536 | isa = PBXTargetDependency; 537 | target = "ServerCrypto::CryptoSupport" /* CryptoSupport */; 538 | targetProxy = 55B4630F1F79965000D3F0AA /* PBXContainerItemProxy */; 539 | }; 540 | OBJ_90 /* PBXTargetDependency */ = { 541 | isa = PBXTargetDependency; 542 | target = "ServerCrypto::Hash" /* Hash */; 543 | targetProxy = 55B4630B1F79965000D3F0AA /* PBXContainerItemProxy */; 544 | }; 545 | OBJ_91 /* PBXTargetDependency */ = { 546 | isa = PBXTargetDependency; 547 | target = "ServerCrypto::CryptoSupport" /* CryptoSupport */; 548 | targetProxy = 55B4630C1F79965000D3F0AA /* PBXContainerItemProxy */; 549 | }; 550 | /* End PBXTargetDependency section */ 551 | 552 | /* Begin XCBuildConfiguration section */ 553 | OBJ_102 /* Debug */ = { 554 | isa = XCBuildConfiguration; 555 | buildSettings = { 556 | ENABLE_TESTABILITY = YES; 557 | FRAMEWORK_SEARCH_PATHS = ( 558 | "$(inherited)", 559 | "$(PLATFORM_DIR)/Developer/Library/Frameworks", 560 | ); 561 | HEADER_SEARCH_PATHS = ( 562 | "$(inherited)", 563 | "$(SRCROOT)/.build/checkouts/ctls--3121380376349719755", 564 | ); 565 | INFOPLIST_FILE = ServerCrypto.xcodeproj/CryptoSupport_Info.plist; 566 | LD_RUNPATH_SEARCH_PATHS = "$(TOOLCHAIN_DIR)/usr/lib/swift/macosx"; 567 | OTHER_LDFLAGS = "$(inherited)"; 568 | OTHER_SWIFT_FLAGS = "$(inherited)"; 569 | PRODUCT_BUNDLE_IDENTIFIER = CryptoSupport; 570 | PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)"; 571 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 572 | SKIP_INSTALL = YES; 573 | SWIFT_VERSION = 4.0; 574 | TARGET_NAME = CryptoSupport; 575 | }; 576 | name = Debug; 577 | }; 578 | OBJ_103 /* Release */ = { 579 | isa = XCBuildConfiguration; 580 | buildSettings = { 581 | ENABLE_TESTABILITY = YES; 582 | FRAMEWORK_SEARCH_PATHS = ( 583 | "$(inherited)", 584 | "$(PLATFORM_DIR)/Developer/Library/Frameworks", 585 | ); 586 | HEADER_SEARCH_PATHS = ( 587 | "$(inherited)", 588 | "$(SRCROOT)/.build/checkouts/ctls--3121380376349719755", 589 | ); 590 | INFOPLIST_FILE = ServerCrypto.xcodeproj/CryptoSupport_Info.plist; 591 | LD_RUNPATH_SEARCH_PATHS = "$(TOOLCHAIN_DIR)/usr/lib/swift/macosx"; 592 | OTHER_LDFLAGS = "$(inherited)"; 593 | OTHER_SWIFT_FLAGS = "$(inherited)"; 594 | PRODUCT_BUNDLE_IDENTIFIER = CryptoSupport; 595 | PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)"; 596 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 597 | SKIP_INSTALL = YES; 598 | SWIFT_VERSION = 4.0; 599 | TARGET_NAME = CryptoSupport; 600 | }; 601 | name = Release; 602 | }; 603 | OBJ_112 /* Debug */ = { 604 | isa = XCBuildConfiguration; 605 | buildSettings = { 606 | }; 607 | name = Debug; 608 | }; 609 | OBJ_113 /* Release */ = { 610 | isa = XCBuildConfiguration; 611 | buildSettings = { 612 | }; 613 | name = Release; 614 | }; 615 | OBJ_3 /* Debug */ = { 616 | isa = XCBuildConfiguration; 617 | buildSettings = { 618 | CLANG_ENABLE_OBJC_ARC = YES; 619 | COMBINE_HIDPI_IMAGES = YES; 620 | COPY_PHASE_STRIP = NO; 621 | DEBUG_INFORMATION_FORMAT = dwarf; 622 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 623 | ENABLE_NS_ASSERTIONS = YES; 624 | GCC_OPTIMIZATION_LEVEL = 0; 625 | HEADER_SEARCH_PATHS = /usr/local/opt/openssl/include; 626 | MACOSX_DEPLOYMENT_TARGET = 10.10; 627 | ONLY_ACTIVE_ARCH = YES; 628 | OTHER_LDFLAGS = "-L/usr/local/opt/openssl/lib"; 629 | OTHER_SWIFT_FLAGS = "-DXcode"; 630 | PRODUCT_NAME = "$(TARGET_NAME)"; 631 | SDKROOT = macosx; 632 | SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator"; 633 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = SWIFT_PACKAGE; 634 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 635 | USE_HEADERMAP = NO; 636 | }; 637 | name = Debug; 638 | }; 639 | OBJ_4 /* Release */ = { 640 | isa = XCBuildConfiguration; 641 | buildSettings = { 642 | CLANG_ENABLE_OBJC_ARC = YES; 643 | COMBINE_HIDPI_IMAGES = YES; 644 | COPY_PHASE_STRIP = YES; 645 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 646 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 647 | GCC_OPTIMIZATION_LEVEL = s; 648 | HEADER_SEARCH_PATHS = /usr/local/opt/openssl/include; 649 | MACOSX_DEPLOYMENT_TARGET = 10.10; 650 | OTHER_LDFLAGS = "-L/usr/local/opt/openssl/lib"; 651 | OTHER_SWIFT_FLAGS = "-DXcode"; 652 | PRODUCT_NAME = "$(TARGET_NAME)"; 653 | SDKROOT = macosx; 654 | SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator"; 655 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = SWIFT_PACKAGE; 656 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 657 | USE_HEADERMAP = NO; 658 | }; 659 | name = Release; 660 | }; 661 | OBJ_49 /* Debug */ = { 662 | isa = XCBuildConfiguration; 663 | buildSettings = { 664 | LD = /usr/bin/true; 665 | OTHER_SWIFT_FLAGS = "-swift-version 4 -I /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/4 -target x86_64-apple-macosx10.10 -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk"; 666 | SWIFT_VERSION = 4.0; 667 | }; 668 | name = Debug; 669 | }; 670 | OBJ_50 /* Release */ = { 671 | isa = XCBuildConfiguration; 672 | buildSettings = { 673 | LD = /usr/bin/true; 674 | OTHER_SWIFT_FLAGS = "-swift-version 4 -I /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm/4 -target x86_64-apple-macosx10.10 -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk"; 675 | SWIFT_VERSION = 4.0; 676 | }; 677 | name = Release; 678 | }; 679 | OBJ_55 /* Debug */ = { 680 | isa = XCBuildConfiguration; 681 | buildSettings = { 682 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; 683 | FRAMEWORK_SEARCH_PATHS = ( 684 | "$(inherited)", 685 | "$(PLATFORM_DIR)/Developer/Library/Frameworks", 686 | ); 687 | HEADER_SEARCH_PATHS = ( 688 | "$(inherited)", 689 | "$(SRCROOT)/.build/checkouts/ctls--3121380376349719755", 690 | ); 691 | INFOPLIST_FILE = ServerCrypto.xcodeproj/ServerCryptoTests_Info.plist; 692 | LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks @loader_path/Frameworks"; 693 | OTHER_LDFLAGS = "$(inherited)"; 694 | OTHER_SWIFT_FLAGS = "$(inherited)"; 695 | SWIFT_VERSION = 4.0; 696 | TARGET_NAME = ServerCryptoTests; 697 | }; 698 | name = Debug; 699 | }; 700 | OBJ_56 /* Release */ = { 701 | isa = XCBuildConfiguration; 702 | buildSettings = { 703 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; 704 | FRAMEWORK_SEARCH_PATHS = ( 705 | "$(inherited)", 706 | "$(PLATFORM_DIR)/Developer/Library/Frameworks", 707 | ); 708 | HEADER_SEARCH_PATHS = ( 709 | "$(inherited)", 710 | "$(SRCROOT)/.build/checkouts/ctls--3121380376349719755", 711 | ); 712 | INFOPLIST_FILE = ServerCrypto.xcodeproj/ServerCryptoTests_Info.plist; 713 | LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks @loader_path/Frameworks"; 714 | OTHER_LDFLAGS = "$(inherited)"; 715 | OTHER_SWIFT_FLAGS = "$(inherited)"; 716 | SWIFT_VERSION = 4.0; 717 | TARGET_NAME = ServerCryptoTests; 718 | }; 719 | name = Release; 720 | }; 721 | OBJ_80 /* Debug */ = { 722 | isa = XCBuildConfiguration; 723 | buildSettings = { 724 | ENABLE_TESTABILITY = YES; 725 | FRAMEWORK_SEARCH_PATHS = ( 726 | "$(inherited)", 727 | "$(PLATFORM_DIR)/Developer/Library/Frameworks", 728 | ); 729 | HEADER_SEARCH_PATHS = ( 730 | "$(inherited)", 731 | "$(SRCROOT)/.build/checkouts/ctls--3121380376349719755", 732 | ); 733 | INFOPLIST_FILE = ServerCrypto.xcodeproj/Signature_Info.plist; 734 | LD_RUNPATH_SEARCH_PATHS = "$(TOOLCHAIN_DIR)/usr/lib/swift/macosx"; 735 | OTHER_LDFLAGS = "$(inherited)"; 736 | OTHER_SWIFT_FLAGS = "$(inherited)"; 737 | PRODUCT_BUNDLE_IDENTIFIER = Signature; 738 | PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)"; 739 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 740 | SKIP_INSTALL = YES; 741 | SWIFT_VERSION = 4.0; 742 | TARGET_NAME = Signature; 743 | }; 744 | name = Debug; 745 | }; 746 | OBJ_81 /* Release */ = { 747 | isa = XCBuildConfiguration; 748 | buildSettings = { 749 | ENABLE_TESTABILITY = YES; 750 | FRAMEWORK_SEARCH_PATHS = ( 751 | "$(inherited)", 752 | "$(PLATFORM_DIR)/Developer/Library/Frameworks", 753 | ); 754 | HEADER_SEARCH_PATHS = ( 755 | "$(inherited)", 756 | "$(SRCROOT)/.build/checkouts/ctls--3121380376349719755", 757 | ); 758 | INFOPLIST_FILE = ServerCrypto.xcodeproj/Signature_Info.plist; 759 | LD_RUNPATH_SEARCH_PATHS = "$(TOOLCHAIN_DIR)/usr/lib/swift/macosx"; 760 | OTHER_LDFLAGS = "$(inherited)"; 761 | OTHER_SWIFT_FLAGS = "$(inherited)"; 762 | PRODUCT_BUNDLE_IDENTIFIER = Signature; 763 | PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)"; 764 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 765 | SKIP_INSTALL = YES; 766 | SWIFT_VERSION = 4.0; 767 | TARGET_NAME = Signature; 768 | }; 769 | name = Release; 770 | }; 771 | OBJ_93 /* Debug */ = { 772 | isa = XCBuildConfiguration; 773 | buildSettings = { 774 | ENABLE_TESTABILITY = YES; 775 | FRAMEWORK_SEARCH_PATHS = ( 776 | "$(inherited)", 777 | "$(PLATFORM_DIR)/Developer/Library/Frameworks", 778 | ); 779 | HEADER_SEARCH_PATHS = ( 780 | "$(inherited)", 781 | "$(SRCROOT)/.build/checkouts/ctls--3121380376349719755", 782 | ); 783 | INFOPLIST_FILE = ServerCrypto.xcodeproj/Hash_Info.plist; 784 | LD_RUNPATH_SEARCH_PATHS = "$(TOOLCHAIN_DIR)/usr/lib/swift/macosx"; 785 | OTHER_LDFLAGS = "$(inherited)"; 786 | OTHER_SWIFT_FLAGS = "$(inherited)"; 787 | PRODUCT_BUNDLE_IDENTIFIER = Hash; 788 | PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)"; 789 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 790 | SKIP_INSTALL = YES; 791 | SWIFT_VERSION = 4.0; 792 | TARGET_NAME = Hash; 793 | }; 794 | name = Debug; 795 | }; 796 | OBJ_94 /* Release */ = { 797 | isa = XCBuildConfiguration; 798 | buildSettings = { 799 | ENABLE_TESTABILITY = YES; 800 | FRAMEWORK_SEARCH_PATHS = ( 801 | "$(inherited)", 802 | "$(PLATFORM_DIR)/Developer/Library/Frameworks", 803 | ); 804 | HEADER_SEARCH_PATHS = ( 805 | "$(inherited)", 806 | "$(SRCROOT)/.build/checkouts/ctls--3121380376349719755", 807 | ); 808 | INFOPLIST_FILE = ServerCrypto.xcodeproj/Hash_Info.plist; 809 | LD_RUNPATH_SEARCH_PATHS = "$(TOOLCHAIN_DIR)/usr/lib/swift/macosx"; 810 | OTHER_LDFLAGS = "$(inherited)"; 811 | OTHER_SWIFT_FLAGS = "$(inherited)"; 812 | PRODUCT_BUNDLE_IDENTIFIER = Hash; 813 | PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)"; 814 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 815 | SKIP_INSTALL = YES; 816 | SWIFT_VERSION = 4.0; 817 | TARGET_NAME = Hash; 818 | }; 819 | name = Release; 820 | }; 821 | /* End XCBuildConfiguration section */ 822 | 823 | /* Begin XCConfigurationList section */ 824 | OBJ_101 /* Build configuration list for PBXNativeTarget "CryptoSupport" */ = { 825 | isa = XCConfigurationList; 826 | buildConfigurations = ( 827 | OBJ_102 /* Debug */, 828 | OBJ_103 /* Release */, 829 | ); 830 | defaultConfigurationIsVisible = 0; 831 | defaultConfigurationName = Debug; 832 | }; 833 | OBJ_111 /* Build configuration list for PBXAggregateTarget "ServerCryptoPackageTests" */ = { 834 | isa = XCConfigurationList; 835 | buildConfigurations = ( 836 | OBJ_112 /* Debug */, 837 | OBJ_113 /* Release */, 838 | ); 839 | defaultConfigurationIsVisible = 0; 840 | defaultConfigurationName = Debug; 841 | }; 842 | OBJ_2 /* Build configuration list for PBXProject "ServerCrypto" */ = { 843 | isa = XCConfigurationList; 844 | buildConfigurations = ( 845 | OBJ_3 /* Debug */, 846 | OBJ_4 /* Release */, 847 | ); 848 | defaultConfigurationIsVisible = 0; 849 | defaultConfigurationName = Debug; 850 | }; 851 | OBJ_48 /* Build configuration list for PBXNativeTarget "ServerCryptoPackageDescription" */ = { 852 | isa = XCConfigurationList; 853 | buildConfigurations = ( 854 | OBJ_49 /* Debug */, 855 | OBJ_50 /* Release */, 856 | ); 857 | defaultConfigurationIsVisible = 0; 858 | defaultConfigurationName = Debug; 859 | }; 860 | OBJ_54 /* Build configuration list for PBXNativeTarget "ServerCryptoTests" */ = { 861 | isa = XCConfigurationList; 862 | buildConfigurations = ( 863 | OBJ_55 /* Debug */, 864 | OBJ_56 /* Release */, 865 | ); 866 | defaultConfigurationIsVisible = 0; 867 | defaultConfigurationName = Debug; 868 | }; 869 | OBJ_79 /* Build configuration list for PBXNativeTarget "Signature" */ = { 870 | isa = XCConfigurationList; 871 | buildConfigurations = ( 872 | OBJ_80 /* Debug */, 873 | OBJ_81 /* Release */, 874 | ); 875 | defaultConfigurationIsVisible = 0; 876 | defaultConfigurationName = Debug; 877 | }; 878 | OBJ_92 /* Build configuration list for PBXNativeTarget "Hash" */ = { 879 | isa = XCConfigurationList; 880 | buildConfigurations = ( 881 | OBJ_93 /* Debug */, 882 | OBJ_94 /* Release */, 883 | ); 884 | defaultConfigurationIsVisible = 0; 885 | defaultConfigurationName = Debug; 886 | }; 887 | /* End XCConfigurationList section */ 888 | }; 889 | rootObject = OBJ_1 /* Project object */; 890 | } 891 | --------------------------------------------------------------------------------