rclone: github.com/ncw/rclone/backend/crypt/pkcs7 Index | Files

package pkcs7

import "github.com/ncw/rclone/backend/crypt/pkcs7"

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

Package Files

pkcs7.go

Variables

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

func Pad Uses

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 Uses

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.

Package pkcs7 imports 1 packages (graph). Updated 2018-01-12. Refresh now. Tools for package owners.