-
Notifications
You must be signed in to change notification settings - Fork 67
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
Incorrect auth tag generated for GCM mode when feeding data using small chunks #52
Comments
Have you checked that master is as new as development branch? |
I was able to apply patch on top of development branch, no conflicts. New test is still failing. |
If you just want to reproduce the issue without the patch and new test, then simplest way would be to modify existing TestEncodeStream to use chunking when calling EncodeStream:
|
I applied the pull request #51 for the other issue and that passes the unit tests. I added the test suggested above now: procedure TestTDECGCM.TestEncodeStreamChunked; but this failes the unit test. Reading what you wrote above the pull request should have fixed that as well. Can you please check what I did in development branch? So we can work on getting this one properly fixed as well. |
Did you find the time to test my version already? |
Hi, Just to clarify, there were two separate issues: one was fixed in PR #51 and this one is another GCM-related issue, that was discovered while I was working on #51. That is why proposed test case was dependent on that PR, but #51 only provided fix for one of the issues. Unfortunately, I don’t have a solution for this other issue, only the test case to reproduce it. |
I started to investigate but I'm not far yet. It is this plain text from the 128 bit test data which fails for me: 3feef98a976a1bd634f364ac428bb59cd51fb159ec1789946918dbd50ea6c9d594a3a31a5269b0da6936c29d063a5fa2cc8a1c. It fails if I specify a buffer size of < 51 byte. The last byte returned is wrong, the remaining ones seem ok. It is the output of CipherProc(Buffer[0], outBuffer[0], Bytes); in CipherProc(Buffer[0], outBuffer[0], Bytes); which is wrong. So much for today. Any help on this is appreciated. |
I think I have found the reason. The vector that fails for me is from gcmEncryptExtIV128.rsp
Error happens in The chunksize is 16 byte, the stream size is 32 byte. Therefore, EncodeStream is called two times. Just for testing, I added a 3rd call with empty data: and surprise: FCipherAES.CalculatedAuthenticationResult Theory: Looking at
It appears like FCalcAuthenticationTag is dependent on |
Describe the bug
Incorrect auth tag generated for GCM mode when feeding data using small chunks (at least when sized to cipher's block size). Using such small chunks appear to conform with DEC's documentation.
To Reproduce
Expected and actual behavior
Test should pass, proving that expected auth tag is generated when streaming data in small chunks.
The text was updated successfully, but these errors were encountered: