pub struct Credential { /* private fields */ }Expand description
A cryptographic credential.
This is tied to a particular client via either its client id or certificate bundle, depending on its credential type, but is independent of any client instance or storage.
To attach to a particular client instance and store, see
TransactionContext::add_credential.
Note: the current database design makes some questionable assumptions:
- There are always either 0 or 1
StoredSignatureKeypairinstances in the DB for a particular signature scheme - There may be multiple
StoredCredentialinstances in the DB for a particular signature scheme, but they all share the sameClientId/ signing key. In other words, the same signing keypair is reused between credentials. - Practically, the code ensures that there is a 1:1 correspondence between signing scheme <-> identity/credential, and we need to maintain that property for now.
Work is ongoing to fix those limitations; see WPB-20844. Until that is resolved, we enforce those restrictions by raising errors as required to preserve DB integrity.
Implementations§
Source§impl Credential
impl Credential
Sourcepub fn x509(cert: CertificateBundle) -> Result<Self, Error>
pub fn x509(cert: CertificateBundle) -> Result<Self, Error>
Create a new x509 credential from a certificate bundle.
Source§impl Credential
impl Credential
Sourcepub fn basic(
signature_scheme: SignatureScheme,
client_id: ClientId,
crypto: impl OpenMlsCrypto,
) -> Result<Self, Error>
pub fn basic( signature_scheme: SignatureScheme, client_id: ClientId, crypto: impl OpenMlsCrypto, ) -> Result<Self, Error>
Generate a basic credential.
The result is independent of any client instance and the database; it lives in memory only.
Sourcepub fn mls_credential(&self) -> &MlsCredential
pub fn mls_credential(&self) -> &MlsCredential
Get the Openmls Credential type.
This stores the credential type (basic/x509).
Sourcepub fn credential_type(&self) -> CredentialType
pub fn credential_type(&self) -> CredentialType
Get the credential type
Sourcepub fn signature_scheme(&self) -> SignatureScheme
pub fn signature_scheme(&self) -> SignatureScheme
Get the signature scheme
Sourcepub fn to_mls_credential_with_key(&self) -> CredentialWithKey
pub fn to_mls_credential_with_key(&self) -> CredentialWithKey
Generate a CredentialWithKey, which combines the credential type with the public portion of the keypair.
Sourcepub fn earliest_validity(&self) -> u64
pub fn earliest_validity(&self) -> u64
Earliest valid time of creation for this credential.
This is represented as seconds after the unix epoch.
Only meaningful for X509, where it is the “valid_from” claim of the leaf credential. For basic credentials, this is always 0 when the credential is first created. It is updated upon being persisted to the database.
Sourcepub fn client_id(&self) -> &ClientIdRef
pub fn client_id(&self) -> &ClientIdRef
Get the client ID associated with this credential
Trait Implementations§
Source§impl Clone for Credential
impl Clone for Credential
Source§fn clone(&self) -> Credential
fn clone(&self) -> Credential
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Credential
impl Debug for Credential
Source§impl<'de> Deserialize<'de> for Credential
impl<'de> Deserialize<'de> for Credential
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<Credential> for CredentialWithKey
impl From<Credential> for CredentialWithKey
Source§fn from(cb: Credential) -> Self
fn from(cb: Credential) -> Self
Source§impl PartialEq for Credential
impl PartialEq for Credential
Source§impl Serialize for Credential
impl Serialize for Credential
impl Eq for Credential
Auto Trait Implementations§
impl Freeze for Credential
impl RefUnwindSafe for Credential
impl Send for Credential
impl Sync for Credential
impl Unpin for Credential
impl UnwindSafe for Credential
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more