Skip to content

Commit

Permalink
Merge pull request parallaxsecond#106 from gowthamsk-arm/fix_clippy_w…
Browse files Browse the repository at this point in the history
…arnings

Fix issues reported by clippy
  • Loading branch information
ionut-arm authored Aug 25, 2022
2 parents bcff414 + 6765de7 commit 73b14b3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion psa-crypto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static INITIALISED: AtomicBool = AtomicBool::new(false);
pub fn init() -> Result<()> {
// It is not a problem to call psa_crypto_init more than once.
Status::from(unsafe { psa_crypto_sys::psa_crypto_init() }).to_result()?;
let _ = INITIALISED.store(true, Ordering::Relaxed);
INITIALISED.store(true, Ordering::Relaxed);

Ok(())
}
Expand Down
26 changes: 13 additions & 13 deletions psa-crypto/src/types/algorithm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use zeroize::Zeroize;
/// Enumeration of possible algorithm definitions.
/// Each variant of the enum contains a main algorithm type (which is required for
/// that variant).
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Zeroize)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Zeroize)]
pub enum Algorithm {
/// An invalid algorithm identifier value.
/// `None` does not allow any cryptographic operation with the key. The key can still be
Expand Down Expand Up @@ -63,7 +63,7 @@ impl Algorithm {
}

/// Enumeration of hash algorithms supported.
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Zeroize)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Zeroize)]
#[allow(deprecated)]
pub enum Hash {
/// MD2
Expand Down Expand Up @@ -125,7 +125,7 @@ impl Hash {
}

/// Enumeration of untruncated MAC algorithms.
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Zeroize)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Zeroize)]
pub enum FullLengthMac {
/// HMAC algorithm
Hmac {
Expand All @@ -139,7 +139,7 @@ pub enum FullLengthMac {
}

/// Enumeration of message authentication code algorithms supported.
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Zeroize)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Zeroize)]
pub enum Mac {
/// Untruncated MAC algorithm
FullLength(FullLengthMac),
Expand Down Expand Up @@ -184,7 +184,7 @@ impl Mac {
}

/// Enumeration of symmetric encryption algorithms supported.
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Zeroize)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Zeroize)]
pub enum Cipher {
/// The stream cipher mode of a stream cipher algorithm.
StreamCipher,
Expand Down Expand Up @@ -220,7 +220,7 @@ impl Cipher {
}
}

#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Zeroize)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Zeroize)]
/// AEAD algorithm with default length tag enumeration
pub enum AeadWithDefaultLengthTag {
/// The CCM authenticated encryption algorithm.
Expand All @@ -233,7 +233,7 @@ pub enum AeadWithDefaultLengthTag {

/// Enumeration of authenticated encryption with additional data algorithms
/// supported.
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Zeroize)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Zeroize)]
pub enum Aead {
/// AEAD algorithm with a default length tag
AeadWithDefaultLengthTag(AeadWithDefaultLengthTag),
Expand Down Expand Up @@ -278,7 +278,7 @@ impl Aead {
}

/// Enumeration of hash algorithms used in "hash-and-sign" algorithms.
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Zeroize)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Zeroize)]
pub enum SignHash {
/// A specific hash algorithm to choose.
Specific(Hash),
Expand Down Expand Up @@ -312,7 +312,7 @@ impl From<Hash> for SignHash {
}

/// Enumeration of asymmetric signing algorithms supported.
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Zeroize)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Zeroize)]
pub enum AsymmetricSignature {
/// RSA PKCS#1 v1.5 signature with hashing.
RsaPkcs1v15Sign {
Expand Down Expand Up @@ -454,7 +454,7 @@ impl AsymmetricSignature {
}

/// Enumeration of asymmetric encryption algorithms supported.
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Zeroize)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Zeroize)]
pub enum AsymmetricEncryption {
/// RSA PKCS#1 v1.5 encryption.
RsaPkcs1v15Crypt,
Expand All @@ -466,7 +466,7 @@ pub enum AsymmetricEncryption {
}

/// Key agreement algorithm enumeration.
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Zeroize)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Zeroize)]
pub enum RawKeyAgreement {
/// The finite-field Diffie-Hellman (DH) key agreement algorithm.
Ffdh,
Expand All @@ -475,7 +475,7 @@ pub enum RawKeyAgreement {
}

/// Enumeration of key agreement algorithms supported.
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Zeroize)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Zeroize)]
pub enum KeyAgreement {
/// Key agreement only algorithm.
Raw(RawKeyAgreement),
Expand All @@ -489,7 +489,7 @@ pub enum KeyAgreement {
}

/// Enumeration of key derivation functions supported.
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Zeroize)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Zeroize)]
pub enum KeyDerivation {
/// HKDF algorithm.
Hkdf {
Expand Down
16 changes: 8 additions & 8 deletions psa-crypto/src/types/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use zeroize::Zeroize;

/// Native definition of the attributes needed to fully describe
/// a cryptographic key.
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Zeroize)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Zeroize)]
pub struct Attributes {
/// Lifetime of the key
pub lifetime: Lifetime,
Expand Down Expand Up @@ -491,7 +491,7 @@ impl Attributes {

/// The lifetime of a key indicates where it is stored and which application and system actions
/// will create and destroy it.
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Zeroize)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Zeroize)]
pub enum Lifetime {
/// A volatile key only exists as long as the identifier to it is not destroyed.
Volatile,
Expand All @@ -504,7 +504,7 @@ pub enum Lifetime {
}

/// Enumeration of key types supported.
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Zeroize)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Zeroize)]
pub enum Type {
/// Not a valid key type for any cryptographic operation but can be used to store arbitrary
/// data in the key store.
Expand Down Expand Up @@ -640,7 +640,7 @@ impl Type {
/// Enumeration of elliptic curve families supported. They are needed to create an ECC key.
/// The specific curve used for each family is given by the `bits` field of the key attributes.
/// See the book for more details.
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Zeroize)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Zeroize)]
pub enum EccFamily {
/// SEC Koblitz curves over prime fields.
/// This family comprises the following curves:
Expand Down Expand Up @@ -721,7 +721,7 @@ impl fmt::Display for EccFamily {
}

/// Enumeration of Diffie Hellman group families supported.
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Zeroize)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Zeroize)]
pub enum DhFamily {
/// Diffie-Hellman groups defined in RFC 7919 Appendix A.
/// This family includes groups with the following `bits`: 2048, 3072, 4096, 6144, 8192.
Expand All @@ -738,7 +738,7 @@ impl fmt::Display for DhFamily {
}

/// Definition of the key policy, what is permitted to do with the key.
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Zeroize)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Zeroize)]
pub struct Policy {
/// Usage flags for the key.
pub usage_flags: UsageFlags,
Expand All @@ -747,7 +747,7 @@ pub struct Policy {
}

/// Definition of the usage flags. They encode what kind of operations are permitted on the key.
#[derive(Copy, Clone, Debug, Default, PartialEq, Serialize, Deserialize, Zeroize)]
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Zeroize)]
pub struct UsageFlags {
/// Permission to export the key.
export: bool,
Expand Down Expand Up @@ -867,7 +867,7 @@ impl UsageFlags {
}

/// Definition of the key ID.
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Zeroize)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Zeroize)]
pub struct Id(pub(crate) psa_key_id_t);

impl Id {
Expand Down
4 changes: 2 additions & 2 deletions psa-crypto/src/types/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::fmt;
pub type Result<T> = core::result::Result<T, Error>;

/// Definition of a PSA status code
#[derive(Clone, Copy, Debug, PartialEq, Zeroize)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Zeroize)]
pub enum Status {
/// Status code for success
Success,
Expand Down Expand Up @@ -46,7 +46,7 @@ impl Status {
}

/// Definition of a PSA status code
#[derive(Clone, Copy, Debug, PartialEq, Zeroize)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Zeroize)]
pub enum Error {
/// An error occurred that does not correspond to any defined failure cause
GenericError,
Expand Down

0 comments on commit 73b14b3

Please sign in to comment.