aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-04-21 15:43:35 +0000
committerlloyd <[email protected]>2010-04-21 15:43:35 +0000
commit1edab5adc81353f74e7c20be4f88093a5cbd2994 (patch)
treea489e0cba8f6d3e973eb932453c16a2efbfe4a3d /src
parenta8980feaf43900bc4a083422b28e3971c22cbe74 (diff)
Fix EMSA_Raw in the case where the original input had leading 0 bytes.
Diffstat (limited to 'src')
-rw-r--r--src/pk_pad/emsa_raw/emsa_raw.cpp20
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;
}
}