Documentation ¶
Index ¶
- Constants
- Variables
- func AddJSONChecksum(data []byte) ([]byte, error)
- func AddJSONSignature(data []byte, envelope *jess.Envelope, trustStore jess.TrustStore) (signedData []byte, err error)
- func AddTextFileChecksum(data []byte, commentSign string, placement TextPlacement) ([]byte, error)
- func AddToSigFile(signature *jess.Letter, sigFileData []byte, removeExistingJessSignatures bool) (newFileData []byte, err error)
- func AddYAMLChecksum(data []byte, placement TextPlacement) ([]byte, error)
- func MakeSigFileSection(signature *jess.Letter) ([]byte, error)
- func ParseSigFile(fileData []byte) (signatures []*jess.Letter, err error)
- func VerifyJSONChecksum(data []byte) error
- func VerifyJSONSignature(data []byte, trustStore jess.TrustStore) (err error)
- func VerifyTextFileChecksum(data []byte, commentSign string) error
- func VerifyYAMLChecksum(data []byte) error
- type FileData
- func SignFile(dataFilePath, signatureFilePath string, metaData map[string]string, ...) (fileData *FileData, err error)
- func SignFileData(fileHash *lhash.LabeledHash, metaData map[string]string, ...) (letter *jess.Letter, fd *FileData, err error)
- func VerifyFile(dataFilePath, signatureFilePath string, metaData map[string]string, ...) (verifiedFileData []*FileData, err error)
- func VerifyFileData(letter *jess.Letter, requiredMetaData map[string]string, ...) (fd *FileData, err error)
- type TextPlacement
Constants ¶
const ( JSONKeyPrefix = "_jess-" JSONChecksumKey = JSONKeyPrefix + "checksum" JSONSignatureKey = JSONKeyPrefix + "signature" )
JSON file metadata keys.
const ( TextKeyPrefix = "jess-" TextChecksumKey = TextKeyPrefix + "checksum" TextSignatureKey = TextKeyPrefix + "signature" )
Text file metadata keys.
const Extension = ".sig"
Extension holds the default file extension to be used for signature files.
Variables ¶
var ( ErrChecksumMissing = errors.New("no checksum found") ErrChecksumFailed = errors.New("checksum does not match") ErrSignatureMissing = errors.New("signature not found") ErrSignatureFailed = errors.New("signature does not match") )
Text Operation Errors.
Functions ¶
func AddJSONChecksum ¶ added in v0.3.2
AddJSONChecksum adds a checksum to a text file.
func AddJSONSignature ¶ added in v0.3.5
func AddTextFileChecksum ¶ added in v0.3.2
func AddTextFileChecksum(data []byte, commentSign string, placement TextPlacement) ([]byte, error)
AddTextFileChecksum adds a checksum to a text file.
func AddToSigFile ¶
func AddToSigFile(signature *jess.Letter, sigFileData []byte, removeExistingJessSignatures bool) (newFileData []byte, err error)
AddToSigFile adds the given signature to the signature file.
func AddYAMLChecksum ¶ added in v0.3.2
func AddYAMLChecksum(data []byte, placement TextPlacement) ([]byte, error)
AddYAMLChecksum adds a checksum to a yaml file.
func MakeSigFileSection ¶
MakeSigFileSection creates a new section for a signature file.
func ParseSigFile ¶
ParseSigFile parses a signature file and extracts any jess signatures from it. If signatures are returned along with an error, the error should be treated as a warning, but the result should also not be treated as a full success, as there might be missing signatures.
func VerifyJSONChecksum ¶ added in v0.3.2
VerifyJSONChecksum checks a checksum in a text file.
func VerifyJSONSignature ¶ added in v0.3.5
func VerifyJSONSignature(data []byte, trustStore jess.TrustStore) (err error)
func VerifyTextFileChecksum ¶ added in v0.3.2
VerifyTextFileChecksum checks a checksum in a text file.
func VerifyYAMLChecksum ¶ added in v0.3.2
VerifyYAMLChecksum checks a checksum in a yaml file.
Types ¶
type FileData ¶
type FileData struct { LabeledHash []byte SignedAt time.Time MetaData map[string]string // contains filtered or unexported fields }
FileData describes a file that is signed.
func SignFile ¶
func SignFile(dataFilePath, signatureFilePath string, metaData map[string]string, envelope *jess.Envelope, trustStore jess.TrustStore) (fileData *FileData, err error)
SignFile signs a file and replaces the signature file with a new one. If the dataFilePath is "-", the file data is read from stdin. Existing jess signatures in the signature file are removed.
func SignFileData ¶
func SignFileData(fileHash *lhash.LabeledHash, metaData map[string]string, envelope *jess.Envelope, trustStore jess.TrustStore) (letter *jess.Letter, fd *FileData, err error)
SignFileData signs the given file checksum and metadata.
func VerifyFile ¶
func VerifyFile(dataFilePath, signatureFilePath string, metaData map[string]string, trustStore jess.TrustStore) (verifiedFileData []*FileData, err error)
VerifyFile verifies the given files and returns the verified file data. If the dataFilePath is "-", the file data is read from stdin. If an error is returned, there was an error in at least some part of the process. Any returned file data struct must be checked for an verification error.
func VerifyFileData ¶
func VerifyFileData(letter *jess.Letter, requiredMetaData map[string]string, trustStore jess.TrustStore) (fd *FileData, err error)
VerifyFileData verifies the given signed file data and returns the file data. If an error is returned, there was an error in at least some part of the process. Any returned file data struct must be checked for an verification error.
func (*FileData) FileHash ¶
func (fd *FileData) FileHash() *lhash.LabeledHash
FileHash returns the labeled hash of the file that was signed.
func (*FileData) VerificationError ¶
VerificationError returns the error encountered during verification.
type TextPlacement ¶ added in v0.3.2
type TextPlacement string
TextPlacement signifies where jess metadata is put in text files.
const ( // TextPlacementTop places the metadata at end of file. TextPlacementTop TextPlacement = "top" // TextPlacementBottom places the metadata at end of file. TextPlacementBottom TextPlacement = "bottom" // TextPlacementAfterComment places the metadata at end of the top comment // block, or at the top, if the first line is not a comment. TextPlacementAfterComment TextPlacement = "after-comment" )