Skip to content

More fixes and improvements#758

Open
sjaeckel wants to merge 6 commits intodevelopfrom
more-fixes-and-improvements
Open

More fixes and improvements#758
sjaeckel wants to merge 6 commits intodevelopfrom
more-fixes-and-improvements

Conversation

@sjaeckel
Copy link
Copy Markdown
Member

@sjaeckel sjaeckel commented May 5, 2026

Checklist

  • documentation is added or updated
  • tests are added or updated
  • if this fixes something: added a Fixes: tag to the commit message

@sjaeckel sjaeckel requested a review from karel-m May 5, 2026 09:34
@sjaeckel sjaeckel force-pushed the more-fixes-and-improvements branch from 6cde560 to 1ee37a5 Compare May 5, 2026 11:16
@karel-m
Copy link
Copy Markdown
Member

karel-m commented May 5, 2026

Do we actually still need sha1_x86_init and sha1_c_init when they are both equal to sha1_init?

@sjaeckel
Copy link
Copy Markdown
Member Author

sjaeckel commented May 5, 2026

Do we actually still need sha1_x86_init and sha1_c_init when they are both equal to sha1_init?

Nope, they could be defined to sha1_init! Will do that :) Thanks!

@karel-m
Copy link
Copy Markdown
Member

karel-m commented May 5, 2026

similarly sha224_x86_init / sha256_x86_init vs sha224_c_init / sha256_c_init

They're the only ones which don't follow the same pattern.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
@sjaeckel sjaeckel force-pushed the more-fixes-and-improvements branch from 1ee37a5 to 2e881d6 Compare May 7, 2026 14:15
@sjaeckel sjaeckel linked an issue May 7, 2026 that may be closed by this pull request
sjaeckel added 5 commits May 7, 2026 16:21
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
* Use a shared init function.
* Fix some functions used in descriptors and implementation.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
Related-to: #742
Fixes: 7ac05df ("Add x86-optimized SHA1.")
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
Related-to: #742
Fixes: 874e095 ("SHA-256 & SHA-224 x86")
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
@sjaeckel sjaeckel force-pushed the more-fixes-and-improvements branch from 2e881d6 to bb93c6e Compare May 7, 2026 14:21
Comment thread src/hashes/sha2/sha256.c
{
ulong32 *state = LTC_ALIGN_BUF(md->sha256.state_buf, 16);
if (state != md->sha256.state) {
XMEMMOVE(state, md->sha256.state, 8 * sizeof(ulong32));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure this is safe. What if the user memcpy the state to a new place. Then they destroys the old state. Think of free(). Then they call process or finish function. The memmove would access already freed memory.

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.

SHA1/SHA224/SHA256 state layouts are not memcpy-safe

3 participants