Documentation ¶
Index ¶
Constants ¶
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 ¶
EncodingType returns the type of the encoding, as in the `Typ` field of the envelope header
func (*Packer) Pack ¶
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 ¶
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