|
14 | 14 | #if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
|
15 | 15 | @_exported import CryptoKit
|
16 | 16 | #else
|
| 17 | +#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION |
| 18 | +import SwiftSystem |
| 19 | +#else |
17 | 20 | import Foundation
|
| 21 | +#endif |
18 | 22 | // MARK: - Generated file, do NOT edit
|
19 | 23 | // any edits of this file WILL be overwritten and thus discarded
|
20 | 24 | // see section `gyb` in `README` for details.
|
| 25 | + |
21 | 26 | %{
|
22 |
| -ciphers = [{"name": "AES.GCM", "recommendedNonceSize": "AES.GCM.defaultNonceByteCount", "nonceValidation": "< AES.GCM.defaultNonceByteCount"},{"name": "ChaChaPoly", "recommendedNonceSize": "ChaChaPoly.nonceByteCount", "nonceValidation": "!= ChaChaPoly.nonceByteCount"}] |
| 27 | +ciphers = [{"name": "AES.GCM", "recommendedNonceSize": "AES.GCM.defaultNonceByteCount", "nonceValidation": "< AES.GCM.defaultNonceByteCount", "dataDescription": "/// - data: A data representation of the nonce.\n/// The initializer throws an error if the data has a length smaller than 12 bytes."}] |
| 28 | + |
| 29 | +if "NO_CHACHAPOLY" in globals(): |
| 30 | + pass |
| 31 | +else: |
| 32 | + ciphers.append({"name": "ChaChaPoly", "recommendedNonceSize": "ChaChaPoly.nonceByteCount", "nonceValidation": "!= ChaChaPoly.nonceByteCount", "dataDescription": "/// - data: A 12-byte data representation of the nonce.\n/// The initializer throws an error if the data isn't 12 bytes long."}) |
23 | 33 | }%
|
| 34 | + |
| 35 | + |
24 | 36 | % for cipher in ciphers:
|
25 | 37 | %{
|
26 | 38 | name = cipher["name"]
|
27 | 39 | nonceSize = cipher["recommendedNonceSize"]
|
28 | 40 | nonceValidation = cipher["nonceValidation"]
|
| 41 | +dataDescription = cipher["dataDescription"] |
29 | 42 | }%
|
30 | 43 |
|
31 | 44 | // MARK: - ${name} + Nonce
|
@@ -56,8 +69,7 @@ extension ${name} {
|
56 | 69 | /// ``init()`` method to instead create a random nonce.
|
57 | 70 | ///
|
58 | 71 | /// - Parameters:
|
59 |
| - /// - data: A 12-byte data representation of the nonce. The initializer throws an |
60 |
| - /// error if the data has a length other than 12 bytes. |
| 72 | +${dataDescription} |
61 | 73 | public init<D: DataProtocol>(data: D) throws {
|
62 | 74 | if data.count ${nonceValidation} {
|
63 | 75 | throw CryptoKitError.incorrectParameterSize
|
|
0 commit comments