From 939621b8c4e3284b80a798d121f116b633d2564e Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Tue, 23 Oct 2018 12:42:44 -0700 Subject: [PATCH] Upgrade dependencies --- Cargo.toml | 5 +++-- src/lib.rs | 13 ++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9b24485..ef6b71f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,8 @@ repository = "https://github.com/acw/simple_asn1" [dependencies] chrono = "^0.4.0" -num = "^0.1.40" +num = "^0.2.0" [dev-dependencies] -quickcheck = "^0.4.1" +quickcheck = "^0.7.1" +rand = "0.5.5" diff --git a/src/lib.rs b/src/lib.rs index c796bd5..0ab63b5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,7 +20,7 @@ //! binary representation, we also provide `FromASN1WithBody`. This can be //! used with the offset information in the primitive `ASN1Block`s to, for //! example, validate signatures in X509 documents. -//! +//! //! Finally, this library supports ASN.1 class information. I'm still not sure //! why it's useful, but there it is. //! @@ -31,6 +31,8 @@ extern crate num; #[cfg(test)] #[macro_use] extern crate quickcheck; +#[cfg(test)] +extern crate rand; use chrono::{DateTime,TimeZone,Utc}; use num::{BigInt,BigUint,FromPrimitive,One,ToPrimitive,Zero}; @@ -608,7 +610,7 @@ pub fn to_der(i: &ASN1Block) -> Result,ASN1EncodeErr> { return Err(ASN1EncodeErr::ObjectIdentVal2TooLarge); } - // the following unwraps must be safe, based on the + // the following unwraps must be safe, based on the // validation above. let value1 = v1.to_u8().unwrap(); let value2 = v2.to_u8().unwrap(); @@ -905,6 +907,7 @@ mod tests { use quickcheck::{Arbitrary,Gen}; use std::fs::File; use std::io::Read; + use rand::{Rng, distributions::Standard}; use super::*; impl Arbitrary for ASN1Class { @@ -993,14 +996,14 @@ mod tests { let nbits = if modbits > maxbits { maxbits } else { maxbits - modbits }; - let bytes = g.gen_iter::().take(size).collect(); + let bytes = g.sample_iter::(&Standard).take(size).collect(); ASN1Block::BitString(class, 0, nbits, bytes) } fn arb_octstr(g: &mut G, _d: usize) -> ASN1Block { let class = ASN1Class::arbitrary(g); let size = g.gen::() as usize % 16; - let bytes = g.gen_iter::().take(size).collect(); + let bytes = g.sample_iter::(&Standard).take(size).collect(); ASN1Block::OctetString(class, 0, bytes) } @@ -1154,7 +1157,7 @@ mod tests { let class = ASN1Class::arbitrary(g); let tag = RandomUint::arbitrary(g); let size = g.gen_range::(0, 128); - let items = g.gen_iter::().take(size).collect(); + let items = g.sample_iter::(&Standard).take(size).collect(); ASN1Block::Unknown(class, 0, tag.x, items) }