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:
- Probably, there are some examples in the tests: https://github.com/indisoluble/AesGcm/tree/master/Example/Tests
- This explanation here: https://stackoverflow.com/a/41680179 might be useful too
- And there are also good examples in the already closed issues: https://github.com/indisoluble/AesGcm/issues?q=is%3Aissue+is%3Aclosed
Thanks @indisoluble, I'm looking into it.