pad

package
v0.0.0-...-34d48bb Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2016 License: LGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package pad implements some padding schemes for block ciphers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Padding

type Padding interface {

	// BlockSize returns the block size of the padding.
	BlockSize() int

	// Returns the overhead, the padding will cause
	// by padding the given byte slice. The overhead
	// will always be between 1 and BlockSize() inclusively.
	Overhead(src []byte) int

	// Pads the last (may incomplete) block of the src slice
	// to a padded and complete block, appends the padding bytes
	// to the src slice and returns this slice.
	// The length of the returned slice is len(src) + Overhead(src)
	Pad(src []byte) []byte

	// Takes a slice and tries to remove the padding bytes
	// form the last block. Therefore the length of the
	// src argument must be a multiply of the blocksize.
	// If the returned error is nil, the padding could be
	// removed successfully. The returned slice holds the
	// unpadded src bytes.
	Unpad(src []byte) ([]byte, error)
}

The Padding interface represents a padding scheme.

func NewISO10126

func NewISO10126(blocksize int, rand io.Reader) Padding

NewISO10126 returns a new pad.Padding, which uses the padding scheme described in ISO 10126. The padding bytes are taken form the given rand argument. If rand is nil, crypto/rand will be used. Only block sizes between 1 and 255 are valid.

func NewPKCS7

func NewPKCS7(blocksize int) Padding

NewPKCS7 returns a new pad.Padding implementing the PKCS 7 scheme. Only block sizes between 1 and 255 are valid.

func NewX923

func NewX923(blocksize int) Padding

NewX923 returns a new pad.Padding implementing the ANSI X.923 scheme. Only block sizes between 1 and 255 are valid.

Jump to

Keyboard shortcuts

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