seal

package
v0.0.0-...-d5f7082 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const NormCrChar = 13
View Source
const NormLfChar = 10
View Source
const NormLowerLimit = 32
View Source
const NormOutOfRangeReplacement = 195
View Source
const NormUpperLimit = 126

Variables

View Source
var NormSpecialReplacement map[int]int = map[int]int{
	201: 64,
	196: 91,
	214: 92,
	197: 93,
	220: 94,
	233: 96,
	228: 123,
	246: 124,
	229: 125,
	252: 126,
}
View Source
var RegexMatchEmptyLines = regexp.MustCompile(`\r\n[\s\t]*\r\n`)

Functions

func FormatContent

func FormatContent(b []byte) []byte

func FormatContentString

func FormatContentString(s string) string

func NormalizeByte

func NormalizeByte(b byte) byte

Normalize a single character

func NormalizeBytes

func NormalizeBytes(b []byte, buf *bytes.Buffer)

Normalize a range of bytes

func NormalizeContent

func NormalizeContent(content []byte) []byte

func NormalizeContentString

func NormalizeContentString(content string) []byte

func NormalizeFirstLine

func NormalizeFirstLine(b []byte) []byte

Ensure that the first line of the content is a maximum of 80 characters long

func PrefixContent

func PrefixContent(content []byte, sealDate string) []byte

func RemoveBlankRows

func RemoveBlankRows(b []byte) []byte

func RemoveBlankRowsString

func RemoveBlankRowsString(s string) string

Types

type HmacSealer

type HmacSealer struct {
	Key            []byte
	KeyVer         []byte
	Hash           func() hash.Hash
	Mac            []byte
	SealDate       string
	OriginalData   []byte
	PrefixedData   []byte
	FormattedData  []byte
	NormalizedData []byte
}

Key: the hex-decoded HMAC key used to seal the file KeyVer (KVV, KeyVerificationValue) is the the value used to verify the key, obtained by sealing the string "00000000" HashFunc: the hash function used to calculate the HMAC seal, default is sha256

func (*HmacSealer) AddData

func (hm *HmacSealer) AddData(data string) error

Append given string to the data

func (*HmacSealer) AddDataBytes

func (hm *HmacSealer) AddDataBytes(data []byte) error

Append given byte slice to the data

func (*HmacSealer) Calculate

func (hm *HmacSealer) Calculate() (err error)

Calculate the HMAC seal MAC for the data

func (*HmacSealer) CheckKvv

func (hm *HmacSealer) CheckKvv(kvv string) error

Check the KVV value against a provided value

func (*HmacSealer) EnsureNoSignature

func (hm *HmacSealer) EnsureNoSignature() error

func (*HmacSealer) GenerateKvv

func (hm *HmacSealer) GenerateKvv() error

Generate and store the KVV Value

func (*HmacSealer) GetKvv

func (hm *HmacSealer) GetKvv() string

Get the KVV value as a hex string (64 characters)

func (*HmacSealer) GetKvvBgFormat

func (hm *HmacSealer) GetKvvBgFormat() string

Get the KVV value as a hex string (32 characters) formatted for use in BG files

func (*HmacSealer) GetMac

func (hm *HmacSealer) GetMac() string

Get the full MAC as a hex string (64 characters)

func (*HmacSealer) GetMacBgFormat

func (hm *HmacSealer) GetMacBgFormat() string

Get the calculated HMAC seal MAC as a hex string (32 characters) formatted for use in BG files

func (*HmacSealer) GetMacBytes

func (hm *HmacSealer) GetMacBytes() []byte

Get the calculated HMAC seal MAC as a bytestring

func (*HmacSealer) GetSignedContent

func (hm *HmacSealer) GetSignedContent() string

func (*HmacSealer) SetData

func (hm *HmacSealer) SetData(data string) error

Replace the data with a given string

func (*HmacSealer) SetDataBytes

func (hm *HmacSealer) SetDataBytes(data []byte) error

Replace the data with a given byte slice

func (*HmacSealer) SetHashFunction

func (hm *HmacSealer) SetHashFunction(hashFunc func() hash.Hash) error

Set the hash function used to hash the file contents

func (*HmacSealer) SetKey

func (hm *HmacSealer) SetKey(key string) error

Set the key used to seal the file

func (*HmacSealer) SetKeyBytes

func (hm *HmacSealer) SetKeyBytes(key []byte) error

Set the key used to seal the file as a byte array

func (*HmacSealer) SetSealDate

func (hm *HmacSealer) SetSealDate(date string) error

Set a custom seal date

func (*HmacSealer) UpdateFormatted

func (hm *HmacSealer) UpdateFormatted() error

Update the values of the Formatted/Normalized data fields Formatted will ensure the correct line endings are present Normalized will normalize the content for HMAC signature

func (*HmacSealer) Validate

func (hm *HmacSealer) Validate() (err error)

Validate that everything is in place to calculate the HMAC seal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL