Skip to content

Commit

Permalink
Use arrays instead of vec! when possible
Browse files Browse the repository at this point in the history
Please see https://rust-lang.github.io/rust-clippy/master/index.html#/useless_vec
for more information.

Signed-off-by: Tomás González <tomasagustin.gonzalezorlando@arm.com>
  • Loading branch information
tgonzalezorlandoarm committed Sep 1, 2023
1 parent 339bfc8 commit add70ca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
20 changes: 10 additions & 10 deletions e2e_tests/tests/per_provider/normal_tests/capability_discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn rsa_encrypt_use_check() {
return;
}

let all_algs = vec![
let all_algs = [
AsymmetricEncryption::RsaPkcs1v15Crypt {},
AsymmetricEncryption::RsaOaep {
hash_alg: Hash::Sha256,
Expand All @@ -63,15 +63,15 @@ fn rsa_encrypt_use_check() {
feature = "mbed-crypto-provider",
feature = "trusted-service-provider",
))]
let supported_algs = vec![
let supported_algs = [
AsymmetricEncryption::RsaPkcs1v15Crypt {},
AsymmetricEncryption::RsaOaep {
hash_alg: Hash::Sha256,
},
];

#[cfg(feature = "cryptoauthlib-provider")]
let supported_algs = vec![];
let supported_algs = [];

let mut attributes = get_default_rsa_attrs();
let _ = attributes.policy.usage_flags.set_encrypt();
Expand Down Expand Up @@ -118,7 +118,7 @@ fn ecc_curve_use_check() {
];

#[cfg(any(feature = "mbed-crypto-provider", feature = "trusted-service-provider",))]
let supported_curves = vec![
let supported_curves = [
(EccFamily::SecpR1, 256),
(EccFamily::SecpK1, 256),
(EccFamily::SectK1, 409),
Expand All @@ -135,7 +135,7 @@ fn ecc_curve_use_check() {
feature = "pkcs11-provider",
feature = "cryptoauthlib-provider"
))]
let supported_curves = vec![(EccFamily::SecpR1, 256)];
let supported_curves = [(EccFamily::SecpR1, 256)];

let mut attributes = get_default_ecc_attrs();
let _ = attributes.policy.usage_flags.set_sign_hash();
Expand Down Expand Up @@ -168,7 +168,7 @@ fn hash_use_check() {
return;
}

let all_hashes = vec![
let all_hashes = [
Hash::Ripemd160,
Hash::Sha224,
Hash::Sha256,
Expand All @@ -183,7 +183,7 @@ fn hash_use_check() {
];

#[cfg(any(feature = "mbed-crypto-provider", feature = "trusted-service-provider",))]
let supported_hashes = vec![
let supported_hashes = [
Hash::Ripemd160,
Hash::Sha224,
Hash::Sha256,
Expand All @@ -198,7 +198,7 @@ fn hash_use_check() {
];

#[cfg(feature = "tpm-provider")]
let supported_hashes = vec![
let supported_hashes = [
Hash::Sha256,
Hash::Sha384,
Hash::Sha512,
Expand All @@ -207,10 +207,10 @@ fn hash_use_check() {
Hash::Sha3_512,
];
#[cfg(feature = "pkcs11-provider")]
let supported_hashes = vec![Hash::Sha224, Hash::Sha256, Hash::Sha384, Hash::Sha512];
let supported_hashes = [Hash::Sha224, Hash::Sha256, Hash::Sha384, Hash::Sha512];

#[cfg(feature = "cryptoauthlib-provider")]
let supported_hashes = vec![Hash::Sha256];
let supported_hashes = [Hash::Sha256];

let mut attributes = get_default_rsa_attrs();
let _ = attributes.policy.usage_flags.set_sign_hash();
Expand Down
8 changes: 4 additions & 4 deletions e2e_tests/tests/per_provider/normal_tests/cipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ fn cipher_encrypt_ecb_invalid_data_size() {
.import_aes_key_cipher(key_name.clone(), KEY_DATA.to_vec(), Cipher::EcbNoPadding)
.unwrap();

let invalid_plaintext = vec![0u8; INVALID_DATA_SIZE];
let invalid_plaintext = [0u8; INVALID_DATA_SIZE];

assert_eq!(
client
Expand Down Expand Up @@ -411,7 +411,7 @@ fn cipher_encrypt_cbc_invalid_data_size() {
.import_aes_key_cipher(key_name.clone(), KEY_DATA.to_vec(), Cipher::CbcNoPadding)
.unwrap();

let invalid_plaintext = vec![0u8; INVALID_DATA_SIZE];
let invalid_plaintext = [0u8; INVALID_DATA_SIZE];

assert_eq!(
client
Expand Down Expand Up @@ -543,7 +543,7 @@ fn cipher_encrypt_empty_data() {
return;
}

let empty_plaintext = vec![];
let empty_plaintext = [];

client
.import_aes_key_cipher(key_name.clone(), KEY_DATA.to_vec(), Cipher::Cfb)
Expand All @@ -568,7 +568,7 @@ fn cipher_decrypt_empty_data() {
return;
}

let empty_ciphertext = vec![];
let empty_ciphertext = [];

client
.import_aes_key_cipher(key_name.clone(), KEY_DATA.to_vec(), Cipher::Cfb)
Expand Down

0 comments on commit add70ca

Please sign in to comment.