singleUse

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: BSD-2-Clause Imports: 8 Imported by: 4

Documentation

Index

Constants

View Source
const TagFpSize = 16

TagFpSize is the size of the TagFP type.

Variables

This section is empty.

Functions

func MakeMAC

func MakeMAC(key []byte, encryptedPayload []byte) []byte

MakeMAC generates the MAC used in both the request and response cMix messages.

func NewRecipientID

func NewRecipientID(pubKey *cyclic.Int, unencryptedPayload []byte) *id.ID

NewRecipientID generates the recipient ID for a single-use sender. The ID is generated from the hash of the unencrypted request payload. The unencryptedPayload must contain a nonce to prevent collision on the same message being sent multiple times.

func NewRequestFingerprint

func NewRequestFingerprint(pubKey *cyclic.Int) format.Fingerprint

NewRequestFingerprint generates the fingerprint used for the request message.

func NewRequestKey

func NewRequestKey(dhKey *cyclic.Int) []byte

NewRequestKey generates the key used for the request message.

func NewRequestPartFingerprint

func NewRequestPartFingerprint(dhKey *cyclic.Int, keyNum uint64) format.Fingerprint

NewRequestPartFingerprint generates the fingerprint for the request message for the given key number.

func NewRequestPartKey

func NewRequestPartKey(dhKey *cyclic.Int, keyNum uint64) []byte

NewRequestPartKey generates the key for the request message that corresponds with the given key number.

func NewResponseFingerprint

func NewResponseFingerprint(dhKey *cyclic.Int, keyNum uint64) format.Fingerprint

NewResponseFingerprint generates the fingerprint for the response message for the given key number.

func NewResponseKey

func NewResponseKey(dhKey *cyclic.Int, keyNum uint64) []byte

NewResponseKey generates the key for the response message that corresponds with the given key number.

func VerifyMAC

func VerifyMAC(key []byte, encryptedPayload, receivedMAC []byte) bool

VerifyMAC determines if the provided MAC is valid for the given key and encrypted payload.

Types

type TagFP

type TagFP [TagFpSize]byte

TagFP uniquely identifies the module that the request message belongs to.

func NewTagFP

func NewTagFP(tag string) TagFP

NewTagFP generates a new tag fingerprint with the given tag. The tag can be anything, but should be long enough so that it is unique.

func UnmarshalTagFP

func UnmarshalTagFP(b []byte) TagFP

UnmarshalTagFP generates a new TagFP from the specified bytes.

func (TagFP) Bytes

func (fp TagFP) Bytes() []byte

Bytes returns the tag fingerprint as a byte slice.

func (TagFP) String

func (fp TagFP) String() string

String returns the base64 string encoding of the tag fingerprint.

Jump to

Keyboard shortcuts

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