Skip to content

Fix AES ECB mode in Data processor - #1986

Merged
WerWolv merged 4 commits into
WerWolv:masterfrom
jumanji144:fix/aes-ecb
Dec 5, 2024
Merged

Fix AES ECB mode in Data processor#1986
WerWolv merged 4 commits into
WerWolv:masterfrom
jumanji144:fix/aes-ecb

Conversation

@jumanji144

Copy link
Copy Markdown
Collaborator

Fix the AES ECB mode in the data processor along with some other misc fixes:

  • Fixed nullpointer node not working
  • Fixed crypto module incorrectly using mbedtls api
  • Fixed crypto module ignoring mbedtls errors
  • Fixed silently ignoring of errors in AES node

}

void process() override {
const auto &mode = static_cast<crypt::AESMode>(m_mode);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I don't think this should be a reference. (How does that even compile??)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think i was just like 'make everything const reference' but i think this works because it converts the lvalue to a rvalue to that lvalue, since its just a static cast to that lvalue. might also be UB

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Yeah I believe static_cast will return a prvalue which will expire right after that line finishes so you have a dangling reference there. It compiles because rvalues can bind to const lvalue references but assignments like this don't cause lifetime extensions so it's still a bug


// if we are in ECB mode, we don't need to set the nonce
if (mode != MBEDTLS_MODE_ECB) {
std::ranges::copy(nonce, nonceCounter.begin());

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Where does the name nonceCounter come from? I feel like it should be called IV or something instead

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

nonceCounter was originally named by you, as shown by the blame, i didn't want to change the naming as i thought it was correctly named by you. I will address it.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

My fault then, sorry

@WerWolv
WerWolv merged commit 3c73f88 into WerWolv:master Dec 5, 2024
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.

2 participants