Skip to content

dsa: remove use of opaque-debug #572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion dsa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ rust-version = "1.57"
digest = "0.10"
num-bigint = { package = "num-bigint-dig", version = "0.8", default-features = false, features = ["prime", "rand", "zeroize"] }
num-traits = { version = "0.2", default-features = false }
opaque-debug = "0.3"
pkcs8 = { version = "0.9", default-features = false, features = ["alloc"] }
rand = { version = "0.8", default-features = false }
rfc6979 = { version = "0.3", path = "../rfc6979" }
Expand Down
4 changes: 1 addition & 3 deletions dsa/src/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use rand::{CryptoRng, RngCore};
/// The common components of an DSA keypair
///
/// (the prime p, quotient q and generator g)
#[derive(Clone, PartialEq, PartialOrd)]
#[derive(Clone, Debug, PartialEq, PartialOrd)]
#[must_use]
pub struct Components {
/// Prime p
Expand All @@ -24,8 +24,6 @@ pub struct Components {
g: BigUint,
}

opaque_debug::implement!(Components);

impl Components {
/// Construct the common components container from its inner values (p, q and g)
pub fn from_components(p: BigUint, q: BigUint, g: BigUint) -> signature::Result<Self> {
Expand Down
4 changes: 1 addition & 3 deletions dsa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ use pkcs8::der::{self, asn1::UIntRef, Decode, Encode, Reader, Sequence};
use signature::SignatureEncoding;

/// Container of the DSA signature
#[derive(Clone)]
#[derive(Clone, Debug)]
#[must_use]
pub struct Signature {
/// Signature part r
Expand All @@ -83,8 +83,6 @@ pub struct Signature {
s: BigUint,
}

opaque_debug::implement!(Signature);

impl Signature {
/// Create a new Signature container from its components
pub fn from_components(r: BigUint, s: BigUint) -> signature::Result<Self> {
Expand Down
15 changes: 12 additions & 3 deletions dsa/src/signing_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
//!

use crate::{Components, Signature, VerifyingKey, OID};
use core::cmp::min;
use core::{
cmp::min,
fmt::{self, Debug},
};
use digest::{core_api::BlockSizeUser, Digest, FixedOutputReset};
use num_bigint::BigUint;
use num_traits::Zero;
Expand Down Expand Up @@ -32,8 +35,6 @@ pub struct SigningKey {
x: Zeroizing<BigUint>,
}

opaque_debug::implement!(SigningKey);

impl SigningKey {
/// Construct a new private key from the public key and private component
pub fn from_components(verifying_key: VerifyingKey, x: BigUint) -> signature::Result<Self> {
Expand Down Expand Up @@ -207,3 +208,11 @@ impl<'a> TryFrom<PrivateKeyInfo<'a>> for SigningKey {
}

impl DecodePrivateKey for SigningKey {}

impl Debug for SigningKey {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("SigningKey")
.field("verifying_key", &self.verifying_key)
.finish_non_exhaustive()
}
}
4 changes: 1 addition & 3 deletions dsa/src/verifying_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use pkcs8::{
use signature::{hazmat::PrehashVerifier, DigestVerifier, Verifier};

/// DSA public key.
#[derive(Clone, PartialEq, PartialOrd)]
#[derive(Clone, Debug, PartialEq, PartialOrd)]
#[must_use]
pub struct VerifyingKey {
/// common components
Expand All @@ -24,8 +24,6 @@ pub struct VerifyingKey {
y: BigUint,
}

opaque_debug::implement!(VerifyingKey);

impl VerifyingKey {
/// Construct a new public key from the common components and the public component
pub fn from_components(components: Components, y: BigUint) -> signature::Result<Self> {
Expand Down