Skip to content

Commit 2fb07ad

Browse files
committed
Fixing compliance and clang formating errors
Signed-off-by: Aasim Shaik <[email protected]>
1 parent b50ec1d commit 2fb07ad

File tree

4 files changed

+61
-62
lines changed

4 files changed

+61
-62
lines changed

tests/crypto/psa_crypto/src/aead.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,11 @@ ZTEST(psa_crypto_test, test_aead_aes_ccm)
7171
PSA_SUCCESS, "Failed to encrypt");
7272

7373
zassert_equal(out_len, sizeof(expect_cipher_tag_buf));
74-
zassert_mem_equal(cipher_tag_buf, expect_cipher_tag_buf,
75-
sizeof(expect_cipher_tag_buf));
74+
zassert_mem_equal(cipher_tag_buf, expect_cipher_tag_buf, sizeof(expect_cipher_tag_buf));
7675
zassert_equal(psa_aead_decrypt(key_id, alg, aes_nonce_buf, sizeof(aes_nonce_buf),
77-
aes_ad_buf, sizeof(aes_ad_buf), cipher_tag_buf, out_len,
78-
decrypted, sizeof(decrypted), &out_len),
79-
PSA_SUCCESS, "Failed to decrypt");
76+
aes_ad_buf, sizeof(aes_ad_buf), cipher_tag_buf, out_len,
77+
decrypted, sizeof(decrypted), &out_len),
78+
PSA_SUCCESS, "Failed to decrypt");
8079

8180
zassert_equal(out_len, sizeof(aes_plaintext));
8281
zassert_mem_equal(decrypted, aes_plaintext, sizeof(aes_plaintext));
@@ -102,21 +101,21 @@ ZTEST(psa_crypto_test, test_aead_aes_gcm)
102101
psa_set_key_algorithm(&attributes, alg);
103102

104103
zassert_equal(psa_import_key(&attributes, aes_key_buf, sizeof(aes_key_buf), &key_id),
105-
PSA_SUCCESS, "Failed to import key");
104+
PSA_SUCCESS, "Failed to import key");
106105

107106
zassert_equal(psa_aead_encrypt(key_id, alg, aes_nonce_buf, sizeof(aes_nonce_buf),
108-
aes_ad_buf, sizeof(aes_ad_buf), aes_plaintext,
109-
sizeof(aes_plaintext), cipher_tag_buf,
110-
sizeof(cipher_tag_buf), &out_len),
111-
PSA_SUCCESS, "Failed to encrypt");
107+
aes_ad_buf, sizeof(aes_ad_buf), aes_plaintext,
108+
sizeof(aes_plaintext), cipher_tag_buf,
109+
sizeof(cipher_tag_buf), &out_len),
110+
PSA_SUCCESS, "Failed to encrypt");
112111

113112
zassert_equal(out_len, sizeof(expect_cipher_tag_buf));
114113
zassert_mem_equal(cipher_tag_buf, expect_cipher_tag_buf, sizeof(expect_cipher_tag_buf));
115114

116115
zassert_equal(psa_aead_decrypt(key_id, alg, aes_nonce_buf, sizeof(aes_nonce_buf),
117-
aes_ad_buf, sizeof(aes_ad_buf), cipher_tag_buf, out_len,
118-
decrypted, sizeof(decrypted), &out_len),
119-
PSA_SUCCESS, "Failed to decrypt");
116+
aes_ad_buf, sizeof(aes_ad_buf), cipher_tag_buf, out_len,
117+
decrypted, sizeof(decrypted), &out_len),
118+
PSA_SUCCESS, "Failed to decrypt");
120119

121120
zassert_equal(out_len, sizeof(aes_plaintext));
122121
zassert_mem_equal(decrypted, aes_plaintext, sizeof(aes_plaintext));

tests/crypto/psa_crypto/src/cipher.c

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ ZTEST(psa_crypto_test, test_cipher_aes_cbc_256_multipart)
4040
psa_set_key_algorithm(&attributes, alg);
4141
psa_set_key_type(&attributes, PSA_KEY_TYPE_AES);
4242
psa_set_key_bits(&attributes, 256);
43-
#if defined(CONFIG_TEST_WRAPPED_KEYS)
44-
psa_set_key_lifetime(&attributes, PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(
45-
PSA_KEY_PERSISTENCE_VOLATILE, 0));
46-
zassert_equal(psa_generate_key(&attributes, &key_id), PSA_SUCCESS,
47-
"Failed to generate key");
48-
#else
49-
zassert_equal(psa_import_key(&attributes, key_256, sizeof(key_256), &key_id),
50-
PSA_SUCCESS, "Failed to import key");
51-
#endif
43+
#if defined(CONFIG_TEST_WRAPPED_KEYS)
44+
psa_set_key_lifetime(&attributes, PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(
45+
PSA_KEY_PERSISTENCE_VOLATILE, 0));
46+
zassert_equal(psa_generate_key(&attributes, &key_id), PSA_SUCCESS,
47+
"Failed to generate key");
48+
#else
49+
zassert_equal(psa_import_key(&attributes, key_256, sizeof(key_256), &key_id), PSA_SUCCESS,
50+
"Failed to import key");
51+
#endif
5252
psa_reset_key_attributes(&attributes);
5353
zassert_equal(psa_cipher_encrypt_setup(&operation, key_id, alg), PSA_SUCCESS,
5454
"Failed to begin encrypt operation");
@@ -95,15 +95,15 @@ ZTEST(psa_crypto_test, test_cipher_aes_cbc_256_single)
9595
psa_set_key_algorithm(&attributes, alg);
9696
psa_set_key_type(&attributes, PSA_KEY_TYPE_AES);
9797
psa_set_key_bits(&attributes, 256);
98-
#if defined(CONFIG_TEST_WRAPPED_KEYS)
99-
psa_set_key_lifetime(&attributes, PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(
100-
PSA_KEY_PERSISTENCE_VOLATILE, 1));
101-
zassert_equal(psa_generate_key(&attributes, &key_id), PSA_SUCCESS,
102-
"Failed to generate key");
103-
#else
104-
zassert_equal(psa_import_key(&attributes, key_256, sizeof(key_256), &key_id),
105-
PSA_SUCCESS, "Failed to import key");
106-
#endif
98+
#if defined(CONFIG_TEST_WRAPPED_KEYS)
99+
psa_set_key_lifetime(&attributes, PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(
100+
PSA_KEY_PERSISTENCE_VOLATILE, 1));
101+
zassert_equal(psa_generate_key(&attributes, &key_id), PSA_SUCCESS,
102+
"Failed to generate key");
103+
#else
104+
zassert_equal(psa_import_key(&attributes, key_256, sizeof(key_256), &key_id), PSA_SUCCESS,
105+
"Failed to import key");
106+
#endif
107107
psa_reset_key_attributes(&attributes);
108108

109109
zassert_equal(psa_cipher_encrypt(key_id, alg, plaintext, sizeof(plaintext),
@@ -133,16 +133,16 @@ ZTEST(psa_crypto_test, test_cipher_aes_ecb_128_single)
133133
psa_set_key_algorithm(&attributes, alg);
134134
psa_set_key_type(&attributes, PSA_KEY_TYPE_AES);
135135
psa_set_key_bits(&attributes, 128);
136-
#if defined(CONFIG_TEST_WRAPPED_KEYS)
137-
psa_set_key_lifetime(&attributes, PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(
138-
PSA_KEY_PERSISTENCE_VOLATILE, 1));
139-
140-
zassert_equal(psa_generate_key(&attributes, &key_id), PSA_SUCCESS,
141-
"Failed to generate key");
142-
#else
143-
zassert_equal(psa_import_key(&attributes, key_128, sizeof(key_128), &key_id),
144-
PSA_SUCCESS, "Failed to import key");
145-
#endif
136+
#if defined(CONFIG_TEST_WRAPPED_KEYS)
137+
psa_set_key_lifetime(&attributes, PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(
138+
PSA_KEY_PERSISTENCE_VOLATILE, 1));
139+
140+
zassert_equal(psa_generate_key(&attributes, &key_id), PSA_SUCCESS,
141+
"Failed to generate key");
142+
#else
143+
zassert_equal(psa_import_key(&attributes, key_128, sizeof(key_128), &key_id), PSA_SUCCESS,
144+
"Failed to import key");
145+
#endif
146146
psa_reset_key_attributes(&attributes);
147147

148148
zassert_equal(psa_cipher_encrypt(key_id, alg, plaintext, sizeof(plaintext), ciphertext,
@@ -188,4 +188,4 @@ ZTEST(psa_crypto_test, test_cipher_chacha20_single)
188188
PSA_SUCCESS, "Failed to decrypt");
189189

190190
zassert_mem_equal(decrypted, plaintext, sizeof(plaintext));
191-
}
191+
}

tests/crypto/psa_crypto/src/key_agreement.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,19 @@ ZTEST(psa_crypto_test, test_key_agreement_ecdh_25519)
4545
psa_set_key_type(&attributes, PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY));
4646
psa_set_key_usage_flags(&attributes, PSA_KEY_USAGE_DERIVE);
4747
psa_set_key_algorithm(&attributes, PSA_ALG_ECDH);
48-
#if defined(CONFIG_TEST_WRAPPED_KEYS)
49-
psa_set_key_lifetime(&attributes, PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(
50-
PSA_KEY_PERSISTENCE_VOLATILE, 0));
51-
#endif
48+
#if defined(CONFIG_TEST_WRAPPED_KEYS)
49+
psa_set_key_lifetime(&attributes, PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(
50+
PSA_KEY_PERSISTENCE_VOLATILE, 0));
51+
#endif
5252
zassert_equal(psa_import_key(&attributes, client_private_key, sizeof(client_private_key),
53-
&key_id),
54-
PSA_SUCCESS, "Failed to import client key");
53+
&key_id),
54+
PSA_SUCCESS, "Failed to import client key");
5555

5656
/* Perform key agreement with server public key */
5757
zassert_equal(psa_raw_key_agreement(PSA_ALG_ECDH, key_id, server_public_key,
5858
sizeof(server_public_key), shared_secret_buf,
5959
sizeof(shared_secret_buf), &shared_secret_len),
60-
PSA_SUCCESS, "Failed to perform key agreement with server");
60+
PSA_SUCCESS, "Failed to perform key agreement with server");
6161

6262
zassert_equal(psa_destroy_key(key_id), PSA_SUCCESS, "Failed to destroy client key");
6363

@@ -66,12 +66,12 @@ ZTEST(psa_crypto_test, test_key_agreement_ecdh_25519)
6666
psa_set_key_type(&attributes, PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY));
6767
psa_set_key_usage_flags(&attributes, PSA_KEY_USAGE_DERIVE);
6868
psa_set_key_algorithm(&attributes, PSA_ALG_ECDH);
69-
#if defined(CONFIG_TEST_WRAPPED_KEYS)
70-
psa_set_key_lifetime(&attributes, PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(
71-
PSA_KEY_PERSISTENCE_VOLATILE, 0));
72-
#endif
69+
#if defined(CONFIG_TEST_WRAPPED_KEYS)
70+
psa_set_key_lifetime(&attributes, PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION(
71+
PSA_KEY_PERSISTENCE_VOLATILE, 0));
72+
#endif
7373
zassert_equal(psa_import_key(&attributes, server_private_key, sizeof(server_private_key),
74-
&key_id),
74+
&key_id),
7575
PSA_SUCCESS, "Failed to import server key");
7676

7777
/* Perform key agreement with client public key */
@@ -81,9 +81,9 @@ ZTEST(psa_crypto_test, test_key_agreement_ecdh_25519)
8181
PSA_SUCCESS, "Failed to perform key agreement with client");
8282

8383
zassert_equal(psa_destroy_key(key_id), PSA_SUCCESS, "Failed to destroy server key");
84-
#if defined(CONFIG_TEST_WRAPPED_KEYS)
84+
#if defined(CONFIG_TEST_WRAPPED_KEYS)
8585
/* Verify shared secret */
8686
zassert_mem_equal(shared_secret_buf, expected_shared_secret, sizeof(expected_shared_secret),
8787
"Key agreement did not resolve the correct shared secret");
88-
#endif
88+
#endif
8989
}

tests/crypto/psa_crypto/src/sign.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ ZTEST(psa_crypto_test, test_sign_ecdsa_secp256r1)
2828
PSA_KEY_USAGE_SIGN_MESSAGE | PSA_KEY_USAGE_VERIFY_MESSAGE);
2929
psa_set_key_algorithm(&attributes, PSA_ALG_ECDSA(PSA_ALG_ANY_HASH));
3030
zassert_equal(psa_generate_key(&attributes, &key_id), PSA_SUCCESS,
31-
"Failed to generate private key");
31+
"Failed to generate private key");
3232

3333
zassert_equal(psa_sign_message(key_id, PSA_ALG_ECDSA(PSA_ALG_SHA_256), plaintext,
34-
MESSAGE_SIZE, signature, sizeof(signature), &signature_len),
35-
PSA_SUCCESS, "Failed to hash-and-sign message");
34+
MESSAGE_SIZE, signature, sizeof(signature), &signature_len),
35+
PSA_SUCCESS, "Failed to hash-and-sign message");
3636
zassert_equal(psa_export_public_key(key_id, pubkey, sizeof(pubkey), &pubkey_len),
37-
PSA_SUCCESS, "Failed to export public key");
37+
PSA_SUCCESS, "Failed to export public key");
3838
zassert_equal(psa_destroy_key(key_id), PSA_SUCCESS, "Failed to destroy private key");
3939

4040
/* Set up attributes for a public key (secp256r1) */
@@ -46,6 +46,6 @@ ZTEST(psa_crypto_test, test_sign_ecdsa_secp256r1)
4646
zassert_equal(psa_import_key(&attributes, pubkey, sizeof(pubkey), &key_id), PSA_SUCCESS,
4747
"Failed to import public key");
4848
zassert_equal(psa_verify_message(key_id, PSA_ALG_ECDSA(PSA_ALG_SHA_256), plaintext,
49-
MESSAGE_SIZE, signature, signature_len),
50-
PSA_SUCCESS, "Failed to verify signature");
49+
MESSAGE_SIZE, signature, signature_len),
50+
PSA_SUCCESS, "Failed to verify signature");
5151
}

0 commit comments

Comments
 (0)