Skip to content

Commit d8f247f

Browse files
committed
---
yaml --- r: 63623 b: refs/heads/snap-stage3 c: 832fe32 h: refs/heads/master i: 63621: f28b982 63619: 876b3e3 63615: d6ba531 v: v3
1 parent 1f1f186 commit d8f247f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+2399
-674
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 3ab5ec4b7c854290ad1bc5192c70cbc0856a5fa7
4+
refs/heads/snap-stage3: 832fe327218e556740ba4e028b7b60cb41212469
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/RELEASES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ Version 0.7 (July 2013)
7878
* extra: `BigInt`, `BigUint` implement numeric and comparison traits.
7979
* extra: `term` uses terminfo now, is more correct.
8080
* extra: `arc` functions converted to methods.
81+
* extra: Implementation of fixed output size variations of SHA-2.
8182

8283
* Tooling
8384
* `unused_unsafe` lint mode for detecting unnecessary `unsafe` blocks.

branches/snap-stage3/src/libextra/bitv.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,8 +666,12 @@ impl BitvSet {
666666
pub fn symmetric_difference_with(&mut self, other: &BitvSet) {
667667
self.other_op(other, |w1, w2| w1 ^ w2);
668668
}
669+
}
670+
671+
impl BaseIter<uint> for BitvSet {
672+
fn size_hint(&self) -> Option<uint> { Some(self.len()) }
669673

670-
pub fn each(&self, blk: &fn(v: &uint) -> bool) -> bool {
674+
fn each(&self, blk: &fn(v: &uint) -> bool) -> bool {
671675
for self.bitv.storage.iter().enumerate().advance |(i, &w)| {
672676
if !iterate_bits(i * uint::bits, w, |b| blk(&b)) {
673677
return false;
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use core::prelude::*;
12+
13+
use core::uint;
14+
use core::vec;
15+
16+
/**
17+
* The Digest trait specifies an interface common to digest functions, such as SHA-1 and the SHA-2
18+
* family of digest functions.
19+
*/
20+
pub trait Digest {
21+
/**
22+
* Provide message data.
23+
*
24+
* # Arguments
25+
*
26+
* * input - A vector of message data
27+
*/
28+
fn input(&mut self, input: &[u8]);
29+
30+
/**
31+
* Retrieve the digest result. This method may be called multiple times.
32+
*/
33+
fn result(&mut self, out: &mut [u8]);
34+
35+
/**
36+
* Reset the digest. This method must be called after result() and before supplying more
37+
* data.
38+
*/
39+
fn reset(&mut self);
40+
41+
/**
42+
* Get the output size in bits.
43+
*/
44+
fn output_bits(&self) -> uint;
45+
}
46+
47+
fn to_hex(rr: &[u8]) -> ~str {
48+
let mut s = ~"";
49+
for rr.iter().advance() |b| {
50+
let hex = uint::to_str_radix(*b as uint, 16u);
51+
if hex.len() == 1 {
52+
s += "0";
53+
}
54+
s += hex;
55+
}
56+
return s;
57+
}
58+
59+
/// Contains utility methods for Digests.
60+
/// FIXME: #7339: Convert to default methods when issues with them are resolved.
61+
pub trait DigestUtil {
62+
/**
63+
* Convenience functon that feeds a string into a digest
64+
*
65+
* # Arguments
66+
*
67+
* * in The string to feed into the digest
68+
*/
69+
fn input_str(&mut self, in: &str);
70+
71+
/**
72+
* Convenience functon that retrieves the result of a digest as a
73+
* ~str in hexadecimal format.
74+
*/
75+
fn result_str(&mut self) -> ~str;
76+
}
77+
78+
impl<D: Digest> DigestUtil for D {
79+
fn input_str(&mut self, in: &str) {
80+
self.input(in.as_bytes());
81+
}
82+
83+
fn result_str(&mut self) -> ~str {
84+
let mut buf = vec::from_elem((self.output_bits()+7)/8, 0u8);
85+
self.result(buf);
86+
return to_hex(buf);
87+
}
88+
}

0 commit comments

Comments
 (0)