onmyway133 / Arcane

:trident: CommonCrypto in Swift, and more

Home Page:https://onmyway133.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Possibly Incorrect Key Size for AES Encryption?

james-rant opened this issue · comments

Arcane/Sources/AES.swift

Lines 48 to 59 in 44c3013

let hashKeyData = hashData.subdata(in: 0..<32)
let ivData = hashData.subdata(in: 32..<48)
let operation = encrypting ? kCCEncrypt : kCCDecrypt
var dataOutMovedLength: size_t = 0
let status = CCCrypt(
CCOperation(operation),
CCAlgorithm(kCCAlgorithmAES128),
CCOptions(kCCOptionPKCS7Padding),
(hashKeyData as NSData).bytes,
kCCKeySizeAES128,

I'm by no means an expert, and I'm quite likely wrong, but when looking at the code linked above, it would appear to me that a 128-bit key size is incorrect when you specify a 32 Byte (256-bit) key data.

Is there perhaps something I'm not understanding?

commented

@james-rantmedia Let's discuss over PR 😉