Skip to content

std: Constify the bytes sent to Sha1::input #4327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 4 additions & 4 deletions src/libstd/sha1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
/**
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down