func DeriveECDHES(alg, apu, apv []byte, privkey interface{}, pubkey interface{}, keysize uint32) ([]byte, error)
func DeriveZ(privkeyif interface{}, pubkeyif interface{}) ([]byte, error)
func Unwrap(block cipher.Block, ciphertxt []byte) ([]byte, error)
func Wrap(kek cipher.Block, cek []byte) ([]byte, error)
AES encrypts content encryption keys using AES key wrap. Contrary to what the name implies, it also decrypt encrypted keys
type AES struct {
// contains filtered or unexported fields
}
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 (kw *AES) Algorithm() jwa.KeyEncryptionAlgorithm
Algorithm returns the key encryption algorithm being used
func (kw *AES) Decrypt(enckey []byte) ([]byte, error)
Decrypt decrypts the encrypted key using AES key unwrap
func (kw *AES) Encrypt(cek []byte) (keygen.ByteSource, error)
KeyEncrypt encrypts the given content encryption key
func (kw *AES) KeyID() string
KeyID returns the key ID associated with this encrypter
func (kw *AES) SetKeyID(v string)
AESGCM encrypts content encryption keys using AES-GCM key wrap.
type AESGCMEncrypt struct {
// contains filtered or unexported fields
}
func NewAESGCMEncrypt(alg jwa.KeyEncryptionAlgorithm, sharedkey []byte) (*AESGCMEncrypt, error)
func (kw AESGCMEncrypt) Algorithm() jwa.KeyEncryptionAlgorithm
func (kw AESGCMEncrypt) Encrypt(cek []byte) (keygen.ByteSource, error)
func (kw AESGCMEncrypt) KeyID() string
func (kw *AESGCMEncrypt) SetKeyID(v string)
Decrypter is an interface for things that can decrypt keys
type Decrypter interface { Algorithm() jwa.KeyEncryptionAlgorithm Decrypt([]byte) ([]byte, error) }
DirectDecrypt does no encryption (Note: Unimplemented)
type DirectDecrypt struct { Key []byte }
func (d DirectDecrypt) Decrypt() ([]byte, error)
Decrypt for DirectDecrypt does not do anything other than return a copy of the embedded key
ECDHESDecrypt decrypts keys using ECDH-ES.
type ECDHESDecrypt struct {
// contains filtered or unexported fields
}
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 (kw ECDHESDecrypt) Algorithm() jwa.KeyEncryptionAlgorithm
Algorithm returns the key encryption algorithm being used
func (kw ECDHESDecrypt) Decrypt(enckey []byte) ([]byte, error)
Decrypt decrypts the encrypted key using ECDH-ES
ECDHESEncrypt encrypts content encryption keys using ECDH-ES.
type ECDHESEncrypt struct {
// contains filtered or unexported fields
}
func NewECDHESEncrypt(alg jwa.KeyEncryptionAlgorithm, enc jwa.ContentEncryptionAlgorithm, keysize int, keyif interface{}) (*ECDHESEncrypt, error)
NewECDHESEncrypt creates a new key encrypter based on ECDH-ES
func (kw ECDHESEncrypt) Algorithm() jwa.KeyEncryptionAlgorithm
Algorithm returns the key encryption algorithm being used
func (kw ECDHESEncrypt) Encrypt(cek []byte) (keygen.ByteSource, error)
KeyEncrypt encrypts the content encryption key using ECDH-ES
func (kw ECDHESEncrypt) KeyID() string
KeyID returns the key ID associated with this encrypter
func (kw *ECDHESEncrypt) SetKeyID(v string)
Encrypter is an interface for things that can encrypt keys
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 SetKeyID(string) }
type Noop struct {
// contains filtered or unexported fields
}
func NewNoop(alg jwa.KeyEncryptionAlgorithm, sharedkey []byte) (*Noop, error)
func (kw *Noop) Algorithm() jwa.KeyEncryptionAlgorithm
func (kw *Noop) Encrypt(cek []byte) (keygen.ByteSource, error)
func (kw *Noop) KeyID() string
func (kw *Noop) SetKeyID(v string)
PBES2Encrypt encrypts keys with PBES2 / PBKDF2 password
type PBES2Encrypt struct {
// contains filtered or unexported fields
}
func NewPBES2Encrypt(alg jwa.KeyEncryptionAlgorithm, password []byte) (*PBES2Encrypt, error)
func (kw PBES2Encrypt) Algorithm() jwa.KeyEncryptionAlgorithm
func (kw PBES2Encrypt) Encrypt(cek []byte) (keygen.ByteSource, error)
func (kw PBES2Encrypt) KeyID() string
func (kw *PBES2Encrypt) SetKeyID(v string)
RSAOAEPDecrypt decrypts keys using RSA OAEP algorithm
type RSAOAEPDecrypt struct {
// contains filtered or unexported fields
}
func NewRSAOAEPDecrypt(alg jwa.KeyEncryptionAlgorithm, privkey *rsa.PrivateKey) (*RSAOAEPDecrypt, error)
NewRSAOAEPDecrypt creates a new key decrypter using RSA OAEP
func (d RSAOAEPDecrypt) Algorithm() jwa.KeyEncryptionAlgorithm
Algorithm returns the key encryption algorithm being used
func (d RSAOAEPDecrypt) Decrypt(enckey []byte) ([]byte, error)
Decrypt decrypts the encrypted key using RSA OAEP
RSAOAEPEncrypt encrypts keys using RSA OAEP algorithm
type RSAOAEPEncrypt struct {
// contains filtered or unexported fields
}
func NewRSAOAEPEncrypt(alg jwa.KeyEncryptionAlgorithm, pubkey *rsa.PublicKey) (*RSAOAEPEncrypt, error)
NewRSAOAEPEncrypt creates a new key encrypter using RSA OAEP
func (e RSAOAEPEncrypt) Algorithm() jwa.KeyEncryptionAlgorithm
Algorithm returns the key encryption algorithm being used
func (e RSAOAEPEncrypt) Encrypt(cek []byte) (keygen.ByteSource, error)
KeyEncrypt encrypts the content encryption key using RSA OAEP
func (e RSAOAEPEncrypt) KeyID() string
KeyID returns the key ID associated with this encrypter
func (e *RSAOAEPEncrypt) SetKeyID(v string)
RSAPKCS15Decrypt decrypts keys using RSA PKCS1v15 algorithm
type RSAPKCS15Decrypt struct {
// contains filtered or unexported fields
}
func NewRSAPKCS15Decrypt(alg jwa.KeyEncryptionAlgorithm, privkey *rsa.PrivateKey, keysize int) *RSAPKCS15Decrypt
NewRSAPKCS15Decrypt creates a new decrypter using RSA PKCS1v15
func (d RSAPKCS15Decrypt) Algorithm() jwa.KeyEncryptionAlgorithm
Algorithm returns the key encryption algorithm being used
func (d RSAPKCS15Decrypt) Decrypt(enckey []byte) ([]byte, error)
Decrypt decrypts the encrypted key using RSA PKCS1v1.5
RSAPKCSEncrypt encrypts keys using RSA PKCS1v15 algorithm
type RSAPKCSEncrypt struct {
// contains filtered or unexported fields
}
func NewRSAPKCSEncrypt(alg jwa.KeyEncryptionAlgorithm, pubkey *rsa.PublicKey) (*RSAPKCSEncrypt, error)
NewRSAPKCSEncrypt creates a new key encrypter using PKCS1v15
func (e RSAPKCSEncrypt) Algorithm() jwa.KeyEncryptionAlgorithm
Algorithm returns the key encryption algorithm being used
func (e RSAPKCSEncrypt) Encrypt(cek []byte) (keygen.ByteSource, error)
KeyEncrypt encrypts the content encryption key using RSA PKCS1v15
func (e RSAPKCSEncrypt) KeyID() string
KeyID returns the key ID associated with this encrypter
func (e *RSAPKCSEncrypt) SetKeyID(v string)