File: 2002_rand.patch

package info (click to toggle)
rust-indieweb 0.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 980 kB
  • sloc: makefile: 12; sh: 1
file content (50 lines) | stat: -rw-r--r-- 1,883 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Description: use older minor version of crate rand, and use crate rand_core
Author: Jonas Smedegaard <dr@jones.dk>
Forwarded: not-needed
Last-Update: 2025-12-11
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/library/Cargo.toml
+++ b/library/Cargo.toml
@@ -36,7 +36,7 @@
 reqwest = { version = "0.12", optional = true }
 miette = { version = "7.2", default-features = false, features = ["derive"] }
 secrecy = { version = "0.10", features = ["serde"] }
-rand = { version = "0.9", default-features = false, features = ["os_rng"] }
+rand = { version = "0.8.5", default-features = false, features = ["getrandom"] }
 serde_with = "3.12.0"
 
 [features]
--- a/library/src/standards/indieauth/mod.rs
+++ b/library/src/standards/indieauth/mod.rs
@@ -2,10 +2,9 @@
 
 use base64::Engine;
 use http::header::{ACCEPT, CONTENT_TYPE};
-use rand::rand_core::OsError;
 #[cfg(feature = "fake")]
 use rand::Rng;
-use rand::TryRngCore;
+use rand::RngCore;
 pub use secrecy::ExposeSecret;
 use secrecy::SecretString;
 use sha2::Digest;
@@ -53,9 +52,6 @@
     #[error("The redemeption endpoint at {url:?} did not declare itself as JSON but as {content_type:?}")]
     RedemptionResponseContentType { url: Url, content_type: String },
 
-    #[error("Failed to invoke the random number generator: {0:#?}")]
-    Random(OsError),
-
     #[error("The client ID must be a HTTP-based URL.")]
     ClientIdMustBeHttp,
 }
@@ -419,7 +415,7 @@
     pub fn generate(method: CodeChallengeMethod) -> Result<(Self, CodeChallengeMethod), Error> {
         let mut bytes = [0u8; 64];
         let mut rng = rand::rngs::OsRng {};
-        rng.try_fill_bytes(&mut bytes[..]).map_err(Error::Random)?;
+        rng.fill_bytes(&mut bytes);
         let verifier = base64::engine::general_purpose::URL_SAFE_NO_PAD.encode(bytes);
         let challenge = Self::from_verifier(&method, verifier);