secureid

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2020 License: MIT Imports: 9 Imported by: 0

README

SecureID Core package

SecureID does AES encryption/decryption of sensitive data to be transmited over public API.

Documentation

Index

Constants

View Source
const (
	Version0 = ProtocolVersion("v0") // see genKeyInfoV0
	Version1 = ProtocolVersion("v1") // see genKeyInfoV1

	Version = ProtocolVersion(Version1) // Current ProtocolVersion
)

Variables

View Source
var (
	DefaultHash = sha512.New // DefaultHash is sha512
)

Functions

func VersionFormat

func VersionFormat(version ProtocolVersion, keyID KeyID) string

VersionFormat contruct Version from ProtocolVersion and KeyID see SecureID Version field

func VersionParse

func VersionParse(str string) (ProtocolVersion, KeyID)

VersionParse return ProtocolVersion and KeyID from Version see SecureID Version field

Types

type HashFunc

type HashFunc func() hash.Hash

HashFunc is used for extenal hash algorithm default is SHA512

func HashFromVersion

func HashFromVersion(version ProtocolVersion) HashFunc

HashFromVersion return HashFunc from ProtocolVersion

type KeyID

type KeyID uint

KeyID type for keys rotation

type Keys

type Keys struct {
	Version ProtocolVersion
	KeyID   KeyID
	// contains filtered or unexported fields
}

Keys struct holds state for encrypt/decrypt SecureID

func DefaultKeys

func DefaultKeys(info SecureInfo, keyID KeyID) *Keys

DefaultKeys return Keys from current ProtocolVersion and KeyID, with SecureInfo

func NewKeys

func NewKeys(info SecureInfo, version ProtocolVersion, keyID KeyID) *Keys

NewKeys return Key from SecureInfo, ProtocolVersion and KeyID

func NewKeysWithHashFunction

func NewKeysWithHashFunction(info SecureInfo, version ProtocolVersion, keyID KeyID, hash HashFunc) *Keys

NewKeysWithHashFunction return Key from SecureInfo, ProtocolVersion, KeyID and HashFunc ProtocolVersion hash is used if nil

func (*Keys) SecureIDFromValue

func (p *Keys) SecureIDFromValue(value Value) (SecureID, error)

SecureIDFromValue return SecureID from Value using Keys state

func (*Keys) ValueFromSecureID

func (p *Keys) ValueFromSecureID(secureID SecureID) (Value, error)

ValueFromSecureID return Value from SecureID using Keys state

type ProtocolVersion

type ProtocolVersion string

ProtocolVersion type for protocol versioning

type SecureID

type SecureID struct {
	Version string `json:"ver"`

	Data  string `json:"id"`
	Check string `json:"sig"`
}

SecureID struct

func SecureIDFromValue

func SecureIDFromValue(info SecureInfo, version ProtocolVersion, keyID KeyID, value Value) (SecureID, error)

SecureIDFromValue convert Value to SecureID using SecureInfo, ProtocolVersion and KeyID

func (*SecureID) Value

func (p *SecureID) Value(info SecureInfo, secureID SecureID) (Value, error)

Value convert SecureID to Value SecureInfo Version and KeyID are retrived from secureID.Version field

type SecureInfo

type SecureInfo struct {
	Seed    Seed   // seed used for keys derivation
	Context string // context used for hkdf
}

SecureInfo struct used for SecureID function and Keys initialisation

type Seed

type Seed []byte

Seed type used to init secrets for Keys

type Value

type Value uint64

Value type used as payload of transmited data

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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