Changeset View
Changeset View
Standalone View
Standalone View
src/script/sigencoding.cpp
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | static bool IsValidSignatureEncoding(const valtype &sig) { | ||||
// Make sure the length of the S element is still inside the signature. | // Make sure the length of the S element is still inside the signature. | ||||
if (5 + lenR >= sig.size()) return false; | if (5 + lenR >= sig.size()) return false; | ||||
// Extract the length of the S element. | // Extract the length of the S element. | ||||
unsigned int lenS = sig[5 + lenR]; | unsigned int lenS = sig[5 + lenR]; | ||||
// Verify that the length of the signature matches the sum of the length | // Verify that the length of the signature matches the sum of the length | ||||
// of the elements. | // of the elements. | ||||
if ((size_t)(lenR + lenS + 7) != sig.size()) return false; | if (size_t(lenR + lenS + 7) != sig.size()) return false; | ||||
// Check whether the R element is an integer. | // Check whether the R element is an integer. | ||||
if (sig[2] != 0x02) return false; | if (sig[2] != 0x02) return false; | ||||
// Zero-length integers are not allowed for R. | // Zero-length integers are not allowed for R. | ||||
if (lenR == 0) return false; | if (lenR == 0) return false; | ||||
// Negative numbers are not allowed for R. | // Negative numbers are not allowed for R. | ||||
▲ Show 20 Lines • Show All 117 Lines • Show Last 20 Lines |