Support of AES 256 with GCM not possible in iOS? [duplicate]

梦想与她 提交于 2019-12-20 07:35:06

问题


Currently the encryption mode supported with AES 256 is CBC. But I want to use AES 256 encryption with GCM mode along with PKCS5Padding / PKCS7Padding.

Do let me know how it can be done ?


回答1:


Common Crypto does not support GCM. But there is an implementation of AES GCM in the Security.framework, and you can add your own header file to use it. However associated data (AEAD) does not work.

From SO Answer by soyer:

CCCryptorStatus CCCryptorGCM(
                 CCOperation     op, // kCCEncrypt, kCCDecrypt
                 CCAlgorithm     kCCAlgorithmAES,
                 const void      *key,    size_t  keyLength,
                 const void      *iv,     size_t  ivLen,
                 const void      *aData,  size_t  aDataLen, // does not work
                 const void      *dataIn, size_t  dataInLength,
                 void            *dataOut,
                 const void      *tag,    size_t *tagLength);

There is an implemntation AES GCM on github that seems reasonable albiet slow in comparison to Common Crypto. Use at your own risk.



来源:https://stackoverflow.com/questions/40213648/support-of-aes-256-with-gcm-not-possible-in-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!