Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/aessafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/*!

The `aessafe` module implements the AES algorithm completely in software without using any table
lookups or other timing dependant mechanisms. This module actually contains two seperate
lookups or other timing dependant mechanisms. This module actually contains two separate
implementations - an implementation that works on a single block at a time and a second
implementation that processes 8 blocks in parallel. Some block encryption modes really only work if
you are processing a single blocks (CFB, OFB, and CBC encryption for example) while other modes
Expand Down Expand Up @@ -88,7 +88,7 @@ is first processed to create all of the round keys where each round key is just
data that is combined into the AES state by the AddRoundKey step as part of each encryption or
decryption round. Processing the round key can be expensive, so this is done before encryption or
decryption. Before encrypting or decrypting data, the data to be processed by be Bit Sliced into 8
seperate variables where each variable holds equivalent bytes from the state. This Bit Sliced state
separate variables where each variable holds equivalent bytes from the state. This Bit Sliced state
is stored as a Bs8State<T>, where T is the type that stores each set of bits. The first
implementation stores these bits in a u32 which permits up to 8 * 32 = 1024 bits of data to be
processed at once. This implementation only processes a single block at a time, so, in reality, only
Expand All @@ -97,7 +97,7 @@ implementation uses u32x4s - vectors of 4 u32s. Thus, we can process 8 * 128 = 4
which corresponds exactly to 8 blocks.

The Bs8State struct implements the AesOps trait, which contains methods for each of the 4 main steps
of the AES algorithm. The types, T, each implement the AesBitValueOps trait, which containts methods
of the AES algorithm. The types, T, each implement the AesBitValueOps trait, which contains methods
necessary for processing a collection or bit values and the AesOps trait relies heavily on this
trait to perform its operations.

Expand Down
10 changes: 5 additions & 5 deletions src/blockmodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl <P: BlockProcessor, X: PaddingProcessor> BlockEngine<P, X> {
next_out);
}

// Process all remaing blocks. We can pull the history out of the buffers without having to
// Process all remaining blocks. We can pull the history out of the buffers without having to
// do any copies
let next_in_size = self.in_hist.len() + self.block_size;
let next_out_size = self.out_hist.len() + self.block_size;
Expand Down Expand Up @@ -433,7 +433,7 @@ pub struct PkcsPadding;
// where padding is stripped. Since BlockEngine doesn't know if its an Encryption or Decryption
// operation, it will call both methods if given a chance. So, this class can't be passed directly
// to BlockEngine. Instead, it must be wrapped with EncPadding or DecPadding which will ensure that
// only the propper methods are called. The client of the library, however, doesn't have to
// only the proper methods are called. The client of the library, however, doesn't have to
// distinguish encryption padding handling from decryption padding handline, which is the whole
// point.
impl PaddingProcessor for PkcsPadding {
Expand Down Expand Up @@ -660,14 +660,14 @@ impl <T: BlockDecryptor, X: PaddingProcessor> Decryptor for CbcDecryptor<T, X> {
}
}

fn add_ctr(ctr: &mut [u8], mut ammount: u8) {
fn add_ctr(ctr: &mut [u8], mut amount: u8) {
for i in ctr.iter_mut().rev() {
let prev = *i;
*i = i.wrapping_add(ammount);
*i = i.wrapping_add(amount);
if *i >= prev {
break;
}
ammount = 1;
amount = 1;
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/cryptoutil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,10 @@ pub fn add_bytes_to_bits(bits: u64, bytes: u64) -> u64 {
let (new_high_bits, new_low_bits) = to_bits(bytes);

if new_high_bits > 0 {
panic!("Numeric overflow occured.")
panic!("Numeric overflow occurred.")
}

bits.checked_add(new_low_bits).expect("Numeric overflow occured.")
bits.checked_add(new_low_bits).expect("Numeric overflow occurred.")
}

/// Adds the specified number of bytes to the bit count, which is a tuple where the first element is
Expand All @@ -297,25 +297,25 @@ pub fn add_bytes_to_bits_tuple
} else {
match hi.checked_add(new_high_bits) {
Some(y) => return (y, x),
None => panic!("Numeric overflow occured.")
None => panic!("Numeric overflow occurred.")
}
}
},
None => {
let z = match new_high_bits.checked_add(1) {
Some(w) => w,
None => panic!("Numeric overflow occured.")
None => panic!("Numeric overflow occurred.")
};
match hi.checked_add(z) {
// This re-executes the addition that was already performed earlier when overflow
// occured, this time allowing the overflow to happen. Technically, this could be
// occurred, this time allowing the overflow to happen. Technically, this could be
// avoided by using the checked add intrinsic directly, but that involves using
// unsafe code and is not really worthwhile considering how infrequently code will
// run in practice. This is the reason that this function requires that the type T
// be UnsignedInt - overflow is not defined for Signed types. This function could
// be implemented for signed types as well if that were needed.
Some(y) => return (y, low.wrapping_add(new_low_bits)),
None => panic!("Numeric overflow occured.")
None => panic!("Numeric overflow occurred.")
}
}
}
Expand Down Expand Up @@ -394,7 +394,7 @@ macro_rules! impl_fixed_buffer( ($name:ident, $size:expr) => (
i += size;
}

// Copy any input data into the buffer. At this point in the method, the ammount of
// Copy any input data into the buffer. At this point in the method, the amount of
// data left in the input vector will be less than the buffer size and the buffer will
// be empty.
let input_remaining = input.len() - i;
Expand Down
2 changes: 1 addition & 1 deletion src/ghash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

/// This is an implementaiton of GHASH as used in GCM [1].
/// This is an implementation of GHASH as used in GCM [1].
/// It is defined as GHASH(H, A, C), where H is a MAC key, A is authenticated data,
/// and C is the ciphertext. GHASH can be used as a keyed MAC, if C is left empty.
///
Expand Down
2 changes: 1 addition & 1 deletion src/pbkdf2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ pub fn pbkdf2_check(password: &str, hashed_value: &str) -> Result<bool, &'static
None => return Err(ERR_STR)
}

// Parse format - currenlty only version 0 is supported
// Parse format - currently only version 0 is supported
match iter.next() {
Some(fstr) => {
match fstr {
Expand Down
2 changes: 1 addition & 1 deletion src/scrypt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ pub fn scrypt_check(password: &str, hashed_value: &str) -> Result<bool, &'static
None => return Err(ERR_STR)
}

// Parse format - currenlty only version 0 (compact) and 1 (expanded) are supported
// Parse format - currently only version 0 (compact) and 1 (expanded) are supported
let params: ScryptParams;
match iter.next() {
Some(fstr) => {
Expand Down
12 changes: 6 additions & 6 deletions src/step_by.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

/// This module just implements a simple verison of step_by() since
/// This module just implements a simple version of step_by() since
/// the function from the standard library is currently unstable.
/// This should be removed once that function becomes stable.

Expand All @@ -14,7 +14,7 @@ use std::ops::{Add, Range};
pub struct StepUp<T> {
next: T,
end: T,
ammount: T
amount: T
}

impl <T> Iterator for StepUp<T> where
Expand All @@ -25,7 +25,7 @@ impl <T> Iterator for StepUp<T> where
fn next(&mut self) -> Option<T> {
if self.next < self.end {
let n = self.next;
self.next = self.next + self.ammount;
self.next = self.next + self.amount;
Some(n)
} else {
None
Expand All @@ -34,16 +34,16 @@ impl <T> Iterator for StepUp<T> where
}

pub trait RangeExt<T> {
fn step_up(self, ammount: T) -> StepUp<T>;
fn step_up(self, amount: T) -> StepUp<T>;
}

impl <T> RangeExt<T> for Range<T> where
T: Add<T, Output = T> + PartialOrd + Copy {
fn step_up(self, ammount: T) -> StepUp<T> {
fn step_up(self, amount: T) -> StepUp<T> {
StepUp {
next: self.start,
end: self.end,
ammount: ammount
amount: amount
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/whirlpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl Digest for Whirlpool {
fn input(&mut self, source: &[u8]) {
assert!(!self.finalized);

// (byte length * 8) = (bit lenght) converted in a 72 bit uint
// (byte length * 8) = (bit length) converted in a 72 bit uint
let len = source.len() as u64;
let len_bits = [
((len >> (56 + 5)) ) as u8,
Expand Down