Documentation ¶
Overview ¶
Package nego implements cryptographic negotiation and secret entrypoint finding.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Entry ¶
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer produces a cryptographic negotiation header, which conceals a variable number of "entrypoints" within a variable-length binary blob of random-looking bits. Each entrypoint hidden in the blob is discoverable and usable only by the owner of a particular public key. Different public keys may be drawn from different ciphersuites, in any combination, without coordination between the ciphersuites.
Each entrypoint contains a short fixed-length blob of encrypted data, which the owner of the entrypoint can decrypt and use to obtain keys and pointers to the "real" content. This "real" content is typically located after the negotiation header and encrypted with a symmetric key included in the entrypoint data, which can be (but doesn't have to be) shared by many or all entrypoints.
func (*Writer) Layout ¶
func (w *Writer) Layout(suiteLevel map[abstract.Suite]int, entrypoints []Entry, rand cipher.Stream) (int, error)
Initialize a Writer to produce one or more negotiation header containing a specified set of entrypoints, whose owners' public keys are drawn from a given set of ciphersuites.
The caller must provide a map 'suiteLevel' with one key per ciphersuite, whose value is the maximum "level" in the header at which the ciphersuite's ephemeral Diffie-Hellman Point may be encoded. This maximum level must be standardized for each ciphersuite, and should be log2(maxsuites), where maxsuites is the maximum number of unique ciphersuites that are likely to exist when this suite is defined.
The Data slices in all entrypoints must have been allocated and sized according to the data the caller wants to suppy each entrypoint, but the content of these Data slices need not be filled in yet.
This function lays out the entrypoints in the negotiation header, and returns the total size of the negotiation headers that will be produced from this layout.
After this initialization and layout computation, multiple independent negotiation headers with varying entrypoint data may be produced more efficiently via Write().
XXX if multiple entrypoints are improperly passed for the same keyholder, bad things happen to security - we should harden the API against that.
func (*Writer) Payload ¶
After Layout() has been called to layout the header, the client may call Payload() any number of times to reserve regions for encrypted payloads in the message. Returns the byte offset in the message where the payload was placed.
Although the client could as well encrypt the data before calling Payload(), we take a cleartext and a cipher.Stream to "make sure" it gets encrypted. (Callers who really want to do their own encryption can pass in a no-op cipher.Stream, but this isn't recommended.)