rfc3961

package
v8.5.3 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package rfc3961 provides encryption and checksum methods as specified in RFC 3961

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DES3DecryptData

func DES3DecryptData(key, data []byte, e etype.EType) ([]byte, error)

DES3DecryptData decrypts the data provided using DES3 and methods specific to the etype provided.

func DES3DecryptMessage

func DES3DecryptMessage(key, ciphertext []byte, usage uint32, e etype.EType) ([]byte, error)

DES3DecryptMessage decrypts the message provided using DES3 and methods specific to the etype provided. The integrity of the message is also verified.

func DES3EncryptData

func DES3EncryptData(key, data []byte, e etype.EType) ([]byte, []byte, error)

DES3EncryptData encrypts the data provided using DES3 and methods specific to the etype provided.

func DES3EncryptMessage

func DES3EncryptMessage(key, message []byte, usage uint32, e etype.EType) ([]byte, []byte, error)

DES3EncryptMessage encrypts the message provided using DES3 and methods specific to the etype provided. The encrypted data is concatenated with its integrity hash to create an encrypted message.

func DES3RandomToKey

func DES3RandomToKey(b []byte) []byte

DES3RandomToKey returns a key from the bytes provided according to the definition in RFC 3961 for DES3 etypes.

func DES3StringToKey

func DES3StringToKey(secret, salt string, e etype.EType) ([]byte, error)

DES3StringToKey returns a key derived from the string provided according to the definition in RFC 3961 for DES3 etypes.

func DeriveKey

func DeriveKey(protocolKey, usage []byte, e etype.EType) ([]byte, error)

DeriveKey derives a key from the protocol key based on the usage and the etype's specific methods.

func DeriveRandom

func DeriveRandom(key, usage []byte, e etype.EType) ([]byte, error)

DeriveRandom implements the RFC 3961 defined function: DR(Key, Constant) = k-truncate(E(Key, Constant, initial-cipher-state)).

key: base key or protocol key. Likely to be a key from a keytab file.

usage: a constant.

n: block size in bits (not bytes) - note if you use something like aes.BlockSize this is in bytes.

k: key length / key seed length in bits. Eg. for AES256 this value is 256.

e: the encryption etype function to use.

func Nfold

func Nfold(m []byte, n int) []byte

Nfold expands the key to ensure it is not smaller than one cipher block. Defined in RFC 3961.

m input bytes that will be "stretched" to the least common multiple of n bits and the bit length of m.

func PseudoRandom

func PseudoRandom(key, b []byte, e etype.EType) ([]byte, error)

PseudoRandom function as defined in RFC 3961

func RandomToKey

func RandomToKey(b []byte) []byte

RandomToKey returns a key from the bytes provided according to the definition in RFC 3961.

func VerifyIntegrity

func VerifyIntegrity(key, ct, pt []byte, usage uint32, etype etype.EType) bool

VerifyIntegrity verifies the integrity of cipertext bytes ct.

Types

This section is empty.

Jump to

Keyboard shortcuts

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