-
Notifications
You must be signed in to change notification settings - Fork 516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HMAC mismatch/Unknown header error. #148
Comments
"Unknown header" means that you're handing it something that is not
RNCryptor data. HMAC Mismatch means your password is wrong, your data is
corrupted, or it is not RNCryptor data (but happens to have a legal
RNCryptor header, which can happen by chance).
I suspect that whatever you are not handing exactly the data you got from
the encryptor to the decryptor. Check your bytes.
|
Thanks for your reply. Actually I was using encryption and decryption in two different projects. I encrypted a set of files in one xcode project and saved them to a location. Then I copied those encrypted files to another xcode project and tried to decrypt. The password used for decryption is same as that of encryption. Also the decryption was successful when I ran the same project multiple times, but this occurs in a random fashion. |
I have the similar problem in my iOS application. I had a solution for this problem a few month ago, but I forgot what I did to solve it :(. Here is my code which encrypts and decrypts data, but it can't decrypt data just in a week after encryption:
|
In all these cases, if you're getting HMAC errors, you either have the wrong password or you've corrupted the data. The more common cause is data corruption, usually due to writing it or reading it in a format you didn't expect. If you're getting the results randomly, you may have race conditions. But in all the cases, you should inspect the data your receive from RNCryptor and the data you send to RNCryptor and confirm they are identical. They are almost certainly not (or the password has changed). |
@rnapier I have situation where I am using async encrypt for encrypting video file while its downloaded and writing it to file on device. Now i have to decrypt it while its being played using AVPlayer and I am using shouldWaitForLoadingOfRequestedResource for decrypting the requested data length and returning that data. Now I can't figure out way to properly decrypt chunks of data when it was encrypted using async encryption. |
@javalnanda See the FAQ. See also #161 for a much longer discussion. |
This is my code . I am getting rncryptor error 2 which means unknown header passed class func decrypt(message: String) -> String {
|
Hi
I was using the RNCryptor for ios for encrypting and decrypting a set of HTML,CSS and JS files. I successfully encrypted the files using:
[RNEncryptor encryptData:fileData withSettings:kRNCryptorAES256Settings password:@"12345_123" error:&error]
While trying to decrypt the files using:
[RNDecryptor decryptData:data withPassword:@"12345_123" error:&error]
I am getting the following errors for some files:
Error: Error Domain=net.robnapier.RNCryptManager Code=1 "HMAC Mismatch" UserInfo=0x7fdbb157b120 {NSLocalizedDescription=HMAC Mismatch}
Error: Error Domain=net.robnapier.RNCryptManager Code=2 "Unknown header" UserInfo=0x7fdbb157ce00 {NSLocalizedDescription=Unknown header}
Any ideas how to fix this?
The text was updated successfully, but these errors were encountered: