Skip to content

Commit 11803fb

Browse files
committed
Update to zip v3, replace rand_core with getrandom
1 parent b49a4a0 commit 11803fb

File tree

6 files changed

+23
-21
lines changed

6 files changed

+23
-21
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
folder:
4646
- "cli"
4747
include:
48-
- toolchain: "1.73"
48+
- toolchain: "1.75"
4949
folder: api
5050
runs-on: ubuntu-latest
5151
steps:
@@ -62,9 +62,9 @@ jobs:
6262
toolchain:
6363
- stable
6464
os:
65-
- ubuntu-22.04
66-
- windows-2022
67-
- macos-13
65+
- ubuntu-latest
66+
- windows-latest
67+
- macos-latest
6868
versions:
6969
- ""
7070
- "-Zminimal-versions"
@@ -107,7 +107,7 @@ jobs:
107107
strategy:
108108
matrix:
109109
toolchain:
110-
- 1.73
110+
- 1.75
111111
runs-on: ubuntu-latest
112112
steps:
113113
- uses: actions/checkout@v4
@@ -129,9 +129,9 @@ jobs:
129129
toolchain:
130130
- stable
131131
os:
132-
- ubuntu-22.04
133-
- windows-2022
134-
- macos-13
132+
- ubuntu-latest
133+
- windows-latest
134+
- macos-latest
135135
versions:
136136
- ""
137137
- "-Zminimal-versions"

.github/workflows/devskim-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
jobs:
1212
lint:
1313
name: DevSkim
14-
runs-on: ubuntu-20.04
14+
runs-on: ubuntu-latest
1515
permissions:
1616
actions: read
1717
contents: read

Cargo.toml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@ default-members = ["api", "cli"]
77
base64 = "0.22.0"
88
clap = { version = "4.4.0", features = ["derive"] }
99
ed25519-dalek = { version = "2.0.0", features = ["digest"] }
10+
getrandom = { version = "0.3.3", features = ["std"] }
1011
normalize-path = "0.2.0"
1112
pretty-error-debug = "0.3.0"
1213
tempfile = "3.0.0"
1314
thiserror = "2.0.8"
14-
zip = { version = "2.0.0", default-features = false }
15-
16-
# Cannot be newer than `ed25519-dalek`'s dependency
17-
rand_core = { version = "0.6.0", features = ["getrandom"] }
15+
zip = { version = "3.0.0", default-features = false }
1816

1917
[workspace.dependencies.zipsign-api]
20-
version = "0.1.3"
18+
version = "0.1.4"
2119
path = "api"
2220
default-features = false
2321
features = ["tar", "zip"]

api/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "zipsign-api"
33
description = "Sign and verify `.zip` and `.tar.gz` files with an ed25519 signing key"
4-
version = "0.1.3"
4+
version = "0.1.4"
55
edition = "2021"
66
authors = ["René Kijewski <[email protected]>"]
77
repository = "https://github.com/Kijewski/zipsign"

cli/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "zipsign"
33
description = "Sign and verify `.zip` and `.tar.gz` files with an ed25519 signing key"
4-
version = "0.1.3"
4+
version = "0.1.4"
55
edition = "2021"
66
authors = ["René Kijewski <[email protected]>"]
77
repository = "https://github.com/Kijewski/zipsign"
@@ -14,10 +14,10 @@ rustdoc-args = ["--generate-link-to-definition", "--cfg=docsrs"]
1414

1515
[dependencies]
1616
clap.workspace = true
17-
ed25519-dalek = { workspace = true, features = ["rand_core"] }
17+
ed25519-dalek.workspace = true
18+
getrandom.workspace = true
1819
normalize-path.workspace = true
1920
pretty-error-debug.workspace = true
20-
rand_core.workspace = true
2121
tempfile.workspace = true
2222
thiserror.workspace = true
2323
zipsign-api.workspace = true

cli/src/generate.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ use std::os::unix::prelude::OpenOptionsExt;
55
use std::path::PathBuf;
66

77
use clap::Parser;
8-
use ed25519_dalek::{KEYPAIR_LENGTH, SigningKey};
9-
use rand_core::OsRng;
8+
use ed25519_dalek::{KEYPAIR_LENGTH, SecretKey, SigningKey};
109

1110
/// Generate a signing key
1211
#[derive(Debug, Parser, Clone)]
@@ -35,6 +34,8 @@ pub(crate) enum Error {
3534
Read(#[source] std::io::Error, PathBuf),
3635
#[error("no valid key found in from {1:?}")]
3736
IllegalKey(#[source] ed25519_dalek::SignatureError, PathBuf),
37+
#[error("could not get random data")]
38+
Random(#[source] getrandom::Error),
3839
}
3940

4041
pub(crate) fn main(args: Cli) -> Result<(), Error> {
@@ -53,7 +54,10 @@ pub(crate) fn main(args: Cli) -> Result<(), Error> {
5354
Err(err) => return Err(Error::IllegalKey(err, args.private_key)),
5455
}
5556
} else {
56-
let key: SigningKey = SigningKey::generate(&mut OsRng);
57+
let mut secret = SecretKey::default();
58+
getrandom::fill(secret.as_mut_slice()).map_err(Error::Random)?;
59+
let key = SigningKey::from_bytes(&{ secret });
60+
5761
let result = OpenOptions::new()
5862
.write(true)
5963
.create(true)

0 commit comments

Comments
 (0)