common

package
v5.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package common provides encryption methods common across encryption types

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetChecksumHash

func GetChecksumHash(b, key []byte, usage uint32, etype etype.EType) ([]byte, error)

GetChecksumHash returns a keyed checksum hash of the bytes provided.

func GetHash

func GetHash(pt, key []byte, usage []byte, etype etype.EType) ([]byte, error)

GetHash generates the keyed hash value according to the etype's hash function.

func GetIntegrityHash

func GetIntegrityHash(b, key []byte, usage uint32, etype etype.EType) ([]byte, error)

GetIntegrityHash returns a keyed integrity hash of the bytes provided.

func GetUsageKc

func GetUsageKc(un uint32) []byte

GetUsageKc returns the checksum key usage value for the usage number un.

RFC 3961: The "well-known constant" used for the DK function is the key usage number, expressed as four octets in big-endian order, followed by one octet indicated below.

Kc = DK(base-key, usage | 0x99);

func GetUsageKe

func GetUsageKe(un uint32) []byte

GetUsageKe returns the encryption key usage value for the usage number un

RFC 3961: The "well-known constant" used for the DK function is the key usage number, expressed as four octets in big-endian order, followed by one octet indicated below.

Ke = DK(base-key, usage | 0xAA);

func GetUsageKi

func GetUsageKi(un uint32) []byte

GetUsageKi returns the integrity key usage value for the usage number un

RFC 3961: The "well-known constant" used for the DK function is the key usage number, expressed as four octets in big-endian order, followed by one octet indicated below.

Ki = DK(base-key, usage | 0x55);

func IterationsToS2Kparams

func IterationsToS2Kparams(i uint32) string

IterationsToS2Kparams converts the number of iterations as an integer to a string representation.

func PKCS7Pad

func PKCS7Pad(b []byte, m int) ([]byte, error)

PKCS7Pad pads bytes according to RFC 2315 to nearest multiple of message size m.

func PKCS7Unpad

func PKCS7Unpad(b []byte, m int) ([]byte, error)

PKCS7Unpad removes RFC 2315 padding from byes where message size is m.

func VerifyChecksum

func VerifyChecksum(key, chksum, msg []byte, usage uint32, etype etype.EType) bool

VerifyChecksum compares the checksum of the msg bytes is the same as the checksum provided.

func ZeroPad

func ZeroPad(b []byte, m int) ([]byte, error)

ZeroPad pads bytes with zeros to nearest multiple of message size m.

Types

This section is empty.

Jump to

Keyboard shortcuts

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