aes

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: LGPL-3.0 Imports: 4 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package aes provides legacy AES helpers kept for backward compatibility.

AesEncrypt and AesDecrypt implement AES-CBC with PKCS#7 padding. CBC provides confidentiality only and does not authenticate the ciphertext, so a tampered message can decrypt to attacker-influenced plaintext and the padding check can be abused as a padding oracle. These functions exist only to read data produced by older releases.

New formats must use an authenticated encryption mode such as AES-GCM (see keypair.EncryptWithCustomScrypt) instead of the raw CBC helpers here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AesDecrypt

func AesDecrypt(ciphertext []byte, key []byte, iv []byte) ([]byte, error)

AesDecrypt decrypts an AES-CBC ciphertext produced by AesEncrypt.

The ciphertext is not authenticated, so a successful return does not prove the data was not modified. Prefer an AEAD for new formats.

func AesEncrypt

func AesEncrypt(plaintext []byte, key []byte, iv []byte) ([]byte, error)

AesEncrypt encrypts plaintext with AES-CBC and PKCS#7 padding.

The returned ciphertext is NOT authenticated. Do not use this function for new formats; use an AEAD instead.

func PKCS5Padding

func PKCS5Padding(src []byte, blockSize int) []byte

func PKCS5UnPadding

func PKCS5UnPadding(src []byte, blockSize int) ([]byte, error)

PKCS5UnPadding validates and removes PKCS#7 padding from src. It rejects empty input, a padding length outside [1, blockSize], a length larger than the buffer and buffers whose length is not a multiple of the block size, and verifies that every padding byte carries the same value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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