Camel case more std types
This commit is contained in:
parent
aab4d6b8d7
commit
ee2ce036cc
4 changed files with 55 additions and 41 deletions
|
|
@ -23,7 +23,7 @@
|
|||
export sha1;
|
||||
|
||||
/// The SHA-1 interface
|
||||
trait sha1 {
|
||||
trait Sha1 {
|
||||
/// Provide message input as bytes
|
||||
fn input((&[u8]));
|
||||
/// Provide message input as string
|
||||
|
|
@ -53,8 +53,8 @@ const k3: u32 = 0xCA62C1D6u32;
|
|||
|
||||
|
||||
/// Construct a `sha` object
|
||||
fn sha1() -> sha1 {
|
||||
type sha1state =
|
||||
fn sha1() -> Sha1 {
|
||||
type Sha1State =
|
||||
{h: ~[mut u32],
|
||||
mut len_low: u32,
|
||||
mut len_high: u32,
|
||||
|
|
@ -63,7 +63,7 @@ fn sha1() -> sha1 {
|
|||
mut computed: bool,
|
||||
work_buf: @~[mut u32]};
|
||||
|
||||
fn add_input(st: &sha1state, msg: &[u8]) {
|
||||
fn add_input(st: &Sha1State, msg: &[u8]) {
|
||||
assert (!st.computed);
|
||||
for vec::each(msg) |element| {
|
||||
st.msg_block[st.msg_block_idx] = element;
|
||||
|
|
@ -79,7 +79,7 @@ fn sha1() -> sha1 {
|
|||
if st.msg_block_idx == msg_block_len { process_msg_block(st); }
|
||||
}
|
||||
}
|
||||
fn process_msg_block(st: &sha1state) {
|
||||
fn process_msg_block(st: &Sha1State) {
|
||||
assert (vec::len(st.h) == digest_buf_len);
|
||||
assert (vec::len(*st.work_buf) == work_buf_len);
|
||||
let mut t: int; // Loop counter
|
||||
|
|
@ -158,7 +158,7 @@ fn sha1() -> sha1 {
|
|||
fn circular_shift(bits: u32, word: u32) -> u32 {
|
||||
return word << bits | word >> 32u32 - bits;
|
||||
}
|
||||
fn mk_result(st: &sha1state) -> ~[u8] {
|
||||
fn mk_result(st: &Sha1State) -> ~[u8] {
|
||||
if !(*st).computed { pad_msg(st); (*st).computed = true; }
|
||||
let mut rs: ~[u8] = ~[];
|
||||
for vec::each_mut((*st).h) |ptr_hpart| {
|
||||
|
|
@ -181,7 +181,7 @@ fn sha1() -> sha1 {
|
|||
* call process_msg_block() appropriately. When it returns, it
|
||||
* can be assumed that the message digest has been computed.
|
||||
*/
|
||||
fn pad_msg(st: &sha1state) {
|
||||
fn pad_msg(st: &Sha1State) {
|
||||
assert (vec::len((*st).msg_block) == msg_block_len);
|
||||
|
||||
/*
|
||||
|
|
@ -218,7 +218,7 @@ fn sha1() -> sha1 {
|
|||
process_msg_block(st);
|
||||
}
|
||||
|
||||
impl sha1state: sha1 {
|
||||
impl Sha1State: Sha1 {
|
||||
fn reset() {
|
||||
assert (vec::len(self.h) == digest_buf_len);
|
||||
self.len_low = 0u32;
|
||||
|
|
@ -253,7 +253,7 @@ fn sha1() -> sha1 {
|
|||
mut computed: false,
|
||||
work_buf: @vec::to_mut(vec::from_elem(work_buf_len, 0u32))
|
||||
};
|
||||
let sh = st as sha1;
|
||||
let sh = st as Sha1;
|
||||
sh.reset();
|
||||
return sh;
|
||||
}
|
||||
|
|
@ -263,7 +263,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test() unsafe {
|
||||
type test = {input: ~str, output: ~[u8]};
|
||||
type Test = {input: ~str, output: ~[u8]};
|
||||
|
||||
fn a_million_letter_a() -> ~str {
|
||||
let mut i = 0;
|
||||
|
|
@ -273,7 +273,7 @@ mod tests {
|
|||
}
|
||||
// Test messages from FIPS 180-1
|
||||
|
||||
let fips_180_1_tests: ~[test] =
|
||||
let fips_180_1_tests: ~[Test] =
|
||||
~[{input: ~"abc",
|
||||
output:
|
||||
~[0xA9u8, 0x99u8, 0x3Eu8, 0x36u8,
|
||||
|
|
@ -299,7 +299,7 @@ mod tests {
|
|||
0x65u8, 0x34u8, 0x01u8, 0x6Fu8]}];
|
||||
// Examples from wikipedia
|
||||
|
||||
let wikipedia_tests: ~[test] =
|
||||
let wikipedia_tests: ~[Test] =
|
||||
~[{input: ~"The quick brown fox jumps over the lazy dog",
|
||||
output:
|
||||
~[0x2fu8, 0xd4u8, 0xe1u8, 0xc6u8,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue