Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

Add support for SHA-512 message digest #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

utzig
Copy link

@utzig utzig commented Jan 3, 2020

This adds SHA-512, which is based on the current SHA-256 code, with the small changes to accommodate the differences between both message digests. I left the license headers basically the same with updated copyright year.

The main reason for adding this is because ed25519 requires the use of SHA-512, and we support ed25519 signature checking in https://github.com/JuulLabs-OSS/mcuboot/, but it currently depends on mbedTLS. With this change it would be possible to build ed25519 validation with our bundled Tinycrypt.

#define sigma1(a)(ROTR((a), 19) ^ ROTR((a), 61) ^ ((a) >> 6))

#define Ch(a, b, c)(((a) & (b)) ^ ((~(a)) & (c)))
#define Maj(a, b, c)(((a) & (b)) ^ ((a) & (c)) ^ ((b) & (c)))
Copy link

Choose a reason for hiding this comment

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

these two macros are exactly the same in sha256.c maybe would be better move it utils.h

Copy link
Author

@utzig utzig Jan 15, 2020

Choose a reason for hiding this comment

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

IMO it makes more sense to leave them here, because it's just two simple definitions that don't increase code size; it ends up being just a maintenance issue, but since the SHA family of hash primitives is not going to change, these definitions are most probably gonna stay here untouched forever! Also utils.h feels a bit too generic, maybe then it would be better to add a sha.h (or sha_data.h, sha_priv.h, etc) file under lib/source to store the shared code.

Copy link

@ceolin ceolin left a comment

Choose a reason for hiding this comment

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

patch looks good to me. @mczraf can you take a look too ?

utzig added a commit to utzig/mcuboot that referenced this pull request Feb 3, 2020
A patch adding sha-512 to upstream tinycrypt was submitted:
intel/tinycrypt#42

While it is not accepted, add the code under a new ext/tinycrypt-sha512
depedency.

Signed-off-by: Fabio Utzig <[email protected]>
utzig added a commit to mcu-tools/mcuboot that referenced this pull request Feb 4, 2020
A patch adding sha-512 to upstream tinycrypt was submitted:
intel/tinycrypt#42

While it is not accepted, add the code under a new ext/tinycrypt-sha512
depedency.

Signed-off-by: Fabio Utzig <[email protected]>
@utzig
Copy link
Author

utzig commented Mar 13, 2020

@mczraf @ceolin So is someone still reviewing this or am I missing something?

@mczraf
Copy link
Contributor

mczraf commented Mar 13, 2020 via email

@utzig utzig closed this Jun 2, 2020
@utzig utzig reopened this Aug 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants