Struct ssb_crypto::NetworkKey[][src]

#[repr(C)]
pub struct NetworkKey(pub [u8; 32]);
Expand description

The network key, or network identifier, used during the secret handshake to prove that both parties are participating in the same ssb network.

The main ssb network uses a publicly-known key, which is available as NetworkKey::SSB_MAIN_NET.

This is an HMAC key; specifically HMAC-SHA-512-256.

Tuple Fields

0: [u8; 32]

Implementations

The size of a NetworkKey, in bytes (32).

The NetworkKey for the primary ssb network.

Deserialize from a slice of bytes. Returns None if the slice length isn’t 32.

Generate a random network key using the given cryptographically-secure random number generator.

Deserialize from the base-64 representation.

Generate an authentication code for the given byte slice.

Examples

use ssb_crypto::NetworkKey;
let netkey = NetworkKey::SSB_MAIN_NET;
let bytes = [1, 2, 3, 4];
let auth = netkey.authenticate(&bytes);
assert!(netkey.verify(&auth, &bytes));

Verify that an authentication code was generated by this key, given the same byte slice.

Generate a random network key.

Examples

use ssb_crypto::NetworkKey;
let key = NetworkKey::generate();
assert_ne!(key, NetworkKey::SSB_MAIN_NET);

Trait Implementations

Get the bytes of this value. Read more

Get the bytes of this value mutably. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.