aboutsummaryrefslogtreecommitdiff
path: root/srp/src
diff options
context:
space:
mode:
Diffstat (limited to 'srp/src')
-rw-r--r--srp/src/client.rs12
-rw-r--r--srp/src/groups.rs3
-rw-r--r--srp/src/lib.rs8
-rw-r--r--srp/src/server.rs6
-rw-r--r--srp/src/tools.rs2
-rw-r--r--srp/src/types.rs6
6 files changed, 15 insertions, 22 deletions
diff --git a/srp/src/client.rs b/srp/src/client.rs
index 8d10b84..6cc1d7f 100644
--- a/srp/src/client.rs
+++ b/srp/src/client.rs
@@ -62,8 +62,8 @@ use digest::Digest;
use generic_array::GenericArray;
use num::{BigUint, Zero};
-use tools::powm;
-use types::{SrpAuthError, SrpGroup};
+use crate::tools::powm;
+use crate::types::{SrpAuthError, SrpGroup};
/// SRP client state before handshake with the server.
pub struct SrpClient<'a, D: Digest> {
@@ -133,7 +133,7 @@ impl<'a, D: Digest> SrpClient<'a, D> {
let k = self.params.compute_k::<D>();
let interm = (k * self.params.powm(x)) % n;
// Because we do operation in modulo N we can get: (kv + g^b) < kv
- let v = if b_pub > &interm {
+ let v = if *b_pub > interm {
(b_pub - &interm) % n
} else {
(n + b_pub - &interm) % n
@@ -186,9 +186,9 @@ impl<'a, D: Digest> SrpClient<'a, D> {
};
Ok(SrpClientVerifier {
- proof: proof,
- server_proof: server_proof,
- key: key,
+ proof,
+ server_proof,
+ key,
})
}
diff --git a/srp/src/groups.rs b/srp/src/groups.rs
index 90b5209..d5c5fb9 100644
--- a/srp/src/groups.rs
+++ b/srp/src/groups.rs
@@ -3,8 +3,9 @@
//! It is strongly recommended to use them instead of custom generated
//! groups. Additionally it is not recommended to use `G_1024` and `G_1536`,
//! they are provided only for compatibility with the legacy software.
+use crate::types::SrpGroup;
+use lazy_static::lazy_static;
use num::BigUint;
-use types::SrpGroup;
lazy_static! {
pub static ref G_1024: SrpGroup = SrpGroup {
diff --git a/srp/src/lib.rs b/srp/src/lib.rs
index 1467496..d05cfa8 100644
--- a/srp/src/lib.rs
+++ b/srp/src/lib.rs
@@ -64,14 +64,6 @@
//! [1]: https://en.wikipedia.org/wiki/Secure_Remote_Password_protocol
//! [2]: https://tools.ietf.org/html/rfc5054
#![doc(html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo_small.png")]
-extern crate digest;
-extern crate generic_array;
-extern crate num;
-#[macro_use]
-extern crate lazy_static;
-
-#[cfg(test)]
-extern crate sha1;
pub mod client;
pub mod groups;
diff --git a/srp/src/server.rs b/srp/src/server.rs
index 52e9c38..a4764d3 100644
--- a/srp/src/server.rs
+++ b/srp/src/server.rs
@@ -40,8 +40,8 @@ use digest::Digest;
use generic_array::GenericArray;
use num::{BigUint, Zero};
-use tools::powm;
-use types::{SrpAuthError, SrpGroup};
+use crate::tools::powm;
+use crate::types::{SrpAuthError, SrpGroup};
/// Data provided by users upon registration, usually stored in the database.
pub struct UserRecord<'a> {
@@ -65,7 +65,7 @@ pub struct SrpServer<D: Digest> {
impl<D: Digest> SrpServer<D> {
/// Create new server state.
pub fn new(
- user: &UserRecord,
+ user: &UserRecord<'_>,
a_pub: &[u8],
b: &[u8],
params: &SrpGroup,
diff --git a/srp/src/tools.rs b/srp/src/tools.rs
index 8cb6910..4fc5db9 100644
--- a/srp/src/tools.rs
+++ b/srp/src/tools.rs
@@ -12,7 +12,7 @@ pub fn powm(base: &BigUint, exp: &BigUint, modulus: &BigUint) -> BigUint {
if &exp % &two == one {
result = (result * &base) % modulus;
}
- exp = exp >> 1;
+ exp >>= 1;
base = (&base * &base) % modulus;
}
result
diff --git a/srp/src/types.rs b/srp/src/types.rs
index e2048a3..6ae8595 100644
--- a/srp/src/types.rs
+++ b/srp/src/types.rs
@@ -1,8 +1,8 @@
//! Additional SRP types.
+use crate::tools::powm;
use digest::Digest;
use num::BigUint;
use std::{error, fmt};
-use tools::powm;
/// SRP authentification error.
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
@@ -11,7 +11,7 @@ pub struct SrpAuthError {
}
impl fmt::Display for SrpAuthError {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "SRP authentification error")
}
}
@@ -53,7 +53,7 @@ impl SrpGroup {
#[cfg(test)]
mod tests {
- use groups::G_1024;
+ use crate::groups::G_1024;
use sha1::Sha1;
#[test]