Struct argonautica::Verifier [−][src]
pub struct Verifier<'a> { /* fields omitted */ }
One of the two main structs. Use it to verify passwords against hashes
Methods
impl<'a> Verifier<'a>
[src]
impl<'a> Verifier<'a>
pub fn new() -> Verifier<'a>
[src]
pub fn new() -> Verifier<'a>
Creates a new Verifier
with the following configuration:
backend
:Backend::C
cpu_pool
: ACpuPool
...- with threads equal to the number of logical cores on your machine
- that is lazily created, i.e. created only if / when you call the method that
needs it (
verify_non_blocking
)
password_clearing
:false
secret_key_clearing
:false
threads
: The number of logical cores on your machine
pub fn configure_backend(&mut self, backend: Backend) -> &mut Verifier<'a>
[src]
pub fn configure_backend(&mut self, backend: Backend) -> &mut Verifier<'a>
Allows you to configure Verifier
with a custom backend. The
default backend is Backend::C
, which is
currently the only backend supported. A Rust backend is planned, but is not currently
available. If you configure a Verifier
with
Backend::Rust
it will error
pub fn configure_cpu_pool(&mut self, cpu_pool: CpuPool) -> &mut Verifier<'a>
[src]
pub fn configure_cpu_pool(&mut self, cpu_pool: CpuPool) -> &mut Verifier<'a>
Allows you to configure Verifier
with a custom
CpuPool
.
The default Verifier
does not have a cpu pool, which is
only needed for the verify_non_blocking
method. If you call verify_non_blocking
without a cpu pool, a default cpu pool will be created for you on the fly; so even
if you never configure Verifier
with this method you can still
use the verify_non_blocking
method.
The default cpu pool has as many threads as the number of logical cores on your machine
pub fn configure_password_clearing(
&mut self,
boolean: bool
) -> &mut Verifier<'a>
[src]
pub fn configure_password_clearing(
&mut self,
boolean: bool
) -> &mut Verifier<'a>
Allows you to configure Verifier
to erase the password bytes
after each call to verify
or its non-blocking equivalent. The default is to not clear out the password
bytes (i.e. false
). If you set this option to true
, you must provide
Verifier
with a mutable password, e.g. a password
constructed from a String
, Vec<u8>
, &mut str
, &mut [u8]
, etc. as opposed to
one constructed from a &str
, &[u8]
, etc., or else verifying will return an
Error
.
pub fn configure_secret_key_clearing(
&mut self,
boolean: bool
) -> &mut Verifier<'a>
[src]
pub fn configure_secret_key_clearing(
&mut self,
boolean: bool
) -> &mut Verifier<'a>
Allows you to configure Verifier
to erase the secret key bytes
after each call to verify
or its non-blocking equivalent. The default is to not clear out the secret key
bytes (i.e. false
). If you set this option to true
, you must provide
Verifier
with a mutable secret key, e.g. a secret key
constructed from a String
, Vec<u8>
, &mut str
, &mut [u8]
, etc. as opposed to
one constructed from a &str
, &[u8]
, etc., or else verifying will return an
Error
.
pub fn configure_threads(&mut self, threads: u32) -> &mut Verifier<'a>
[src]
pub fn configure_threads(&mut self, threads: u32) -> &mut Verifier<'a>
Allows you to configure Verifier
to use a custom number of
threads. The default is the number of physical cores on your machine. If you choose
a number of threads that is greater than the lanes configuration of your hash,
Verifier
will use the minimum of the two.
pub fn to_owned(&self) -> Verifier<'static>
[src]
pub fn to_owned(&self) -> Verifier<'static>
Clones the Verifier
, returning a new
Verifier
with a static
lifetime. Use this method if you
would like to move a Verifier
to another thread
pub fn verify(&mut self) -> Result<bool, Error>
[src]
pub fn verify(&mut self) -> Result<bool, Error>
The primary method (blocking version)
After you have configured Verifier
to your liking and provided
it will all the data it needs to verify a password, i.e.
- a string-encoded hash or
HashRaw
, - a
Password
, - a
SecretKey
(if required), AdditionalData
(if required),
call this method to verify that the password matches the hash or
HashRaw
pub fn verify_non_blocking(
&mut self
) -> impl Future<Item = bool, Error = Error>
[src]
pub fn verify_non_blocking(
&mut self
) -> impl Future<Item = bool, Error = Error>
The primary method (non-blocking version)
Same as verify
except it returns a
Future
instead of a Result
pub fn with_additional_data<AD>(
&mut self,
additional_data: AD
) -> &mut Verifier<'a> where
AD: Into<AdditionalData>,
[src]
pub fn with_additional_data<AD>(
&mut self,
additional_data: AD
) -> &mut Verifier<'a> where
AD: Into<AdditionalData>,
Allows you to provide Verifier
with the additional data
that was originally used to create the hash. Normally hashes are not created with
additional data; so you are not likely to need this method
pub fn with_hash<S>(&mut self, hash: S) -> &mut Verifier<'a> where
S: AsRef<str>,
[src]
pub fn with_hash<S>(&mut self, hash: S) -> &mut Verifier<'a> where
S: AsRef<str>,
Allows you to provide Verifier
with the hash to verify
against (in the form of a string-encoded hash like those produced by the
hash
or
hash_non_blocking
methods on Hasher
)
pub fn with_hash_raw(&mut self, hash_raw: &HashRaw) -> &mut Verifier<'a>
[src]
pub fn with_hash_raw(&mut self, hash_raw: &HashRaw) -> &mut Verifier<'a>
Allows you to provide Verifier
with the hash to verify
against (in the form of a HashRaw
like those produced
by the hash_raw
or
hash_raw_non_blocking
methods on Hasher
)
pub fn with_password<P>(&mut self, password: P) -> &mut Verifier<'a> where
P: Into<Password<'a>>,
[src]
pub fn with_password<P>(&mut self, password: P) -> &mut Verifier<'a> where
P: Into<Password<'a>>,
Allows you to provide Verifier
with the password
to verify against
pub fn with_secret_key<SK>(&mut self, secret_key: SK) -> &mut Verifier<'a> where
SK: Into<SecretKey<'a>>,
[src]
pub fn with_secret_key<SK>(&mut self, secret_key: SK) -> &mut Verifier<'a> where
SK: Into<SecretKey<'a>>,
Allows you to provide Verifier
with the secret key
that was initially used to create the hash
pub fn additional_data(&self) -> Option<&AdditionalData>
[src]
pub fn additional_data(&self) -> Option<&AdditionalData>
Read-only access to the Verifier
's
AdditionalData
, if any
pub fn config(&self) -> VerifierConfig
[src]
pub fn config(&self) -> VerifierConfig
Read-only access to the Verifier
's
VerifierConfig
pub fn hash(&self) -> Option<String>
[src]
pub fn hash(&self) -> Option<String>
Returns the Verifier
's string-encoded hash, if any
pub fn hash_raw(&self) -> Result<Option<HashRaw>, Error>
[src]
pub fn hash_raw(&self) -> Result<Option<HashRaw>, Error>
pub fn password(&self) -> Option<&Password<'a>>
[src]
pub fn password(&self) -> Option<&Password<'a>>
pub fn secret_key(&self) -> Option<&SecretKey<'a>>
[src]
pub fn secret_key(&self) -> Option<&SecretKey<'a>>