Library guide · API index and notation
This page is generated from the bundled library in this checkout. Signatures and adjacent source comments are reproduced below; the linked guide explains usage, storage, failures, and platform support.
import "std/crypto"
Names used in signatures
Unqualified names denote this package’s types (including other source files in the same package), language built-ins, or generic parameters such as T. Qualified names use the import aliases below. These aliases belong to the library source; import a dependency yourself to use its alias in your program.
| Alias | Package | Source file |
|---|---|---|
io |
std/io |
crypto.dodo |
ptr |
core/ptr |
crypto.dodo |
ErrorKind
Enum · Source
Portable cryptographic errors and secret-handling helpers. No entropy source, primitive implementation, allocator or native library is imported here:
std/crypto/randomreads the operating system’s CSPRNG andstd/crypto/opensslwraps OpenSSL’s libcrypto.
pub enum ErrorKind {
InvalidInput, BufferTooSmall, AllocationFailed, Unavailable, Backend
}
Error
Struct · Source
pub struct Error {
pub kind: ErrorKind
// Numeric OS or OpenSSL code only; never key, plaintext or digest bytes.
pub code: i32
}
Error.format
Function · Source
pub fn format<F>(&self, output: &mut F) -> void!io.Error
failure
Function · Source
pub fn failure(kind: ErrorKind, code: i32) -> Error
equal
Function · Source
Compares MACs, tokens and other secrets without exiting at the first differing byte. Lengths are not secret: unequal lengths return false at once.
pub fn equal(left: &[u8], right: &[u8]) -> bool
wipe
Function · Source
Overwrites secret bytes with zeros using stores the optimizer cannot remove as dead, even when the storage is never read again.
pub fn wipe(bytes: &mut[u8])