add nkode-rs
This commit is contained in:
@@ -1,6 +1,2 @@
|
||||
pub mod models;
|
||||
pub mod client;
|
||||
pub mod server;
|
||||
pub mod in_memory_auth_repo;
|
||||
pub mod in_memory_auth_session;
|
||||
pub mod in_memory_transport;
|
||||
pub mod nkode;
|
||||
pub mod opaque;
|
||||
|
||||
1
src/nkode.rs
Normal file
1
src/nkode.rs
Normal file
@@ -0,0 +1 @@
|
||||
use nkode_rs::nkode_core::policy::DEFAULT_POLICY;
|
||||
@@ -9,7 +9,7 @@ use opaque_ke::{
|
||||
RegistrationRequest,
|
||||
};
|
||||
|
||||
use crate::models::{RegisterSession, LoginSession, NKodeCipherSuite, PasswordFile};
|
||||
use crate::opaque::models::{RegisterSession, LoginSession, NKodeCipherSuite, PasswordFile};
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::models::PasswordFile;
|
||||
use crate::server::{AuthRepo, AuthRepoError};
|
||||
use crate::opaque::models::PasswordFile;
|
||||
use crate::opaque::server::{AuthRepo, AuthRepoError};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct InMemoryAuthRepo {
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::collections::HashMap;
|
||||
use crate::server::{RegCache, LoginCache, AuthSession};
|
||||
use crate::opaque::server::{RegCache, LoginCache, AuthSession};
|
||||
use opaque_ke::{ServerLogin};
|
||||
use crate::models::NKodeCipherSuite;
|
||||
use crate::opaque::models::NKodeCipherSuite;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Default)]
|
||||
@@ -4,11 +4,11 @@ use tokio::sync::Mutex;
|
||||
use std::sync::Arc;
|
||||
use uuid::Uuid;
|
||||
use opaque_ke::{CredentialFinalization, CredentialRequest, RegistrationRequest};
|
||||
use crate::client::{ClientAuthError, ServerConnectionLogin, ServerConnectionRegister};
|
||||
use crate::models::{LoginSession, RegisterSession, NKodeCipherSuite, NKodeServerSetup, PasswordFile};
|
||||
use crate::server::{OpaqueAuth, CredKind, Key, Code};
|
||||
use crate::in_memory_auth_repo::InMemoryAuthRepo;
|
||||
use crate::in_memory_auth_session::InMemoryAuthSession;
|
||||
use crate::opaque::client::{ClientAuthError, ServerConnectionLogin, ServerConnectionRegister};
|
||||
use crate::opaque::models::{LoginSession, RegisterSession, NKodeCipherSuite, NKodeServerSetup, PasswordFile};
|
||||
use crate::opaque::server::{OpaqueAuth, CredKind, Key, Code};
|
||||
use crate::opaque::in_memory_auth_repo::InMemoryAuthRepo;
|
||||
use crate::opaque::in_memory_auth_session::InMemoryAuthSession;
|
||||
|
||||
pub struct InMemoryServer<K: CredKind> {
|
||||
auth: OpaqueAuth<InMemoryAuthRepo, InMemoryAuthSession>,
|
||||
6
src/opaque/mod.rs
Normal file
6
src/opaque/mod.rs
Normal file
@@ -0,0 +1,6 @@
|
||||
pub mod server;
|
||||
pub mod models;
|
||||
pub mod client;
|
||||
pub mod in_memory_auth_repo;
|
||||
pub mod in_memory_auth_session;
|
||||
pub mod in_memory_transport;
|
||||
@@ -4,7 +4,7 @@ use opaque_ke::{
|
||||
ServerRegistration,
|
||||
};
|
||||
use uuid::Uuid;
|
||||
use crate::models::{RegisterSession, LoginSession, NKodeCipherSuite, NKodeServerSetup, PasswordFile};
|
||||
use crate::opaque::models::{RegisterSession, LoginSession, NKodeCipherSuite, NKodeServerSetup, PasswordFile};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum AuthRepoError {
|
||||
@@ -49,7 +49,6 @@ pub trait AuthSession {
|
||||
fn clear_login_session(&mut self, session_id: &Uuid) -> Result<(), String>;
|
||||
}
|
||||
|
||||
|
||||
pub trait CredKind {
|
||||
fn has<R: AuthRepo>(repo: &R, id: &[u8]) -> bool;
|
||||
fn get_pf<R: AuthRepo>(repo: &R, id: &[u8]) -> Result<PasswordFile, AuthRepoError>;
|
||||
@@ -189,14 +188,3 @@ impl<R: AuthRepo, S: AuthSession> OpaqueAuth<R, S> {
|
||||
Ok(finish.session_key.to_vec())
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------- Usage notes ----------------
|
||||
//
|
||||
// You now have these concrete “types” for your call sites:
|
||||
//
|
||||
// KeyAuthRegistration<R, S> == OpaqueAuth<Registration<Key>, R, S>
|
||||
// CodeAuthRegistration<R, S> == OpaqueAuth<Registration<Code>, R, S>
|
||||
// KeyAuthLogin<R, S> == OpaqueAuth<Login<Key>, R, S>
|
||||
// CodeAuthLogin<R, S> == OpaqueAuth<Login<Code>, R, S>
|
||||
//
|
||||
// And you only wrote the reg/login OPAQUE logic once.
|
||||
Reference in New Issue
Block a user