crypto

package
v0.0.0-...-14162c0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyAgreementSize = 32
	RandomLimit      = 256
)

Const byte sizes for key, signature

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(sealedMessage *SealedMessage, ourEncryptionKey *KeyAgreementKeyPair, theirSigningKey *SigningPublicKey) ([]byte, error)

Decrypt data

func HKDF

func HKDF(hash func() hash.Hash, secret []byte, additionalInfo []byte) ([]byte, error)

HKDF creates 256 bit derived key

Types

type IdentityKeyPair

type IdentityKeyPair struct {
	Signing      *SigningKeyPair
	KeyAgreement *KeyAgreementKeyPair
}

IdentityKeyPair is a pair of signign and key agreement

func NewIdentityKeyPair

func NewIdentityKeyPair() *IdentityKeyPair

NewIdentityKeyPair create a new identity key pair for signing and key agreement

type KeyAgreementKeyPair

type KeyAgreementKeyPair struct {
	PrivateKey *KeyAgreementPrivateKey
	PublicKey  *KeyAgreementPublicKey
}

KeyAgreementKeyPair is a pair of private and public key agreement keys

func NewKeyAgreementKeyPair

func NewKeyAgreementKeyPair() *KeyAgreementKeyPair

NewKeyAgreementKeyPair creates new ECKeyPair

type KeyAgreementPrivateKey

type KeyAgreementPrivateKey struct {
	// contains filtered or unexported fields
}

KeyAgreementPrivateKey represents a 256 bit Curve25519 private key for key exchange (KX).

func NewKeyAgreementPrivateKeyFrom

func NewKeyAgreementPrivateKeyFrom(b []byte) *KeyAgreementPrivateKey

NewKeyAgreementPrivateKeyFrom initializes a private key with the given value

func NewKeyAgreementPrivateKeyFromBase64String

func NewKeyAgreementPrivateKeyFromBase64String(value string) (*KeyAgreementPrivateKey, error)

NewKeyAgreementPrivateKeyFromBase64String init's a private key from base64 string

func (*KeyAgreementPrivateKey) Key

func (k *KeyAgreementPrivateKey) Key() []byte

Key returns the value of the private key.

func (*KeyAgreementPrivateKey) SharedSecretFrom

func (k *KeyAgreementPrivateKey) SharedSecretFrom(theirPublicKey *KeyAgreementPublicKey) []byte

SharedSecretFrom computes a shared secret with the provided public key from another party.

func (*KeyAgreementPrivateKey) ToBase64String

func (k *KeyAgreementPrivateKey) ToBase64String() string

ToBase64String returns base64 string.

type KeyAgreementPublicKey

type KeyAgreementPublicKey struct {
	// contains filtered or unexported fields
}

KeyAgreementPublicKey represents a 256 bit Curve25519 public key for key exchange (KX)

func NewKeyAgreementPublicKeyFrom

func NewKeyAgreementPublicKeyFrom(b []byte) *KeyAgreementPublicKey

NewKeyAgreementPublicKeyFrom initializes a public key with the given value

func NewKeyAgreementPublicKeyFromBase64String

func NewKeyAgreementPublicKeyFromBase64String(value string) (*KeyAgreementPublicKey, error)

NewKeyAgreementPublicKeyFromBase64String initilizes a public key from base64 string

func (*KeyAgreementPublicKey) Key

func (k *KeyAgreementPublicKey) Key() []byte

Key returns the value of the public key.

func (*KeyAgreementPublicKey) ToBase64String

func (k *KeyAgreementPublicKey) ToBase64String() string

ToBase64String returns base64 string.

type SealedMessage

type SealedMessage struct {
	EphemeralPublicKey *KeyAgreementPublicKey
	Signature          []byte
	Cipher             []byte
}

SealedMessage contain sealed info

func Encrypt

func Encrypt(data []byte, theirPublicKey *KeyAgreementPublicKey, ourSigningKey *SigningKeyPair) (*SealedMessage, error)

Encrypt data

type SigningKeyPair

type SigningKeyPair struct {
	PrivateKey *SigningPrivateKey
	PublicKey  *SigningPublicKey
}

SigningKeyPair is a pair of private and public signing keys

func NewSigningKeyPair

func NewSigningKeyPair() *SigningKeyPair

NewSigningKeyPair creates new signing key pair

type SigningPrivateKey

type SigningPrivateKey struct {
	// contains filtered or unexported fields
}

SigningPrivateKey represents signing private key

func NewSigningPrivateKeyFrom

func NewSigningPrivateKeyFrom(b []byte) *SigningPrivateKey

NewSigningPrivateKeyFrom initializes a private key with given value

func (*SigningPrivateKey) Key

func (k *SigningPrivateKey) Key() []byte

Key returns the value of signing private key

func (*SigningPrivateKey) Sign

func (k *SigningPrivateKey) Sign(message []byte) []byte

Sign returns signature using Ed25519

func (*SigningPrivateKey) ToBase64String

func (k *SigningPrivateKey) ToBase64String() string

ToBase64String returns base64 string.

type SigningPublicKey

type SigningPublicKey struct {
	// contains filtered or unexported fields
}

SigningPublicKey represents signing public key for verification

func NewSigningPublicKeyFrom

func NewSigningPublicKeyFrom(b []byte) *SigningPublicKey

NewSigningPublicKeyFrom initializes a public key with the given value

func (*SigningPublicKey) IsValidSignature

func (k *SigningPublicKey) IsValidSignature(signature []byte, message []byte) bool

IsValidSignature checks if the message has valid signature using Ed25519

func (*SigningPublicKey) Key

func (k *SigningPublicKey) Key() []byte

Key returns value of signing public key

func (*SigningPublicKey) ToBase64String

func (k *SigningPublicKey) ToBase64String() string

ToBase64String returns base64 string.

Jump to

Keyboard shortcuts

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