Documentation
¶
Index ¶
- Variables
- func AESDecrypt(ciphertext []byte, key []byte, iv []byte) ([]byte, error)
- func AESEncrypt(plaintext []byte, key []byte, iv []byte) ([]byte, error)
- func CheckKeyAndIVSize(key []byte, iv []byte) ([]byte, []byte, error)
- func PKCS7Padding(plaintext []byte, blockSize int) ([]byte, error)
- func PKCS7Unpadding(b []byte, blocksize int) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrInvalidBlockSize indicates block size <= 0. ErrInvalidBlockSize = errors.New("invalid block size") // ErrInvalidPKCS7Data indicates bad input to PKCS7 pad or unpad. ErrInvalidPKCS7Data = errors.New("invalid PKCS7 data (empty or not padded)") // ErrInvalidPKCS7Padding indicates PKCS7 unpad fails. ErrInvalidPKCS7Padding = errors.New("invalid padding on input") // ErrEmptyCiphertext indicates empty ciphertext. ErrEmptyCiphertext = errors.New("empty ciphertext") // ErrInvalidCiphertextSize indicates that the size of ciphertext is not a multiple of blocksize. ErrInvalidCiphertextSize = errors.New("invalid ciphertext size") // ErrInvalidKeySize indicates that the size of key is not 16 bytes ErrInvalidKeySize = errors.New("invalid key size") // ErrInvalidIVSize indicates that the size of iv is not 16 bytes ErrInvalidIVSize = errors.New("invalid iv size") )
Functions ¶
func AESDecrypt ¶
AESDecrypt decrypts ciphertext with AES and returns plaintext
func AESEncrypt ¶
AESEncrypt returns ciphertext which is encrypted with AES from plaintext mode: CBC padding: PKCS7 key size: 16 bytes iv size: 16 bytes
func CheckKeyAndIVSize ¶
CheckKeyAndIVSize requires that both key's size and iv's size must be 16 bytes
func PKCS7Padding ¶
PKCS7Padding pads bytes to the right of plaintext so that the length of plaintext after padding will be a multiple of blocksize(16 bytes for AES).
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.