soter

package
v0.0.0-...-dc37d03 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SerializeSoterContainer

func SerializeSoterContainer(tag string, payload []byte) []byte

SerializeSoterContainer packs the tagged payload into a Soter container.

This is a convenience method to quickly pack the payload into a byte slice.

func SoterKDF

func SoterKDF(input []byte, label string, outputBytes int, context ...[]byte) []byte

SoterKDF derives a new key of requested length from an input key. Label indicates key derivation purpose. Derived key is also bound to provided context data (if any). Output key length must be between 1 and 32 bytes.

Types

type AlgorithmID

type AlgorithmID uint32

AlgorithmID encodes symmetric algorithm parameters for Soter.

func MakeAlgorithmID

func MakeAlgorithmID(algorithm SymmetricAlgorithm, kdf KeyDerivationFunction, padding PaddingAlgorithm, keyBits int) AlgorithmID

MakeAlgorithmID constructs algorithm ID from components.

func (AlgorithmID) Algorithm

func (id AlgorithmID) Algorithm() SymmetricAlgorithm

Algorithm returns symmetric algorithm component.

func (AlgorithmID) KDF

KDF returns key derivation function.

func (AlgorithmID) KeyBits

func (id AlgorithmID) KeyBits() int

KeyBits returns size of the key in bits.

func (AlgorithmID) Padding

func (id AlgorithmID) Padding() PaddingAlgorithm

Padding returns padding algorithm.

type KeyDerivationFunction

type KeyDerivationFunction int

KeyDerivationFunction indicates key derivation function in AlgorithmID.

const (
	NoKDF            KeyDerivationFunction = 0x0
	PBKDF2HmacSha256 KeyDerivationFunction = 0x1
)

Supported KeyDerivationFunction values.

type PaddingAlgorithm

type PaddingAlgorithm int

PaddingAlgorithm indicates padding algorithm in AlgorithmID.

const (
	NoPadding    PaddingAlgorithm = 0x0
	PKCS7Padding PaddingAlgorithm = 0x1
)

Supported PaddingAlgorithm values.

type SoterContainer

type SoterContainer struct {
	TagBytes [4]byte
	Payload  []byte
}

SoterContainer is a lightweight data container with basic integrity checks.

func NewSoterContainer

func NewSoterContainer(tag string, payload []byte) *SoterContainer

NewSoterContainer makes a new Soter container with given tag and payload.

This is a convenience method so that you don't have to deal with arrays, as most of Themis tags are actually strings.

func ParseSoterContainer

func ParseSoterContainer(buffer []byte) (*SoterContainer, []byte)

ParseSoterContainer extracts and validates a Soter container from the buffer. It also returns the remaining part of the buffer.

func (*SoterContainer) Checksum

func (container *SoterContainer) Checksum() []byte

Checksum computes CRC checksum of this container.

func (*SoterContainer) Serialize

func (container *SoterContainer) Serialize(buffer []byte) []byte

Serialize this container, append it to the given buffer, and return it.

func (*SoterContainer) Tag

func (container *SoterContainer) Tag() string

Tag returns Soter container tag as a string.

type SymmetricAlgorithm

type SymmetricAlgorithm int

SymmetricAlgorithm indicates symmetric encryption algorithm in AlgorithmID.

const (
	AesECB SymmetricAlgorithm = 0x1
	AesCBC SymmetricAlgorithm = 0x2
	AesXTS SymmetricAlgorithm = 0x3
	AesGCM SymmetricAlgorithm = 0x4
)

Supported SymmetricAlgorithm values.

Jump to

Keyboard shortcuts

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