Struct sequoia_octopus_librnp::RnpContext
source · pub struct RnpContext { /* private fields */ }
Implementations§
source§impl RnpContext
impl RnpContext
pub fn policy(&self) -> RwLockReadGuard<'_, StandardPolicy<'static>>
sourcepub fn insert_cert(&mut self, cert: Cert)
pub fn insert_cert(&mut self, cert: Cert)
Inserts a cert into the keystore.
This strips any secret key material.
§Locking
This acquires a write lock on the keystore and, if the certificate is already present, a write lock on the certificate’s cell.
sourcepub fn insert_cert_external(&mut self, cert: Cert)
pub fn insert_cert_external(&mut self, cert: Cert)
Inserts a cert from an external source into the keystore.
This strips any secret key material.
certs from external sources won’t be serialized.
§Locking
This acquires a write lock on the keystore and, if the certificate is already present, a write lock on the certificate’s cell.
sourcepub fn insert_key(&mut self, cert: Cert)
pub fn insert_key(&mut self, cert: Cert)
Inserts a key into the keystore.
Secret key material is preserved.
§Locking
This acquires a write lock on the keystore and, if the certificate is already present, a write lock on the certificate’s cell.
sourcepub fn cert(&self, by: &RnpIdentifier) -> Option<Cert>
pub fn cert(&self, by: &RnpIdentifier) -> Option<Cert>
Retrieves a certificate from the keystore by userid.
RNP searches both the certring and the keyring, and the keyhandle can thus refer to two certificates, potentially different versions of the same, or even different certificates! Since we merge the key keyrings, this is not a problem for us.
§Locking
This acquires a read lock on the keystore and one or more certificates’ cells. See the corresponding search methods for details.
sourcepub fn cert_by_userid(&self, uid: &UserID) -> Option<Cert>
pub fn cert_by_userid(&self, uid: &UserID) -> Option<Cert>
Retrieves a certificate by userid.
XXX: This is super dodgy. rnp.h says “Note: only valid userids are checked while searching by userid.” but it is not clear what that means.
XXX: I think it would be better to fail these lookups. Are they used by TB?
§Locking
This acquires a read lock on the keystore. Currently, this function performs a linear scan of all keys. As such, it potentially acquires (in turn) a read lock on all of the certificates’ cells.
sourcepub fn cert_by_subkey_handle(&self, handle: &KeyHandle) -> Option<Cert>
pub fn cert_by_subkey_handle(&self, handle: &KeyHandle) -> Option<Cert>
Retrieves a certificate from the keystore by (sub)key handle.
§Locking
This acquires a read lock on the keystore and, if a matching certificate is present, a read lock on the certificate’s cell.
sourcepub fn cert_by_subkey_fp(&self, fp: &Fingerprint) -> Option<Cert>
pub fn cert_by_subkey_fp(&self, fp: &Fingerprint) -> Option<Cert>
Retrieves a certificate from the keystore by (sub)key fingerprint.
§Locking
This acquires a read lock on the keystore and, if a matching certificate is present, a read lock on the certificate’s cell.
source§impl RnpContext
impl RnpContext
pub fn request_password( &mut self, key: Option<&RnpKey>, reason: RnpPasswordFor ) -> Option<Password>
sourcepub fn decrypt_key_for(
&mut self,
cert: Option<&Cert>,
key: Key<SecretParts, UnspecifiedRole>,
reason: RnpPasswordFor
) -> Result<Key<SecretParts, UnspecifiedRole>>
pub fn decrypt_key_for( &mut self, cert: Option<&Cert>, key: Key<SecretParts, UnspecifiedRole>, reason: RnpPasswordFor ) -> Result<Key<SecretParts, UnspecifiedRole>>
Decrypts the given key, if necessary.
sourcepub fn key_is_locked(&mut self, key: &Key<SecretParts, UnspecifiedRole>) -> bool
pub fn key_is_locked(&mut self, key: &Key<SecretParts, UnspecifiedRole>) -> bool
Returns false iff the key has not been unlocked.
sourcepub fn key_lock(&mut self, key: &Key<SecretParts, UnspecifiedRole>)
pub fn key_lock(&mut self, key: &Key<SecretParts, UnspecifiedRole>)
Locks the key.
sourcepub fn key_unlock(
&mut self,
key: Key<SecretParts, UnspecifiedRole>,
password: Option<Password>
) -> Result<()>
pub fn key_unlock( &mut self, key: Key<SecretParts, UnspecifiedRole>, password: Option<Password> ) -> Result<()>
Unlocks the key.
If password
is None, this function will ask for a password
using the callback.
sourcepub fn key_unlocked_ref(
&self,
key: &Key<UnspecifiedParts, UnspecifiedRole>
) -> Option<&Key<SecretParts, UnspecifiedRole>>
pub fn key_unlocked_ref( &self, key: &Key<UnspecifiedParts, UnspecifiedRole> ) -> Option<&Key<SecretParts, UnspecifiedRole>>
Returns a reference to the unlocked key in the cache, if it exists.