···7272 }
7373}
74747575-pub struct AeadTranport<S: NekoSec> {
7575+pub struct AeadTransport<S: NekoSec> {
7676 pub(crate) aead: AeadNeko<S>,
7777 pub(crate) epstein: aead::Nonce<AeadNeko<S>>,
7878 pub(crate) trump: aead::Nonce<AeadNeko<S>>,
7979 handshake_role: Role,
8080}
81818282-impl<S: NekoSec> zeroize::Zeroize for AeadTranport<S> {
8282+impl<S: NekoSec> zeroize::Zeroize for AeadTransport<S> {
8383 fn zeroize(&mut self) {
8484 self.aead.zeroize();
8585 self.epstein.zeroize();
···8787 }
8888}
89899090-impl<S: NekoSec> zeroize::ZeroizeOnDrop for AeadTranport<S> {}
9090+impl<S: NekoSec> zeroize::ZeroizeOnDrop for AeadTransport<S> {}
91919292-impl<S: NekoSec> Drop for AeadTranport<S> {
9292+impl<S: NekoSec> Drop for AeadTransport<S> {
9393 fn drop(&mut self) {
9494 zeroize::Zeroize::zeroize(self);
9595 }
9696}
97979898-impl<S: NekoSec> AeadTranport<S> {
9898+impl<S: NekoSec> AeadTransport<S> {
9999 pub(crate) fn new(
100100 key: Key<AeadNeko<S>>,
101101 outbound: aead::Nonce<AeadNeko<S>>,
···152152}
153153154154pub struct SendState<'a, S: NekoSec> {
155155- transport: &'a AeadTranport<S>,
155155+ transport: &'a AeadTransport<S>,
156156 counter: u64,
157157}
158158···174174}
175175176176pub struct RecvState<'a, S: NekoSec> {
177177- transport: &'a AeadTranport<S>,
177177+ transport: &'a AeadTransport<S>,
178178 counter: u64,
179179}
180180···213213 let outbound = 123u128.to_ne_bytes();
214214 let inbound = 234u128.to_ne_bytes();
215215216216- let alice = AeadTranport::<Neko128>::new(
216216+ let alice = AeadTransport::<Neko128>::new(
217217 shared_secret.into(),
218218 outbound.into(),
219219 inbound.into(),
220220 Role::Sender,
221221 );
222222- let bob = AeadTranport::<Neko128>::new(
222222+ let bob = AeadTransport::<Neko128>::new(
223223 shared_secret.into(),
224224 outbound.into(),
225225 inbound.into(),
···286286 let outbound = 123u128.to_ne_bytes();
287287 let inbound = 234u128.to_ne_bytes();
288288289289- let alice = AeadTranport::<Neko128>::new(
289289+ let alice = AeadTransport::<Neko128>::new(
290290 shared_secret.into(),
291291 outbound.into(),
292292 inbound.into(),
293293 Role::Sender,
294294 );
295295- let bob = AeadTranport::<Neko256>::new(
295295+ let bob = AeadTransport::<Neko256>::new(
296296 shared_secret.into(),
297297 outbound.into(),
298298 inbound.into(),
+14-2
wharrgarbl-neko/src/lib.rs
···167167 self.position += ratchet_bytes;
168168 }
169169170170+ /// Sets a provided key into the cipher state.
170171 pub fn key(&mut self, data: &NekoKey<Sec>) {
171172 self.begin_op(ops::KEY);
172173173174 self.overwrite(data);
174175 }
175176177177+ /// Absorbs a nonce value into the cipher state
176178 pub fn nonce(&mut self, data: &NekoNonce) {
177179 self.begin_op(ops::NONCE);
178180179181 self.absorb(data);
180182 }
181183182182- /// Absorb associated data into the cipher. This should include a nonce at least,
183183- /// along with other data coming from the app.
184184+ /// Absorb associated data into the cipher.
184185 pub fn ad(&mut self, data: &[u8]) {
185186 self.begin_op(ops::AD);
186187187188 self.absorb(data);
188189 }
189190191191+ /// Pseudo-random Function. Used to generate new keys/nonces from the
192192+ /// cipher state.
190193 pub fn prf(&mut self, data: &mut [u8]) {
191194 self.begin_op(ops::PRF);
192195···195198 self.squeeze(data);
196199 }
197200201201+ /// Create a message authentication code (MAC). This is used to validate the resulting
202202+ /// state after ingesting/encrypting data.
198203 pub fn create_mac(&mut self) -> NekoTag {
199204 self.begin_op(ops::MAC);
200205···207212 tag
208213 }
209214215215+ /// Validates a provided MAC. After ingesting/decrypting data, the resulting state
216216+ /// of the cipher should be the same as the sender's. The MAC validates that this
217217+ /// is correct. Any differences in length/bits/etc, should result in an invalid MAC.
210218 pub fn verify_mac(&mut self, data: &NekoTag) -> aead::Result<()> {
211219 self.begin_op(ops::MAC);
212220···225233 }
226234 }
227235236236+ /// Takes a cleartext buffer, and encrypts it in place.
228237 pub fn encrypt(&mut self, data: &mut [u8]) {
229238 self.begin_op(ops::ENC);
230239···233242 self.absorb_and_set(data);
234243 }
235244245245+ /// Takes a ciphertext buffer, and decrypts it in place.
236246 pub fn decrypt(&mut self, data: &mut [u8]) {
237247 self.begin_op(ops::ENC);
238248···252262 self.absorb(data);
253263 }
254264265265+ /// Permutes and zeros a portion of the cipher state in order to provide forward secrecy.
266266+ /// The amount of bits zeroed is dependent on the cipher strength (128/256).
255267 pub fn ratchet(&mut self) {
256268 self.begin_op(ops::RATCHET);
257269