keyenc

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 4, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Unwrap

func Unwrap(block cipher.Block, ciphertxt []byte) ([]byte, error)

func Wrap

func Wrap(kek cipher.Block, cek []byte) ([]byte, error)

Types

type AESCGM

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

AESCGM encrypts content encryption keys using AES-CGM key wrap. Contrary to what the name implies, it also decrypt encrypted keys

func NewAESCGM

func NewAESCGM(alg jwa.KeyEncryptionAlgorithm, sharedkey []byte) (*AESCGM, error)

NewAESCGM creates a key-wrap encrypter using AES-CGM. Although the name suggests otherwise, this does the decryption as well.

func (*AESCGM) Algorithm

func (kw *AESCGM) Algorithm() jwa.KeyEncryptionAlgorithm

Algorithm returns the key encryption algorithm being used

func (*AESCGM) Decrypt

func (kw *AESCGM) Decrypt(enckey []byte) ([]byte, error)

Decrypt decrypts the encrypted key using AES-CGM key unwrap

func (*AESCGM) Encrypt

func (kw *AESCGM) Encrypt(cek []byte) (keygen.ByteSource, error)

KeyEncrypt encrypts the given content encryption key

func (*AESCGM) KeyID

func (kw *AESCGM) KeyID() string

KeyID returns the key ID associated with this encrypter

type Decrypter

type Decrypter interface {
	Algorithm() jwa.KeyEncryptionAlgorithm
	Decrypt([]byte) ([]byte, error)
}

Decrypter is an interface for things that can decrypt keys

type DirectDecrypt

type DirectDecrypt struct {
	Key []byte
}

DirectDecrypt does no encryption (Note: Unimplemented)

func (DirectDecrypt) Decrypt

func (d DirectDecrypt) Decrypt() ([]byte, error)

Decrypt for DirectDecrypt does not do anything other than return a copy of the embedded key

type ECDHESDecrypt

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

ECDHESDecrypt decrypts keys using ECDH-ES.

func NewECDHESDecrypt

func NewECDHESDecrypt(alg jwa.KeyEncryptionAlgorithm, pubkey *ecdsa.PublicKey, apu, apv []byte, privkey *ecdsa.PrivateKey) *ECDHESDecrypt

NewECDHESDecrypt creates a new key decrypter using ECDH-ES

func (ECDHESDecrypt) Algorithm

func (kw ECDHESDecrypt) Algorithm() jwa.KeyEncryptionAlgorithm

Algorithm returns the key encryption algorithm being used

func (ECDHESDecrypt) Decrypt

func (kw ECDHESDecrypt) Decrypt(enckey []byte) ([]byte, error)

Decrypt decrypts the encrypted key using ECDH-ES

type ECDHESEncrypt

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

ECDHESEncrypt encrypts content encryption keys using ECDH-ES.

func NewECDHESEncrypt

func NewECDHESEncrypt(alg jwa.KeyEncryptionAlgorithm, key *ecdsa.PublicKey) (*ECDHESEncrypt, error)

NewECDHESEncrypt creates a new key encrypter based on ECDH-ES

func (ECDHESEncrypt) Algorithm

func (kw ECDHESEncrypt) Algorithm() jwa.KeyEncryptionAlgorithm

Algorithm returns the key encryption algorithm being used

func (ECDHESEncrypt) Encrypt

func (kw ECDHESEncrypt) Encrypt(cek []byte) (keygen.ByteSource, error)

KeyEncrypt encrypts the content encryption key using ECDH-ES

func (ECDHESEncrypt) KeyID

func (kw ECDHESEncrypt) KeyID() string

KeyID returns the key ID associated with this encrypter

type Encrypter

type Encrypter interface {
	Algorithm() jwa.KeyEncryptionAlgorithm
	Encrypt([]byte) (keygen.ByteSource, error)
	// KeyID returns the key id for this Encrypter. This exists so that
	// you can pass in a Encrypter to MultiEncrypt, you can rest assured
	// that the generated key will have the proper key ID.
	KeyID() string
}

Encrypter is an interface for things that can encrypt keys

type RSAOAEPDecrypt

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

RSAOAEPDecrypt decrypts keys using RSA OAEP algorithm

func NewRSAOAEPDecrypt

func NewRSAOAEPDecrypt(alg jwa.KeyEncryptionAlgorithm, privkey *rsa.PrivateKey) (*RSAOAEPDecrypt, error)

NewRSAOAEPDecrypt creates a new key decrypter using RSA OAEP

func (RSAOAEPDecrypt) Algorithm

Algorithm returns the key encryption algorithm being used

func (RSAOAEPDecrypt) Decrypt

func (d RSAOAEPDecrypt) Decrypt(enckey []byte) ([]byte, error)

Decrypt decryptes the encrypted key using RSA OAEP

type RSAOAEPEncrypt

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

RSAOAEPEncrypt encrypts keys using RSA OAEP algorithm

func NewRSAOAEPEncrypt

func NewRSAOAEPEncrypt(alg jwa.KeyEncryptionAlgorithm, pubkey *rsa.PublicKey) (*RSAOAEPEncrypt, error)

NewRSAOAEPEncrypt creates a new key encrypter using RSA OAEP

func (RSAOAEPEncrypt) Algorithm

Algorithm returns the key encryption algorithm being used

func (RSAOAEPEncrypt) Encrypt

func (e RSAOAEPEncrypt) Encrypt(cek []byte) (keygen.ByteSource, error)

KeyEncrypt encrypts the content encryption key using RSA OAEP

func (RSAOAEPEncrypt) KeyID

func (e RSAOAEPEncrypt) KeyID() string

KeyID returns the key ID associated with this encrypter

type RSAPKCS15Decrypt

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

RSAPKCS15Decrypt decrypts keys using RSA PKCS1v15 algorithm

func NewRSAPKCS15Decrypt

func NewRSAPKCS15Decrypt(alg jwa.KeyEncryptionAlgorithm, privkey *rsa.PrivateKey, keysize int) *RSAPKCS15Decrypt

NewRSAPKCS15Decrypt creates a new decrypter using RSA PKCS1v15

func (RSAPKCS15Decrypt) Algorithm

Algorithm returns the key encryption algorithm being used

func (RSAPKCS15Decrypt) Decrypt

func (d RSAPKCS15Decrypt) Decrypt(enckey []byte) ([]byte, error)

Decrypt decryptes the encrypted key using RSA PKCS1v1.5

type RSAPKCSEncrypt

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

RSAPKCSEncrypt encrypts keys using RSA PKCS1v15 algorithm

func NewRSAPKCSEncrypt

func NewRSAPKCSEncrypt(alg jwa.KeyEncryptionAlgorithm, pubkey *rsa.PublicKey) (*RSAPKCSEncrypt, error)

NewRSAPKCSEncrypt creates a new key encrypter using PKCS1v15

func (RSAPKCSEncrypt) Algorithm

Algorithm returns the key encryption algorithm being used

func (RSAPKCSEncrypt) Encrypt

func (e RSAPKCSEncrypt) Encrypt(cek []byte) (keygen.ByteSource, error)

KeyEncrypt encrypts the content encryption key using RSA PKCS1v15

func (RSAPKCSEncrypt) KeyID

func (e RSAPKCSEncrypt) KeyID() string

KeyID returns the key ID associated with this encrypter

Jump to

Keyboard shortcuts

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