arcane

package module
v0.0.0-...-54fa747 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2020 License: MIT Imports: 10 Imported by: 0

README

arcane

Experimenting with cryptography stuff.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnableToGetEncryptionKey is returned when Opener is not able to decrypt the encryption key.
	ErrUnableToGetEncryptionKey = errors.New("unable to get encryption key used to encrypt the message")
	// ErrUnableToParseSealerCert is returned if Opener is not able to parse the certificate sent by Sealer.
	ErrUnableToParseSealerCert = errors.New("unable to parse certificate used to seal message")
	// ErrUntrustedCert is returned if the certificate sent by the sealer is not trusted.
	ErrUntrustedCert = errors.New("sealer certificate is not trusted")
	// ErrInvalidSignature is returned if signature is not valid.
	ErrInvalidSignature = errors.New("invalid signature")
	// ErrUnableToDecryptPayload is returned if Opener is not able to decrypt payload.
	ErrUnableToDecryptPayload = errors.New("unable to decrypt payload")
	// ErrMessageExpired is returned when a message is past its expiration.
	ErrMessageExpired = errors.New("message is expired")
)

Functions

This section is empty.

Types

type Envelope

type Envelope struct {
	Header  Header `json:"header"`
	Payload []byte `json:"payload"`
}

Envelope is ...

type Header struct {
	SealerCert   []byte `json:"sealerCert"`
	Signature    []byte `json:"signature"`
	EncryptedKey []byte `json:"encryptedKey"`
	Created      string `json:"created"`
	Expires      string `json:"expires"`
}

Header is ...

type Opener

type Opener struct {
	PrivateKey *rsa.PrivateKey
	CertPool   *x509.CertPool
}

Opener is used to open a encrypted and signed message,

func (*Opener) Open

func (o *Opener) Open(message *Envelope) ([]byte, error)

Open opens a *Message and returns the payload if no errors are encountered.

type Sealer

type Sealer struct {
	TimeToLive   time.Duration
	PrivateKey   *rsa.PrivateKey
	Cert         *x509.Certificate
	ReceiverCert *x509.Certificate
}

Sealer is used to encrypt and sign a message.

func (*Sealer) Seal

func (s *Sealer) Seal(payload []byte) (*Envelope, error)

Seal encrypts and signs a payload.

Directories

Path Synopsis
cmd
generatecert command
seal command

Jump to

Keyboard shortcuts

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