libsignalgo.mau.fi/libsignal/cipher Index | Files

package cipher

import "go.mau.fi/libsignal/cipher"

CBC describes a block cipher mode. In cryptography, a block cipher mode of operation is an algorithm that uses a block cipher to provide an information service such as confidentiality or authenticity. A block cipher by itself is only suitable for the secure cryptographic transformation (encryption or decryption) of one fixed-length group of bits called a block. A mode of operation describes how to repeatedly apply a cipher's single-block operation to securely transform amounts of data larger than a block.

This package simplifies the usage of AES-256-CBC.

Package cipher is a package for common encrypt/decrypt of symmetric key messages.

Index

Variables

var (
	// ErrInvalidBlockSize indicates hash blocksize <= 0.
	ErrInvalidBlockSize = errors.New("invalid blocksize")

	// ErrInvalidPKCS7Data indicates bad input to PKCS7 pad or unpad.
	ErrInvalidPKCS7Data = errors.New("invalid PKCS7 data (empty or not padded)")

	// ErrInvalidPKCS7Padding indicates PKCS7 unpad fails to bad input.
	ErrInvalidPKCS7Padding = errors.New("invalid padding on input")
)

PKCS7 errors.

Functions

func Decrypt

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

Decrypt will use the given key, iv, and ciphertext and return the plaintext bytes.

func DecryptCbc

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

Decrypt is a function that decrypts a given cipher text with a provided key and initialization vector(iv).

func Encrypt

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

Encrypt will use the given iv, key, and plaintext bytes and return ciphertext bytes.

func EncryptCbc

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

Encrypt is a function that encrypts plaintext with a given key and an optional initialization vector(iv).

Source Files

Cbc.go Cipher.go

Version
v0.1.2 (latest)
Published
Feb 12, 2025
Platform
linux/amd64
Imports
7 packages
Last checked
1 week ago

Tools for package owners.