Fix signature padding, return verify error in validator

This commit is contained in:
Jeroen Bobbeldijk
2017-07-04 21:59:13 +02:00
parent 41a9627fee
commit 3eedc089d0
2 changed files with 4 additions and 2 deletions

View File

@@ -81,7 +81,7 @@ func (context *SignContext) createSignature() ([]byte, error) {
file_content = file_content[:len(file_content)-1]
// Collect the parts to sign.
sign_content := make([]byte, context.ByteRangeValues[1]+context.ByteRangeValues[3])
sign_content := make([]byte, 0)
sign_content = append(sign_content, file_content[context.ByteRangeValues[0]:(context.ByteRangeValues[0]+context.ByteRangeValues[1])]...)
sign_content = append(sign_content, file_content[context.ByteRangeValues[2]:(context.ByteRangeValues[2]+context.ByteRangeValues[3])]...)

View File

@@ -123,10 +123,12 @@ func Verify(file *os.File) (apiResp *Response, err error) {
// Read the byte range from the raw file and add it to the contents.
// This content will be hashed with the corresponding algorithm to
// verify the signature.
content, err := ioutil.ReadAll(io.NewSectionReader(file, v.Key("ByteRange").Index(i-1).Int64(), v.Key("ByteRange").Index(i).Int64()))
if err != nil {
apiResp.Error = fmt.Sprintln("Failed to get ByteRange:", i, err)
}
p7.Content = append(p7.Content, content...)
}
@@ -178,7 +180,7 @@ func Verify(file *os.File) (apiResp *Response, err error) {
signer.ValidSignature = true
signer.TrustedIssuer = false
}
//apiResp.Error = fmt.Sprintln("Failed to verify signature:", err)
apiResp.Error = fmt.Sprintln("Failed to verify signature:", err)
} else {
signer.ValidSignature = true
signer.TrustedIssuer = true