Skip to content

Commit

Permalink
fix: set salt as empty (#232)
Browse files Browse the repository at this point in the history
* fix: set salt as empty

* fix: resolve comment
  • Loading branch information
Ezequiel Leanes authored Feb 3, 2024
1 parent c6a93cd commit e8bb502
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions Sources/XMTPiOS/Crypto.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<SHA256>.deriveKey(
inputKeyMaterial: SymmetricKey(data: secret),
salt: salt,
info: info,
outputByteCount: 32)
return key
} catch {
throw CryptoError.keyDerivationError
}
let key = HKDF<SHA256>.deriveKey(
inputKeyMaterial: SymmetricKey(data: secret),
salt: Data(),
info: info,
outputByteCount: 32)
return key
}

static func generateHmacSignature(secret: Data, info: Data, message: Data) throws -> Data {
Expand Down

0 comments on commit e8bb502

Please sign in to comment.