mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 12:20:56 +00:00
bug 1047494 - refactor tautological size check in mozilla::pkix::VerifySignedData r=briansmith
This commit is contained in:
parent
807f12f4d6
commit
bff07e5d42
@ -92,12 +92,6 @@ Result
|
||||
VerifySignedData(const SignedDataWithSignature& sd,
|
||||
Input subjectPublicKeyInfo, void* pkcs11PinArg)
|
||||
{
|
||||
// See bug 921585.
|
||||
if (sd.data.GetLength() >
|
||||
static_cast<unsigned int>(std::numeric_limits<int>::max())) {
|
||||
return Result::FATAL_ERROR_INVALID_ARGS;
|
||||
}
|
||||
|
||||
SECOidTag pubKeyAlg;
|
||||
SECOidTag digestAlg;
|
||||
switch (sd.algorithm) {
|
||||
@ -153,8 +147,12 @@ VerifySignedData(const SignedDataWithSignature& sd,
|
||||
return rv;
|
||||
}
|
||||
|
||||
// The static_cast is safe according to the check above that references
|
||||
// bug 921585.
|
||||
// The static_cast is safe as long as the length of the data in sd.data can
|
||||
// fit in an int. Right now that length is stored as a uint16_t, so this
|
||||
// works. In the future this may change, hence the assertion.
|
||||
// See also bug 921585.
|
||||
static_assert(sizeof(decltype(sd.data.GetLength())) < sizeof(int),
|
||||
"sd.data.GetLength() must fit in an int");
|
||||
SECItem dataSECItem(UnsafeMapInputToSECItem(sd.data));
|
||||
SECItem signatureSECItem(UnsafeMapInputToSECItem(sd.signature));
|
||||
SECStatus srv = VFY_VerifyDataDirect(dataSECItem.data,
|
||||
|
Loading…
x
Reference in New Issue
Block a user