Skip to content

Commit

Permalink
add check on cipher_len inside sancus_unwrap_with_key
Browse files Browse the repository at this point in the history
Normally, `sancus_unwrap_with_key` always fails if cipher_len is zero. 
This commit solves this issue by leveraging `sancus_untag_with_key`
  • Loading branch information
gianlu33 committed Oct 15, 2021
1 parent 7b26b35 commit 666f960
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/sancus_support/sm_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,11 @@ always_inline int sancus_unwrap_with_key(const void* key,
size_t cipher_len,
const void* tag, void* body)
{
// fix: if cipher_len is zero, just compare the MACs using sancus_untag
if(cipher_len == 0) {
return sancus_untag_with_key(key, ad, ad_len, tag);
}

void* ad_end = (char*)ad + ad_len;
void* cipher_end = (char*)cipher + cipher_len;
int ret;
Expand Down

0 comments on commit 666f960

Please sign in to comment.