Merge pull request #1010 from sr-gi/enforce_signature_length

This commit is contained in:
Matt Corallo 2021-07-20 23:25:40 +00:00 committed by GitHub
commit ef4bfdca3c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -36,6 +36,11 @@ fn sigrec_encode(sig_rec: RecoverableSignature) -> Vec<u8> {
}
fn sigrec_decode(sig_rec: Vec<u8>) -> Result<RecoverableSignature, Error> {
// Signature must be 64 + 1 bytes long (compact signature + recovery id)
if sig_rec.len() != 65 {
return Err(Error::InvalidSignature);
}
let rsig = &sig_rec[1..];
let rid = sig_rec[0] as i32 - 31;