Skip to content
This repository was archived by the owner on Sep 22, 2021. It is now read-only.

Commit 9de0a83

Browse files
committed
Resolved most clippy warnings 'doc_markdown'.
1 parent 2fc78fc commit 9de0a83

File tree

10 files changed

+103
-104
lines changed

10 files changed

+103
-104
lines changed

src/aes.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub enum KeySize {
2222
}
2323

2424
// aes in electronic codebook mode (ecb) encryption
25-
/// Get the best implementation of an EcbEncryptor
25+
/// Get the best implementation of an `EcbEncryptor`
2626
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
2727
pub fn ecb_encryptor<X: PaddingProcessor + Send + 'static>(
2828
key_size: KeySize,
@@ -51,7 +51,7 @@ pub fn ecb_encryptor<X: PaddingProcessor + Send + 'static>(
5151
}
5252
}
5353

54-
/// Get the best implementation of an EcbEncryptor
54+
/// Get the best implementation of an `EcbEncryptor`
5555
#[cfg(all(not(target_arch = "x86"), not(target_arch = "x86_64")))]
5656
pub fn ecb_encryptor<X: PaddingProcessor + Send + 'static>(
5757
key_size: KeySize,
@@ -74,7 +74,7 @@ pub fn ecb_encryptor<X: PaddingProcessor + Send + 'static>(
7474
}
7575

7676
// aes in electronic codebook mode (ecb) decryption
77-
/// Get the best implementation of an EcbDecryptor
77+
/// Get the best implementation of an `EcbDecryptor`
7878
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
7979
pub fn ecb_decryptor<X: PaddingProcessor + Send + 'static>(
8080
key_size: KeySize,
@@ -101,7 +101,7 @@ pub fn ecb_decryptor<X: PaddingProcessor + Send + 'static>(
101101
}
102102
}
103103

104-
/// Get the best implementation of an EcbDecryptor
104+
/// Get the best implementation of an `EcbDecryptor`
105105
#[cfg(all(not(target_arch = "x86"), not(target_arch = "x86_64")))]
106106
pub fn ecb_decryptor<X: PaddingProcessor + Send + 'static>(
107107
key_size: KeySize,
@@ -124,7 +124,7 @@ pub fn ecb_decryptor<X: PaddingProcessor + Send + 'static>(
124124
}
125125

126126
// aes in cipher block chaining mode (cbc) encryption
127-
/// Get the best implementation of a CbcEncryptor
127+
/// Get the best implementation of a `CbcEncryptor`
128128
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
129129
pub fn cbc_encryptor<X: PaddingProcessor + Send + 'static>(
130130
key_size: KeySize,
@@ -152,7 +152,7 @@ pub fn cbc_encryptor<X: PaddingProcessor + Send + 'static>(
152152
}
153153
}
154154

155-
/// Get the best implementation of a CbcEncryptor
155+
/// Get the best implementation of a `CbcEncryptor`
156156
#[cfg(all(not(target_arch = "x86"), not(target_arch = "x86_64")))]
157157
pub fn cbc_encryptor<X: PaddingProcessor + Send + 'static>(
158158
key_size: KeySize,
@@ -176,7 +176,7 @@ pub fn cbc_encryptor<X: PaddingProcessor + Send + 'static>(
176176
}
177177

178178
// aes in cipher block chaining mode (cbc) decryption
179-
/// Get the best implementation of a CbcDecryptor
179+
/// Get the best implementation of a `CbcDecryptor`
180180
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
181181
pub fn cbc_decryptor<X: PaddingProcessor + Send + 'static>(
182182
key_size: KeySize,
@@ -204,7 +204,7 @@ pub fn cbc_decryptor<X: PaddingProcessor + Send + 'static>(
204204
}
205205
}
206206

207-
/// Get the best implementation of a CbcDecryptor
207+
/// Get the best implementation of a `CbcDecryptor`
208208
#[cfg(all(not(target_arch = "x86"), not(target_arch = "x86_64")))]
209209
pub fn cbc_decryptor<X: PaddingProcessor + Send + 'static>(
210210
key_size: KeySize,

src/aessafe.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,38 +89,37 @@ data that is combined into the AES state by the AddRoundKey step as part of each
8989
decryption round. Processing the round key can be expensive, so this is done before encryption or
9090
decryption. Before encrypting or decrypting data, the data to be processed by be Bit Sliced into 8
9191
seperate variables where each variable holds equivalent bytes from the state. This Bit Sliced state
92-
is stored as a Bs8State<T>, where T is the type that stores each set of bits. The first
92+
is stored as a `Bs8State<T>`, where `T` is the type that stores each set of bits. The first
9393
implementation stores these bits in a u32 which permits up to 8 * 32 = 1024 bits of data to be
9494
processed at once. This implementation only processes a single block at a time, so, in reality, only
9595
512 bits are processed at once and the remaining 512 bits of the variables are unused. The 2nd
9696
implementation uses u32x4s - vectors of 4 u32s. Thus, we can process 8 * 128 = 4096 bits at once,
9797
which corresponds exactly to 8 blocks.
9898
99-
The Bs8State struct implements the AesOps trait, which contains methods for each of the 4 main steps
100-
of the AES algorithm. The types, T, each implement the AesBitValueOps trait, which containts methods
101-
necessary for processing a collection or bit values and the AesOps trait relies heavily on this
99+
The `Bs8State` struct implements the `AesOps` trait, which contains methods for each of the 4 main steps
100+
of the AES algorithm. The types, `T`, each implement the `AesBitValueOps` trait, which containts methods
101+
necessary for processing a collection or bit values and the `AesOps` trait relies heavily on this
102102
trait to perform its operations.
103103
104-
The Bs4State and Bs2State struct implement operations of various subfields of the full GF(2^8)
104+
The `Bs4State` and `Bs2State` struct implement operations of various subfields of the full GF(2^8)
105105
finite field which allows for efficient computation of the AES S-Boxes. See [7] for details.
106106
107107
## References
108108
109109
[1] - "Cache-Collision Timing Attacks Against AES". Joseph Bonneau and Ilya Mironov.
110-
http://www.jbonneau.com/doc/BM06-CHES-aes_cache_timing.pdf
110+
<http://www.jbonneau.com/doc/BM06-CHES-aes_cache_timing.pdf>
111111
[2] - "Software mitigations to hedge AES against cache-based software side channel vulnerabilities".
112-
Ernie Brickell, et al. http://eprint.iacr.org/2006/052.pdf.
112+
Ernie Brickell, et al. <http://eprint.iacr.org/2006/052.pdf>.
113113
[3] - "Cache Attacks and Countermeasures: the Case of AES (Extended Version)".
114-
Dag Arne Osvik, et al. tau.ac.il/~tromer/papers/cache.pdf‎.
114+
Dag Arne Osvik, et al. <tau.ac.il/~tromer/papers/cache.pdf>‎.
115115
[4] - "A Fast New DES Implementation in Software". Eli Biham.
116-
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.52.5429&rep=rep1&type=pdf.
116+
<http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.52.5429&rep=rep1&type=pdf>.
117117
[5] - "Faster and Timing-Attack Resistant AES-GCM". Emilia K ̈asper and Peter Schwabe.
118-
http://www.chesworkshop.org/ches2009/presentations/01_Session_1/CHES2009_ekasper.pdf.
119-
[6] - "FAST AES DECRYPTION". Vinit Azad. http://webcache.googleusercontent.com/
120-
search?q=cache:ld_f8pSgURcJ:csusdspace.calstate.edu/bitstream/handle/10211.9/1224/
121-
Vinit_Azad_MS_Report.doc%3Fsequence%3D2+&cd=4&hl=en&ct=clnk&gl=us&client=ubuntu.
118+
<http://www.chesworkshop.org/ches2009/presentations/01_Session_1/CHES2009_ekasper.pdf>.
119+
[6] - "FAST AES DECRYPTION". Vinit Azad.
120+
<http://webcache.googleusercontent.com/search?q=cache:ld_f8pSgURcJ:csusdspace.calstate.edu/bitstream/handle/10211.9/1224/Vinit_Azad_MS_Report.doc%3Fsequence%3D2+&cd=4&hl=en&ct=clnk&gl=us&client=ubuntu>.
122121
[7] - "A Very Compact Rijndael S-box". D. Canright.
123-
http://www.dtic.mil/cgi-bin/GetTRDoc?AD=ADA434781.
122+
<http://www.dtic.mil/cgi-bin/GetTRDoc?AD=ADA434781>.
124123
*/
125124

126125
use std::ops::{BitAnd, BitXor, Not};

src/blockmodes.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,29 @@ use symmetriccipher::{BlockEncryptor, BlockEncryptorX8, Encryptor, BlockDecrypto
1919
SynchronousStreamCipher, SymmetricCipherError};
2020
use symmetriccipher::SymmetricCipherError::{InvalidPadding, InvalidLength};
2121

22-
/// The BlockProcessor trait is used to implement modes that require processing complete blocks of
23-
/// data. The methods of this trait are called by the BlockEngine which is in charge of properly
22+
/// The `BlockProcessor` trait is used to implement modes that require processing complete blocks of
23+
/// data. The methods of this trait are called by the `BlockEngine` which is in charge of properly
2424
/// buffering input data.
2525
trait BlockProcessor {
2626
/// Process a block of data. The in_hist and out_hist parameters represent the input and output
2727
/// when the last block was processed. These values are necessary for certain modes.
2828
fn process_block(&mut self, in_hist: &[u8], out_hist: &[u8], input: &[u8], output: &mut [u8]);
2929
}
3030

31-
/// A PaddingProcessor handles adding or removing padding
31+
/// A `PaddingProcessor` handles adding or removing padding
3232
pub trait PaddingProcessor {
3333
/// Add padding to the last block of input data
3434
/// If the mode can't handle a non-full block, it signals that error by simply leaving the block
35-
/// as it is which will be detected as an InvalidLength error.
35+
/// as it is which will be detected as an `InvalidLength` error.
3636
fn pad_input<W: WriteBuffer>(&mut self, input_buffer: &mut W);
3737

3838
/// Remove padding from the last block of output data
3939
/// If false is returned, the processing fails
4040
fn strip_output<R: ReadBuffer>(&mut self, output_buffer: &mut R) -> bool;
4141
}
4242

43-
/// The BlockEngine is implemented as a state machine with the following states. See comments in the
44-
/// BlockEngine code for more information on the states.
43+
/// The `BlockEngine` is implemented as a state machine with the following states. See comments in the
44+
/// `BlockEngine` code for more information on the states.
4545
#[derive(Clone, Copy)]
4646
enum BlockEngineState {
4747
FastMode,
@@ -53,28 +53,28 @@ enum BlockEngineState {
5353
Error(SymmetricCipherError)
5454
}
5555

56-
/// BlockEngine buffers input and output data and handles sending complete block of data to the
57-
/// Processor object. Additionally, BlockEngine handles logic necessary to add or remove padding by
56+
/// `BlockEngine` buffers input and output data and handles sending complete block of data to the
57+
/// Processor object. Additionally, `BlockEngine` handles logic necessary to add or remove padding by
5858
/// calling the appropriate methods on the Processor object.
5959
struct BlockEngine<P, X> {
6060
/// The block sized expected by the Processor
6161
block_size: usize,
6262

63-
/// in_hist and out_hist keep track of data that was input to and output from the last
64-
/// invocation of the process_block() method of the Processor. Depending on the mode, these may
63+
/// `in_hist` and `out_hist` keep track of data that was input to and output from the last
64+
/// invocation of the `process_block()` method of the Processor. Depending on the mode, these may
6565
/// be empty vectors if history is not needed.
6666
in_hist: Vec<u8>,
6767
out_hist: Vec<u8>,
6868

6969
/// If some input data is supplied, but not a complete blocks worth, it is stored in this buffer
70-
/// until enough arrives that it can be passed to the process_block() method of the Processor.
70+
/// until enough arrives that it can be passed to the `process_block()` method of the Processor.
7171
in_scratch: OwnedWriteBuffer,
7272

7373
/// If input data is processed but there isn't enough space in the output buffer to store it,
74-
/// it is written into out_write_scratch. OwnedWriteBuffer's may be converted into
75-
/// OwnedReaderBuffers without re-allocating, so, after being written, out_write_scratch is
76-
/// turned into out_read_scratch. After that, if is written to the output as more output becomes
77-
/// available. The main point is - only out_write_scratch or out_read_scratch contains a value
74+
/// it is written into `out_write_scratch`. `OwnedWriteBuffer`s may be converted into
75+
/// `OwnedReaderBuffer`s without re-allocating, so, after being written, `out_write_scratch` is
76+
/// turned into `out_read_scratch`. After that, if is written to the output as more output becomes
77+
/// available. The main point is - only `out_write_scratch` or `out_read_scratch` contains a value
7878
/// at any given time; never both.
7979
out_write_scratch: Option<OwnedWriteBuffer>,
8080
out_read_scratch: Option<OwnedReadBuffer>,
@@ -105,7 +105,7 @@ fn update_history(in_hist: &mut [u8], out_hist: &mut [u8], last_in: &[u8], last_
105105
}
106106

107107
impl <P: BlockProcessor, X: PaddingProcessor> BlockEngine<P, X> {
108-
/// Create a new BlockProcessor instance with the given processor and block_size. No history
108+
/// Create a new `BlockProcessor` instance with the given processor and `block_size`. No history
109109
/// will be saved.
110110
fn new(processor: P, padding: X, block_size: usize) -> BlockEngine<P, X> {
111111
BlockEngine {
@@ -121,7 +121,7 @@ impl <P: BlockProcessor, X: PaddingProcessor> BlockEngine<P, X> {
121121
}
122122
}
123123

124-
/// Create a new BlockProcessor instance with the given processor, block_size, and initial input
124+
/// Create a new `BlockProcessor` instance with the given processor, `block_size`, and initial input
125125
/// and output history.
126126
fn new_with_history(
127127
processor: P,
@@ -136,9 +136,9 @@ impl <P: BlockProcessor, X: PaddingProcessor> BlockEngine<P, X> {
136136
}
137137
}
138138

139-
/// This implements the FastMode state. Ideally, the encryption or decryption operation should
140-
/// do the bulk of its work in FastMode. Significantly, FastMode avoids doing copies as much as
141-
/// possible. The FastMode state does not handle the final block of data.
139+
/// This implements the `FastMode` state. Ideally, the encryption or decryption operation should
140+
/// do the bulk of its work in `FastMode`. Significantly, `FastMode` avoids doing copies as much as
141+
/// possible. The `FastMode` state does not handle the final block of data.
142142
fn fast_mode<R: ReadBuffer, W: WriteBuffer>(
143143
&mut self,
144144
input: &mut R,
@@ -211,7 +211,7 @@ impl <P: BlockProcessor, X: PaddingProcessor> BlockEngine<P, X> {
211211
}
212212
}
213213

214-
/// This method implements the BlockEngine state machine.
214+
/// This method implements the `BlockEngine` state machine.
215215
fn process<R: ReadBuffer, W: WriteBuffer>(
216216
&mut self,
217217
input: &mut R,
@@ -460,7 +460,7 @@ impl PaddingProcessor for PkcsPadding {
460460
}
461461
}
462462

463-
/// Wraps a PaddingProcessor so that only pad_input() will actually be called.
463+
/// Wraps a `PaddingProcessor` so that only `pad_input()` will actually be called.
464464
pub struct EncPadding<X> {
465465
padding: X
466466
}
@@ -474,7 +474,7 @@ impl <X: PaddingProcessor> PaddingProcessor for EncPadding<X> {
474474
fn strip_output<R: ReadBuffer>(&mut self, _: &mut R) -> bool { true }
475475
}
476476

477-
/// Wraps a PaddingProcessor so that only strip_output() will actually be called.
477+
/// Wraps a `PaddingProcessor` so that only `strip_output()` will actually be called.
478478
pub struct DecPadding<X> {
479479
padding: X
480480
}

src/cryptoutil.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ impl <T> WriteExt for T where T: io::Write {
244244
}
245245
}
246246

247-
/// symm_enc_or_dec() implements the necessary functionality to turn a SynchronousStreamCipher into
247+
/// `symm_enc_or_dec()` implements the necessary functionality to turn a `SynchronousStreamCipher` into
248248
/// an Encryptor or Decryptor
249249
pub fn symm_enc_or_dec<S: SynchronousStreamCipher, R: ReadBuffer, W: WriteBuffer>(
250250
c: &mut S,
@@ -266,7 +266,7 @@ fn to_bits(x: u64) -> (u64, u64) {
266266
(x >> 61, x << 3)
267267
}
268268

269-
/// Adds the specified number of bytes to the bit count. panic!() if this would cause numeric
269+
/// Adds the specified number of bytes to the bit count. `panic!()` if this would cause numeric
270270
/// overflow.
271271
pub fn add_bytes_to_bits(bits: u64, bytes: u64) -> u64 {
272272
let (new_high_bits, new_low_bits) = to_bits(bytes);
@@ -279,7 +279,7 @@ pub fn add_bytes_to_bits(bits: u64, bytes: u64) -> u64 {
279279
}
280280

281281
/// Adds the specified number of bytes to the bit count, which is a tuple where the first element is
282-
/// the high order value. panic!() if this would cause numeric overflow.
282+
/// the high order value. `panic!()` if this would cause numeric overflow.
283283
pub fn add_bytes_to_bits_tuple
284284
(bits: (u64, u64), bytes: u64) -> (u64, u64) {
285285
let (new_high_bits, new_low_bits) = to_bits(bytes);
@@ -322,8 +322,8 @@ pub fn add_bytes_to_bits_tuple
322322
}
323323

324324

325-
/// A FixedBuffer, likes its name implies, is a fixed size buffer. When the buffer becomes full, it
326-
/// must be processed. The input() method takes care of processing and then clearing the buffer
325+
/// A `FixedBuffer`, likes its name implies, is a fixed size buffer. When the buffer becomes full, it
326+
/// must be processed. The `input()` method takes care of processing and then clearing the buffer
327327
/// automatically. However, other methods do not and require the caller to process the buffer. Any
328328
/// method that modifies the buffer directory or provides the caller with bytes that can be modifies
329329
/// results in those bytes being marked as used by the buffer.
@@ -482,7 +482,7 @@ impl FixedBuffer128 {
482482
impl_fixed_buffer!(FixedBuffer128, 128);
483483

484484

485-
/// The StandardPadding trait adds a method useful for various hash algorithms to a FixedBuffer
485+
/// The `StandardPadding` trait adds a method useful for various hash algorithms to a `FixedBuffer`
486486
/// struct.
487487
pub trait StandardPadding {
488488
/// Add standard padding to the buffer. The buffer must not be full when this method is called

src/fortuna.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
* as its parent.
3636
*
3737
* However, this appears not to be possible in Rust, due to
38-
* https://github.com/rust-lang/rust/issues/16799
38+
* <https://github.com/rust-lang/rust/issues/16799>
3939
* The reason is that Rust's process management all happens through its
4040
* stdlib runtime, which explicitly does not support forking, so it provides
4141
* no mechanism with which to detect forks.
@@ -398,7 +398,7 @@ mod tests {
398398
let mut output = [0; 100];
399399
// Expected output from experiments with pycryto
400400
// Note that this does not match the results for the Go implementation
401-
// as described at http://www.seehuhn.de/pages/fortuna ... I believe
401+
// as described at <http://www.seehuhn.de/pages/fortuna> ... I believe
402402
// this is because the author there is reusing some Fortuna state from
403403
// the previous test. These results agree with pycrypto on a fresh slate
404404
let mut f = Fortuna::new_unseeded();

src/hkdf.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// except according to those terms.
66

77
//! This module implements the HMAC-based Extract-and-Expand Key
8-
//! Derivation Function as specified by https://tools.ietf.org/html/rfc5869.
8+
//! Derivation Function as specified by <https://tools.ietf.org/html/rfc5869>.
99
1010
use std::iter::repeat;
1111
use cryptoutil::copy_memory;
@@ -21,7 +21,7 @@ use mac::Mac;
2121
/// * digest - The digest function to use.
2222
/// * salt - The optional salt value (a non-secret random value) to use.
2323
/// * ikm - The input keying material to use.
24-
/// * prk - The output buffer to fill with a digest.output_bytes() length
24+
/// * prk - The output buffer to fill with a `digest.output_bytes()` length
2525
/// pseudo random key.
2626
pub fn hkdf_extract<D: Digest>(mut digest: D, salt: &[u8], ikm: &[u8], prk: &mut [u8]) {
2727
assert!(prk.len() == digest.output_bytes());
@@ -38,7 +38,7 @@ pub fn hkdf_extract<D: Digest>(mut digest: D, salt: &[u8], ikm: &[u8], prk: &mut
3838
///
3939
/// # Arguments
4040
/// * digest - The digest function to use.
41-
/// * prk - The pseudorandom key of at least digest.output_bytes() octets.
41+
/// * prk - The pseudorandom key of at least `digest.output_bytes()` octets.
4242
/// * info - The optional context and application specific information to use.
4343
/// * okm - The output buffer to fill with the derived key value.
4444
pub fn hkdf_expand<D: Digest>(mut digest: D, prk: &[u8], info: &[u8], okm: &mut [u8]) {

src/mac.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
// except according to those terms.
66

77
/*!
8-
* The mac module defines the Message Authentication Code (Mac) trait.
8+
* The mac module defines the Message Authentication Code (`Mac`) trait.
99
*/
1010

1111
use util::fixed_time_eq;
1212

1313
/**
14-
* The Mac trait defines methods for a Message Authentication function.
14+
* The `Mac` trait defines methods for a Message Authentication function.
1515
*/
1616
pub trait Mac {
1717
/**
@@ -29,7 +29,7 @@ pub trait Mac {
2929
fn reset(&mut self);
3030

3131
/**
32-
* Obtain the result of a Mac computation as a MacResult.
32+
* Obtain the result of a Mac computation as a `MacResult`.
3333
*/
3434
fn result(&mut self) -> MacResult;
3535

@@ -47,15 +47,15 @@ pub trait Mac {
4747
}
4848

4949
/**
50-
* A MacResult wraps a Mac code and provides a safe Eq implementation that runs in fixed time.
50+
* A `MacResult` wraps a Mac code and provides a safe Eq implementation that runs in fixed time.
5151
*/
5252
pub struct MacResult {
5353
code: Vec<u8>
5454
}
5555

5656
impl MacResult {
5757
/**
58-
* Create a new MacResult.
58+
* Create a new `MacResult`.
5959
*/
6060
pub fn new(code: &[u8]) -> MacResult {
6161
MacResult {
@@ -64,7 +64,7 @@ impl MacResult {
6464
}
6565

6666
/**
67-
* Create a new MacResult taking ownership of the specified code value.
67+
* Create a new `MacResult` taking ownership of the specified code value.
6868
*/
6969
pub fn new_from_owned(code: Vec<u8>) -> MacResult {
7070
MacResult {

0 commit comments

Comments
 (0)