std: Constify the bytes sent to Sha1::input
We are of course never going to modify the data, and this change allows us to accept data from to_bytes::IterBytes types.
This commit is contained in:
parent
392708e3b1
commit
ae69c2fc7d
1 changed files with 4 additions and 4 deletions
|
|
@ -37,7 +37,7 @@ use core::vec;
|
|||
/// The SHA-1 interface
|
||||
trait Sha1 {
|
||||
/// Provide message input as bytes
|
||||
fn input((&[u8]));
|
||||
fn input((&[const u8]));
|
||||
/// Provide message input as string
|
||||
fn input_str((&str));
|
||||
/**
|
||||
|
|
@ -75,9 +75,9 @@ pub fn sha1() -> Sha1 {
|
|||
mut computed: bool,
|
||||
work_buf: @~[mut u32]};
|
||||
|
||||
fn add_input(st: &Sha1State, msg: &[u8]) {
|
||||
fn add_input(st: &Sha1State, msg: &[const u8]) {
|
||||
assert (!st.computed);
|
||||
for vec::each(msg) |element| {
|
||||
for vec::each_const(msg) |element| {
|
||||
st.msg_block[st.msg_block_idx] = *element;
|
||||
st.msg_block_idx += 1u;
|
||||
st.len_low += 8u32;
|
||||
|
|
@ -243,7 +243,7 @@ pub fn sha1() -> Sha1 {
|
|||
self.h[4] = 0xC3D2E1F0u32;
|
||||
self.computed = false;
|
||||
}
|
||||
fn input(msg: &[u8]) { add_input(&self, msg); }
|
||||
fn input(msg: &[const u8]) { add_input(&self, msg); }
|
||||
fn input_str(msg: &str) {
|
||||
let bs = str::to_bytes(msg);
|
||||
add_input(&self, bs);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue