Module box_stream::crypto [] [src]

Low-level bindings to box-stream-c. You probably don't need to use this module directly.

Structs

PlainHeader

The result of decrypting a cypher_header. This is sodiumoxide::crypto::secretbox::MACBYTES smaller than the encrypted header since the leading mac is not needed anymore.

Constants

CYPHER_HEADER_SIZE

The size of an encrypted header: The header's mac, the length of the following packet, and the max of the following packet.

MAX_PACKET_SIZE

The maximum allowed size of a single packet passed to encrypt_packet.

MAX_PACKET_USIZE

Same as MAX_PACKET_SIZE, but as a usize.

Functions

decrypt_header

If this returns true, it decrypts a received header into out. Returns false if the cyper_header was invalid.

decrypt_header_inplace

Same as decrypt_header, but writes the result into cypher_header. If this returns true, cypher_header can be safely cast to a PlainHeader.

decrypt_packet

Decrypts a received packet, given a pointer to the corresponding plain_header, and writes the result into out. Returns false on invalid input, in which case the content of out is unspecified.

decrypt_packet_inplace

Same as decrypt_packet, but writes the result into cypher_packet.

encrypt_packet

Writes the encrypted header and payload for a given plaintext packet into out.

final_header

Writes the final header that signals the end of the box stream into out.