I want to use the aes-128-ctr in Swift with the CryptoSwift library, however my resulting ciphertext is too long.
My IV is 16 bytes, salt 32 bytes and the aes plaintext is also 32 bytes, why is the resulting ciphertext 48 bytes, thus padded with another 16 bytes?
let salt: [UInt8] = Array("tkmlidnonknkqgvapjrpdcductebsozn".utf8)
let derivedKey = try PKCS5.PBKDF2(password: password, salt: salt, iterations: numberOfIterations, variant: .sha256).calculate()
let iv: [UInt8] = Array("abcdefgthksdfghj".utf8)
let aesKey: [UInt8] = Array(derivedKey[..<16])
let aes = try AES(key: aesKey, blockMode: .CTR(iv: iv))
let ciphertext = try aes.encrypt(password)
here the password is the mentioned 32 bytes plaintext.
Additionally, is there any way to generate a random salt? I found that
let iv: [UInt8] = AES.randomIV(AES.blockSize)
generates a random IV, however how do I get such a salt?