about summary refs log tree commit diff
path: root/src/libextra/crypto
AgeCommit message (Collapse)AuthorLines
2013-10-27Remove MD5 and Sha2. Move Sha1 and support code into librustpkg.Palmer Cox-2201/+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-15Require module documentation with missing_docAlex Crichton-0/+6
Closes #9824
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-26auto merge of #9503 : dcrewi/rust/fix-digest-visibility, r=alexcrichtonbors-7/+13
I really have no idea why the tests didn't fail. Maybe it's another cross-crate issue?
2013-09-25Fix visibility of digest implementationsDavid Creswick-7/+13
2013-09-25auto merge of #9345 : Dretch/rust/digest-result-bytes, r=cmrbors-14/+16
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-14/+16
2013-09-15Use std::iter::range_stepblake2-ppc-26/+18
Use the iterator version instead of the old uint::/int::range_step functions.
2013-09-06move and duplicate macro defns in sha2 to make them hygienicJohn Clements-22/+40
... it would also have been possible to add all of their dependencies, but that would have increased the already-lengthy list of parameters. Also, if we had macros that could expand into macro defns, you could stage it. This seemed like the least painful choice.
2013-08-27librustc: Fix merge fallout.Patrick Walton-1/+2
2013-08-20rm obsolete integer to_str{,_radix} free functionsDaniel Micay-2/+1
2013-08-18auto merge of #8551 : huonw/rust/speling, r=alexcrichtonbors-4/+4
(This doesn't add/remove `u`s or change `ize` to `ise`, or anything like that.)
2013-08-18More spelling corrections.Huon Wilson-4/+4
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-42/+65
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-17MD5: Create an implementation of MD5.Palmer Cox-0/+329
2013-08-17Crypto: Add little-endian versions of existing functions: read_u32v_le and ↵Palmer Cox-0/+28
write_u32_le.
2013-08-12Forbid pub/priv where it has no effectAlex Crichton-4/+4
Closes #5495
2013-08-03remove obsolete `foreach` keywordDaniel Micay-5/+5
this has been replaced by `for`
2013-08-03replace all remaining `for` with `foreach` or `do`Daniel Micay-8/+12
2013-08-02Sha1: Update Sha1 to use new functionality in cryptoutil.rsPalmer Cox-101/+37
2013-08-02Crypto: Add overflow checking addition functions.Palmer Cox-55/+71
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-21/+63
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-02Crypto: Remove DigestUtil and convert to default methods on the Digest trait.Palmer Cox-28/+22
2013-08-02Sha2: Re-write the Sha2 compression functions to improve performance.Palmer Cox-102/+91
The Sha2 compression functions were re-written to execute the message scheduling calculations in the same loop as the rest of the compression function. The compiler is able to generate much better code. Additionally, innermost part of the compression functions were turned into macros to reduce code duplicate and to make the functions more concise.
2013-08-02Sha2: Create cryptoutil.rs and re-write the Sha2 module to make use of it.Palmer Cox-451/+549
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.
2013-08-02Sha2: Remove the result_X() methods; move logic into the Digest impls.Palmer Cox-73/+50
The result_X() methods just calculate an output of a fixed size. They don't really have much to do with running the actually hash algorithm until the very last step - the output. It makes much more sense to put all this logic into the Digest impls for each specific variation on the hash function.
2013-08-02Sha2: Rearrage traits / impls / structs.Palmer Cox-248/+257
The code was arranged so that the core Sha2 code came first, and then all of the various implementation of Digest followed along later. The problem is that the Sha512 compression function code is far away from the Sha512 Digest implementation, so, if you are trying to read over the code, you need to scroll all around the file for no good reason. The code was rearranged so that all of the Sha512 code is in one place and all of the Sha256 code is in another and so that all impls for a struct are near the definition of that struct.
2013-08-02Sha2: Remove unecessary integer type specifications.Palmer Cox-36/+36
2013-08-02replace `range` with an external iteratorDaniel Micay-9/+6
2013-08-01migrate many `for` loops to `foreach`Daniel Micay-7/+7
2013-08-01make `in` and `foreach` get treated as keywordsDaniel Micay-53/+53
2013-07-19extra: add some microbenchmarksGraydon Hoare-0/+110
2013-07-17test: Fix tests.Patrick Walton-6/+7
2013-07-04Remove standalone comparison functions in vec, make the trait impls better.Huon Wilson-3/+2
2013-06-29Great renaming: propagate throughout the rest of the codebaseCorey Richardson-7/+4
2013-06-28librustc: Fix merge fallout and test cases.Patrick Walton-2/+2
2013-06-27Convert vec::[mut_]slice to methods, remove vec::const_slice.Huon Wilson-40/+39
2013-06-24Implement the fixed output size versions of the SHA-2 digest functions.Palmer Cox-0/+1125
2013-06-24Create a Digest trait for common methods on digests and convert the SHA-1 ↵Palmer Cox-31/+110
implementation to use it. The DigestUtil trait was created for helper methods since default methods still have issues.
2013-06-24Improve the SHA-1 implementationPalmer Cox-234/+203
* Rename struct Sha1State to Sha1 * Remove all use of @ types * Use fixed length vectors * Move all of the inner functions from inside sha1() to top level, private functions * Sha1 instances are now created via Sha1::new() * Update all constant names to uppercase * Remove unecessary assert_eq!s * Remove check_vec_eq() helper function; use vec::eq() instead
2013-06-23Create a crypto submodule and move the SHA-1 implementation into it.Palmer Cox-0/+410