Skip to main content

Crate ejson

Crate ejson 

Source
Expand description

EJSON - Encrypted JSON secrets management.

This crate provides utilities for managing encrypted secrets in source control using public-key cryptography (NaCl Box).

Supports JSON (.ejson, .json), TOML (.etoml, .toml), and YAML (.eyaml, .eyml, .yaml, .yml) file formats.

§Security Features

  • Private keys are zeroized from memory when dropped
  • File operations use locking to prevent race conditions
  • Path traversal attacks are prevented through validation
  • Maximum file size limits prevent denial of service
  • Constant-time comparisons for key validation

Re-exports§

pub use crypto::KeyBytes;
pub use format::FileFormat;
pub use handler::FormatError;
pub use handler::FormatHandler;
pub use handler::KEY_SIZE;
pub use handler::PUBLIC_KEY_FIELD;
pub use typed::DecryptedContent;
pub use typed::DecryptedValue;

Modules§

boxed_message
Wire format for encrypted messages.
crypto
Cryptographic operations for ejson using NaCl Box (Curve25519 + XSalsa20 + Poly1305).
env
Environment variable export utilities for EJSON/EYAML/ETOML files.
format
File format detection for ejson files.
handler
Format handler trait for unified file format support.
json
JSON processing for ejson files.
toml
TOML processing for etoml files.
typed
Typed API for working with decrypted content.
yaml
YAML processing for eyaml files.

Enums§

EjsonError
Errors that can occur during ejson operations.

Constants§

MAX_FILE_SIZE
Maximum file size for encryption/decryption operations (10 MB). This prevents denial of service through memory exhaustion.

Functions§

decrypt
Decrypt data from a reader and write to a writer.
decrypt_bytes_typed
Decrypt bytes and return the decrypted contents as a typed value.
decrypt_file
Decrypt a file and return the decrypted contents.
decrypt_file_typed
Decrypt a file and return the decrypted contents as a typed value.
decrypt_with_format
Decrypt data with a specific format.
encrypt
Encrypt data from a reader and write to a writer.
encrypt_file_in_place
Encrypt a file in place with file locking.
encrypt_with_format
Encrypt data with a specific format.
generate_keypair
Generate a new ejson keypair.