Fix signature padding, return verify error in validator
This commit is contained in:
@@ -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])]...)
|
||||
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user