Skip to content

Commit

Permalink
dont count example code to coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
bitfl0wer committed Apr 15, 2024
1 parent fcd5056 commit cd6e4ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions examples/ed25519_basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ impl Signature for Ed25519Signature {
}
}

#[cfg(not(tarpaulin_include))]
fn from_bitstring(signature: &[u8]) -> Self {
let mut signature_vec = signature.to_vec();
signature_vec.resize(64, 0);
Expand All @@ -113,6 +114,7 @@ impl Signature for Ed25519Signature {
// The `SignatureBitStringEncoding` trait is used to convert a signature to a bit string. We implement
// it for our signature type.
impl SignatureBitStringEncoding for Ed25519Signature {
#[cfg(not(tarpaulin_include))]
fn to_bitstring(&self) -> der::Result<der::asn1::BitString> {
BitString::from_bytes(&self.as_signature().to_bytes())
}
Expand Down Expand Up @@ -182,13 +184,15 @@ impl PublicKey<Ed25519Signature> for Ed25519PublicKey {
// certificate or a CSR. It is named after the `SubjectPublicKeyInfo` type from the X.509
// standard, and thus includes the information needed to encode the public key in a certificate
// or a CSR.
#[cfg(not(tarpaulin_include))]
fn public_key_info(&self) -> PublicKeyInfo {
PublicKeyInfo {
algorithm: Ed25519Signature::algorithm_identifier(),
public_key_bitstring: BitString::from_bytes(&self.key.to_bytes()).unwrap(),
}
}

#[cfg(not(tarpaulin_include))]
fn from_public_key_info(public_key_info: PublicKeyInfo) -> Self {
let mut key_vec = public_key_info.public_key_bitstring.raw_bytes().to_vec();
key_vec.resize(32, 0);
Expand Down
3 changes: 3 additions & 0 deletions examples/ed25519_cert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ impl Signature for Ed25519Signature {
}
}

#[cfg(not(tarpaulin_include))]
fn from_bitstring(signature: &[u8]) -> Self {
let mut signature_vec = signature.to_vec();
signature_vec.resize(64, 0);
Expand Down Expand Up @@ -192,6 +193,7 @@ struct Ed25519PublicKey {
impl PublicKey<Ed25519Signature> for Ed25519PublicKey {
// Verifies a signature. We use the `verify_strict` method from the ed25519-dalek crate.
// This method is used to mitigate weak key forgery.
#[cfg(not(tarpaulin_include))]
fn verify_signature(
&self,
signature: &Ed25519Signature,
Expand All @@ -214,6 +216,7 @@ impl PublicKey<Ed25519Signature> for Ed25519PublicKey {
}
}

#[cfg(not(tarpaulin_include))]
fn from_public_key_info(public_key_info: PublicKeyInfo) -> Self {
let mut key_vec = public_key_info.public_key_bitstring.raw_bytes().to_vec();
key_vec.resize(32, 0);
Expand Down

0 comments on commit cd6e4ca

Please sign in to comment.