-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add sancus_untag
functions and fix sancus_unwrap_with_key
#37
Add sancus_untag
functions and fix sancus_unwrap_with_key
#37
Conversation
src/sancus_support/sm_support.h
Outdated
} | ||
|
||
// compare MAC with provided reference `tag` | ||
return constant_time_cmp(tag, computed_tag, SANCUS_TAG_SIZE) == 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jovanbulck would this comparison be a security issue as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes good point,it might, so better to avoid this. Since the function already returns an int, no need to do this comparison to zero.
I changed the order of these functions so that we could call `sancus_untag_with_key` inside sancus_`unwrap_with_key`. To do so, the former needs to be declared before the latter
Normally, `sancus_unwrap_with_key` always fails if cipher_len is zero. This commit solves this issue by leveraging `sancus_untag_with_key`
af7a2be
to
666f960
Compare
Merged, thanks @gianlu33 ! 👍 |
Add `sancus_untag` functions and fix `sancus_unwrap_with_key`
Add `sancus_untag` functions and fix `sancus_unwrap_with_key`
This implements what discussed in #36 and fixes (in sw of course) the bug mentioned in sancus-tee/sancus-core#26.
About the constant-time comparison function, I basically copied the NaCl function referenced in #31. However, I didn't really understand why they use this logic in the return statement:
Is there a specific reason for this logic (I mean, in terms of security)? Can't this be simplified to something like
return d == 0
?I also had to move
sancus_tag
andsancus_tag_with_key
up in the file. The reason is because I added a call tosancus_untag_with_key
insidesancus_unwrap_with_key
, therefore the former needed to be declared before the latter.Edit: I just read what @jovanbulck wrote in #31, so that logic in the
return
statement is to avoid having an if branch. Good!