include::../description.adoc[]

== Noncompliant Code Example

CommonCrypto library:

----
import CommonCrypto

let algorithm = CCAlgorithm(kCCAlgorithmDES) // Noncompliant: 64 bits block size
----

https://github.com/iosdevzone/IDZSwiftCommonCrypto[IDZSwiftCommonCrypto] library:

----
import IDZSwiftCommonCrypto

let algorithm = .des // Noncompliant: 64 bits block size
----

https://github.com/krzyzanowskim/CryptoSwift[CryptoSwift]

----
import CryptoSwift

let blowfish = try Blowfish(key: key, blockMode: GCM(iv: iv, mode: .combined), padding: .pkcs7) // Noncompliant: 64 bits block size
----

== Compliant Solution

https://swift.org/blog/crypto/[Swift Crypto] library: prefer using this library which is native and officially supported by Apple

----
import Crypto

let sealedBox = try AES.GCM.seal(input, using: key) // Compliant
----

CommonCrypto library:

----
import CommonCrypto

let algorithm = CCAlgorithm(kCCAlgorithmAES) // Compliant
----

https://github.com/iosdevzone/IDZSwiftCommonCrypto[IDZSwiftCommonCrypto] library:

----
import IDZSwiftCommonCrypto

let algorithm = .aes // Compliant
----

https://github.com/krzyzanowskim/CryptoSwift[CryptoSwift]

----
import CryptoSwift

let aes = try AES(key: key, iv: iv) // Compliant
----

include::../see.adoc[]

ifdef::rspecator-view[]
== Comments And Links
(visible only on this page)

include::../comments-and-links.adoc[]
endif::rspecator-view[]
