Browse Source

Merge branch 'master' into aberenguel/master

Marcin Krzyzanowski 4 years ago
parent
commit
48aaff6fb3
39 changed files with 358 additions and 370 deletions
  1. 1 1
      .github/ISSUE_TEMPLATE/bug_report.md
  2. 0 7
      .github/ISSUE_TEMPLATE/feature_request.md
  3. 21 0
      .github/workflows/linux.yml
  4. 24 0
      .github/workflows/macos.yml
  5. 0 1
      .swift-version
  6. 1 1
      .travis.yml
  7. 15 0
      CHANGELOG
  8. 4 1
      CONTRIBUTORS.txt
  9. 1 1
      CryptoSwift.playground/contents.xcplayground
  10. 5 5
      CryptoSwift.podspec
  11. 1 9
      CryptoSwift.xcodeproj/project.pbxproj
  12. 0 22
      CryptoSwift.xcodeproj/xcshareddata/xcbaselines/754BE45F19693E190098E6F3.xcbaseline/2774350F-3E36-4FB9-835D-90E1E9EF7CE0.plist
  13. 0 22
      CryptoSwift.xcodeproj/xcshareddata/xcbaselines/754BE45F19693E190098E6F3.xcbaseline/7797B693-C86A-4026-B2CE-05813EFA26F4.plist
  14. 0 68
      CryptoSwift.xcodeproj/xcshareddata/xcbaselines/754BE45F19693E190098E6F3.xcbaseline/85434D17-7706-4DE9-AFA7-B1DD0BD9FA39.plist
  15. 0 22
      CryptoSwift.xcodeproj/xcshareddata/xcbaselines/754BE45F19693E190098E6F3.xcbaseline/9396A4FE-F8F7-4542-8F75-DE77E1FEBEB9.plist
  16. 0 22
      CryptoSwift.xcodeproj/xcshareddata/xcbaselines/754BE45F19693E190098E6F3.xcbaseline/BD46E9D4-C65B-4C11-9BB5-B8B05CCE976F.plist
  17. 0 22
      CryptoSwift.xcodeproj/xcshareddata/xcbaselines/754BE45F19693E190098E6F3.xcbaseline/C6E1ABC4-5FB9-4A9E-8171-64B34C8D865C.plist
  18. 0 71
      CryptoSwift.xcodeproj/xcshareddata/xcbaselines/754BE45F19693E190098E6F3.xcbaseline/Info.plist
  19. 1 1
      CryptoSwift.xcodeproj/xcshareddata/xcschemes/CryptoSwift-TestHostApp.xcscheme
  20. 1 1
      CryptoSwift.xcodeproj/xcshareddata/xcschemes/CryptoSwift.xcscheme
  21. 1 1
      CryptoSwift.xcodeproj/xcshareddata/xcschemes/Tests.xcscheme
  22. 1 5
      CryptoSwift.xcodeproj/xcshareddata/xcschemes/TestsPerformance-Mac.xcscheme
  23. 1 5
      CryptoSwift.xcodeproj/xcshareddata/xcschemes/TestsPerformance-iOS.xcscheme
  24. 2 2
      Package.swift
  25. 77 43
      README.md
  26. 9 7
      Sources/CryptoSwift/CMAC.swift
  27. 9 0
      Sources/CryptoSwift/Foundation/AES+Foundation.swift
  28. 6 6
      Sources/CryptoSwift/Generics.swift
  29. 2 6
      Sources/CryptoSwift/PKCS/PKCS7Padding.swift
  30. 2 2
      Sources/CryptoSwift/UInt16+Extension.swift
  31. 2 2
      Sources/CryptoSwift/UInt32+Extension.swift
  32. 2 2
      Sources/CryptoSwift/UInt64+Extension.swift
  33. 40 1
      Tests/CryptoSwiftTests/CMACTests.swift
  34. 5 5
      Tests/CryptoSwiftTests/DigestTests.swift
  35. 1 0
      config/Project-Debug.xcconfig
  36. 4 2
      config/Project-Shared.xcconfig
  37. 3 0
      config/Tests-Shared.xcconfig
  38. 115 3
      scripts/build-framework.sh
  39. 1 1
      scripts/generate-contributors-list.sh

+ 1 - 1
.github/ISSUE_TEMPLATE/bug_report.md

@@ -8,5 +8,5 @@ about: Create a report to help us improve
 
 
 **Reproduce**
-Steps to reproduce the behavior:
+Steps to reproduce:
 1.

+ 0 - 7
.github/ISSUE_TEMPLATE/feature_request.md

@@ -1,7 +0,0 @@
----
-name: Feature request
-about: Suggest an idea for this project
-
----
-
-**Describe the solution you'd like**

+ 21 - 0
.github/workflows/linux.yml

@@ -0,0 +1,21 @@
+name: Linux
+
+on:
+  push:
+    branches: [ master ]
+  pull_request:
+    branches: [ master ]
+
+jobs:
+  build:
+
+    runs-on: ubuntu-18.04
+
+    steps:
+    - uses: actions/checkout@v2
+
+    - name: Swift Package Build
+      run: swift build -v
+
+    - name: Run tests
+      run: swift test -c release -Xswiftc -enable-testing -Xswiftc -DCI -Xswiftc -Xfrontend -Xswiftc -solver-memory-threshold -Xswiftc -Xfrontend -Xswiftc 999999999

+ 24 - 0
.github/workflows/macos.yml

@@ -0,0 +1,24 @@
+name: macOS
+
+on:
+  push:
+    branches: [ master ]
+  pull_request:
+    branches: [ master ]
+
+env:
+  DEVELOPER_DIR: /Applications/Xcode_11.4.1.app/Contents/Developer
+
+jobs:
+  build:
+
+    runs-on: macos-latest
+
+    steps:
+    - uses: actions/checkout@v2
+
+    - name: Swift Package Build
+      run: swift build -v
+
+    - name: Run tests
+      run: swift test -c release -Xswiftc -enable-testing -Xswiftc -DCI -Xswiftc -Xfrontend -Xswiftc -solver-memory-threshold -Xswiftc -Xfrontend -Xswiftc 999999999

+ 0 - 1
.swift-version

@@ -1 +0,0 @@
-5.1

+ 1 - 1
.travis.yml

@@ -6,7 +6,7 @@ matrix:
          dist: trusty
          sudo: required
        - os: osx
-         osx_image: xcode11.3
+         osx_image: xcode11.4
 install:
     - eval "$(curl -sL https://swiftenv.fuller.li/install.sh)"
 script:

+ 15 - 0
CHANGELOG

@@ -1,3 +1,18 @@
+1.3.3
+- Xcode 12.2 update
+- build-framework.sh now output CryptoSwift.xcframework
+
+1.3.2
+- Swift 5.3 update (Xcode 12)
+- Bump target platform (iOS 9, macOS 10.12)
+- Allow CMAC with any Cipher
+- Remove CMAC key limit
+
+1.3.1
+- Fix tests
+- Swift 5.2 update
+- Address possible timing issue
+
 1.3.0
 - Adds ISO-78164 padding
 - Performance improvements

+ 4 - 1
CONTRIBUTORS.txt

@@ -1,5 +1,5 @@
 For the purpose of tracking copyright, this is the list of individuals and
-organizations who have contributed source code to ObjectivePGP.
+organizations who have contributed source code to CryptoSwift.
 
 ### Contributors
 
@@ -16,6 +16,7 @@ organizations who have contributed source code to ObjectivePGP.
 - Ayaka Nonaka <ayanonagon@gmail.com>
 - Bart Cone <cone.bart@gmail.com>
 - Bing Cheung <32565605+eungch@users.noreply.github.com>
+- Bogdan Bystritskiy <q80061@gmail.com>
 - Brice Cesarin <bc@dejamobile.com>
 - Bryan Chen <xlchen1291@gmail.com>
 - Bryant Luk <bryant.luk@bryantluk.com>
@@ -27,6 +28,7 @@ organizations who have contributed source code to ObjectivePGP.
 - Cihat Gündüz <github@cihatguenduez.de>
 - Dave Wood <dave@cerebralgardens.com>
 - Dima Kalachov <dima.kalachov@gmail.com>
+- Dusan Klinec <dusan.klinec@gmail.com>
 - Eneko Alonso <eneko.alonso@gmail.com>
 - Evan Maloney <emaloney@gilt.com>
 - Evin Ugur <evinoog96@gmail.com>
@@ -96,6 +98,7 @@ organizations who have contributed source code to ObjectivePGP.
 - jose <nextgenappsllc@gmail.com>
 - mrahmiao <mrahmiao@gmail.com>
 - spatno <seanpatno@gmail.com>
+- sweepty <adie0423@gmail.com>
 - venj <im.venj@gmail.com>
 
 **Updating this list**

+ 1 - 1
CryptoSwift.playground/contents.xcplayground

@@ -1,4 +1,4 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <playground version='5.0' target-platform='macos' display-mode='raw'>
     <timeline fileName='timeline.xctimeline'/>
-</playground>
+</playground>

+ 5 - 5
CryptoSwift.podspec

@@ -1,6 +1,6 @@
 Pod::Spec.new do |s|
   s.name         = "CryptoSwift"
-  s.version      = "1.3.0"
+  s.version      = "1.3.3"
   s.source       = { :git => "https://github.com/krzyzanowskim/CryptoSwift.git", :tag => "#{s.version}" }
   s.summary      = "Cryptography in Swift. SHA, MD5, CRC, PBKDF, Poly1305, HMAC, CMAC, HDKF, Scrypt, ChaCha20, Rabbit, Blowfish, AES."
   s.description  = "Cryptography functions and helpers for Swift implemented in Swift. SHA-1, SHA-2, SHA-3, MD5, PBKDF1, PBKDF2, Scrypt, CRC, Poly1305, HMAC, ChaCha20, Rabbit, Blowfish, AES"
@@ -8,10 +8,10 @@ Pod::Spec.new do |s|
   s.license      = {:type => "Attribution", :file => "LICENSE"}
   s.authors      = {'Marcin Krzyżanowski' => 'marcin@krzyzanowskim.com'}
   s.social_media_url = "https://twitter.com/krzyzanowskim"
-  s.cocoapods_version = '>= 1.6.0'
-  s.swift_version = "5.1"
-  s.ios.deployment_target = "8.0"
-  s.osx.deployment_target = "10.10"
+  s.cocoapods_version = '>= 1.9.1'
+  s.swift_version = "5.3"
+  s.ios.deployment_target = "9.0"
+  s.osx.deployment_target = "10.12"
   s.watchos.deployment_target = "2.0"
   s.tvos.deployment_target = "9.0"
   s.source_files  = "Sources/CryptoSwift/**/*.swift"

+ 1 - 9
CryptoSwift.xcodeproj/project.pbxproj

@@ -8,10 +8,6 @@
 
 /* Begin PBXBuildFile section */
 		0AF023D5230F2B0F008E4E68 /* ISO78164Padding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AF023D4230F2B0F008E4E68 /* ISO78164Padding.swift */; };
-		0AF023D6230F2B0F008E4E68 /* ISO78164Padding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AF023D4230F2B0F008E4E68 /* ISO78164Padding.swift */; };
-		0AF023D7230F2B0F008E4E68 /* ISO78164Padding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AF023D4230F2B0F008E4E68 /* ISO78164Padding.swift */; };
-		0AF023D8230F2B0F008E4E68 /* ISO78164Padding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AF023D4230F2B0F008E4E68 /* ISO78164Padding.swift */; };
-		0AF023D9230F2B0F008E4E68 /* ISO78164Padding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AF023D4230F2B0F008E4E68 /* ISO78164Padding.swift */; };
 		0EE73E71204D598100110E11 /* CMAC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE73E70204D598100110E11 /* CMAC.swift */; };
 		0EE73E74204D59C200110E11 /* CMACTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE73E72204D599C00110E11 /* CMACTests.swift */; };
 		14156CE52011422400DDCFBC /* ChaCha20Poly1305Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14156CE42011422400DDCFBC /* ChaCha20Poly1305Tests.swift */; };
@@ -738,7 +734,7 @@
 			isa = PBXProject;
 			attributes = {
 				LastSwiftUpdateCheck = 0930;
-				LastUpgradeCheck = 1020;
+				LastUpgradeCheck = 1220;
 				ORGANIZATIONNAME = "Marcin Krzyzanowski";
 				TargetAttributes = {
 					75211F91207249D8004E41F8 = {
@@ -834,7 +830,6 @@
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
-				0AF023D6230F2B0F008E4E68 /* ISO78164Padding.swift in Sources */,
 				75211F95207249D8004E41F8 /* AppDelegate.swift in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -927,7 +922,6 @@
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
-				0AF023D7230F2B0F008E4E68 /* ISO78164Padding.swift in Sources */,
 				75C2E76D1D55F097003D2BCA /* Access.swift in Sources */,
 				75482EA41CB310B7001F66A5 /* PBKDF.swift in Sources */,
 				758A94291A65C67400E46135 /* HMACTests.swift in Sources */,
@@ -958,7 +952,6 @@
 				7564F0552072EAEB00CA5A96 /* ExtensionsTestPerf.swift in Sources */,
 				7564F0562072EAEB00CA5A96 /* DigestTestsPerf.swift in Sources */,
 				81F279E22181F5C500449EDA /* ScryptTestsPerf.swift in Sources */,
-				0AF023D9230F2B0F008E4E68 /* ISO78164Padding.swift in Sources */,
 				7564F0572072EAEB00CA5A96 /* TestsPerformance.swift in Sources */,
 				7564F0582072EAEB00CA5A96 /* AESTestsPerf.swift in Sources */,
 			);
@@ -974,7 +967,6 @@
 				7595C15C2072E5B900EA1A5F /* ExtensionsTestPerf.swift in Sources */,
 				7595C1582072E5B900EA1A5F /* DigestTestsPerf.swift in Sources */,
 				81F279E12181F5C500449EDA /* ScryptTestsPerf.swift in Sources */,
-				0AF023D8230F2B0F008E4E68 /* ISO78164Padding.swift in Sources */,
 				7595C14D2072E48C00EA1A5F /* TestsPerformance.swift in Sources */,
 				7595C1592072E5B900EA1A5F /* AESTestsPerf.swift in Sources */,
 			);

+ 0 - 22
CryptoSwift.xcodeproj/xcshareddata/xcbaselines/754BE45F19693E190098E6F3.xcbaseline/2774350F-3E36-4FB9-835D-90E1E9EF7CE0.plist

@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>classNames</key>
-	<dict>
-		<key>AESTests</key>
-		<dict>
-			<key>testAESEncryptPerformance()</key>
-			<dict>
-				<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
-				<dict>
-					<key>baselineAverage</key>
-					<real>2.5786</real>
-					<key>baselineIntegrationDisplayName</key>
-					<string>Local Baseline</string>
-				</dict>
-			</dict>
-		</dict>
-	</dict>
-</dict>
-</plist>

+ 0 - 22
CryptoSwift.xcodeproj/xcshareddata/xcbaselines/754BE45F19693E190098E6F3.xcbaseline/7797B693-C86A-4026-B2CE-05813EFA26F4.plist

@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>classNames</key>
-	<dict>
-		<key>AESTests</key>
-		<dict>
-			<key>testAESEncryptPerformance()</key>
-			<dict>
-				<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
-				<dict>
-					<key>baselineAverage</key>
-					<real>3.093</real>
-					<key>baselineIntegrationDisplayName</key>
-					<string>Local Baseline</string>
-				</dict>
-			</dict>
-		</dict>
-	</dict>
-</dict>
-</plist>

+ 0 - 68
CryptoSwift.xcodeproj/xcshareddata/xcbaselines/754BE45F19693E190098E6F3.xcbaseline/85434D17-7706-4DE9-AFA7-B1DD0BD9FA39.plist

@@ -1,68 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>classNames</key>
-	<dict>
-		<key>AESTests</key>
-		<dict>
-			<key>testAESPerformance()</key>
-			<dict>
-				<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
-				<dict>
-					<key>baselineAverage</key>
-					<real>0.62</real>
-					<key>baselineIntegrationDisplayName</key>
-					<string>Local Baseline</string>
-				</dict>
-			</dict>
-			<key>testAES_decrypt_performance()</key>
-			<dict>
-				<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
-				<dict>
-					<key>baselineAverage</key>
-					<real>0.571</real>
-					<key>baselineIntegrationDisplayName</key>
-					<string>Local Baseline</string>
-				</dict>
-			</dict>
-			<key>testAES_encrypt_performance()</key>
-			<dict>
-				<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
-				<dict>
-					<key>baselineAverage</key>
-					<real>0.535</real>
-					<key>baselineIntegrationDisplayName</key>
-					<string>Local Baseline</string>
-				</dict>
-			</dict>
-		</dict>
-		<key>ChaCha20Tests</key>
-		<dict>
-			<key>testChaCha20Performance()</key>
-			<dict>
-				<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
-				<dict>
-					<key>baselineAverage</key>
-					<real>0.176</real>
-					<key>baselineIntegrationDisplayName</key>
-					<string>Local Baseline</string>
-				</dict>
-			</dict>
-		</dict>
-		<key>CryptoSwiftTests</key>
-		<dict>
-			<key>testMD5PerformanceSwift()</key>
-			<dict>
-				<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
-				<dict>
-					<key>baselineAverage</key>
-					<real>0.087</real>
-					<key>baselineIntegrationDisplayName</key>
-					<string>Local Baseline</string>
-				</dict>
-			</dict>
-		</dict>
-	</dict>
-</dict>
-</plist>

+ 0 - 22
CryptoSwift.xcodeproj/xcshareddata/xcbaselines/754BE45F19693E190098E6F3.xcbaseline/9396A4FE-F8F7-4542-8F75-DE77E1FEBEB9.plist

@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>classNames</key>
-	<dict>
-		<key>ChaCha20Tests</key>
-		<dict>
-			<key>testChaCha20Performance()</key>
-			<dict>
-				<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
-				<dict>
-					<key>baselineAverage</key>
-					<real>0.15</real>
-					<key>baselineIntegrationDisplayName</key>
-					<string>Local Baseline</string>
-				</dict>
-			</dict>
-		</dict>
-	</dict>
-</dict>
-</plist>

+ 0 - 22
CryptoSwift.xcodeproj/xcshareddata/xcbaselines/754BE45F19693E190098E6F3.xcbaseline/BD46E9D4-C65B-4C11-9BB5-B8B05CCE976F.plist

@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>classNames</key>
-	<dict>
-		<key>AESTests</key>
-		<dict>
-			<key>testAESEncryptPerformance()</key>
-			<dict>
-				<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
-				<dict>
-					<key>baselineAverage</key>
-					<real>0.23441</real>
-					<key>baselineIntegrationDisplayName</key>
-					<string>Local Baseline</string>
-				</dict>
-			</dict>
-		</dict>
-	</dict>
-</dict>
-</plist>

+ 0 - 22
CryptoSwift.xcodeproj/xcshareddata/xcbaselines/754BE45F19693E190098E6F3.xcbaseline/C6E1ABC4-5FB9-4A9E-8171-64B34C8D865C.plist

@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>classNames</key>
-	<dict>
-		<key>AESTests</key>
-		<dict>
-			<key>testAESPerformance()</key>
-			<dict>
-				<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
-				<dict>
-					<key>baselineAverage</key>
-					<real>14.71</real>
-					<key>baselineIntegrationDisplayName</key>
-					<string>Local Baseline</string>
-				</dict>
-			</dict>
-		</dict>
-	</dict>
-</dict>
-</plist>

+ 0 - 71
CryptoSwift.xcodeproj/xcshareddata/xcbaselines/754BE45F19693E190098E6F3.xcbaseline/Info.plist

@@ -1,71 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>runDestinationsByUUID</key>
-	<dict>
-		<key>85434D17-7706-4DE9-AFA7-B1DD0BD9FA39</key>
-		<dict>
-			<key>localComputer</key>
-			<dict>
-				<key>busSpeedInMHz</key>
-				<integer>100</integer>
-				<key>cpuCount</key>
-				<integer>1</integer>
-				<key>cpuKind</key>
-				<string>Intel Core i7</string>
-				<key>cpuSpeedInMHz</key>
-				<integer>2200</integer>
-				<key>logicalCPUCoresPerPackage</key>
-				<integer>4</integer>
-				<key>modelCode</key>
-				<string>MacBookAir7,2</string>
-				<key>physicalCPUCoresPerPackage</key>
-				<integer>2</integer>
-				<key>platformIdentifier</key>
-				<string>com.apple.platform.macosx</string>
-			</dict>
-			<key>targetArchitecture</key>
-			<string>x86_64</string>
-			<key>targetDevice</key>
-			<dict>
-				<key>modelCode</key>
-				<string>iPhone8,1</string>
-				<key>platformIdentifier</key>
-				<string>com.apple.platform.iphonesimulator</string>
-			</dict>
-		</dict>
-		<key>9396A4FE-F8F7-4542-8F75-DE77E1FEBEB9</key>
-		<dict>
-			<key>localComputer</key>
-			<dict>
-				<key>busSpeedInMHz</key>
-				<integer>100</integer>
-				<key>cpuCount</key>
-				<integer>1</integer>
-				<key>cpuKind</key>
-				<string>Intel Core i7</string>
-				<key>cpuSpeedInMHz</key>
-				<integer>1700</integer>
-				<key>logicalCPUCoresPerPackage</key>
-				<integer>4</integer>
-				<key>modelCode</key>
-				<string>MacBookAir6,2</string>
-				<key>physicalCPUCoresPerPackage</key>
-				<integer>2</integer>
-				<key>platformIdentifier</key>
-				<string>com.apple.platform.macosx</string>
-			</dict>
-			<key>targetArchitecture</key>
-			<string>x86_64</string>
-			<key>targetDevice</key>
-			<dict>
-				<key>modelCode</key>
-				<string>iPhone7,2</string>
-				<key>platformIdentifier</key>
-				<string>com.apple.platform.iphonesimulator</string>
-			</dict>
-		</dict>
-	</dict>
-</dict>
-</plist>

+ 1 - 1
CryptoSwift.xcodeproj/xcshareddata/xcschemes/CryptoSwift-TestHostApp.xcscheme

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Scheme
-   LastUpgradeVersion = "1020"
+   LastUpgradeVersion = "1220"
    version = "1.3">
    <BuildAction
       parallelizeBuildables = "NO"

+ 1 - 1
CryptoSwift.xcodeproj/xcshareddata/xcschemes/CryptoSwift.xcscheme

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Scheme
-   LastUpgradeVersion = "1020"
+   LastUpgradeVersion = "1220"
    version = "1.3">
    <BuildAction
       parallelizeBuildables = "NO"

+ 1 - 1
CryptoSwift.xcodeproj/xcshareddata/xcschemes/Tests.xcscheme

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Scheme
-   LastUpgradeVersion = "1020"
+   LastUpgradeVersion = "1220"
    version = "1.3">
    <BuildAction
       parallelizeBuildables = "NO"

+ 1 - 5
CryptoSwift.xcodeproj/xcshareddata/xcschemes/TestsPerformance-Mac.xcscheme

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Scheme
-   LastUpgradeVersion = "1020"
+   LastUpgradeVersion = "1220"
    version = "1.3">
    <BuildAction
       parallelizeBuildables = "NO"
@@ -23,8 +23,6 @@
             </BuildableReference>
          </TestableReference>
       </Testables>
-      <AdditionalOptions>
-      </AdditionalOptions>
    </TestAction>
    <LaunchAction
       buildConfiguration = "Test"
@@ -36,8 +34,6 @@
       debugDocumentVersioning = "YES"
       debugServiceExtension = "internal"
       allowLocationSimulation = "YES">
-      <AdditionalOptions>
-      </AdditionalOptions>
    </LaunchAction>
    <ProfileAction
       buildConfiguration = "Release"

+ 1 - 5
CryptoSwift.xcodeproj/xcshareddata/xcschemes/TestsPerformance-iOS.xcscheme

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Scheme
-   LastUpgradeVersion = "1020"
+   LastUpgradeVersion = "1220"
    version = "1.3">
    <BuildAction
       parallelizeBuildables = "NO"
@@ -23,8 +23,6 @@
             </BuildableReference>
          </TestableReference>
       </Testables>
-      <AdditionalOptions>
-      </AdditionalOptions>
    </TestAction>
    <LaunchAction
       buildConfiguration = "Test"
@@ -36,8 +34,6 @@
       debugDocumentVersioning = "YES"
       debugServiceExtension = "internal"
       allowLocationSimulation = "YES">
-      <AdditionalOptions>
-      </AdditionalOptions>
    </LaunchAction>
    <ProfileAction
       buildConfiguration = "Test"

+ 2 - 2
Package.swift

@@ -1,11 +1,11 @@
-// swift-tools-version:5.0
+// swift-tools-version:5.2
 
 import PackageDescription
 
 let package = Package(
   name: "CryptoSwift",
   platforms: [
-    .macOS(.v10_10), .iOS(.v8), .tvOS(.v9)
+    .macOS(.v10_12), .iOS(.v9), .tvOS(.v9)
   ],
   products: [
     .library(

+ 77 - 43
README.md

@@ -1,12 +1,9 @@
 [![Platform](https://img.shields.io/badge/Platforms-iOS%20%7C%20Android%20%7CmacOS%20%7C%20watchOS%20%7C%20tvOS%20%7C%20Linux-4E4E4E.svg?colorA=28a745)](#installation)
 
 [![Swift support](https://img.shields.io/badge/Swift-3.1%20%7C%203.2%20%7C%204.0%20%7C%204.1%20%7C%204.2%20%7C%205.0-lightgrey.svg?colorA=28a745&colorB=4E4E4E)](#swift-versions-support)
+[![Swift Package Manager compatible](https://img.shields.io/badge/SPM-compatible-brightgreen.svg?style=flat&colorA=28a745&&colorB=4E4E4E)](https://github.com/apple/swift-package-manager)
 [![CocoaPods Compatible](https://img.shields.io/cocoapods/v/CryptoSwift.svg?style=flat&label=CocoaPods&colorA=28a745&&colorB=4E4E4E)](https://cocoapods.org/pods/CryptoSwift)
 [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-brightgreen.svg?style=flat&colorA=28a745&&colorB=4E4E4E)](https://github.com/Carthage/Carthage)
-[![Accio supported](https://img.shields.io/badge/Accio-supported-brightgreen.svg?style=flat&colorA=28a745&&colorB=4E4E4E)](https://github.com/JamitLabs/Accio)
-[![Swift Package Manager compatible](https://img.shields.io/badge/SPM-compatible-brightgreen.svg?style=flat&colorA=28a745&&colorB=4E4E4E)](https://github.com/apple/swift-package-manager)
-
-[![Twitter](https://img.shields.io/badge/Twitter-@krzyzanowskim-blue.svg?style=flat)](http://twitter.com/krzyzanowskim)
 
 # CryptoSwift
 
@@ -20,9 +17,11 @@ Crypto related functions and helpers for [Swift](https://swift.org) implemented
 
 ## Sponsorship
 
-If you (or your Company) use this work, please consider [Sponsorship](https://github.com/users/krzyzanowskim/sponsorship). This is the only option to keep the project alive, that is in your own best interrest.
+It takes some time to keep it all for your convenience, so maybe spare $1, so I can keep working on that. There are more than 8000 clones daily. If I'd get $1/month from each company that uses my work here, I'd say we're even. Hurry up, find the [Sponsorship](https://github.com/users/krzyzanowskim/sponsorship) button, and fulfill your duty.
 
-CryptoSwift isn't backed by a big company and is developer in my spare time that I also use to as a freelancer.
+CryptoSwift isn't backed by any big company and is developer in my spare time that I also use to as a freelancer.
+
+[![Twitter](https://img.shields.io/badge/Twitter-@krzyzanowskim-blue.svg?style=flat)](http://twitter.com/krzyzanowskim)
 
 ## Requirements
 Good mood
@@ -108,44 +107,32 @@ To install CryptoSwift, add it as a submodule to your project (on the top level
 
 It is recommended to enable [Whole-Module Optimization](https://swift.org/blog/whole-module-optimizations/) to gain better performance. Non-optimized build results in significantly worse performance.
 
-#### Embedded Framework
-
-Embedded frameworks require a minimum deployment target of iOS 8 or OS X Mavericks (10.9). Drag the `CryptoSwift.xcodeproj` file into your Xcode project, and add appropriate framework as a dependency to your target. Now select your App and choose the General tab for the app target. Find *Embedded Binaries* and press "+", then select `CryptoSwift.framework` (iOS, OS X, watchOS or tvOS)
-
-![](https://cloud.githubusercontent.com/assets/758033/10834511/25a26852-7e9a-11e5-8c01-6cc8f1838459.png)
-
-Sometimes "embedded framework" option is not available. In that case, you have to add new build phase for the target
+#### Swift Package Manager
 
-![](https://cloud.githubusercontent.com/assets/758033/18415615/d5edabb0-77f8-11e6-8c94-f41d9fc2b8cb.png)
+You can use [Swift Package Manager](https://swift.org/package-manager/) and specify dependency in `Package.swift` by adding this:
 
-##### iOS, macOS, watchOS, tvOS
+```swift
+.package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", .upToNextMinor(from: "1.3.3"))
+```
 
-In the project, you'll find [single scheme](https://mxcl.dev/PromiseKit/news/2016/08/Multiplatform-Single-Scheme-Xcode-Projects/) for all platforms:
-- CryptoSwift
+See: [Package.swift - manual](http://blog.krzyzanowskim.com/2016/08/09/package-swift-manual/)
 
-#### Swift versions support
+Notice: Swift Package Manager uses debug configuration for debug Xcode build, that may result in significant (up to x10000) worse performance. Performance characteristic is different in Release build. To overcome this prolem, consider embed `CryptoSwift.xcframework` described below.
 
-- Swift 1.2: branch [swift12](https://github.com/krzyzanowskim/CryptoSwift/tree/swift12) version <= 0.0.13
-- Swift 2.1: branch [swift21](https://github.com/krzyzanowskim/CryptoSwift/tree/swift21) version <= 0.2.3
-- Swift 2.2, 2.3: branch [swift2](https://github.com/krzyzanowskim/CryptoSwift/tree/swift2) version <= 0.5.2
-- Swift 3.1, branch [swift3](https://github.com/krzyzanowskim/CryptoSwift/tree/swift3) version <= 0.6.9
-- Swift 3.2, branch [swift32](https://github.com/krzyzanowskim/CryptoSwift/tree/swift32) version = 0.7.0
-- Swift 4.0, branch [swift4](https://github.com/krzyzanowskim/CryptoSwift/tree/swift4) version <= 0.12.0
-- Swift 4.2, branch [swift42](https://github.com/krzyzanowskim/CryptoSwift/tree/swift42) version <= 0.15.0
-- Swift 5.0, branch [swift5](https://github.com/krzyzanowskim/CryptoSwift/tree/swift5) version <= 1.2.0
-- Swift 5.1 and newer, branch [master](https://github.com/krzyzanowskim/CryptoSwift/tree/master)
+Notice: As of Swift 5.3, it's impossible to use Swift Package Manager to distribute binary (pre-compiled, optimized) version of CryptoSwift for every platform.
 
 #### CocoaPods
 
 You can use [CocoaPods](https://cocoapods.org/pods/CryptoSwift).
 
 ```ruby
-pod 'CryptoSwift', '~> 1.0'
+pod 'CryptoSwift', '~> 1.3.3'
 ```
 
 Bear in mind that CocoaPods will build CryptoSwift without [Whole-Module Optimization](https://swift.org/blog/whole-module-optimizations/) that may impact performance. You can change it manually after installation, or use [cocoapods-wholemodule](https://github.com/jedlewison/cocoapods-wholemodule) plugin.
 
 #### Carthage
+
 You can use [Carthage](https://github.com/Carthage/Carthage).
 Specify in Cartfile:
 
@@ -155,26 +142,41 @@ github "krzyzanowskim/CryptoSwift"
 
 Run `carthage` to build the framework and drag the built CryptoSwift.framework into your Xcode project. Follow [build instructions](https://github.com/Carthage/Carthage#getting-started). [Common issues](https://github.com/krzyzanowskim/CryptoSwift/issues/492#issuecomment-330822874).
 
-#### Swift Package Manager
+#### XCFramework
 
-You can use [Swift Package Manager](https://swift.org/package-manager/) and specify dependency in `Package.swift` by adding this:
+XCFrameworks require Xcode 11 or later and they can be integrated similarly to how we’re used to integrating the `.framework` format.
+Please us a script [scripts/build-framework.sh](scripts/build-framework.sh) to generate binary `CryptoSwift.xcframework` archive that you can use as a dependency in Xcode.
 
-```swift
-.package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", .upToNextMinor(from: "1.0"))
-```
+CryptoSwift.xcframework is a Release (Optimized) binary that offer best available Swift code performance.
 
-See: [Package.swift - manual](http://blog.krzyzanowskim.com/2016/08/09/package-swift-manual/)
+<img width="320" alt="Screen Shot 2020-10-27 at 00 06 32" src="https://user-images.githubusercontent.com/758033/97240586-f0878280-17ee-11eb-9119-e5a960417d04.png">
 
-#### Accio
-You can use [Accio](https://github.com/JamitLabs/Accio). Specify in `Package.swift`:
+#### Embedded Framework
 
-```swift
-.package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", .upToNextMajor(from: "1.0")),
-```
+Embedded frameworks require a minimum deployment target of iOS 9 or macOS Sierra (10.12). Drag the `CryptoSwift.xcodeproj` file into your Xcode project, and add appropriate framework as a dependency to your target. Now select your App and choose the General tab for the app target. Find *Embedded Binaries* and press "+", then select `CryptoSwift.framework` (iOS, macOS, watchOS or tvOS)
 
-Then run `accio update`.
+![](https://cloud.githubusercontent.com/assets/758033/10834511/25a26852-7e9a-11e5-8c01-6cc8f1838459.png)
 
----
+Sometimes "embedded framework" option is not available. In that case, you have to add new build phase for the target.
+
+![](https://cloud.githubusercontent.com/assets/758033/18415615/d5edabb0-77f8-11e6-8c94-f41d9fc2b8cb.png)
+
+##### iOS, macOS, watchOS, tvOS
+
+In the project, you'll find [single scheme](https://mxcl.dev/PromiseKit/news/2016/08/Multiplatform-Single-Scheme-Xcode-Projects/) for all platforms:
+- CryptoSwift
+
+#### Swift versions support
+
+- Swift 1.2: branch [swift12](https://github.com/krzyzanowskim/CryptoSwift/tree/swift12) version <= 0.0.13
+- Swift 2.1: branch [swift21](https://github.com/krzyzanowskim/CryptoSwift/tree/swift21) version <= 0.2.3
+- Swift 2.2, 2.3: branch [swift2](https://github.com/krzyzanowskim/CryptoSwift/tree/swift2) version <= 0.5.2
+- Swift 3.1, branch [swift3](https://github.com/krzyzanowskim/CryptoSwift/tree/swift3) version <= 0.6.9
+- Swift 3.2, branch [swift32](https://github.com/krzyzanowskim/CryptoSwift/tree/swift32) version = 0.7.0
+- Swift 4.0, branch [swift4](https://github.com/krzyzanowskim/CryptoSwift/tree/swift4) version <= 0.12.0
+- Swift 4.2, branch [swift42](https://github.com/krzyzanowskim/CryptoSwift/tree/swift42) version <= 0.15.0
+- Swift 5.0, branch [swift5](https://github.com/krzyzanowskim/CryptoSwift/tree/swift5) version <= 1.2.0
+- Swift 5.1 and newer, branch [master](https://github.com/krzyzanowskim/CryptoSwift/tree/master)
 
 ## How-to
 
@@ -359,8 +361,40 @@ Variant of AES encryption (AES-128, AES-192, AES-256) depends on given key lengt
 - AES-256 = 32 bytes
 
 AES-256 example
+
 ```swift
-try AES(key: [1,2,3,...,32], blockMode: CBC(iv: [1,2,3,...,16]), padding: .pkcs7)
+let encryptedBytes = try AES(key: [1,2,3,...,32], blockMode: CBC(iv: [1,2,3,...,16]), padding: .pkcs7)
+```
+
+Full example:
+
+```swift
+let password: [UInt8] = Array("s33krit".utf8)
+let salt: [UInt8] = Array("nacllcan".utf8)
+
+/* Generate a key from a `password`. Optional if you already have a key */
+let key = try PKCS5.PBKDF2(
+    password: password,
+    salt: salt,
+    iterations: 4096,
+    keyLength: 32, /* AES-256 */
+    variant: .sha256
+).calculate()
+
+/* Generate random IV value. IV is public value. Either need to generate, or get it from elsewhere */
+let iv = AES.randomIV(AES.blockSize)
+
+/* AES cryptor instance */
+let aes = try AES(key: key, blockMode: CBC(iv: iv), padding: .pkcs7)
+
+/* Encrypt Data */
+let inputData = Data()
+let encryptedBytes = try aes.encrypt(inputData.bytes)
+let encryptedData = Data(encryptedBytes)
+
+/* Decrypt Data */
+let decryptedBytes = try aes.decrypt(encryptedData.bytes)
+let decryptedData = Data(decryptedBytes)
 ```
 
 ###### All at once
@@ -438,7 +472,7 @@ do {
     let aes = try AES(key: key, blockMode: gcm, padding: .noPadding)
     let encrypted = try aes.encrypt(plaintext)
     let tag = gcm.authenticationTag
-catch {
+} catch {
     // failed
 }
 ```

+ 9 - 7
Sources/CryptoSwift/CMAC.swift

@@ -25,18 +25,20 @@ public class CMAC: Authenticator {
   private static let Rb: Array<UInt8> = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87]
 
   public init(key: Array<UInt8>) throws {
-    if key.count != 16 {
-      throw Error.wrongKeyLength
-    }
     self.key = SecureBytes(bytes: key)
   }
 
   // MARK: Authenticator
 
+  // AES-CMAC
   public func authenticate(_ bytes: Array<UInt8>) throws -> Array<UInt8> {
-    let aes = try AES(key: Array(key), blockMode: CBC(iv: CMAC.Zero), padding: .noPadding)
+    let cipher = try AES(key: Array(key), blockMode: CBC(iv: CMAC.Zero), padding: .noPadding)
+    return try self.authenticate(bytes, cipher: cipher)
+  }
 
-    let l = try aes.encrypt(CMAC.Zero)
+  // CMAC using a Cipher
+  public func authenticate(_ bytes: Array<UInt8>, cipher: Cipher) throws -> Array<UInt8> {
+    let l = try cipher.encrypt(CMAC.Zero)
     var subKey1 = self.leftShiftOneBit(l)
     if (l[0] & 0x80) != 0 {
       subKey1 = xor(CMAC.Rb, subKey1)
@@ -70,11 +72,11 @@ public class CMAC: Authenticator {
     var y = Array<UInt8>(repeating: 0x00, count: CMAC.BlockSize)
     for block in blocks {
       y = xor(block, x)
-      x = try aes.encrypt(y)
+      x = try cipher.encrypt(y)
     }
     // the difference between CMAC and CBC-MAC is that CMAC xors the final block with a secret value
     y = self.process(lastBlock: lastBlock, with: x)
-    return try aes.encrypt(y)
+    return try cipher.encrypt(y)
   }
 
   func process(lastBlock: ArraySlice<UInt8>, with x: [UInt8]) -> [UInt8] {

+ 9 - 0
Sources/CryptoSwift/Foundation/AES+Foundation.swift

@@ -17,6 +17,15 @@ import Foundation
 
 extension AES {
   /// Initialize with CBC block mode.
+  ///
+  /// - Parameters:
+  ///   - key: Key as a String.
+  ///   - iv: IV as a String.
+  ///   - padding: Padding
+  /// - Throws: Error
+  ///
+  /// The input is a String, that is treat as sequence of bytes made directly out of String.
+  /// If input is Base64 encoded data (which is a String technically) it is not decoded automatically for you.
   public convenience init(key: String, iv: String, padding: Padding = .pkcs7) throws {
     try self.init(key: key.bytes, blockMode: CBC(iv: iv.bytes), padding: padding)
   }

+ 6 - 6
Sources/CryptoSwift/Generics.swift

@@ -19,12 +19,12 @@
 /// - parameter length: length of output array. By default size of value type
 ///
 /// - returns: Array of bytes
-@_specialize(exported: true, where T == Int)
-@_specialize(exported: true, where T == UInt)
-@_specialize(exported: true, where T == UInt8)
-@_specialize(exported: true, where T == UInt16)
-@_specialize(exported: true, where T == UInt32)
-@_specialize(exported: true, where T == UInt64)
+@_specialize(where T == Int)
+@_specialize(where T == UInt)
+@_specialize(where T == UInt8)
+@_specialize(where T == UInt16)
+@_specialize(where T == UInt32)
+@_specialize(where T == UInt64)
 func arrayOfBytes<T: FixedWidthInteger>(value: T, length totalBytes: Int = MemoryLayout<T>.size) -> Array<UInt8> {
   let valuePointer = UnsafeMutablePointer<T>.allocate(capacity: 1)
   valuePointer.pointee = value

+ 2 - 6
Sources/CryptoSwift/PKCS/PKCS7Padding.swift

@@ -30,14 +30,10 @@ struct PKCS7Padding: PaddingProtocol {
     var withPadding = bytes
     if padding == 0 {
       // If the original data is a multiple of N bytes, then an extra block of bytes with value N is added.
-      for _ in 0..<blockSize {
-        withPadding += Array<UInt8>(arrayLiteral: UInt8(blockSize))
-      }
+      withPadding += Array<UInt8>(repeating: UInt8(blockSize), count: Int(blockSize))
     } else {
       // The value of each added byte is the number of bytes that are added
-      for _ in 0..<padding {
-        withPadding += Array<UInt8>(arrayLiteral: UInt8(padding))
-      }
+      withPadding += Array<UInt8>(repeating: padding, count: Int(padding))
     }
     return withPadding
   }

+ 2 - 2
Sources/CryptoSwift/UInt16+Extension.swift

@@ -15,12 +15,12 @@
 
 /** array of bytes */
 extension UInt16 {
-  @_specialize(exported: true, where T == ArraySlice<UInt8>)
+  @_specialize(where T == ArraySlice<UInt8>)
   init<T: Collection>(bytes: T) where T.Element == UInt8, T.Index == Int {
     self = UInt16(bytes: bytes, fromIndex: bytes.startIndex)
   }
 
-  @_specialize(exported: true, where T == ArraySlice<UInt8>)
+  @_specialize(where T == ArraySlice<UInt8>)
   init<T: Collection>(bytes: T, fromIndex index: T.Index) where T.Element == UInt8, T.Index == Int {
     if bytes.isEmpty {
       self = 0

+ 2 - 2
Sources/CryptoSwift/UInt32+Extension.swift

@@ -24,12 +24,12 @@ extension UInt32: _UInt32Type {}
 
 /** array of bytes */
 extension UInt32 {
-  @_specialize(exported: true, where T == ArraySlice<UInt8>)
+  @_specialize(where T == ArraySlice<UInt8>)
   init<T: Collection>(bytes: T) where T.Element == UInt8, T.Index == Int {
     self = UInt32(bytes: bytes, fromIndex: bytes.startIndex)
   }
 
-  @_specialize(exported: true, where T == ArraySlice<UInt8>)
+  @_specialize(where T == ArraySlice<UInt8>)
   init<T: Collection>(bytes: T, fromIndex index: T.Index) where T.Element == UInt8, T.Index == Int {
     if bytes.isEmpty {
       self = 0

+ 2 - 2
Sources/CryptoSwift/UInt64+Extension.swift

@@ -15,12 +15,12 @@
 
 /** array of bytes */
 extension UInt64 {
-  @_specialize(exported: true, where T == ArraySlice<UInt8>)
+  @_specialize(where T == ArraySlice<UInt8>)
   init<T: Collection>(bytes: T) where T.Element == UInt8, T.Index == Int {
     self = UInt64(bytes: bytes, fromIndex: bytes.startIndex)
   }
 
-  @_specialize(exported: true, where T == ArraySlice<UInt8>)
+  @_specialize(where T == ArraySlice<UInt8>)
   init<T: Collection>(bytes: T, fromIndex index: T.Index) where T.Element == UInt8, T.Index == Int {
     if bytes.isEmpty {
       self = 0

+ 40 - 1
Tests/CryptoSwiftTests/CMACTests.swift

@@ -14,6 +14,7 @@
 //
 
 // Test vectors from https://tools.ietf.org/html/rfc4493
+// Text vectors from http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/tv/omac1-tv.txt
 
 import XCTest
 @testable import CryptoSwift
@@ -55,10 +56,48 @@ final class CMACTests: XCTestCase {
     XCTAssertEqual(cmac, expectedMac, "Invalid authentication result")
   }
 
+  func testOMACTextVectors() {
+    // Test vectors: http://www.nuee.nagoya-u.ac.jp/labs/tiwata/omac/tv/omac1-tv.txt
+    let vectors: [(key: [UInt8], msg: [UInt8], cmac: [UInt8])] = [
+      // AES-192
+      (key: [0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52, 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5, 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b],
+       msg: [],
+       cmac: [0xd1, 0x7d, 0xdf, 0x46, 0xad, 0xaa, 0xcd, 0xe5, 0x31, 0xca, 0xc4, 0x83, 0xde, 0x7a, 0x93, 0x67]),
+      (key: [0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52, 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5, 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b],
+       msg: [0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a],
+       cmac: [0x9e, 0x99, 0xa7, 0xbf, 0x31, 0xe7, 0x10, 0x90, 0x06, 0x62, 0xf6, 0x5e, 0x61, 0x7c, 0x51, 0x84]),
+      (key: [0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52, 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5, 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b],
+       msg: [0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11],
+       cmac: [0x8a, 0x1d, 0xe5, 0xbe, 0x2e, 0xb3, 0x1a, 0xad, 0x08, 0x9a, 0x82, 0xe6, 0xee, 0x90, 0x8b, 0x0e]),
+      (key: [0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52, 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5, 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b],
+       msg: [0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10],
+       cmac: [0xa1, 0xd5, 0xdf, 0x0e, 0xed, 0x79, 0x0f, 0x79, 0x4d, 0x77, 0x58, 0x96, 0x59, 0xf3, 0x9a, 0x11]),
+      // AES-256
+      (key: [0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe, 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81, 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7, 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4],
+       msg: [],
+       cmac: [0x02, 0x89, 0x62, 0xf6, 0x1b, 0x7b, 0xf8, 0x9e, 0xfc, 0x6b, 0x55, 0x1f, 0x46, 0x67, 0xd9, 0x83]),
+      (key: [0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe, 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81, 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7, 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4],
+       msg: [0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a],
+       cmac: [0x28, 0xa7, 0x02, 0x3f, 0x45, 0x2e, 0x8f, 0x82, 0xbd, 0x4b, 0xf2, 0x8d, 0x8c, 0x37, 0xc3, 0x5c]),
+      (key: [0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe, 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81, 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7, 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4],
+       msg: [0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11],
+       cmac: [0xaa, 0xf3, 0xd8, 0xf1, 0xde, 0x56, 0x40, 0xc2, 0x32, 0xf5, 0xb1, 0x69, 0xb9, 0xc9, 0x11, 0xe6]),
+      (key: [0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe, 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81, 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7, 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4],
+       msg: [0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10],
+       cmac: [0xe1, 0x99, 0x21, 0x90, 0x54, 0x9f, 0x6e, 0xd5, 0x69, 0x6a, 0x2c, 0x05, 0x6c, 0x31, 0x54, 0x10]),
+    ]
+
+    for v in vectors {
+      let cmac = try! CMAC(key: v.key).authenticate(v.msg)
+      XCTAssertEqual(cmac, v.cmac, "Failed \(v)")
+    }
+  }
+
   static let allTests = [
     ("testMessageLength0", testMessageLength0),
     ("testMessageLength16", testMessageLength16),
     ("testMessageLength40", testMessageLength40),
-    ("testMessageLength64", testMessageLength64)
+    ("testMessageLength64", testMessageLength64),
+    ("testOMACTextVectors", testOMACTextVectors)
   ]
 }

+ 5 - 5
Tests/CryptoSwiftTests/DigestTests.swift

@@ -190,21 +190,21 @@ final class DigestTests: XCTestCase {
   }
 
   func testCRC32() {
-    let data: Data = Data(bytes: UnsafePointer<UInt8>([49, 50, 51] as Array<UInt8>), count: 3)
+    let data: Data = Data(bytes: [49, 50, 51] as Array<UInt8>, count: 3)
     XCTAssertEqual(data.crc32(seed: nil).toHexString(), "884863d2", "CRC32 calculation failed")
 
     XCTAssertEqual("".crc32(seed: nil), "00000000", "CRC32 calculation failed")
   }
 
   func testCRC32C() {
-    let data: Data = Data(bytes: UnsafePointer<UInt8>([0x32, 0, 0, 0] as Array<UInt8>), count: 4)
+    let data: Data = Data(bytes: [0x32, 0, 0, 0] as Array<UInt8>, count: 4)
     XCTAssertEqual(data.crc32c(seed: nil).toHexString(), "c941cdf0", "CRC32C calculation failed")
     XCTAssertEqual("".crc32c(seed: nil), "00000000", "CRC32 calculation failed")
   }
 
   func testCRC32NotReflected() {
     let bytes: Array<UInt8> = [0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39]
-    let data: Data = Data(bytes: UnsafePointer<UInt8>(bytes), count: bytes.count)
+    let data: Data = Data(bytes: bytes, count: bytes.count)
     XCTAssertEqual(data.crc32(seed: nil, reflect: false).toHexString(), "fc891918", "CRC32 (with reflection) calculation failed")
 
     XCTAssertEqual("".crc32(seed: nil, reflect: false), "00000000", "CRC32 (with reflection) calculation failed")
@@ -216,7 +216,7 @@ final class DigestTests: XCTestCase {
   }
 
   func testChecksum() {
-    let data: Data = Data(bytes: UnsafePointer<UInt8>([49, 50, 51] as Array<UInt8>), count: 3)
+    let data: Data = Data(bytes: [49, 50, 51] as Array<UInt8>, count: 3)
     XCTAssert(data.checksum() == 0x96, "Invalid checksum")
   }
 
@@ -228,7 +228,7 @@ final class DigestTests: XCTestCase {
       }
       count = len
     }
-    let data: Data = Data(bytes: UnsafePointer<UInt8>(a), count: len)
+    let data: Data = Data(bytes: a, count: len)
     self.measure {
       _ = data.checksum()
     }

+ 1 - 0
config/Project-Debug.xcconfig

@@ -13,3 +13,4 @@ GCC_PREPROCESSOR_DEFINITIONS = $(inherited) DEBUG=1
 SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG
 METAL_ENABLE_DEBUG_INFO = YES
 ONLY_ACTIVE_ARCH = YES
+ENABLE_TESTABILITY = YES

+ 4 - 2
config/Project-Shared.xcconfig

@@ -5,7 +5,7 @@
 // https://github.com/dempseyatgithub/BuildSettingExtractor
 //
 
-MARKETING_VERSION = 1.3.0
+MARKETING_VERSION = 1.3.3
 
 SUPPORTED_PLATFORMS = iphonesimulator iphoneos macosx appletvos watchos appletvsimulator watchsimulator
 
@@ -15,7 +15,7 @@ SWIFT_VERSION = 5.0
 TARGETED_DEVICE_FAMILY = 1,2,3,4
 
 TVOS_DEPLOYMENT_TARGET = 9.0
-IPHONEOS_DEPLOYMENT_TARGET = 8.0
+IPHONEOS_DEPLOYMENT_TARGET = 9.0
 MACOSX_DEPLOYMENT_TARGET = 10.12
 WATCHOS_DEPLOYMENT_TARGET = 2.0
 
@@ -76,6 +76,8 @@ GCC_WARN_UNUSED_FUNCTION = YES
 GCC_WARN_UNUSED_LABEL = YES
 GCC_WARN_UNUSED_VARIABLE = YES
 
+CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES
+
 VERSION_INFO_PREFIX =
 VERSIONING_SYSTEM = apple-generic
 CURRENT_PROJECT_VERSION = 1

+ 3 - 0
config/Tests-Shared.xcconfig

@@ -17,3 +17,6 @@ OTHER_SWIFT_FLAGS = $(inherited) -Xfrontend -debug-time-function-bodies
 
 // Disable for tests. https://twitter.com/krzyzanowskim/status/1191515868401983489
 BUILD_LIBRARY_FOR_DISTRIBUTION = NO
+
+MACOSX_DEPLOYMENT_TARGET = 10.15
+

+ 115 - 3
scripts/build-framework.sh

@@ -1,7 +1,119 @@
 #!/usr/bin/env bash
 
-set -ex
+set -e
 
-echo "Build frameworks in directory $(pwd)"
+BASE_PWD="$PWD"
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
+OUTPUT_DIR=$( mktemp -d )
+COMMON_SETUP="-project ${SCRIPT_DIR}/../CryptoSwift.xcodeproj -scheme CryptoSwift -configuration Release -quiet SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES"
 
-carthage build --no-skip-current --configuration "Release" --platform all
+# carthage build --no-skip-current --create-xcframework --configuration "Release" --platform all
+
+# macOS
+DERIVED_DATA_PATH=$( mktemp -d )
+xcrun xcodebuild build \
+	$COMMON_SETUP \
+	-derivedDataPath "${DERIVED_DATA_PATH}" \
+	-destination 'generic/platform=macOS'
+
+mkdir -p "${OUTPUT_DIR}/macos"
+cp -r "${DERIVED_DATA_PATH}/Build/Products/Release/CryptoSwift.framework" "${OUTPUT_DIR}/macos"
+rm -rf "${DERIVED_DATA_PATH}"
+
+# macOS Catalyst
+DERIVED_DATA_PATH=$( mktemp -d )
+xcrun xcodebuild build \
+	$COMMON_SETUP \
+	-derivedDataPath "${DERIVED_DATA_PATH}" \
+	-destination 'generic/platform=macOS,variant=Mac Catalyst'
+
+mkdir -p "${OUTPUT_DIR}/maccatalyst"
+cp -r "${DERIVED_DATA_PATH}/Build/Products/Release-maccatalyst/CryptoSwift.framework" "${OUTPUT_DIR}/maccatalyst"
+rm -rf "${DERIVED_DATA_PATH}"
+
+# iOS
+DERIVED_DATA_PATH=$( mktemp -d )
+xcrun xcodebuild build \
+	$COMMON_SETUP \
+	-derivedDataPath "${DERIVED_DATA_PATH}" \
+	-destination 'generic/platform=iOS'
+
+mkdir -p "${OUTPUT_DIR}/iphoneos"
+cp -r "${DERIVED_DATA_PATH}/Build/Products/Release-iphoneos/CryptoSwift.framework" "${OUTPUT_DIR}/iphoneos"
+rm -rf "${DERIVED_DATA_PATH}"
+
+# iOS Simulator
+DERIVED_DATA_PATH=$( mktemp -d )
+xcrun xcodebuild build \
+	$COMMON_SETUP \
+	-derivedDataPath "${DERIVED_DATA_PATH}" \
+	-destination 'generic/platform=iOS Simulator'
+
+mkdir -p "${OUTPUT_DIR}/iphonesimulator"
+cp -r "${DERIVED_DATA_PATH}/Build/Products/Release-iphonesimulator/CryptoSwift.framework" "${OUTPUT_DIR}/iphonesimulator"
+rm -rf "${DERIVED_DATA_PATH}"
+
+# tvOS
+DERIVED_DATA_PATH=$( mktemp -d )
+xcrun xcodebuild build \
+	$COMMON_SETUP \
+	-derivedDataPath "${DERIVED_DATA_PATH}" \
+	-destination 'generic/platform=tvOS'
+
+mkdir -p "${OUTPUT_DIR}/appletvos"
+cp -r "${DERIVED_DATA_PATH}/Build/Products/Release-appletvos/CryptoSwift.framework" "${OUTPUT_DIR}/appletvos"
+rm -rf "${DERIVED_DATA_PATH}"
+
+# tvOS Simulator
+DERIVED_DATA_PATH=$( mktemp -d )
+xcrun xcodebuild build \
+	$COMMON_SETUP \
+	-derivedDataPath "${DERIVED_DATA_PATH}" \
+	-destination 'generic/platform=tvOS Simulator'
+
+mkdir -p "${OUTPUT_DIR}/appletvsimulator"
+cp -r "${DERIVED_DATA_PATH}/Build/Products/Release-appletvsimulator/CryptoSwift.framework" "${OUTPUT_DIR}/appletvsimulator"
+rm -rf "${DERIVED_DATA_PATH}"
+
+# watchOS
+DERIVED_DATA_PATH=$( mktemp -d )
+xcrun xcodebuild build \
+	$COMMON_SETUP \
+	-derivedDataPath "${DERIVED_DATA_PATH}" \
+	-destination 'generic/platform=watchOS'
+
+mkdir -p "${OUTPUT_DIR}/watchos"
+cp -r "${DERIVED_DATA_PATH}/Build/Products/Release-watchos/CryptoSwift.framework" "${OUTPUT_DIR}/watchos"
+rm -rf "${DERIVED_DATA_PATH}"
+
+# watchOS Simulator
+DERIVED_DATA_PATH=$( mktemp -d )
+xcrun xcodebuild build \
+	$COMMON_SETUP \
+	-derivedDataPath "${DERIVED_DATA_PATH}" \
+	-destination 'generic/platform=watchOS Simulator'
+
+mkdir -p "${OUTPUT_DIR}/watchsimulator"
+cp -r "${DERIVED_DATA_PATH}/Build/Products/Release-watchsimulator/CryptoSwift.framework" "${OUTPUT_DIR}/watchsimulator"
+rm -rf "${DERIVED_DATA_PATH}"
+
+# XCFRAMEWORK
+xcrun xcodebuild -create-xcframework \
+	-framework "${OUTPUT_DIR}/iphoneos/CryptoSwift.framework" \
+	-framework "${OUTPUT_DIR}/iphonesimulator/CryptoSwift.framework" \
+	-framework "${OUTPUT_DIR}/appletvos/CryptoSwift.framework" \
+	-framework "${OUTPUT_DIR}/appletvsimulator/CryptoSwift.framework" \
+	-framework "${OUTPUT_DIR}/watchos/CryptoSwift.framework" \
+	-framework "${OUTPUT_DIR}/watchsimulator/CryptoSwift.framework" \
+	-framework "${OUTPUT_DIR}/macos/CryptoSwift.framework" \
+	-framework "${OUTPUT_DIR}/maccatalyst/CryptoSwift.framework" \
+	-output ${OUTPUT_DIR}/CryptoSwift.xcframework
+
+# zip CryptoSwift.xcframework.zip ${OUTPUT_DIR}/CryptoSwift.xcframework
+mv ${OUTPUT_DIR}/CryptoSwift.xcframework ${BASE_PWD}
+
+echo "✔️ CryptoSwift.xcframework"
+
+rm -rf ${OUTPUT_DIR}
+
+cd ${BASE_PWD}

+ 1 - 1
scripts/generate-contributors-list.sh

@@ -19,7 +19,7 @@ contributors=$( cd "$here"/.. && git shortlog -es | cut -f2 | sed 's/^/- /' )
 
 cat > "$here/../CONTRIBUTORS.txt" <<- EOF
 	For the purpose of tracking copyright, this is the list of individuals and
-	organizations who have contributed source code to ObjectivePGP.
+	organizations who have contributed source code to CryptoSwift.
 
 	### Contributors