authcrypt

package
v0.1.3-0...-617a0de Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// C20P Chacha20Poly1305 algorithm
	C20P = ContentEncryption("C20P") // Chacha20 encryption + Poly1305 authenticator cipher (96 bits nonce)
	// XC20P XChacha20Poly1305 algorithm
	XC20P = ContentEncryption("XC20P") // XChacha20 encryption + Poly1305 authenticator cipher (192 bits nonce)

)

Variables

This section is empty.

Functions

This section is empty.

Types

type ContentEncryption

type ContentEncryption string

ContentEncryption represents a content encryption algorithm.

type Envelope

type Envelope struct {
	Protected  string      `json:"protected,omitempty"`
	Recipients []Recipient `json:"recipients,omitempty"`
	AAD        string      `json:"aad,omitempty"`
	IV         string      `json:"iv,omitempty"`
	Tag        string      `json:"tag,omitempty"`
	CipherText string      `json:"ciphertext,omitempty"`
}

Envelope represents a JWE envelope as per the Aries Encryption envelope specs

type Packer

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

Packer represents an Authcrypt Packer/Unpacker that outputs/reads JWE envelopes

func New

func New(ctx packer.Provider, alg ContentEncryption) (*Packer, error)

New will create an Packer instance to 'AuthCrypt' payloads for the given sender and recipients arguments and the encryption alg argument. Possible algorithms supported are: C20P (chacha20-poly1305 ietf) XC20P (xchacha20-poly1305 ietf) The returned Packer contains all the information required to pack and unpack payloads.

func (*Packer) EncodingType

func (p *Packer) EncodingType() string

EncodingType returns the type of the encoding, as in the `Typ` field of the envelope header

func (*Packer) Pack

func (p *Packer) Pack(payload, senderVerKey []byte, recipientsVerKeys [][]byte) ([]byte, error)

Pack will JWE encode the payload argument for the sender and recipients Using (X)Chacha20 encryption algorithm and Poly1305 authenticator It will encrypt by fetching the sender's encryption key corresponding to senderVerKey and converting the list of recipientsVerKeys into a list of encryption keys

func (*Packer) Unpack

func (p *Packer) Unpack(envelope []byte) (*transport.Envelope, error)

Unpack will JWE decode the envelope argument for the recipientPrivKey and validates the envelope's recipients has a match for recipientKeyPair.Pub key. Using (X)Chacha20 cipher and Poly1305 authenticator for the encrypted payload and encrypted CEK. The current recipient is the one with the sender's encrypted key that successfully decrypts with recipientKeyPair.Priv Key.

type Recipient

type Recipient struct {
	EncryptedKey string           `json:"encrypted_key,omitempty"`
	Header       RecipientHeaders `json:"header,omitempty"`
}

Recipient is a recipient of an envelope including the shared encryption key

type RecipientHeaders

type RecipientHeaders struct {
	APU string `json:"apu,omitempty"`
	IV  string `json:"iv,omitempty"`
	Tag string `json:"tag,omitempty"`
	KID string `json:"kid,omitempty"`
	SPK string `json:"spk,omitempty"`
}

RecipientHeaders are the recipient headers

Jump to

Keyboard shortcuts

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