diff --git a/Sources/web3swift/KeystoreManager/BIP32HDNode.swift b/Sources/web3swift/KeystoreManager/BIP32HDNode.swift index 267b7f024..e76cf7017 100755 --- a/Sources/web3swift/KeystoreManager/BIP32HDNode.swift +++ b/Sources/web3swift/KeystoreManager/BIP32HDNode.swift @@ -100,7 +100,7 @@ public class HDNode { public init?(seed: Data) { guard seed.count >= 16 else {return nil} let hmacKey = "Bitcoin seed".data(using: .ascii)! - let hmac:Authenticator = HMAC(key: hmacKey.bytes, variant: HMAC.Variant.sha512) + let hmac:Authenticator = HMAC(key: hmacKey.bytes, variant: HMAC.Variant.sha2(.sha512)) guard let entropy = try? hmac.authenticate(seed.bytes) else {return nil} guard entropy.count == 64 else { return nil} let I_L = entropy[0..<32] @@ -135,7 +135,7 @@ extension HDNode { if trueIndex < (UInt32(1) << 31) { trueIndex = trueIndex + (UInt32(1) << 31) } - let hmac:Authenticator = HMAC(key: self.chaincode.bytes, variant: .sha512) + let hmac:Authenticator = HMAC(key: self.chaincode.bytes, variant: .sha2(.sha512)) var inputForHMAC = Data() inputForHMAC.append(Data([UInt8(0x00)])) inputForHMAC.append(self.privateKey!) @@ -145,7 +145,7 @@ extension HDNode { entropy = ent } else { trueIndex = index - let hmac:Authenticator = HMAC(key: self.chaincode.bytes, variant: .sha512) + let hmac:Authenticator = HMAC(key: self.chaincode.bytes, variant: .sha2(.sha512)) var inputForHMAC = Data() inputForHMAC.append(self.publicKey) inputForHMAC.append(trueIndex.serialize32()) @@ -203,7 +203,7 @@ extension HDNode { if index >= (UInt32(1) << 31) || hardened { return nil // no derivation of hardened public key from extended public key } else { - let hmac:Authenticator = HMAC(key: self.chaincode.bytes, variant: .sha512) + let hmac:Authenticator = HMAC(key: self.chaincode.bytes, variant: .sha2(.sha512)) var inputForHMAC = Data() inputForHMAC.append(self.publicKey) inputForHMAC.append(index.serialize32()) diff --git a/Sources/web3swift/KeystoreManager/BIP32Keystore.swift b/Sources/web3swift/KeystoreManager/BIP32Keystore.swift index 9fc8f8935..929ce8436 100755 --- a/Sources/web3swift/KeystoreManager/BIP32Keystore.swift +++ b/Sources/web3swift/KeystoreManager/BIP32Keystore.swift @@ -297,11 +297,11 @@ public class BIP32Keystore: AbstractKeystore { var hashVariant: HMAC.Variant?; switch algo { case "hmac-sha256": - hashVariant = HMAC.Variant.sha256 + hashVariant = HMAC.Variant.sha2(.sha256) case "hmac-sha384": - hashVariant = HMAC.Variant.sha384 + hashVariant = HMAC.Variant.sha2(.sha384) case "hmac-sha512": - hashVariant = HMAC.Variant.sha512 + hashVariant = HMAC.Variant.sha2(.sha512) default: hashVariant = nil } diff --git a/Sources/web3swift/KeystoreManager/BIP39.swift b/Sources/web3swift/KeystoreManager/BIP39.swift index 93df2f923..1cb6ff988 100755 --- a/Sources/web3swift/KeystoreManager/BIP39.swift +++ b/Sources/web3swift/KeystoreManager/BIP39.swift @@ -150,7 +150,7 @@ public class BIP39 { guard let mnemData = mnemonics.decomposedStringWithCompatibilityMapping.data(using: .utf8) else {return nil} let salt = "mnemonic" + password guard let saltData = salt.decomposedStringWithCompatibilityMapping.data(using: .utf8) else {return nil} - guard let seedArray = try? PKCS5.PBKDF2(password: mnemData.bytes, salt: saltData.bytes, iterations: 2048, keyLength: 64, variant: HMAC.Variant.sha512).calculate() else {return nil} + guard let seedArray = try? PKCS5.PBKDF2(password: mnemData.bytes, salt: saltData.bytes, iterations: 2048, keyLength: 64, variant: HMAC.Variant.sha2(.sha512)).calculate() else {return nil} // let seed = Data(bytes:seedArray) let seed = Data(seedArray) return seed diff --git a/Sources/web3swift/KeystoreManager/EthereumKeystoreV3.swift b/Sources/web3swift/KeystoreManager/EthereumKeystoreV3.swift index 775268a74..84cebdd3f 100755 --- a/Sources/web3swift/KeystoreManager/EthereumKeystoreV3.swift +++ b/Sources/web3swift/KeystoreManager/EthereumKeystoreV3.swift @@ -182,11 +182,11 @@ public class EthereumKeystoreV3: AbstractKeystore { var hashVariant: HMAC.Variant?; switch algo { case "hmac-sha256": - hashVariant = HMAC.Variant.sha256 + hashVariant = HMAC.Variant.sha2(.sha256) case "hmac-sha384": - hashVariant = HMAC.Variant.sha384 + hashVariant = HMAC.Variant.sha2(.sha384) case "hmac-sha512": - hashVariant = HMAC.Variant.sha512 + hashVariant = HMAC.Variant.sha2(.sha512) default: hashVariant = nil }