Adding gyb discrepancy check to sanity script. (#13)

* 1) Adding gyb to scripts
2) Adding warning in gyb files about gyb overwritting manual edits to gyb generated swift files
3) Updated README with gyb instructions
4) Adding script for running all gyb generation
5) Adding CI check for discrepancies in gyb generated files

* Updating Dockerfile
This commit is contained in:
Alexander Cyon authored and GitHub committed 2020-02-05 17:44:21 +00:00
1 parent 36ea42cbb3
commit de232cbd67
15 files changed
+1366 -20

No files matched your search

+3
View File
@@ -15,6 +15,9 @@
@_exported import CryptoKit
#else
import Foundation
// MARK: - Generated file, do NOT edit
// any edits of this file WILL be overwritten and thus discarded
// see section `gyb` in `README` for details.
extension AES.GCM {
public struct Nonce: ContiguousBytes, Sequence {
+3
View File
@@ -15,6 +15,9 @@
@_exported import CryptoKit
#else
import Foundation
// MARK: - Generated file, do NOT edit
// any edits of this file WILL be overwritten and thus discarded
// see section `gyb` in `README` for details.
%{
ciphers = [{"name": "AES.GCM", "recommendedNonceSize": "AES.GCM.defaultNonceByteCount", "nonceValidation": "< AES.GCM.defaultNonceByteCount"},{"name": "ChaChaPoly", "recommendedNonceSize": "ChaChaPoly.nonceByteCount", "nonceValidation": "!= ChaChaPoly.nonceByteCount"}]
}%
+5 -1
View File
@@ -14,6 +14,9 @@
#if (os(macOS) || os(iOS) || os(watchOS) || os(tvOS)) && CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
// MARK: - Generated file, do NOT edit
// any edits of this file WILL be overwritten and thus discarded
// see section `gyb` in `README` for details.
@available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, macCatalyst 13.0, *)
public struct SHA256Digest: DigestPrivate {
@@ -61,6 +64,7 @@ public struct SHA256Digest: DigestPrivate {
}
}
@available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, macCatalyst 13.0, *)
public struct SHA384Digest: DigestPrivate {
let bytes: (UInt64, UInt64, UInt64, UInt64, UInt64, UInt64)
@@ -109,6 +113,7 @@ public struct SHA384Digest: DigestPrivate {
}
}
@available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, macCatalyst 13.0, *)
public struct SHA512Digest: DigestPrivate {
let bytes: (UInt64, UInt64, UInt64, UInt64, UInt64, UInt64, UInt64, UInt64)
@@ -205,7 +210,6 @@ public struct SHA1Digest: DigestPrivate {
}
}
}
extension Insecure {
@available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, macCatalyst 13.0, *)
public struct MD5Digest: DigestPrivate {
+5 -6
View File
@@ -14,27 +14,26 @@
#if (os(macOS) || os(iOS) || os(watchOS) || os(tvOS)) && CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
// MARK: - Generated file, do NOT edit
// any edits of this file WILL be overwritten and thus discarded
// see section `gyb` in `README` for details.
%{
digests_and_length = [{"name": "SHA256", "count": 32},{"name": "SHA384","count":48},{"name":"SHA512", "count": 64},{"name":"SHA1", "count":20, "prefix":"Insecure"},{"name":"MD5", "count":16, "prefix":"Insecure"}]
}%
% for HF in digests_and_length:
%{
name = HF["name"]
byteCount = HF["count"]
wordsCount = (byteCount*8)/64 + (0 if ((byteCount*8)%64) == 0 else 1)
}%
%{
if "prefix" in HF.keys():
protocol_prefix = "extension " + HF["prefix"] + "{"
protocol_prefix = "extension " + HF["prefix"] + " {"
protocol_suffix = "}"
else:
protocol_prefix = ""
protocol_suffix = ""
}%
${protocol_prefix}
@available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, macCatalyst 13.0, *)
public struct ${name}Digest: DigestPrivate {
@@ -78,7 +77,7 @@ public struct ${name}Digest: DigestPrivate {
}
public func hash(into hasher: inout Hasher) {
self.withUnsafeBytes {hasher.combine(bytes: $0)}
self.withUnsafeBytes { hasher.combine(bytes: $0) }
}
}
${protocol_suffix}
+3
View File
@@ -23,6 +23,9 @@ typealias NISTCurvePrivateKeyImpl = OpenSSLNISTCurvePrivateKeyImpl
#endif
import Foundation
// MARK: - Generated file, do NOT edit
// any edits of this file WILL be overwritten and thus discarded
// see section `gyb` in `README` for details.
extension P256 {
public enum Signing {
+3 -4
View File
@@ -23,13 +23,13 @@ typealias NISTCurvePrivateKeyImpl = OpenSSLNISTCurvePrivateKeyImpl
#endif
import Foundation
// MARK: - Generated file, do NOT edit
// any edits of this file WILL be overwritten and thus discarded
// see section `gyb` in `README` for details.
%{
NIST_CURVES = ["P256", "P384", "P521"]
CURVES_FUNC = ["Signing", "KeyAgreement"]
}%
% for CURVE in NIST_CURVES:
% for FUNC in CURVES_FUNC:
@@ -90,7 +90,6 @@ extension ${CURVE} {
% end
% end
% for CURVE in NIST_CURVES:
extension ${CURVE}.KeyAgreement.PrivateKey: DiffieHellmanKeyAgreement {
/// Performs a key agreement with provided public key share.
+3
View File
@@ -15,6 +15,9 @@
@_exported import CryptoKit
#else
import Foundation
// MARK: - Generated file, do NOT edit
// any edits of this file WILL be overwritten and thus discarded
// see section `gyb` in `README` for details.
protocol NISTECDSASignature {
init<D: DataProtocol>(rawRepresentation: D) throws
+5 -5
View File
@@ -15,7 +15,9 @@
@_exported import CryptoKit
#else
import Foundation
// MARK: - Generated file, do NOT edit
// any edits of this file WILL be overwritten and thus discarded
// see section `gyb` in `README` for details.
%{
NIST_CURVES_AND_HF = [{"curve": "P256", "hf": "SHA256"},{"curve": "P384", "hf": "SHA384"},{"curve": "P521", "hf": "SHA512"}]
}%
@@ -38,7 +40,6 @@ protocol NISTSigning {
CURVE = CURVE_AND_HF["curve"]
HF = CURVE_AND_HF["hf"]
}%
/// An ECDSA (Elliptic Curve Digital Signature Algorithm) Signature
extension ${CURVE}.Signing {
public struct ECDSASignature: ContiguousBytes, NISTECDSASignature {
@@ -67,8 +68,8 @@ extension ${CURVE}.Signing {
var composite: (r: Data, s: Data) {
let combined = rawRepresentation
assert(combined.count%2 == 0)
let half = combined.count/2
assert(combined.count % 2 == 0)
let half = combined.count / 2
return (combined.prefix(upTo: half), combined.suffix(from: half))
}
@@ -155,5 +156,4 @@ extension ${CURVE}.Signing.PublicKey: DigestValidator {
}
% end
#endif // Linux or !SwiftPM