diff options
author | lloyd <[email protected]> | 2010-04-21 15:43:35 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-04-21 15:43:35 +0000 |
commit | 1edab5adc81353f74e7c20be4f88093a5cbd2994 (patch) | |
tree | a489e0cba8f6d3e973eb932453c16a2efbfe4a3d /src/pk_pad/emsa_raw | |
parent | a8980feaf43900bc4a083422b28e3971c22cbe74 (diff) |
Fix EMSA_Raw in the case where the original input had leading 0 bytes.
Diffstat (limited to 'src/pk_pad/emsa_raw')
-rw-r--r-- | src/pk_pad/emsa_raw/emsa_raw.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/pk_pad/emsa_raw/emsa_raw.cpp b/src/pk_pad/emsa_raw/emsa_raw.cpp index 5dfe20a50..734dc3698 100644 --- a/src/pk_pad/emsa_raw/emsa_raw.cpp +++ b/src/pk_pad/emsa_raw/emsa_raw.cpp @@ -44,7 +44,25 @@ bool EMSA_Raw::verify(const MemoryRegion<byte>& coded, const MemoryRegion<byte>& raw, u32bit) { - return (coded == raw); + if(coded.size() == raw.size()) + return (coded == raw); + + if(coded.size() > raw.size()) + return false; + + // handle zero padding differences + const u32bit leading_zeros_expected = raw.size() - coded.size(); + + bool same_modulo_leading_zeros = true; + + for(u32bit i = 0; i != leading_zeros_expected; ++i) + if(raw[i]) + same_modulo_leading_zeros = false; + + if(!same_mem(&coded[0], &raw[leading_zeros_expected], coded.size())) + same_modulo_leading_zeros = false; + + return same_modulo_leading_zeros; } } |