[−][src]Struct ssb_crypto::NetworkKey
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.
Implementations
impl NetworkKey
[src]
pub const SIZE: usize
[src]
The size of a NetworkKey, in bytes (32).
pub const SSB_MAIN_NET: NetworkKey
[src]
The NetworkKey for the primary ssb network.
pub fn from_slice(s: &[u8]) -> Option<Self>
[src]
Deserialize from a slice of bytes.
Returns None
if the slice length isn't 32.
pub fn generate_with_rng<R>(r: &mut R) -> NetworkKey where
R: CryptoRng + RngCore,
[src]
R: CryptoRng + RngCore,
Generate a random network key using the given cryptographically-secure random number generator.
pub fn from_base64(s: &str) -> Option<Self>
[src]
Deserialize from the base-64 representation.
impl NetworkKey
[src]
pub fn authenticate(&self, b: &[u8]) -> NetworkAuth
[src]
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));
pub fn verify(&self, auth: &NetworkAuth, b: &[u8]) -> bool
[src]
Verify that an authentication code was generated by this key, given the same byte slice.
pub fn generate() -> NetworkKey
[src]
Generate a random network key.
Examples
use ssb_crypto::NetworkKey; let key = NetworkKey::generate(); assert_ne!(key, NetworkKey::SSB_MAIN_NET);
Trait Implementations
impl AsBytes for NetworkKey
[src]
fn only_derive_is_allowed_to_implement_this_trait() where
Self: Sized,
[src]
Self: Sized,
fn as_bytes(&self) -> &[u8]
[src]
fn as_bytes_mut(&mut self) -> &mut [u8] where
Self: FromBytes,
[src]
Self: FromBytes,
impl Clone for NetworkKey
[src]
fn clone(&self) -> NetworkKey
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for NetworkKey
[src]
impl Drop for NetworkKey
[src]
impl PartialEq<NetworkKey> for NetworkKey
[src]
fn eq(&self, other: &NetworkKey) -> bool
[src]
fn ne(&self, other: &NetworkKey) -> bool
[src]
impl StructuralPartialEq for NetworkKey
[src]
impl Zeroize for NetworkKey
[src]
Auto Trait Implementations
impl RefUnwindSafe for NetworkKey
impl Send for NetworkKey
impl Sync for NetworkKey
impl Unpin for NetworkKey
impl UnwindSafe for NetworkKey
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
fn vzip(self) -> V
impl<Z> Zeroize for Z where
Z: DefaultIsZeroes,
[src]
Z: DefaultIsZeroes,