algorithm

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AESGenerateIV added in v0.5.0

func AESGenerateIV(rand io.Reader) ([]byte, error)

func AESGenerateNonce added in v0.5.0

func AESGenerateNonce(rand io.Reader) ([]byte, error)

func As added in v0.5.0

func As[T any](algorithm any, target *T) bool

func GetHash added in v0.3.0

func GetHash(algorithm SignAlgorithm) (crypto.Hash, error)

func NewAlgorithm added in v0.3.0

func NewAlgorithm(key azkeys.JSONWebKey, rand io.Reader) (any, error)

Types

type AES added in v0.5.0

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

func (AES) DecryptAESCBC added in v0.7.0

func (a AES) DecryptAESCBC(algorithm EncryptAESCBCAlgorithm, ciphertext, iv []byte) (DecryptResult, error)

func (AES) DecryptAESGCM added in v0.7.0

func (a AES) DecryptAESGCM(algorithm EncryptAESGCMAlgorithm, ciphertext, nonce, authenticationTag, additionalAuthenticatedData []byte) (DecryptResult, error)

func (AES) EncryptAESCBC added in v0.5.0

func (a AES) EncryptAESCBC(algorithm EncryptAESCBCAlgorithm, plaintext, iv []byte) (EncryptResult, error)

func (AES) EncryptAESGCM added in v0.5.0

func (a AES) EncryptAESGCM(algorithm EncryptAESGCMAlgorithm, plaintext, nonce, additionalAuthenticatedData []byte) (EncryptResult, error)

func (AES) UnwrapKey added in v0.7.0

func (a AES) UnwrapKey(algorithm WrapKeyAlgorithm, encryptedKey []byte) (UnwrapKeyResult, error)

func (AES) WrapKey added in v0.6.0

func (a AES) WrapKey(algorithm WrapKeyAlgorithm, key []byte) (WrapKeyResult, error)

type AESEncrypter added in v0.5.0

type AESEncrypter interface {
	EncryptAESCBC(algorithm EncryptAESCBCAlgorithm, plaintext, iv []byte) (EncryptResult, error)
	DecryptAESCBC(algorithm EncryptAESCBCAlgorithm, ciphertext, iv []byte) (DecryptResult, error)
	EncryptAESGCM(algorithm EncryptAESGCMAlgorithm, plaintext, nonce, additionalAuthenticatedData []byte) (EncryptResult, error)
	DecryptAESGCM(algorithm EncryptAESGCMAlgorithm, ciphertext, nonce, authenticationTag, additionalAuthenticatedData []byte) (DecryptResult, error)
}

type DecryptResult added in v0.3.0

type DecryptResult struct {
	// Algorithm is encryption algorithm used to decrypt.
	Algorithm EncryptAlgorithm

	// KeyID is the key ID used to decrypt.
	KeyID string

	// Plaintext is the decryption result.
	Plaintext []byte
}

type ECDsa

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

func (ECDsa) Sign

func (c ECDsa) Sign(algorithm SignAlgorithm, digest []byte) (SignResult, error)

func (ECDsa) Verify

func (c ECDsa) Verify(algorithm SignAlgorithm, digest, signature []byte) (VerifyResult, error)

type EncryptAESCBCAlgorithm added in v0.5.0

type EncryptAESCBCAlgorithm = azkeys.EncryptionAlgorithm

type EncryptAESGCMAlgorithm added in v0.5.0

type EncryptAESGCMAlgorithm = azkeys.EncryptionAlgorithm

type EncryptAlgorithm added in v0.5.0

type EncryptAlgorithm = azkeys.EncryptionAlgorithm

type EncryptResult added in v0.3.0

type EncryptResult struct {
	// Algorithm is encryption algorithm used to encrypt.
	Algorithm EncryptAlgorithm

	// KeyID is the key ID used to encrypt. This key ID should be retained.
	KeyID string

	// Ciphertext is the encryption result.
	Ciphertext []byte

	// IV is the initialization vector used to encrypt using AES-CBC.
	IV []byte

	// Nonce is the nonce used to encrypt using AES-GCM.
	Nonce []byte

	// AdditionalAuthenticatedData passed to EncryptAESGCM.
	AdditionalAuthenticatedData []byte

	// AuthenticationTag returned from EncryptAESGCM.
	AuthenticationTag []byte
}

type Encrypter added in v0.5.0

type Encrypter interface {
	Encrypt(algorithm EncryptAlgorithm, plaintext []byte) (EncryptResult, error)
	Decrypt(algorithm EncryptAlgorithm, ciphertext []byte) (DecryptResult, error)
}

type KeyWrapper added in v0.6.0

type KeyWrapper interface {
	WrapKey(algorithm WrapKeyAlgorithm, key []byte) (WrapKeyResult, error)
	UnwrapKey(algorithm WrapKeyAlgorithm, encryptedKey []byte) (UnwrapKeyResult, error)
}

type RSA added in v0.3.0

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

func (RSA) Decrypt added in v0.7.0

func (r RSA) Decrypt(algorithm EncryptAlgorithm, ciphertext []byte) (DecryptResult, error)

func (RSA) Encrypt added in v0.3.0

func (r RSA) Encrypt(algorithm EncryptAlgorithm, plaintext []byte) (EncryptResult, error)

func (RSA) Sign added in v0.7.0

func (r RSA) Sign(algorithm SignAlgorithm, digest []byte) (SignResult, error)

func (RSA) UnwrapKey added in v0.7.0

func (r RSA) UnwrapKey(algorithm WrapKeyAlgorithm, encryptedKey []byte) (UnwrapKeyResult, error)

func (RSA) Verify added in v0.3.0

func (r RSA) Verify(algorithm SignAlgorithm, digest, signature []byte) (VerifyResult, error)

func (RSA) WrapKey added in v0.3.0

func (r RSA) WrapKey(algorithm WrapKeyAlgorithm, key []byte) (WrapKeyResult, error)

type SignAlgorithm added in v0.5.0

type SignAlgorithm = azkeys.SignatureAlgorithm

type SignResult

type SignResult struct {
	// Algorithm is the signature algorithm used to sign.
	Algorithm SignAlgorithm

	// KeyID is the key ID used to sign. This key ID should be retained.
	KeyID string

	// Signature is a signed hash of the data.
	Signature []byte
}

type Signer added in v0.5.0

type Signer interface {
	Sign(algorithm SignAlgorithm, digest []byte) (SignResult, error)
	Verify(algorithm SignAlgorithm, digest, signature []byte) (VerifyResult, error)
}

type UnwrapKeyResult added in v0.3.0

type UnwrapKeyResult struct {
	// Algorithm is the key wrap algorithm used to unwrap.
	Algorithm WrapKeyAlgorithm

	// KeyID is the key ID used to unwrap.
	KeyID string

	// Key is the unwrapped (decrypted) key.
	Key []byte
}

type VerifyResult

type VerifyResult struct {
	// Algorithm is the signature algorithm used to verify.
	Algorithm SignAlgorithm

	// KeyID is the key ID used to verify.
	KeyID string

	// Valid is true of the signature is valid.
	Valid bool
}

type WrapKeyAlgorithm added in v0.5.0

type WrapKeyAlgorithm = azkeys.EncryptionAlgorithm

type WrapKeyResult added in v0.3.0

type WrapKeyResult struct {
	// Algorithm is the key wrap algorithm used to wrap.
	Algorithm WrapKeyAlgorithm

	// KeyID is the key ID used to wrap. This key ID should be retained.
	KeyID string

	// EncryptedKey is the wrapped (encrypted) key.
	EncryptedKey []byte
}

Jump to

Keyboard shortcuts

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