subtle

package
v0.0.0-...-57c6170 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package subtle provides subtle implementations of the AEAD primitive.

Index

Constants

View Source
const (

	// AES128Size value in number of bytes.
	AES128Size = 16
	// AES192Size value in number of bytes.
	AES192Size = 24
	// AES256Size value in number of bytes.
	AES256Size = 32
)
View Source
const (
	// AESCBCIVSize is the IV size that this implementation supports.
	AESCBCIVSize = 16
)

Variables

This section is empty.

Functions

func Pad

func Pad(text []byte, originalTextSize, blockSize int) []byte

Pad text to blockSize.

func Unpad

func Unpad(text []byte) []byte

Unpad a padded text of blockSize.

func ValidateAESKeySize

func ValidateAESKeySize(sizeInBytes uint32) error

ValidateAESKeySize checks if the given key size is a valid AES key size.

func ValidateAESKeySizeForGoJose

func ValidateAESKeySizeForGoJose(sizeInBytes uint32) error

ValidateAESKeySizeForGoJose checks if the given key size is a valid AES key size.

Types

type AESCBC

type AESCBC struct {
	Key []byte
}

AESCBC is an implementation of AEAD interface.

func NewAESCBC

func NewAESCBC(key []byte) (*AESCBC, error)

NewAESCBC returns an AESCBC instance. The key argument should be the AES key, either 16, 24 or 32 bytes to select AES-128, AES-192 or AES-256.

func (*AESCBC) Decrypt

func (a *AESCBC) Decrypt(ciphertext []byte) ([]byte, error)

Decrypt decrypts ciphertext.

func (*AESCBC) Encrypt

func (a *AESCBC) Encrypt(plaintext []byte) ([]byte, error)

Encrypt encrypts plaintext using AES in CTR mode. The resulting ciphertext consists of two parts: (1) the IV used for encryption and (2) the actual ciphertext.

type AESCBCHMAC

type AESCBCHMAC struct {
	Key []byte
}

AESCBCHMAC is an implementation of AEAD interface.

func NewAESCBCHMAC

func NewAESCBCHMAC(key []byte) (*AESCBCHMAC, error)

NewAESCBCHMAC returns an AES CBC HMAC instance. The key argument should be the AES key, either 16, 24 or 32 bytes to select AES-128, AES-192 or AES-256. ivSize specifies the size of the IV in bytes.

func (*AESCBCHMAC) Decrypt

func (a *AESCBCHMAC) Decrypt(ciphertext, additionalData []byte) ([]byte, error)

Decrypt decrypts ciphertext.

func (*AESCBCHMAC) Encrypt

func (a *AESCBCHMAC) Encrypt(plaintext, additionalData []byte) ([]byte, error)

Encrypt encrypts plaintext using AES in CTR mode. The resulting ciphertext consists of two parts: (1) a random IV used for encryption and (2) the actual ciphertext.

Jump to

Keyboard shortcuts

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