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 = 32 // StreamKeyLength is the key size of the stream cipher in bytes. StreamKeyLength = 32 // 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 )
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 nike.PrivateKey }
PacketKeys are the per-hop Sphinx Packet Keys, derived from the blinded DH key exchange.
func KDF ¶
func KDF(ikm []byte, scheme nike.Scheme) *PacketKeys
KDF takes the input key material and returns the Sphinx Packet keys. HOWEVER if the NIKE scheme interface object is set to nil then the BlindingFactor will not be generated by the KDF. The reason we do this is because KEMSphinx doesn't need the BlindingFactor.
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.