pub struct Interceptor {
pub key_store: Arc<RwLock<KeyStore>>,
pub handshake_store: HandshakeStore,
pub replay_store: Option<ConnectionManager>,
}Expand description
Actix-web middleware that transparently decrypts incoming request bodies and encrypts outgoing response bodies using the X25519 ECDH + AES-256-GCM + HMAC-SHA256 pipeline.
§Usage
use alterion_encrypt::interceptor::Interceptor;
use alterion_encrypt::{init_key_store, init_handshake_store, start_rotation};
let store = init_key_store(3600);
let hs = init_handshake_store();
start_rotation(store.clone(), 3600, hs.clone());
// App::new().wrap(Interceptor { key_store: store, handshake_store: hs, replay_store: None })Request path (POST / PUT / PATCH):
- Collect raw body bytes.
- MessagePack-decode a
Requestand validate timestamp. - Perform X25519 ECDH using the server key identified by
key_idand the client’s ephemeral public key from the packet. - Derive a wrap key via HKDF-SHA256 and use it to AES-GCM-unwrap the client’s
enc_key. - AES-256-GCM-decrypt the payload using
enc_key. - Inject
DecryptedBodyandRequestSessionKeysinto request extensions.
Requests whose body is not a valid Request are passed through unchanged.
Response path (only when RequestSessionKeys was set):
JSON → deflate compress → msgpack → AES-256-GCM (enc_key) → HMAC-SHA256 (mac key derived
from enc_key) → Response → msgpack.
Fields§
§key_store: Arc<RwLock<KeyStore>>§handshake_store: HandshakeStore§replay_store: Option<ConnectionManager>Trait Implementations§
Source§impl<S, B> Transform<S, ServiceRequest> for Interceptorwhere
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error> + 'static,
B: MessageBody + 'static,
impl<S, B> Transform<S, ServiceRequest> for Interceptorwhere
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error> + 'static,
B: MessageBody + 'static,
Source§type Response = ServiceResponse<EitherBody<B>>
type Response = ServiceResponse<EitherBody<B>>
Responses produced by the service.
Source§type Transform = InterceptorService<S>
type Transform = InterceptorService<S>
The
TransformService value created by this factorySource§type Future = Ready<Result<<Interceptor as Transform<S, ServiceRequest>>::Transform, <Interceptor as Transform<S, ServiceRequest>>::InitError>>
type Future = Ready<Result<<Interceptor as Transform<S, ServiceRequest>>::Transform, <Interceptor as Transform<S, ServiceRequest>>::InitError>>
The future response value.
Source§fn new_transform(&self, service: S) -> Self::Future
fn new_transform(&self, service: S) -> Self::Future
Creates and returns a new Transform component, asynchronously
Auto Trait Implementations§
impl Freeze for Interceptor
impl !RefUnwindSafe for Interceptor
impl Send for Interceptor
impl Sync for Interceptor
impl Unpin for Interceptor
impl UnsafeUnpin for Interceptor
impl !UnwindSafe for Interceptor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more