Expand description
This crate allows for working with WireGuard keys. WireGuard uses asymmetric x25519 keys, which are represented by the Privkey and Pubkey types respectively. Private keys can be generated randomly, and their corresponding public key can be derived. Additionally, WireGuard allows using a preshared key as additional security layer, which is just a random 256-bit value. This is represented by the Secret type.
For security reasons, this crate uses the Zeroize trait to mark all types containing cryyptographically relevant information to be cleared on drop. The x25519_dalek_fiat crate is used for x25519 operations.
This crate allows for encoding keys in various ways. The crate supports base64
, which is
typically used by WireGuard, but hex
and base32
can be enabled as well. Enabling encodings
also enables parsing from that encoding.
The serde feature, which is enabled by default, adds serialize and deserialize support for WireGuard types. How these types are serialized depends on the format: when serializing into human-readable formats, such as JSON, the keys are serialized as base64-encoded strings. However, when serializing to binary formats such as Bincode, keys are serialized as raw bytes.
The optional schema
feature adds information to the types allowing to generate JSON schema
from them automatically using schemars.
Enabling the rocket
feature adds the ability to parse any WireGuard types from a HTTP
request using the [FromParam][rocket::request::FromParam] trait.
Structs§
Enums§
- Parse
Error - Possible errors that can be generated when parsing WireGuard keys.
Constants§
- PRIVKEY_
LEN - Length (in bytes) of a WireGuard private key (ed25519).
- PUBKEY_
LEN - Length (in bytes) of a WireGuard public key (ed25519).
- SECRET_
LEN - Length (in bytes) of a WireGuard preshared key.