| 209 | } |
| 210 | |
| 211 | bool CheckSignatureEncoding(const std::vector<unsigned char> &vchSig, script_verify_flags flags, ScriptError* serror) { |
| 212 | // Empty signature. Not strictly DER encoded, but allowed to provide a |
| 213 | // compact way to provide an invalid signature for use with CHECK(MULTI)SIG |
| 214 | if (vchSig.size() == 0) { |
| 215 | return true; |
| 216 | } |
| 217 | if ((flags & (SCRIPT_VERIFY_DERSIG | SCRIPT_VERIFY_LOW_S | SCRIPT_VERIFY_STRICTENC)) != 0 && !IsValidSignatureEncoding(vchSig)) { |
| 218 | return set_error(serror, SCRIPT_ERR_SIG_DER); |
| 219 | } else if ((flags & SCRIPT_VERIFY_LOW_S) != 0 && !IsLowDERSignature(vchSig, serror)) { |
| 220 | // serror is set |
| 221 | return false; |
| 222 | } else if ((flags & SCRIPT_VERIFY_STRICTENC) != 0 && !IsDefinedHashtypeSignature(vchSig)) { |
| 223 | return set_error(serror, SCRIPT_ERR_SIG_HASHTYPE); |
| 224 | } |
| 225 | return true; |
| 226 | } |
| 227 | |
| 228 | bool static CheckPubKeyEncoding(const valtype &vchPubKey, script_verify_flags flags, const SigVersion &sigversion, ScriptError* serror) { |
| 229 | if ((flags & SCRIPT_VERIFY_STRICTENC) != 0 && !IsCompressedOrUncompressedPubKey(vchPubKey)) { |
no test coverage detected