1
0
Fork 0
mirror of https://github.com/gocsaf/csaf.git synced 2025-12-22 11:55:40 +01:00
gocsaf/cmd/csaf_provider/files.go
Bernhard E. Reiter cf49c7e414
Fix go.mod and internal dependencies (#371)
* Use a "/v2" in the module path to match the git version tag which
   lead with a 2. Change all mention of the module as dependency
   internally as well.
2023-06-05 10:24:35 +02:00

34 lines
970 B
Go

// This file is Free Software under the MIT License
// without warranty, see README.md and LICENSES/MIT.txt for details.
//
// SPDX-License-Identifier: MIT
//
// SPDX-FileCopyrightText: 2021 German Federal Office for Information Security (BSI) <https://www.bsi.bund.de>
// Software-Engineering: 2021 Intevation GmbH <https://intevation.de>
package main
import (
"crypto/sha256"
"crypto/sha512"
"os"
"github.com/csaf-poc/csaf_distribution/v2/util"
)
func writeHashedFile(fname, name string, data []byte, armored string) error {
// Write the file itself.
if err := os.WriteFile(fname, data, 0644); err != nil {
return err
}
// Write SHA256 sum.
if err := util.WriteHashToFile(fname+".sha256", name, sha256.New(), data); err != nil {
return err
}
// Write SHA512 sum.
if err := util.WriteHashToFile(fname+".sha512", name, sha512.New(), data); err != nil {
return err
}
// Write signature.
return os.WriteFile(fname+".asc", []byte(armored), 0644)
}