pub struct RnpContext { /* private fields */ }

Implementations§

source§

impl RnpContext

source

pub fn policy(&self) -> RwLockReadGuard<'_, StandardPolicy<'static>>

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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

pub fn cert_by_subkey_id(&self, id: &KeyID) -> Option<Cert>

Retrieves a certificate from the keystore by (sub)key keyid.

§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

pub fn cert_by_subkey_grip(&self, grip: &Keygrip) -> Option<Cert>

Retrieves a certificate from the keystore by (sub)key keygrip.

§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

source

pub fn request_password( &mut self, key: Option<&RnpKey>, reason: RnpPasswordFor ) -> Option<Password>

source

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.

source

pub fn key_is_locked(&mut self, key: &Key<SecretParts, UnspecifiedRole>) -> bool

Returns false iff the key has not been unlocked.

source

pub fn key_lock(&mut self, key: &Key<SecretParts, UnspecifiedRole>)

Locks the key.

source

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.

source

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.

Trait Implementations§

source§

impl Default for RnpContext

source§

fn default() -> RnpContext

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more