keyenc

package
v2.0.21 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeriveECDHES

func DeriveECDHES(alg, apu, apv []byte, privkey interface{}, pubkey interface{}, keysize uint32) ([]byte, error)

func DeriveZ

func DeriveZ(privkeyif interface{}, pubkeyif interface{}) ([]byte, error)

func Unwrap

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

func Wrap

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

Types

type AES

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

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

func NewAES

func NewAES(alg jwa.KeyEncryptionAlgorithm, sharedkey []byte) (*AES, error)

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

func (*AES) Algorithm

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

Algorithm returns the key encryption algorithm being used

func (*AES) Decrypt

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

Decrypt decrypts the encrypted key using AES key unwrap

func (*AES) EncryptKey added in v2.0.10

func (kw *AES) EncryptKey(cek []byte) (keygen.ByteSource, error)

KeyEncrypt encrypts the given content encryption key

func (*AES) KeyID

func (kw *AES) KeyID() string

KeyID returns the key ID associated with this encrypter

func (*AES) SetKeyID

func (kw *AES) SetKeyID(v string)

type AESGCMEncrypt

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

AESGCM encrypts content encryption keys using AES-GCM key wrap.

func NewAESGCMEncrypt

func NewAESGCMEncrypt(alg jwa.KeyEncryptionAlgorithm, sharedkey []byte) (*AESGCMEncrypt, error)

func (AESGCMEncrypt) Algorithm

func (kw AESGCMEncrypt) Algorithm() jwa.KeyEncryptionAlgorithm

func (AESGCMEncrypt) EncryptKey added in v2.0.10

func (kw AESGCMEncrypt) EncryptKey(cek []byte) (keygen.ByteSource, error)

func (AESGCMEncrypt) KeyID

func (kw AESGCMEncrypt) KeyID() string

func (*AESGCMEncrypt) SetKeyID

func (kw *AESGCMEncrypt) SetKeyID(v string)

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(keyalg jwa.KeyEncryptionAlgorithm, contentalg jwa.ContentEncryptionAlgorithm, pubkey interface{}, apu, apv []byte, privkey interface{}) *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, enc jwa.ContentEncryptionAlgorithm, keysize int, keyif interface{}, apu, apv []byte) (*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) EncryptKey added in v2.0.10

func (kw ECDHESEncrypt) EncryptKey(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

func (*ECDHESEncrypt) SetKeyID

func (kw *ECDHESEncrypt) SetKeyID(v string)

type Encrypter

type Encrypter interface {
	Algorithm() jwa.KeyEncryptionAlgorithm
	EncryptKey([]byte) (keygen.ByteSource, error)
}

Encrypter is an interface for things that can encrypt keys

type Noop

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

func NewNoop

func NewNoop(alg jwa.KeyEncryptionAlgorithm, sharedkey []byte) (*Noop, error)

func (*Noop) Algorithm

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

func (*Noop) EncryptKey added in v2.0.10

func (kw *Noop) EncryptKey(_ []byte) (keygen.ByteSource, error)

func (*Noop) KeyID

func (kw *Noop) KeyID() string

func (*Noop) SetKeyID

func (kw *Noop) SetKeyID(v string)

type PBES2Encrypt

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

PBES2Encrypt encrypts keys with PBES2 / PBKDF2 password

func NewPBES2Encrypt

func NewPBES2Encrypt(alg jwa.KeyEncryptionAlgorithm, password []byte) (*PBES2Encrypt, error)

func (PBES2Encrypt) Algorithm

func (kw PBES2Encrypt) Algorithm() jwa.KeyEncryptionAlgorithm

func (PBES2Encrypt) EncryptKey added in v2.0.10

func (kw PBES2Encrypt) EncryptKey(cek []byte) (keygen.ByteSource, error)

func (PBES2Encrypt) KeyID

func (kw PBES2Encrypt) KeyID() string

func (*PBES2Encrypt) SetKeyID

func (kw *PBES2Encrypt) SetKeyID(v string)

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 decrypts 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) EncryptKey added in v2.0.10

func (e RSAOAEPEncrypt) EncryptKey(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

func (*RSAOAEPEncrypt) SetKeyID

func (e *RSAOAEPEncrypt) SetKeyID(v string)

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 decrypts 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) EncryptKey added in v2.0.10

func (e RSAPKCSEncrypt) EncryptKey(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

func (*RSAPKCSEncrypt) SetKeyID

func (e *RSAPKCSEncrypt) SetKeyID(v string)

Jump to

Keyboard shortcuts

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