@@ -85,4 +85,8 @@ public struct HKDF {
}
return Array(ret.prefix(self.dkLen))
+
+ public func callAsFunction() throws -> Array<UInt8> {
+ try calculate()
+ }
@@ -61,6 +61,11 @@ public final class MD5: DigestType {
+ public func callAsFunction(_ bytes: Array<UInt8>) -> Array<UInt8> {
+ calculate(for: bytes)
// mutating currentHash in place is way faster than returning new result
fileprivate func process(block chunk: ArraySlice<UInt8>, currentHash: inout Array<UInt32>) {
assert(chunk.count == 16 * 4)
@@ -93,5 +93,9 @@ public extension PKCS5 {
return Array(t[0..<self.keyLength])
+ public func callAsFunction() -> Array<UInt8> {
+ calculate()
@@ -83,6 +83,10 @@ public extension PKCS5 {
@@ -45,6 +45,10 @@ public final class SHA1: DigestType {
@usableFromInline
func process(block chunk: ArraySlice<UInt8>, currentHash hh: inout ContiguousArray<UInt32>) {
// break chunk into sixteen 32-bit words M[j], 0 ≤ j ≤ 15, big-endian
@@ -169,6 +169,10 @@ public final class SHA2: DigestType {
func process64(block chunk: ArraySlice<UInt8>, currentHash hh: inout Array<UInt64>) {
// break chunk into sixteen 64-bit words M[j], 0 ≤ j ≤ 15, big-endian
@@ -96,6 +96,10 @@ public final class SHA3: DigestType {
/// 1. For all pairs (x,z) such that 0≤x<5 and 0≤z<w, let
/// C[x,z]=A[x, 0,z] ⊕ A[x, 1,z] ⊕ A[x, 2,z] ⊕ A[x, 3,z] ⊕ A[x, 4,z].
/// 2. For all pairs (x, z) such that 0≤x<5 and 0≤z<w let
@@ -101,6 +101,11 @@ public final class Scrypt {
let block = [UInt8](bufferPointer)
return try PKCS5.PBKDF2(password: Array(self.password), salt: block, iterations: 1, keyLength: self.dkLen, variant: .sha2(.sha256)).calculate()
private extension Scrypt {