core: github.com/katzenpost/core/sphinx/internal/crypto Index | Files

package crypto

import "github.com/katzenpost/core/sphinx/internal/crypto"

Package crypto provides the Katzenpost parameterization of the Sphinx Packet Format cryptographic operations.

Index

Package Files

crypto.go hkdf_expand.go

Constants

const (
    // HashLength is the output size of the unkeyed hash in bytes.
    HashLength = sha512.Size256

    // MACKeyLength is the key size of the MAC in bytes.
    MACKeyLength = 32

    // MACLength is the tag size of the MAC in bytes.
    MACLength = 16

    // StreamKeyLength is the key size of the stream cipher in bytes.
    StreamKeyLength = 16

    // StreamIVLength is the IV size of the stream cipher in bytes.
    StreamIVLength = 16

    // SPRPKeyLength is the key size of the SPRP in bytes.
    SPRPKeyLength = 48

    // SPRPIVLength is the IV size of the SPRP in bytes.
    SPRPIVLength = StreamIVLength

    // GroupElementLength is the length of a DH group element in bytes.
    GroupElementLength = ecdh.GroupElementLength
)

func Hash Uses

func Hash(msg []byte) [HashLength]byte

Hash calculates the digest of message m.

func NewMAC Uses

func NewMAC(key *[MACKeyLength]byte) hash.Hash

NewMAC returns a new hash.Hash implementing the Sphinx MAC with the provided key.

func SPRPDecrypt Uses

func SPRPDecrypt(key *[SPRPKeyLength]byte, iv *[SPRPIVLength]byte, msg []byte) []byte

SPRPDecrypt returns the plaintext of the message msg, decrypted via the Sphinx SPRP with the provided key and IV.

func SPRPEncrypt Uses

func SPRPEncrypt(key *[SPRPKeyLength]byte, iv *[SPRPIVLength]byte, msg []byte) []byte

SPRPEncrypt returns the ciphertext of the message msg, encrypted via the Sphinx SPRP with the provided key and IV.

type PacketKeys Uses

type PacketKeys struct {
    HeaderMAC          [MACKeyLength]byte
    HeaderEncryption   [StreamKeyLength]byte
    HeaderEncryptionIV [StreamIVLength]byte
    PayloadEncryption  [SPRPKeyLength]byte
    BlindingFactor     [GroupElementLength]byte
}

PacketKeys are the per-hop Sphinx Packet Keys, derived from the blinded DH key exchange.

func KDF Uses

func KDF(ikm *[GroupElementLength]byte) *PacketKeys

KDF takes the input key material and returns the Sphinx Packet keys.

func (*PacketKeys) Reset Uses

func (k *PacketKeys) Reset()

Reset clears the PacketKeys structure such that no sensitive data is left in memory.

type Stream Uses

type Stream struct {
    cipher.Stream
}

Stream is the Sphinx stream cipher.

func NewStream Uses

func NewStream(key *[StreamKeyLength]byte, iv *[StreamIVLength]byte) *Stream

NewStream returns a new Stream implementing the Sphinx Stream Cipher with the provided key and IV.

func (*Stream) KeyStream Uses

func (s *Stream) KeyStream(dst []byte)

KeyStream fills the buffer dst with key stream output.

func (*Stream) Reset Uses

func (s *Stream) Reset()

Reset clears the Stream instance such that no sensitive data is left in memory.

Package crypto imports 9 packages (graph) and is imported by 2 packages. Updated 2019-08-21. Refresh now. Tools for package owners.