pkcs7

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2025 License: MIT Imports: 1 Imported by: ? modules, 0 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 pkcs7 implements PKCS#7 padding

This is a standard way of encoding variable length buffers into buffers which are a multiple of an underlying crypto block size.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorPaddingNotFound      = errors.New("bad PKCS#7 padding - not padded")
	ErrorPaddingNotAMultiple  = errors.New("bad PKCS#7 padding - not a multiple of blocksize")
	ErrorPaddingTooLong       = errors.New("bad PKCS#7 padding - too long")
	ErrorPaddingTooShort      = errors.New("bad PKCS#7 padding - too short")
	ErrorPaddingNotAllTheSame = errors.New("bad PKCS#7 padding - not all the same")
)

Errors Unpad can return

Functions

func Pad

func Pad(n int, buf []byte) []byte

Pad buf using PKCS#7 to a multiple of n.

Appends the padding to buf - make a copy of it first if you don't want it modified.

func Unpad

func Unpad(n int, buf []byte) ([]byte, error)

Unpad buf using PKCS#7 from a multiple of n returning a slice of buf or an error if malformed.

Types

This section is empty.

Jump to

Keyboard shortcuts

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