about summary refs log tree commit diff
path: root/src/libextra/crypto/cryptoutil.rs
AgeCommit message (Collapse)AuthorLines
2013-10-27Remove MD5 and Sha2. Move Sha1 and support code into librustpkg.Palmer Cox-428/+0
2013-10-23std::rand: add distributions::Range for generating [lo, hi).Huon Wilson-1/+1
This reifies the computations required for uniformity done by (the old) `Rng.gen_integer_range` (now Rng.gen_range), so that they can be amortised over many invocations, if it is called in a loop. Also, it makes it correct, but using a trait + impls for each type, rather than trying to coerce `Int` + `u64` to do the right thing. This also makes it more extensible, e.g. big integers could & should implement SampleRange.
2013-10-22Drop the '2' suffix from logging macrosAlex Crichton-7/+7
Who doesn't like a massive renaming?
2013-10-07Fix existing privacy/visibility violationsAlex Crichton-1/+1
This commit fixes all of the fallout of the previous commit which is an attempt to refine privacy. There were a few unfortunate leaks which now must be plugged, and the most horrible one is the current `shouldnt_be_public` module now inside `std::rt`. I think that this either needs a slight reorganization of the runtime, or otherwise it needs to just wait for the external users of these modules to get replaced with their `rt` implementations. Other fixes involve making things pub which should be pub, and otherwise updating error messages that now reference privacy instead of referencing an "unresolved name" (yay!).
2013-09-30extra: Remove usage of fmt!Alex Crichton-7/+7
2013-09-25auto merge of #9345 : Dretch/rust/digest-result-bytes, r=cmrbors-1/+4
I would find this function useful.
2013-09-23std: merge rand::{Rng,RngUtil} with default methods.Huon Wilson-3/+2
Also, documentation & general clean-up: - remove `gen_char_from`: better served by `sample` or `choose`. - `gen_bytes` generalised to `gen_vec`. - `gen_int_range`/`gen_uint_range` merged into `gen_integer_range` and made to be properly uniformly distributed. Fixes #8644. Minor adjustments to other functions.
2013-09-20Add a new Digest.result_bytes convenience function.Gareth Smith-1/+4
2013-08-27librustc: Fix merge fallout.Patrick Walton-1/+2
2013-08-18auto merge of #8551 : huonw/rust/speling, r=alexcrichtonbors-1/+1
(This doesn't add/remove `u`s or change `ize` to `ise`, or anything like that.)
2013-08-18More spelling corrections.Huon Wilson-1/+1
2013-08-17Crypto: Add tests for add_bytes_to_bits functions.Palmer Cox-0/+47
2013-08-17Crypto: update checked addition functions to use CheckedAdd intrinsic.Palmer Cox-36/+59
The shift_add_check_overflow and shift_add_check_overflow_tuple functions are re-written to be more efficient and to make use of the CheckedAdd instrinsic instead of manually checking for integer overflow. * The invokation leading_zeros() is removed and replaced with simple integer comparison. The leading_zeros() method results in a ctpop LLVM instruction and it may not be efficient on all architectures; integer comparisons, however, are efficient on just about any architecture. * The methods lose the ability for the caller to specify a particular shift value - that functionality wasn't being used and removing it allows for the code to be simplified. * Finally, the methods are renamed to add_bytes_to_bits and add_bytes_to_bits_tuple to reflect their very specific purposes.
2013-08-17Crypto: Add little-endian versions of existing functions: read_u32v_le and ↵Palmer Cox-0/+28
write_u32_le.
2013-08-02Crypto: Add overflow checking addition functions.Palmer Cox-0/+51
Added functions to cryptoutil.rs that perform an addition after shifting the 2nd parameter by a specified constant. These function fail!() if integer overflow will result. Updated the Sha2 implementation to use these functions.
2013-08-02Crypto: Add large input tests for all DigestsPalmer Cox-0/+33
Create a helper function in cryptoutil.rs which feeds 1,000,000 'a's into a Digest with varying input sizes and then checks the result. This is essentially the same as one of Sha1's existing tests, so, that test was re-implemented using this method. New tests were added using this method for Sha512 and Sha256.
2013-08-02Sha2: Create cryptoutil.rs and re-write the Sha2 module to make use of it.Palmer Cox-0/+243
There are 2 main pieces of functionality in cryptoutil.rs: * A set of unsafe function for efficiently reading and writing u32 and u64 values. All of these functions are fairly easy to audit to confirm that they do what they are supposed to. * A FixedBuffer struct. This struct keeps track of input data until there is enough of it to execute the a function on it which expects a fixed block of data. The Sha2 module was rewritten to take advantage of the new functions in cryptoutil as well as FixedBuffer. The result is that the duplicate code for maintaining a buffer of input data is removed from the Sha512 and Sha256 implementation. Additionally, the FixedBuffer code is much more efficient than the previous code was.