From e8bb50299de9554a3df1da511fe2e4a3c63a9348 Mon Sep 17 00:00:00 2001 From: Ezequiel Leanes Date: Sat, 3 Feb 2024 15:54:01 -0300 Subject: [PATCH] fix: set salt as empty (#232) * fix: set salt as empty * fix: resolve comment --- Sources/XMTPiOS/Crypto.swift | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/Sources/XMTPiOS/Crypto.swift b/Sources/XMTPiOS/Crypto.swift index 4f3e7126..72c397a7 100644 --- a/Sources/XMTPiOS/Crypto.swift +++ b/Sources/XMTPiOS/Crypto.swift @@ -8,7 +8,7 @@ import Foundation public typealias CipherText = Xmtp_MessageContents_Ciphertext enum CryptoError: Error { - case randomBytes, combinedPayload, keyDerivationError, hmacSignatureError + case randomBytes, combinedPayload, hmacSignatureError } enum Crypto { @@ -105,17 +105,12 @@ enum Crypto { } static func hkdfHmacKey(secret: Data, info: Data) throws -> SymmetricKey { - do { - let salt = try secureRandomBytes(count: 32) - let key = HKDF.deriveKey( - inputKeyMaterial: SymmetricKey(data: secret), - salt: salt, - info: info, - outputByteCount: 32) - return key - } catch { - throw CryptoError.keyDerivationError - } + let key = HKDF.deriveKey( + inputKeyMaterial: SymmetricKey(data: secret), + salt: Data(), + info: info, + outputByteCount: 32) + return key } static func generateHmacSignature(secret: Data, info: Data, message: Data) throws -> Data {