Skip to content

Commit f390e05

Browse files
author
Daniel
authored
[87] Implement direct encryption and symmetric JWKs (airsidemobile#92)
* Add direct encryption sketch * Change encryptor initializer parameter name * Add symmetric decryption * Make base64url and secure random public * [87] Implement symmetric JWKs * [87] Update gitignore * [87] Remove shared data file * [87] Commit workspace checks * [87] Add basic test suite for direct encryption * [87] Clean up encrypter * [87] Add swiftlint exception * [87] Update decryption * [87] Extend direct encryption tests * [87] Add old encrypter initializer for compatability * [87] Update tests fro encrypter init * [87] Add old decrypter init for comapatibility * [87] Update decrypter tests * [87] Update header tests for direct * [87] Update sym key documentation * [87] Add symmetric JWK tests * [87] Implement symmetirc jek set support and tests * Update readme * [87] Fix comment headers * [87] Fix more comments and some typos * [87] Fix formatting * [87] Formatting * [87] Add empty encrypted key commetn * [87] Formatting * [87] Add json to key doc * [87] Update error message * [87] Rename key type to OCT
1 parent 61c70b1 commit f390e05

30 files changed

+1049
-147
lines changed

.gitignore

+37-59
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
1+
2+
# Created by https://www.gitignore.io/api/xcode,macos,carthage,cocoapods
3+
4+
### Carthage ###
5+
# Carthage
16
#
2-
# macOS
3-
#
7+
# Add this line if you want to avoid checking in source code from Carthage dependencies.
8+
# Carthage/Checkouts
9+
10+
Carthage/Build
411

12+
### CocoaPods ###
13+
## CocoaPods GitIgnore Template
14+
15+
# CocoaPods - Only use to conserve bandwidth / Save time on Pushing
16+
# - Also handy if you have a large number of dependant pods
17+
# - AS PER https://guides.cocoapods.org/using/using-cocoapods.html NEVER IGNORE THE LOCK FILE
18+
Pods/
19+
20+
### macOS ###
521
# General
6-
*.DS_Store
22+
.DS_Store
723
.AppleDouble
824
.LSOverride
925

@@ -29,15 +45,22 @@ Network Trash Folder
2945
Temporary Items
3046
.apdisk
3147

32-
#
48+
### Xcode ###
3349
# Xcode
3450
#
51+
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
3552

36-
## Build generated
53+
## User settings
54+
xcuserdata/
55+
56+
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
57+
*.xcscmblueprint
58+
*.xccheckout
59+
60+
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
3761
build/
3862
DerivedData/
39-
40-
## Various settings
63+
*.moved-aside
4164
*.pbxuser
4265
!default.pbxuser
4366
*.mode1v3
@@ -46,58 +69,13 @@ DerivedData/
4669
!default.mode2v3
4770
*.perspectivev3
4871
!default.perspectivev3
49-
xcuserdata/
50-
**/xcuserdata/
51-
52-
## Other
53-
*.moved-aside
54-
*.xccheckout
55-
*.xcscmblueprint
5672

57-
## Obj-C/Swift specific
58-
*.hmap
59-
*.ipa
60-
*.dSYM.zip
61-
*.dSYM
73+
### Xcode Patch ###
74+
*.xcodeproj/*
75+
!*.xcodeproj/project.pbxproj
76+
!*.xcodeproj/xcshareddata/
77+
!*.xcworkspace/contents.xcworkspacedata
78+
/*.gcno
6279

63-
## Playgrounds
64-
timeline.xctimeline
65-
playground.xcworkspace
6680

67-
# Swift Package Manager
68-
#
69-
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
70-
# Packages/
71-
# Package.pins
72-
.build/
73-
74-
# CocoaPods
75-
#
76-
# We recommend against adding the Pods directory to your .gitignore. However
77-
# you should judge for yourself, the pros and cons are mentioned at:
78-
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
79-
#
80-
Pods/
81-
82-
# Carthage
83-
#
84-
# Add this line if you want to avoid checking in source code from Carthage dependencies.
85-
# Carthage/Checkouts
86-
87-
Carthage/Build
88-
89-
# fastlane
90-
#
91-
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
92-
# screenshots whenever they are needed.
93-
# For more information about the recommended setup visit:
94-
# https://docs.fastlane.tools/best-practices/source-control/#source-control
95-
96-
fastlane/report.xml
97-
fastlane/Preview.html
98-
fastlane/screenshots
99-
fastlane/test_output
100-
/test_output
101-
102-
.idea/
103-
sonar-reports/
81+
# End of https://www.gitignore.io/api/xcode,macos,carthage,cocoapods

JOSESwift.xcodeproj/project.pbxproj

+28-4
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@
99
/* Begin PBXBuildFile section */
1010
6505236E1FB4940100E0B1B1 /* AESEncrypter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6505236D1FB4940100E0B1B1 /* AESEncrypter.swift */; };
1111
650523701FB494BE00E0B1B1 /* AESDecrypter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6505236F1FB494BE00E0B1B1 /* AESDecrypter.swift */; };
12+
6506D9E920F4CA2000F34DD8 /* SymmetricKeyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6506D9E820F4CA2000F34DD8 /* SymmetricKeyTests.swift */; };
1213
65125A321FBF85FA007CF3AE /* JWSDeserializationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65125A311FBF85FA007CF3AE /* JWSDeserializationTests.swift */; };
1314
6514ADC92031DD15008A4DD3 /* ASN1DEREncoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6514ADC82031DD15008A4DD3 /* ASN1DEREncoding.swift */; };
1415
6514ADCB2031DD27008A4DD3 /* ASN1DEREncodingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6514ADCA2031DD27008A4DD3 /* ASN1DEREncodingTests.swift */; };
1516
652C613A1FD99A3300578E2A /* JWSSigningInputTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652C61391FD99A3300578E2A /* JWSSigningInputTest.swift */; };
1617
652F6DE91F73E6780002DEE0 /* Serializer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F6DE81F73E6780002DEE0 /* Serializer.swift */; };
1718
6533552A1F8F6B6800A660C6 /* JWEHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 653355291F8F6B6800A660C6 /* JWEHeader.swift */; };
1819
6533552E1F8FB61000A660C6 /* JWE.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6533552D1F8FB61000A660C6 /* JWE.swift */; };
20+
653365E520ECCB71002630D7 /* JWEDirectEncryptionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 653365E420ECCB71002630D7 /* JWEDirectEncryptionTests.swift */; };
21+
65344C3E20F4CC9000FCBBA1 /* DataSymmetricKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65344C3D20F4CC9000FCBBA1 /* DataSymmetricKey.swift */; };
1922
65353F5D1F750A6A003E099B /* DataExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65353F5C1F750A6A003E099B /* DataExtensions.swift */; };
2023
653656072035D6C700A3AC3B /* JWKSetCollectionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 653656062035D6C700A3AC3B /* JWKSetCollectionTests.swift */; };
2124
653656092035D86E00A3AC3B /* JWKSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 653656082035D86E00A3AC3B /* JWKSet.swift */; };
@@ -42,10 +45,13 @@
4245
65A77E941F7285A900A66DDE /* JOSEHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65A77E931F7285A900A66DDE /* JOSEHeader.swift */; };
4346
65A7A1991F7295F5009449E7 /* Payload.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65A7A1981F7295F5009449E7 /* Payload.swift */; };
4447
65A9D3DC1F45CDD7004E0B61 /* JOSESwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 65FBFDE21F45CC7C005C7D68 /* JOSESwift.framework */; };
48+
65A9EE4B20FDD7A900E9C566 /* EncrypterDecrypterInitializationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65A9EE4A20FDD7A900E9C566 /* EncrypterDecrypterInitializationTests.swift */; };
4549
65D1D0651F7A4DB3006377CD /* DataConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65D1D0641F7A4DB3006377CD /* DataConvertible.swift */; };
4650
65D1D0671F7A878D006377CD /* Deserializer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65D1D0661F7A878D006377CD /* Deserializer.swift */; };
4751
65D8680F1F7CE35000769BBF /* RSAVerifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65D8680E1F7CE35000769BBF /* RSAVerifier.swift */; };
4852
65D868111F7CEBA200769BBF /* Verifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65D868101F7CEBA200769BBF /* Verifier.swift */; };
53+
65D8E8E820F499EF0059506A /* SymmetricKeys.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65D8E8E720F499EF0059506A /* SymmetricKeys.swift */; };
54+
65D8E8EA20F4AF880059506A /* SymmetricKeyCodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65D8E8E920F4AF880059506A /* SymmetricKeyCodable.swift */; };
4955
65E733CC1FEBE8320009EAC6 /* JWKExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65E733CB1FEBE8320009EAC6 /* JWKExtensions.swift */; };
5056
65E733D11FEBF7960009EAC6 /* JWKParameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65E733D01FEBF7960009EAC6 /* JWKParameters.swift */; };
5157
65E733D31FEBFDB30009EAC6 /* JWKtoJSONTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65E733D21FEBFDB30009EAC6 /* JWKtoJSONTests.swift */; };
@@ -55,7 +61,7 @@
5561
65FBFDE71F45CC7C005C7D68 /* JOSESwift.h in Headers */ = {isa = PBXBuildFile; fileRef = 65FBFDE51F45CC7C005C7D68 /* JOSESwift.h */; settings = {ATTRIBUTES = (Public, ); }; };
5662
C803EFE51FA77E3000B71335 /* JWSTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C803EFE41FA77E3000B71335 /* JWSTests.swift */; };
5763
C803EFE91FA7893A00B71335 /* JWSHeaderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C803EFE81FA7893A00B71335 /* JWSHeaderTests.swift */; };
58-
C803EFED1FA8849C00B71335 /* JWETests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C803EFEC1FA8849C00B71335 /* JWETests.swift */; };
64+
C803EFED1FA8849C00B71335 /* JWERSATests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C803EFEC1FA8849C00B71335 /* JWERSATests.swift */; };
5965
C803EFEF1FA884C100B71335 /* JWEHeaderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C803EFEE1FA884C100B71335 /* JWEHeaderTests.swift */; };
6066
C803EFF31FA8A98F00B71335 /* DataExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C803EFF21FA8A98F00B71335 /* DataExtensionTests.swift */; };
6167
C81DBD581FFE66E700ECF69E /* AES.swift in Sources */ = {isa = PBXBuildFile; fileRef = C81DBD571FFE66E700ECF69E /* AES.swift */; };
@@ -101,13 +107,16 @@
101107
/* Begin PBXFileReference section */
102108
6505236D1FB4940100E0B1B1 /* AESEncrypter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AESEncrypter.swift; sourceTree = "<group>"; };
103109
6505236F1FB494BE00E0B1B1 /* AESDecrypter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AESDecrypter.swift; sourceTree = "<group>"; };
110+
6506D9E820F4CA2000F34DD8 /* SymmetricKeyTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SymmetricKeyTests.swift; sourceTree = "<group>"; };
104111
65125A311FBF85FA007CF3AE /* JWSDeserializationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JWSDeserializationTests.swift; sourceTree = "<group>"; };
105112
6514ADC82031DD15008A4DD3 /* ASN1DEREncoding.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ASN1DEREncoding.swift; sourceTree = "<group>"; };
106113
6514ADCA2031DD27008A4DD3 /* ASN1DEREncodingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ASN1DEREncodingTests.swift; sourceTree = "<group>"; };
107114
652C61391FD99A3300578E2A /* JWSSigningInputTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JWSSigningInputTest.swift; sourceTree = "<group>"; };
108115
652F6DE81F73E6780002DEE0 /* Serializer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Serializer.swift; sourceTree = "<group>"; };
109116
653355291F8F6B6800A660C6 /* JWEHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JWEHeader.swift; sourceTree = "<group>"; };
110117
6533552D1F8FB61000A660C6 /* JWE.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JWE.swift; sourceTree = "<group>"; };
118+
653365E420ECCB71002630D7 /* JWEDirectEncryptionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JWEDirectEncryptionTests.swift; sourceTree = "<group>"; };
119+
65344C3D20F4CC9000FCBBA1 /* DataSymmetricKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataSymmetricKey.swift; sourceTree = "<group>"; };
111120
65353F5C1F750A6A003E099B /* DataExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataExtensions.swift; sourceTree = "<group>"; };
112121
653656062035D6C700A3AC3B /* JWKSetCollectionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JWKSetCollectionTests.swift; sourceTree = "<group>"; };
113122
653656082035D86E00A3AC3B /* JWKSet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JWKSet.swift; sourceTree = "<group>"; };
@@ -135,10 +144,13 @@
135144
65A7A1981F7295F5009449E7 /* Payload.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Payload.swift; sourceTree = "<group>"; };
136145
65A9D3D71F45CDD7004E0B61 /* Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
137146
65A9D3DB1F45CDD7004E0B61 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
147+
65A9EE4A20FDD7A900E9C566 /* EncrypterDecrypterInitializationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EncrypterDecrypterInitializationTests.swift; sourceTree = "<group>"; };
138148
65D1D0641F7A4DB3006377CD /* DataConvertible.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataConvertible.swift; sourceTree = "<group>"; };
139149
65D1D0661F7A878D006377CD /* Deserializer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Deserializer.swift; sourceTree = "<group>"; };
140150
65D8680E1F7CE35000769BBF /* RSAVerifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RSAVerifier.swift; sourceTree = "<group>"; };
141151
65D868101F7CEBA200769BBF /* Verifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Verifier.swift; sourceTree = "<group>"; };
152+
65D8E8E720F499EF0059506A /* SymmetricKeys.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SymmetricKeys.swift; sourceTree = "<group>"; };
153+
65D8E8E920F4AF880059506A /* SymmetricKeyCodable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SymmetricKeyCodable.swift; sourceTree = "<group>"; };
142154
65E733CB1FEBE8320009EAC6 /* JWKExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JWKExtensions.swift; sourceTree = "<group>"; };
143155
65E733D01FEBF7960009EAC6 /* JWKParameters.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JWKParameters.swift; sourceTree = "<group>"; };
144156
65E733D21FEBFDB30009EAC6 /* JWKtoJSONTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JWKtoJSONTests.swift; sourceTree = "<group>"; };
@@ -150,7 +162,7 @@
150162
65FBFDE61F45CC7C005C7D68 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
151163
C803EFE41FA77E3000B71335 /* JWSTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JWSTests.swift; sourceTree = "<group>"; };
152164
C803EFE81FA7893A00B71335 /* JWSHeaderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JWSHeaderTests.swift; sourceTree = "<group>"; };
153-
C803EFEC1FA8849C00B71335 /* JWETests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JWETests.swift; sourceTree = "<group>"; };
165+
C803EFEC1FA8849C00B71335 /* JWERSATests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JWERSATests.swift; sourceTree = "<group>"; };
154166
C803EFEE1FA884C100B71335 /* JWEHeaderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JWEHeaderTests.swift; sourceTree = "<group>"; };
155167
C803EFF21FA8A98F00B71335 /* DataExtensionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataExtensionTests.swift; sourceTree = "<group>"; };
156168
C81DBD571FFE66E700ECF69E /* AES.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AES.swift; sourceTree = "<group>"; };
@@ -221,8 +233,10 @@
221233
isa = PBXGroup;
222234
children = (
223235
65676D8A1FC220C70031B26D /* JWEDeserializationTests.swift */,
224-
C803EFEC1FA8849C00B71335 /* JWETests.swift */,
236+
C803EFEC1FA8849C00B71335 /* JWERSATests.swift */,
225237
C803EFEE1FA884C100B71335 /* JWEHeaderTests.swift */,
238+
653365E420ECCB71002630D7 /* JWEDirectEncryptionTests.swift */,
239+
65A9EE4A20FDD7A900E9C566 /* EncrypterDecrypterInitializationTests.swift */,
226240
);
227241
name = JWE;
228242
sourceTree = "<group>";
@@ -327,6 +341,7 @@
327341
65684A4E2031971A00E56C68 /* RSAPublicKeyToSecKeyTests.swift */,
328342
653656062035D6C700A3AC3B /* JWKSetCollectionTests.swift */,
329343
6536560A2035DC3900A3AC3B /* JWKSetCodingTests.swift */,
344+
6506D9E820F4CA2000F34DD8 /* SymmetricKeyTests.swift */,
330345
);
331346
name = JWK;
332347
sourceTree = "<group>";
@@ -340,6 +355,8 @@
340355
653656082035D86E00A3AC3B /* JWKSet.swift */,
341356
6536560C2035DF8300A3AC3B /* JWKSetCodable.swift */,
342357
65F44EB21FE2E1C6000C5EA0 /* RSAKeys.swift */,
358+
65D8E8E720F499EF0059506A /* SymmetricKeys.swift */,
359+
65D8E8E920F4AF880059506A /* SymmetricKeyCodable.swift */,
343360
65826AB12028696000AFFC46 /* RSAKeyCodable.swift */,
344361
6582614E2029F2D100B594ED /* ASN1DERParsing.swift */,
345362
6514ADC82031DD15008A4DD3 /* ASN1DEREncoding.swift */,
@@ -423,6 +440,7 @@
423440
isa = PBXGroup;
424441
children = (
425442
6582614C2029E98A00B594ED /* DataRSAPublicKey.swift */,
443+
65344C3D20F4CC9000FCBBA1 /* DataSymmetricKey.swift */,
426444
6546FB0E2029DD10002E421F /* SecKeyRSAPublicKey.swift */,
427445
C85012E21FE04E0C00EC49FA /* SecureRandom.swift */,
428446
C81DD9271FD7096100026024 /* HMAC.swift */,
@@ -595,6 +613,9 @@
595613
6536560B2035DC3900A3AC3B /* JWKSetCodingTests.swift in Sources */,
596614
65676D8B1FC220C70031B26D /* JWEDeserializationTests.swift in Sources */,
597615
6546D606203580C6007217FB /* JWKRSADecodingTests.swift in Sources */,
616+
65A9EE4B20FDD7A900E9C566 /* EncrypterDecrypterInitializationTests.swift in Sources */,
617+
653365E520ECCB71002630D7 /* JWEDirectEncryptionTests.swift in Sources */,
618+
6506D9E920F4CA2000F34DD8 /* SymmetricKeyTests.swift in Sources */,
598619
65684A4D2031935200E56C68 /* RSAPublicKeyToDataTests.swift in Sources */,
599620
6575696D203EF9CE004A0EFD /* JWSValidationTests.swift in Sources */,
600621
65A103A1202B03BB00D22BF5 /* ASN1DERParsingTests.swift in Sources */,
@@ -606,7 +627,7 @@
606627
C803EFE51FA77E3000B71335 /* JWSTests.swift in Sources */,
607628
C84BDE191FAB44BE0002B5D0 /* CryptoTestCase.swift in Sources */,
608629
6514ADCB2031DD27008A4DD3 /* ASN1DEREncodingTests.swift in Sources */,
609-
C803EFED1FA8849C00B71335 /* JWETests.swift in Sources */,
630+
C803EFED1FA8849C00B71335 /* JWERSATests.swift in Sources */,
610631
C8F096501FC56B25000BEE4D /* RSAEncrypterTests.swift in Sources */,
611632
65125A321FBF85FA007CF3AE /* JWSDeserializationTests.swift in Sources */,
612633
65A103A3202B0CDF00D22BF5 /* DataRSAPublicKeyTests.swift in Sources */,
@@ -646,10 +667,13 @@
646667
65826AB22028696000AFFC46 /* RSAKeyCodable.swift in Sources */,
647668
C8610F092029B15600859FCC /* Algorithms.swift in Sources */,
648669
6505236E1FB4940100E0B1B1 /* AESEncrypter.swift in Sources */,
670+
65D8E8E820F499EF0059506A /* SymmetricKeys.swift in Sources */,
649671
65D1D0651F7A4DB3006377CD /* DataConvertible.swift in Sources */,
650672
6533552E1F8FB61000A660C6 /* JWE.swift in Sources */,
651673
C85B1EF4204D82860026BDCB /* Signer.swift in Sources */,
674+
65D8E8EA20F4AF880059506A /* SymmetricKeyCodable.swift in Sources */,
652675
C85B1EF6204D82970026BDCB /* RSASigner.swift in Sources */,
676+
65344C3E20F4CC9000FCBBA1 /* DataSymmetricKey.swift in Sources */,
653677
65D868111F7CEBA200769BBF /* Verifier.swift in Sources */,
654678
C86B876D203D857B00208387 /* JOSESwiftError.swift in Sources */,
655679
65A77E941F7285A900A66DDE /* JOSEHeader.swift in Sources */,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

JOSESwift/Sources/AESDecrypter.swift

+8
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,15 @@ import Foundation
2525

2626
/// A `SymmetricDecrypter` to decrypt a cipher text with an `AES` algorithm.
2727
internal struct AESDecrypter: SymmetricDecrypter {
28+
typealias KeyType = AES.KeyType
29+
2830
let algorithm: SymmetricKeyAlgorithm
31+
let symmetricKey: KeyType?
32+
33+
init(algorithm: SymmetricKeyAlgorithm, symmetricKey: KeyType? = nil) {
34+
self.algorithm = algorithm
35+
self.symmetricKey = symmetricKey
36+
}
2937

3038
func decrypt(_ context: SymmetricDecryptionContext, with symmetricKey: Data) throws -> Data {
3139
// Check if the key length contains both HMAC key and the actual symmetric key.

JOSESwift/Sources/AESEncrypter.swift

+8
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,15 @@ import Foundation
2525

2626
/// A `SymmetricEncrypter` to encrypt plaintext with an `AES` algorithm.
2727
internal struct AESEncrypter: SymmetricEncrypter {
28+
typealias KeyType = AES.KeyType
29+
2830
let algorithm: SymmetricKeyAlgorithm
31+
let symmetricKey: KeyType?
32+
33+
init(algorithm: SymmetricKeyAlgorithm, symmetricKey: KeyType? = nil) {
34+
self.algorithm = algorithm
35+
self.symmetricKey = symmetricKey
36+
}
2937

3038
func encrypt(_ plaintext: Data, with symmetricKey: Data, additionalAuthenticatedData: Data) throws -> SymmetricEncryptionContext {
3139
// Generate random intitialization vector.

0 commit comments

Comments
 (0)