clean up lots of things, server-side API improved

This commit is contained in:
lumi 2017-03-25 23:15:34 +01:00
commit 6c11716926
8 changed files with 419 additions and 272 deletions

View file

@ -8,6 +8,8 @@ use openssl::sign::Signer;
use common::Password;
use secret;
use base64;
/// Generate a nonce for SCRAM authentication.
@ -19,6 +21,9 @@ pub fn generate_nonce() -> Result<String, ErrorStack> {
/// A trait which defines the needed methods for SCRAM.
pub trait ScramProvider {
/// The kind of secret this `ScramProvider` requires.
type SecretKind: secret::SecretKind;
/// The name of the hash function.
fn name() -> &'static str;
@ -37,6 +42,8 @@ pub struct Sha1;
impl ScramProvider for Sha1 {
// TODO: look at all these unwraps
type SecretKind = secret::Pbkdf2Sha1;
fn name() -> &'static str {
"SHA-1"
}
@ -98,6 +105,8 @@ pub struct Sha256;
impl ScramProvider for Sha256 {
// TODO: look at all these unwraps
type SecretKind = secret::Pbkdf2Sha256;
fn name() -> &'static str {
"SHA-256"
}