Function
VerifyArtifactChecksum
(artifact Artifact, data []byte)
Source from the content-addressed store, hash-verified
| 43 | } |
| 44 | |
| 45 | func VerifyArtifactChecksum(artifact Artifact, data []byte) error { |
| 46 | expected := strings.ToLower(strings.TrimSpace(artifact.SHA256)) |
| 47 | if expected == "" { |
| 48 | return fmt.Errorf("artifact checksum missing") |
| 49 | } |
| 50 | actualBytes := sha256.Sum256(data) |
| 51 | actual := hex.EncodeToString(actualBytes[:]) |
| 52 | if actual != expected { |
| 53 | return fmt.Errorf("artifact checksum mismatch") |
| 54 | } |
| 55 | return nil |
| 56 | } |
Tested by
no test coverage detected