indisoluble / AesGcm

(DEPRECATED - USE: https://developer.apple.com/documentation/cryptokit/aes/gcm) Galois/Counter Mode (GCM) with Advanced Encryption System (AES).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to get cipheredData from IAGCipheredData object?

harishios opened this issue · comments

Hi Team,

Need help here, I need to get the cipheredData and authenticationTagData from the object iagData

IAGCipheredData *iagData = [IAGAesGcm cipheredDataByAuthenticatedEncryptingPlainData:ciphertext
                                                              withAdditionalAuthenticatedData:aad
                                                                      authenticationTagLength:IAGAuthenticationTagLength128
                                                                         initializationVector:iv
                                                                                          key:key
                                                                                        error:nil];

Any help appreciated.

Hi @harishios,

IAGCipheredData is a simple NS class with a few read only properties: https://github.com/indisoluble/AesGcm/blob/master/AesGcm/Classes/IAGCipheredData.h , precisely the values you are looking for.

Hope I could answer your question.

Hi @indisoluble,
Thanks for quick response. I see those are read only properties.

I thought the method cipheredDataByAuthenticatedEncryptingPlainData returns IAGCipheredData in which the prop cipheredData is an encrypted data. Correct me if I'm wrong.

I need an encrypted DATA with AES256 GCM. Could you please help me on that?

There is no cipheredData property in IAGCipheredData, instead you have: cipheredBuffer (which is a pointer to an array of bytes) and cipheredBufferLength (which is the length of the array). You can easily build a NSData instance with those 2 properties.

Thanks @indisoluble: I tried to convert, but no success. Do you have any sample code to convert cipheredBuffer to NSData? Thanks in advance.

Hi again:

Thanks @indisoluble, I'm looking into it.