diff options
Diffstat (limited to 'utils/verification.go')
-rw-r--r-- | utils/verification.go | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/utils/verification.go b/utils/verification.go index 94e8b7e..bd6c875 100644 --- a/utils/verification.go +++ b/utils/verification.go @@ -9,23 +9,25 @@ import ( "sort" "strings" - "github.com/spdx/tools-golang/spdx" + "github.com/spdx/tools-golang/spdx/common" + "github.com/spdx/tools-golang/spdx/v2_1" + "github.com/spdx/tools-golang/spdx/v2_2" ) // GetVerificationCode2_1 takes a slice of files and an optional filename // for an "excludes" file, and returns a Package Verification Code calculated // according to SPDX spec version 2.1, section 3.9.4. -func GetVerificationCode2_1(files []*spdx.File2_1, excludeFile string) (spdx.PackageVerificationCode, error) { +func GetVerificationCode2_1(files []*v2_1.File, excludeFile string) (common.PackageVerificationCode, error) { // create slice of strings - unsorted SHA1s for all files shas := []string{} for i, f := range files { if f == nil { - return spdx.PackageVerificationCode{}, fmt.Errorf("got nil file for identifier %v", i) + return common.PackageVerificationCode{}, fmt.Errorf("got nil file for identifier %v", i) } if f.FileName != excludeFile { // find the SHA1 hash, if present for _, checksum := range f.Checksums { - if checksum.Algorithm == spdx.SHA1 { + if checksum.Algorithm == common.SHA1 { shas = append(shas, checksum.Value) } } @@ -43,7 +45,7 @@ func GetVerificationCode2_1(files []*spdx.File2_1, excludeFile string) (spdx.Pac hsha1.Write([]byte(shasConcat)) bs := hsha1.Sum(nil) - code := spdx.PackageVerificationCode{ + code := common.PackageVerificationCode{ Value: fmt.Sprintf("%x", bs), ExcludedFiles: []string{excludeFile}, } @@ -54,17 +56,17 @@ func GetVerificationCode2_1(files []*spdx.File2_1, excludeFile string) (spdx.Pac // GetVerificationCode2_2 takes a slice of files and an optional filename // for an "excludes" file, and returns a Package Verification Code calculated // according to SPDX spec version 2.2, section 3.9.4. -func GetVerificationCode2_2(files []*spdx.File2_2, excludeFile string) (spdx.PackageVerificationCode, error) { +func GetVerificationCode2_2(files []*v2_2.File, excludeFile string) (common.PackageVerificationCode, error) { // create slice of strings - unsorted SHA1s for all files shas := []string{} for i, f := range files { if f == nil { - return spdx.PackageVerificationCode{}, fmt.Errorf("got nil file for identifier %v", i) + return common.PackageVerificationCode{}, fmt.Errorf("got nil file for identifier %v", i) } if f.FileName != excludeFile { // find the SHA1 hash, if present for _, checksum := range f.Checksums { - if checksum.Algorithm == spdx.SHA1 { + if checksum.Algorithm == common.SHA1 { shas = append(shas, checksum.Value) } } @@ -82,7 +84,7 @@ func GetVerificationCode2_2(files []*spdx.File2_2, excludeFile string) (spdx.Pac hsha1.Write([]byte(shasConcat)) bs := hsha1.Sum(nil) - code := spdx.PackageVerificationCode{ + code := common.PackageVerificationCode{ Value: fmt.Sprintf("%x", bs), ExcludedFiles: []string{excludeFile}, } |