Skip to content

Commit

Permalink
Correct a check during RsaSha256 fulfillment loading:
Browse files Browse the repository at this point in the history
The specification requires that we verify that the
signature and modulus of an RSA-SHA256 fulfillment
are both the same length (specifically that they
have "the same number of octets") referring to the
encoded length.

We were, instead, checking the number of bytes that
the signature and modulus had after decoding.
  • Loading branch information
nbougalis committed Dec 23, 2016
1 parent effd8c9 commit 5a688f9
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/ripple/conditions/impl/RsaSha256.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ parsePayloadHelper(
std::memcpy (signature.alloc (len), start, len);
std::advance (start, len);

// Per 4.4.2 of the RFC we must check whether the
// signature and modulus consist of the same number
// of octets:
if (signature.size() != modulus.size())
return false;

// Enforce constraints from the RFC:
BigNum sig (BN_bin2bn (
signature.data(), signature.size(), nullptr));
Expand All @@ -178,13 +184,8 @@ parsePayloadHelper(
if (!checkModulusLength (modBytes))
return false;

// Per 4.4.2 of the RFC we must check whether the
// signature and modulus consist of the same number
// of octets and that the signature is numerically
// less than the modulus:
if (BN_num_bytes (sig.get()) != modBytes)
return false;

// Per 4.4.2 of the RFC we must check that the signature
// is numerically less than the modulus:
return BN_cmp (sig.get(), mod.get()) < 0;
}

Expand Down

0 comments on commit 5a688f9

Please sign in to comment.