aes

package
v0.0.0-...-214c3af Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Xor

func Xor(x []byte, y []byte)

Xor applies y xor to x. Please make sure that len(y) >= len(x).

Types

type AES

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

func NewAES

func NewAES(key []byte) (*AES, error)

NewAES returns a pointer of type AES and an error.

key: The following algorithms will be used based on the size of the key:

16 bytes = AES-128

24 bytes = AES-192

32 bytes = AES-256

func (*AES) DecryptCBC

func (a *AES) DecryptCBC(in []byte, iv []byte, unpad utils.UnpaddingFunc) []byte

DecryptCBC returns the plaintext of CBC-mode decryption. The iv must be 128bit.

func (*AES) DecryptCFB

func (a *AES) DecryptCFB(in []byte, iv []byte, s int) []byte

DecryptCFB decrypts every s bytes of ciphertext, with s at least 1 and no more than 128. The iv must be 128bit.

func (*AES) DecryptCTR

func (a *AES) DecryptCTR(in []byte, iv []byte) []byte

DecryptCTR returns the plaintext of CTR-mode decryption. The iv must be 128bit. It is exactly the same with EncryptCTR.

func (*AES) DecryptECB

func (a *AES) DecryptECB(in []byte, unpad utils.UnpaddingFunc) []byte

DecryptECB returns the plaintext of ECB-mode decryption.

func (*AES) DecryptGCM

func (a *AES) DecryptGCM(in []byte, iv []byte, auth []byte, tag []byte) []byte

DecryptGCM returns the plaintext of GCM-mode decryption or a nil if authentication failed.

func (*AES) DecryptOFB

func (a *AES) DecryptOFB(in []byte, iv []byte) []byte

DecryptOFB returns the plaintext of OFB-mode decryption. The iv must be 128bit.

func (*AES) EncryptCBC

func (a *AES) EncryptCBC(in []byte, iv []byte, pad utils.PaddingFunc) []byte

EncryptCBC returns the cipher of CBC-mode encryption. The iv must be 128bit.

func (*AES) EncryptCFB

func (a *AES) EncryptCFB(in []byte, iv []byte, s int) []byte

EncryptCFB encrypts every s bytes of plaintext, with s at least 1 and no more than 128. The iv must be 128bit.

func (*AES) EncryptCTR

func (a *AES) EncryptCTR(in []byte, iv []byte) []byte

EncryptCTR returns the ciphertext of CTR-mode encryption. The iv must be 128bit.

func (*AES) EncryptECB

func (a *AES) EncryptECB(in []byte, pad utils.PaddingFunc) []byte

EncryptECB returns the cipher of ECB-mode encryption.

func (*AES) EncryptGCM

func (a *AES) EncryptGCM(in []byte, iv []byte, auth []byte, tagLen int) ([]byte, []byte)

EncryptGCM returns the ciphertext of GCM-mode encryption and the tag.

func (*AES) EncryptGCTR

func (a *AES) EncryptGCTR(in []byte, ICB []byte) []byte

EncryptGCTR encrypts plaintext in with initial counter block ICB.

func (*AES) EncryptOFB

func (a *AES) EncryptOFB(in []byte, iv []byte) []byte

EncryptOFB returns the cipher of OFB-mode encryption. The iv must be 128bit.

Jump to

Keyboard shortcuts

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