Can I use AES128 with GCM mode on iOS?

So, my question is for stackoverflow verbs: if there is a way (native, library, framework, whatever ..) for encrypting data with AES (preferably 128, but maybe also 256) using strong Initialized encryption algorithm , say GCM mode ?

The question is short, I did some research and I found only one library that seems to support it ( RNCryptor ), but it also seems to use a password for encryption instead of keys (for example, you provide a password and the library made a key), and I don’t like it, I prefer to manage my keys independently .

I also look at CommonCryptor.h , and I found this line, which seems to me to be the only GCM link in the commoncryptor source code (but I could be wrong, in fact I probably am wrong):

case kCCModeGCM: if((ref->symMode[direction].gcm = getCipherMode(cipher, mode, direction).gcm) == NULL) return kCCUnimplemented;

Thanks in advance!

+4
source share
3 answers

Thanks owlstead, I looked deeper into RNCryptor and found a solution.

First of all, after many searches, it seems that Zaph was right, and iOS does not provide GCM, but uses it in iOS. ref there: iOS Security feb 2014

-, RNCryptor GCM, AES256 CBC (Cipher Block Chaining), , HMAC + SHA1. .

, RNCryptor :

NSData *encryptedData = [RNEncryptor encryptData:yourData
                                        withSettings:kRNCryptorAES256Settings
                                       encryptionKey:encryptionKey
                                             HMACKey:HMACKey
                                               error:&error];

NSData *decryptedData = [RNDecryptor decryptData:encryptedData withEncryptionKey:encryptionKey HMACKey:HMACKey error:&decryptionError];

RNCryptor .

: AES256, : , , AES256, :

+2

RNCryptor HMAC, . . RNCryptor ( !).

(, , IV), . , .

, , - , , /, RNCryptor.

+2

GCM CommonCrypto. , Apple GCM ios5.

+1

Source: https://habr.com/ru/post/1540719/


All Articles