Skip to content

Commit

Permalink
Use namespaced features for serde; MSRV 1.60 (#251)
Browse files Browse the repository at this point in the history
Gets rid of the `serde_crate` hacks.

Weak/namespaced features should also make it possible to make more of
the functionality in this crate optional.
  • Loading branch information
tarcieri authored Jan 17, 2023
1 parent 3c2a3f8 commit da1997d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
rust:
- 1.57.0 # MSRV
- 1.60.0 # MSRV
- stable
target:
- thumbv7em-none-eabi
Expand All @@ -37,7 +37,7 @@ jobs:
strategy:
matrix:
rust:
- 1.57.0 # MSRV
- 1.60.0 # MSRV
- stable
steps:
- uses: actions/checkout@v3
Expand Down
12 changes: 3 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repository = "https://github.com/RustCrypto/RSA"
keywords = ["rsa", "encryption", "security", "crypto"]
categories = ["cryptography"]
readme = "README.md"
rust-version = "1.57"
rust-version = "1.60"

[dependencies]
num-bigint = { version = "0.8.2", features = ["i128", "u64_digit", "prime", "zeroize"], default-features = false, package = "num-bigint-dig" }
Expand All @@ -25,13 +25,7 @@ pkcs1 = { version = "0.4", default-features = false, features = ["pkcs8", "alloc
pkcs8 = { version = "0.9", default-features = false, features = ["alloc"] }
signature = { version = "2", default-features = false , features = ["digest", "rand_core"] }
zeroize = { version = "1", features = ["alloc"] }

[dependencies.serde_crate]
package = "serde"
optional = true
version = "1.0.103"
default-features = false
features = ["derive"]
serde = { version = "1.0.103", optional = true, default-features = false, features = ["derive"] }

[dev-dependencies]
base64ct = { version = "1", features = ["alloc"] }
Expand All @@ -51,7 +45,7 @@ name = "key"
[features]
default = ["std", "pem"]
nightly = ["num-bigint/nightly"]
serde = ["num-bigint/serde", "serde_crate"]
serde = ["dep:serde", "num-bigint/serde"]
expose-internals = []
std = ["digest/std", "pkcs1/std", "pkcs8/std", "rand_core/std", "signature/std"]
pem = ["pkcs1/pem", "pkcs8/pem"]
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![crates.io][crate-image]][crate-link]
[![Documentation][doc-image]][doc-link]
[![Build Status][build-image]][build-link]
![minimum rustc 1.57][msrv-image]
![MSRV][msrv-image]
[![Project Chat][chat-image]][chat-link]
[![dependency status][deps-image]][deps-link]

Expand Down Expand Up @@ -70,7 +70,7 @@ There will be three phases before `1.0` 🚢 can be released.
## Minimum Supported Rust Version (MSRV)
All crates in this repository support Rust 1.57 or higher. In future
All crates in this repository support Rust 1.60 or higher. In future
minimally supported version of Rust can be changed, but it will be done with
a minor version bump.
Expand All @@ -97,7 +97,7 @@ dual licensed as above, without any additional terms or conditions.
[doc-link]: https://docs.rs/rsa
[build-image]: https://github.com/rustcrypto/RSA/workflows/CI/badge.svg
[build-link]: https://github.com/RustCrypto/RSA/actions?query=workflow%3ACI+branch%3Amaster
[msrv-image]: https://img.shields.io/badge/rustc-1.57+-blue.svg
[msrv-image]: https://img.shields.io/badge/rustc-1.60+-blue.svg
[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg
[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260047-RSA
[deps-image]: https://deps.rs/repo/github/RustCrypto/RSA/status.svg
Expand Down
14 changes: 3 additions & 11 deletions src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use num_bigint::{BigInt, BigUint};
use num_traits::{One, ToPrimitive};
use rand_core::CryptoRngCore;
#[cfg(feature = "serde")]
use serde_crate::{Deserialize, Serialize};
use serde::{Deserialize, Serialize};
use zeroize::Zeroize;

use crate::algorithms::{generate_multi_prime_key, generate_multi_prime_key_with_exp};
Expand Down Expand Up @@ -35,23 +35,15 @@ pub trait PrivateKey: DecryptionPrimitive + PublicKeyParts {}

/// Represents the public part of an RSA key.
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
serde(crate = "serde_crate")
)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct RsaPublicKey {
n: BigUint,
e: BigUint,
}

/// Represents a whole RSA key, public and private parts.
#[derive(Debug, Clone)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
serde(crate = "serde_crate")
)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct RsaPrivateKey {
/// Public components of the private key.
pubkey_components: RsaPublicKey,
Expand Down

0 comments on commit da1997d

Please sign in to comment.