Skip to content

Commit 406ac20

Browse files
read nonce length from ContentCryptor
1 parent a015234 commit 406ac20

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Sources/CryptomatorCryptoLib/Cryptor.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public class Cryptor {
154154
// MARK: - File Header Encryption and Decryption
155155

156156
func createHeader() throws -> FileHeader {
157-
let nonce = try cryptoSupport.createRandomBytes(size: kCCBlockSizeAES128)
157+
let nonce = try cryptoSupport.createRandomBytes(size: contentCryptor.nonceLen)
158158
let contentKey = try cryptoSupport.createRandomBytes(size: kCCKeySizeAES256)
159159
return FileHeader(nonce: nonce, contentKey: contentKey)
160160
}
@@ -301,7 +301,7 @@ public class Cryptor {
301301
}
302302

303303
func encryptSingleChunk(_ chunk: [UInt8], chunkNumber: UInt64, headerNonce: [UInt8], fileKey: [UInt8]) throws -> [UInt8] {
304-
let chunkNonce = try cryptoSupport.createRandomBytes(size: kCCBlockSizeAES128)
304+
let chunkNonce = try cryptoSupport.createRandomBytes(size: contentCryptor.nonceLen)
305305
return try contentCryptor.encrypt(chunk, key: fileKey, nonce: chunkNonce, ad: headerNonce, chunkNumber.bigEndian.byteArray())
306306
}
307307

0 commit comments

Comments
 (0)