bug 1047494 - refactor tautological size check in mozilla::pkix::VerifySignedData r=briansmith

This commit is contained in:
David Keeler 2014-08-08 11:28:44 -07:00
parent 807f12f4d6
commit bff07e5d42

View File

@ -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,