chez-libs

(crypto envelope)
Login

Generic Envelopes

Synopsis

(import (crypto envelope))

Generic record container for cryptographic messages.

Envelopes

record: envelope

procedure: (envelope? any)

procedure: (make-envelope algorithm nonce message signature)

procedure: (envelope-algorithm envelope)

procedure: (envelope-nonce envelope)

procedure: (envelope-message envelope)

procedure: (envelope-signature envelope)

Envelopes are records holding a string that describes the cryptographic algorithm, a bytevector nonce (or #f if not applicable), the bytevector message, and a bytevector signature (or #f if not applicable).

procedure: (valid-envelope? algorithm nonce-length signature-length any)

Extended predicate that checks whether the last argument is an envelope with suitable properties: The algorithm in the record must be equal? to the given argument, the nonce must have the given length (unless nonce-length is #f), and the signature must have the given length (unless signature-length is #f).

I/O Operations

procedure: (get-envelope port)

Read a binary representation of an envelope from the given port.

procedure: (put-envelope port envelope)

Write a binary representation of the given envelope to the given port.

procedure: (bytevector->envelope bytevector)

Decodes a binary representation of an envelope from the given bytevector. Returns #f in case of encoding errors.

procedure: (envelope->bytevector envelope)

Encodes a binary representation of the given envelope into a bytevector.