Skip to content

Commit

Permalink
remove cfg features
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Tate <[email protected]>
  • Loading branch information
Ryanmtate committed Aug 28, 2024
1 parent d0c7439 commit 033fd5e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/core/authorization_request/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,11 @@ impl std::fmt::Display for Nonce {
}

impl Nonce {
#[cfg(feature = "rand")]
pub fn random(rng: &mut impl rand::Rng) -> Self {
use rand::distributions::Alphanumeric;
/// Crate a new `Nonce` with a random value of the given length.
pub fn random(rng: &mut impl rand::Rng, length: usize) -> Self {
use rand::distributions::{Alphanumeric, DistString};

Self((0..16).map(|_| rng.sample(Alphanumeric) as char).collect())
Self(Alphanumeric.sample_string(rng, length))
}
}

Expand Down
4 changes: 0 additions & 4 deletions src/core/authorization_request/verification/verifier.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use anyhow::Result;
#[cfg(feature = "p256")]
use anyhow::{bail, Error};
#[cfg(feature = "p256")]
use p256::ecdsa::signature::Verifier as _;
use x509_cert::spki::SubjectPublicKeyInfoRef;

Expand All @@ -15,11 +13,9 @@ pub trait Verifier: Sized {
fn verify(&self, payload: &[u8], signature: &[u8]) -> Result<()>;
}

#[cfg(feature = "p256")]
#[derive(Debug, Clone)]
pub struct P256Verifier(p256::ecdsa::VerifyingKey);

#[cfg(feature = "p256")]
impl Verifier for P256Verifier {
fn from_spki(spki: SubjectPublicKeyInfoRef<'_>, algorithm: String) -> Result<Self> {
if algorithm != "ES256" {
Expand Down
8 changes: 0 additions & 8 deletions src/verifier/request_signer.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
#[cfg(feature = "p256")]
use anyhow::Result;
use async_trait::async_trait;
#[cfg(feature = "p256")]
use p256::ecdsa::{signature::Signer, Signature, SigningKey};
#[cfg(feature = "p256")]
use ssi_claims::jws::{JWSSigner, JWSSignerInfo};
#[cfg(feature = "p256")]
use ssi_jwk::Algorithm;

use ssi_jwk::JWK;
Expand Down Expand Up @@ -33,14 +29,12 @@ pub trait RequestSigner: Debug {
}
}

#[cfg(feature = "p256")]
#[derive(Debug)]
pub struct P256Signer {
key: SigningKey,
jwk: JWK,
}

#[cfg(feature = "p256")]
impl P256Signer {
pub fn new(key: SigningKey) -> Result<Self> {
let pk: p256::PublicKey = key.verifying_key().into();
Expand All @@ -53,7 +47,6 @@ impl P256Signer {
}
}

#[cfg(feature = "p256")]
#[async_trait]
impl RequestSigner for P256Signer {
type Error = anyhow::Error;
Expand All @@ -77,7 +70,6 @@ impl RequestSigner for P256Signer {
}
}

#[cfg(feature = "p256")]
impl JWSSigner for P256Signer {
async fn fetch_info(&self) -> std::result::Result<JWSSignerInfo, ssi_claims::SignatureError> {
let algorithm = self.jwk.algorithm.unwrap_or(Algorithm::ES256);
Expand Down

0 comments on commit 033fd5e

Please sign in to comment.