Skip to content
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

Fix issue 723 - Fixed use of ECB with Botan #724

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

antoinelochet
Copy link

Here is my proposed fix for issue 723

@antoinelochet antoinelochet changed the title #723 - Fixed use of ECB with Botan Fix issue 723 - Fixed use of ECB with Botan Sep 1, 2023
Copy link

@bjosv bjosv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable.
Are all the extra debug printouts needed? I seems that existing printouts are quite sparse with information, maybe for security reasons(?).

As an addition I suggest that we also disable 2 testcases when built WITH_BOTAN.
They will always fail when using Botan as I understand it. WDYT?

1) test: AESTests::testECB (F) line: 518 AESTests.cpp
assertion failed
- Expression: aes->encryptInit(&aesKey128, SymMode::ECB, IV)


2) test: DESTests::testECB (F) line: 537 DESTests.cpp
assertion failed
- Expression: des->encryptInit(&desKey56, SymMode::ECB, IV)

src/lib/data_mgr/SecureDataManager.cpp Show resolved Hide resolved
@antoinelochet
Copy link
Author

antoinelochet commented Jan 16, 2024

I think that you are right about the tests.

I have added the debug logs because they are often useful. I agree that some security reasons, it may seem bad, but:

  • using SoftHSM in production is madness
  • using SoftHSM in production WITH debug logs is beyond madness

So I thought this was tolerable. But per your request, I deleted all the offending lines.

Copy link

@bjosv bjosv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good comments. Using debug logs in production would be "beyond madness" :)

@@ -328,6 +328,7 @@ void AESTests::testCBC()
}
}

#ifndef WITH_BOTAN
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this will give an undefined reference to this function while linking.
Maybe its better to just remove the registration of the testcase in the header file.

#ifndef WITH_BOTAN
        CPPUNIT_TEST(testECB);
#endif

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for the testECB() testcase in:
src/lib/crypto/test/DESTests.h

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I followed your suggestion and compilation/linking is ok now.
The tests fail on the src/lib/test though but I am pretty sure that it was the case before my changes.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Looks good.

@bjosv bjosv mentioned this pull request Jan 18, 2024
@anpa8480
Copy link

anpa8480 commented Jun 21, 2024

if you revert BotanSymmetricAlgorithm.cpp 8fd89ec and uncomment if (mode == SymMode::ECB) all tests are passing.

Tested with Botan 2.19.3
image

@antoinelochet
Copy link
Author

if you revert BotanSymmetricAlgorithm.cpp 8fd89ec and uncomment if (mode == SymMode::ECB) all tests are passing.

Tested with Botan 2.19.3 image

That's because ECB is not taken into account during compilation phase. It does not fix the failing tests in src/lib

@anpa8480
Copy link

anpa8480 commented Jun 21, 2024

if you revert BotanSymmetricAlgorithm.cpp 8fd89ec and uncomment if (mode == SymMode::ECB) all tests are passing.
Tested with Botan 2.19.3 image

That's because ECB is not taken into account during compilation phase. It does not fix the failing tests in src/lib

Sorry I dont understand what do you mean "ECB is not taken into account". You mean because Botan_ecb.cpp is missing in CMakelists.txt? The test was performed with dev branch and not with fix-botan-ecb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants