Skip to content

Commit 9c6053c

Browse files
author
a2-ron
committed
Update dependencies
1 parent 2832ed5 commit 9c6053c

File tree

3 files changed

+40
-5
lines changed

3 files changed

+40
-5
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ bytes = "1.0"
2525
chrono = { version = "0.4.19", features = ["serde"], optional = true }
2626
crc32fast = "1.2"
2727
flate2 = { version = "1.0", default-features = false }
28-
frunk = { version = "0.3.2", optional = true }
28+
frunk = { version = "0.4", optional = true }
2929
lazy_static = "1"
3030
lexical = "5.2"
3131
num-bigint = { version = "0.4" }

src/crypto/rsa.rs

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,10 @@ impl PublicKey {
203203

204204
#[cfg(test)]
205205
mod tests {
206+
use std::io::Read;
207+
206208
use super::*;
207-
use rand::rngs::adapter::ReadRng;
209+
use rand::RngCore;
208210

209211
const SEED: &[u8; 64] = b"\x03\x2e\x45\x32\x6f\xa8\x59\xa7\x2e\xc2\x35\xac\xff\x92\x9b\x15\xd1\
210212
\x37\x2e\x30\xb2\x07\x25\x5f\x06\x11\xb8\xf7\x85\xd7\x64\x37\x41\x52\xe0\xac\x00\x9e\x50\x9e\
@@ -218,6 +220,39 @@ mod tests {
218220
\x7a\x25\x19\x29\x85\xa8\x42\xdb\xff\x8e\x13\xef\xee\x5b\x7e\x7e\x55\xbb\xe4\xd3\x89\x64\x7c\
219221
\x68\x6a\x9a\x9a\xb3\xfb\x88\x9b\x2d\x77\x67\xd3\x83\x7e\xea\x4e\x0a\x2f\x04";
220222

223+
/// Replacement for the deprecated `rand::ReadRng`.
224+
struct Seed<'a>(&'a [u8]);
225+
226+
impl<'a> RngCore for Seed<'a> {
227+
fn next_u32(&mut self) -> u32 {
228+
let mut buf = [0; 4];
229+
self.fill_bytes(&mut buf);
230+
u32::from_le_bytes(buf)
231+
}
232+
233+
fn next_u64(&mut self) -> u64 {
234+
let mut buf = [0; 8];
235+
self.fill_bytes(&mut buf);
236+
u64::from_le_bytes(buf)
237+
}
238+
239+
fn fill_bytes(&mut self, dest: &mut [u8]) {
240+
self.try_fill_bytes(dest).unwrap_or_else(|err| {
241+
panic!(
242+
"reading random bytes from Read implementation failed; error: {}",
243+
err
244+
)
245+
});
246+
}
247+
248+
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand::Error> {
249+
if dest.is_empty() {
250+
return Ok(());
251+
}
252+
self.0.read_exact(dest).map_err(|e| rand::Error::new(e))
253+
}
254+
}
255+
221256
#[test]
222257
fn mgf1() {
223258
let mask = Pkcs1OaepPadding::<()>::mgf1(&SEED[..], 128);
@@ -292,7 +327,7 @@ mod tests {
292327
BigUint::from_bytes_be(&exponent),
293328
);
294329

295-
let rng = ReadRng::new(&*seed1);
330+
let rng = Seed(&*seed1);
296331
let pad = Pkcs1Padding::new(rng);
297332

298333
let cipher_text = public_key.encrypt_block(msg1, pad);
@@ -344,7 +379,7 @@ mod tests {
344379
BigUint::from_bytes_be(&exponent),
345380
);
346381

347-
let rng = ReadRng::new(&*seed);
382+
let rng = Seed(&*seed);
348383
let pad = Pkcs1OaepPadding::new(rng);
349384

350385
let cipher_text = public_key.encrypt_block(msg, pad);

src/row/convert/frunk.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ fn hlist_from_row() {
162162
.into(),
163163
);
164164

165-
let val: frunk::Hlist![
165+
let val: frunk::HList![
166166
u8,
167167
Vec<u8>,
168168
u16,

0 commit comments

Comments
 (0)