You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When Trtying AES-GCM encrpyption, the IV and AES Key need to be hex-encoded string converted to Array and does not work random Data converted to Array.
Is this expected to working this way or am i missing any point , I am using Swift random IV and key Generator
public static func generate(count: Int) throws -> Data {
guard count > 0 else {
throw SecureRandomError.countMustBeGreaterThanZero
}
var generatedRandom = Data(count: count)
let randomGenerationStatus = generatedRandom.withUnsafeMutableBytes { mutableRandomBytes in
// Force unwrapping is ok, since the buffer is guaranteed not to be empty.
// From the docs: If the baseAddress of this buffer is nil, the count is zero.
// swiftlint:disable:next force_unwrapping
SecRandomCopyBytes(kSecRandomDefault, count, mutableRandomBytes.baseAddress!)
}
guard randomGenerationStatus == errSecSuccess else {
throw SecureRandomError.failed(status: randomGenerationStatus)
}
return generatedRandom
}
This discussion was converted from issue #847 on July 17, 2022 13:15.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Describe the bug
When Trtying AES-GCM encrpyption, the IV and AES Key need to be hex-encoded string converted to Array and does not work random Data converted to Array.
Is this expected to working this way or am i missing any point , I am using Swift random IV and key Generator
public static func generate(count: Int) throws -> Data {
guard count > 0 else {
throw SecureRandomError.countMustBeGreaterThanZero
}
Reproduce
Steps to reproduce:
1.
Beta Was this translation helpful? Give feedback.
All reactions