Documentation ¶
Overview ¶
Package crypto provides the Katzenpost parameterization of the Sphinx Packet Format cryptographic operations.
Index ¶
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 )
Variables ¶
This section is empty.
Functions ¶
func NewMAC ¶
func NewMAC(key *[MACKeyLength]byte) hash.Hash
NewMAC returns a new hash.Hash implementing the Sphinx MAC with the provided key.
func SPRPDecrypt ¶
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 ¶
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.
Types ¶
type PacketKeys ¶
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 ¶
func KDF(ikm *[GroupElementLength]byte) *PacketKeys
KDF takes the input key material and returns the Sphinx Packet keys.
func (*PacketKeys) Reset ¶
func (k *PacketKeys) Reset()
Reset clears the PacketKeys structure such that no sensitive data is left in memory.
type Stream ¶
Stream is the Sphinx stream cipher.
func NewStream ¶
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.