[][src]Crate safe_crypto

This is a convenience library providing abstractions for cryptographic functions required by other SAFE Network libraries.

Structs

Nonce

Nonce structure used for authenticated symmetric encryption.

PublicEncryptKey

The public key used encrypt data that can only be decrypted by the corresponding secret key, which is represented by SecretEncryptKey. Use gen_encrypt_keypair() to generate a public and secret key pair.

PublicSignKey

Public signing key used to verify that the signature appended to a message was actually issued by the creator of the public key.

SecretEncryptKey

Reference counted secret encryption key used to decrypt data previously encrypted with PublicEncryptKey. Use gen_encrypt_keypair() to generate a public and secret key pair.

SecretSignKey

Reference counted secret signing key used to verify signatures previously signed with PublicSignKey.

Seed

Seed structure used to generate sign and encrypt keypairs deterministically.

SharedSecretKey

Precomputed shared secret key.

Signature

Detached signature.

SymmetricKey

Secret key for authenticated symmetric encryption.

Enums

Error

This error is returned if encryption or decryption fails. The encryption failure is rare and mostly connected to serialisation failures. Decryption can fail because of invalid keys, invalid data, or deserialisation failures.

Constants

HASH_BYTES

Hash length in bytes.

NONCE_BYTES

Nonce length in bytes.

PUBLIC_ENCRYPT_KEY_BYTES

Public encryption key length in bytes.

PUBLIC_SIGN_KEY_BYTES

Public signing key length in bytes.

SECRET_ENCRYPT_KEY_BYTES

Secret encryption key length in bytes.

SECRET_SIGN_KEY_BYTES

Secret signing key length in bytes.

SEED_BYTES

Seed length in bytes.

SHARED_SECRET_KEY_BYTES

Shared secret key length in bytes.

SIGNATURE_BYTES

Cryptographic signature length in bytes.

SYMMETRIC_KEY_BYTES

Symmetric key length in bytes.

Functions

derive_key_from_pw

Uses password-based key derivation to securely derive a byte vector from a password and salt. output may be used to construct any of the keys in this library.

gen_encrypt_keypair

Randomly generates a secret key and a corresponding public key.

gen_sign_keypair

Construct random public and secret signing key pair.

gen_sign_keypair_from_seed

Construct random public and secret signing key pair from a seed.

hash

Produces a 256-bit crypto hash out of the provided data.

init

Initialise safe_crypto including the random number generator for the key generation functions.