Skip to content

Commit

Permalink
fix: apply suggestions from code review (#22)
Browse files Browse the repository at this point in the history
Co-authored-by: Falko Galperin <10247603+falko17@users.noreply.github.com>
  • Loading branch information
pulsastrix and falko17 authored Aug 9, 2024
1 parent f29afed commit 6a6c95a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#![recursion_limit = "512"]

use cfg_aliases::cfg_aliases;

fn main() {
// Set up some aliases for conditional compilation (in order to avoid repetition).
cfg_aliases! {
rustcrypto_encrypt_base: {
any(
Expand Down
9 changes: 4 additions & 5 deletions src/token/cose/crypto_impl/rustcrypto/mac/hmac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::token::cose::crypto_impl::rustcrypto::RustCryptoContext;
use crate::token::cose::{CoseSymmetricKey, CryptoBackend};

impl<RNG: RngCore + CryptoRng> RustCryptoContext<RNG> {
/// Compute the HMAC of `payload` using the given `key` and `payload` with the HMAC function
/// Compute the HMAC of `payload` using the given `key` with the HMAC function
/// `MAC`.
fn compute_hmac_using_mac<MAC: hmac::digest::KeyInit + Update + FixedOutput + MacMarker>(
key: &CoseSymmetricKey<'_, <Self as CryptoBackend>::Error>,
Expand All @@ -23,8 +23,7 @@ impl<RNG: RngCore + CryptoRng> RustCryptoContext<RNG> {
hmac.finalize().into_bytes().to_vec()
}

/// Verify the HMAC of `payload` using the given `key` and `payload` with the HMAC function
/// `MAC`.
/// Verify the HMAC of `payload` using the given `key` with the HMAC function `MAC`.
fn verify_hmac_using_mac<MAC: hmac::digest::KeyInit + Update + FixedOutput + MacMarker>(
key: &CoseSymmetricKey<'_, <Self as CryptoBackend>::Error>,
payload: &[u8],
Expand All @@ -38,7 +37,7 @@ impl<RNG: RngCore + CryptoRng> RustCryptoContext<RNG> {
hmac.verify_slice(tag).map_err(CoseCipherError::from)
}

/// Compute the HMAC of `payload` using the given `key` and `payload` with the HMAC function
/// Compute the HMAC of `payload` using the given `key` with the HMAC function
/// specified in the `algorithm`.
pub(super) fn compute_hmac(
algorithm: iana::Algorithm,
Expand All @@ -61,7 +60,7 @@ impl<RNG: RngCore + CryptoRng> RustCryptoContext<RNG> {
}
}

/// Verify the HMAC `tag` of `payload` using the given `key` and `payload` with the HMAC
/// Verify the HMAC `tag` of `payload` using the given `key` with the HMAC
/// function specified in the `algorithm`.
pub(super) fn verify_hmac(
algorithm: iana::Algorithm,
Expand Down
2 changes: 1 addition & 1 deletion src/token/cose/crypto_impl/rustcrypto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub enum CoseRustCryptoCipherError {
/// Error regarding elliptic curve operations.
#[cfg(feature = "rustcrypto-ecdsa")]
EcError(elliptic_curve::Error),
/// Error in ECDSA operation
/// Error in ECDSA operation.
#[cfg(feature = "rustcrypto-ecdsa")]
EcdsaError(ecdsa::Error),
/// Invalid elliptic curve point.
Expand Down
4 changes: 2 additions & 2 deletions src/token/cose/crypto_impl/rustcrypto/sign/ecdsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ impl<RNG: RngCore + CryptoRng> RustCryptoContext<RNG> {
.map_err(CoseCipherError::from)
} else {
// x must be Some here due to the previous condition.
let pubkey_coord = if key.y.is_some() {
let pubkey_coord = if let Some(y) = key.y {
EncodedPoint::<CRV>::from_affine_coordinates(
key.x.unwrap().into(),
key.y.unwrap().into(),
y.into(),
false,
)
} else {
Expand Down

0 comments on commit 6a6c95a

Please sign in to comment.