Struct tor_hscrypto::ope::AesOpeKey
source · pub struct AesOpeKey { /* private fields */ }
ope
only.Expand description
Key for a simple order-preserving encryption on the offset from the start of an SRV protocol run.
The algorithm here is chosen to be the same as used in the C tor implementation.
Implementations§
source§impl AesOpeKey
impl AesOpeKey
sourcepub fn from_secret(secret: &[u8]) -> Self
pub fn from_secret(secret: &[u8]) -> Self
Construct a new AesOpeKey
from a given secret.
The secret should be unpredictable by an adversary.
sourcepub fn encrypt(&self, offset: SrvPeriodOffset) -> u64
pub fn encrypt(&self, offset: SrvPeriodOffset) -> u64
Encrypt offset
to a 64-bit number.
(We do not implement a decryption operation.)
§Limitations
Like all order-preserving encryption, this scheme leaks information by its nature. It also leaks more information than necessary: (the adversary can get a rough estimate for our input by dividing the output by 0x8001). The only security property that this algorithm tries to provide is that it prevents an adversary from inferring our clock skew.
This algorithm is also not very efficient in its implementation. We expect that the result will become unacceptable if the time period is ever larger than a few days.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AesOpeKey
impl RefUnwindSafe for AesOpeKey
impl Send for AesOpeKey
impl Sync for AesOpeKey
impl Unpin for AesOpeKey
impl UnwindSafe for AesOpeKey
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more