Crate safe_crypto[][src]

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

Structs

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.

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

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.

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

gen_encrypt_keypair

Randomly generates a secret key and a corresponding public key.

gen_sign_keypair

Construct random public and secret signing key pair.

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.