Skip to content

Commit b50ec1d

Browse files
committed
Resolved the build errors and compailance issue
Signed-off-by: Aasim Shaik <[email protected]>
1 parent 3ad3252 commit b50ec1d

File tree

4 files changed

+25
-29
lines changed

4 files changed

+25
-29
lines changed

tests/crypto/psa_crypto/src/aead.c

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,15 @@ 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, sizeof(expect_cipher_tag_buf));
75-
74+
zassert_mem_equal(cipher_tag_buf, expect_cipher_tag_buf,
75+
sizeof(expect_cipher_tag_buf));
7676
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");
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");
8080

8181
zassert_equal(out_len, sizeof(aes_plaintext));
8282
zassert_mem_equal(decrypted, aes_plaintext, sizeof(aes_plaintext));
83-
8483
zassert_equal(psa_destroy_key(key_id), PSA_SUCCESS, "Failed to destroy key");
8584
}
8685

@@ -103,21 +102,21 @@ ZTEST(psa_crypto_test, test_aead_aes_gcm)
103102
psa_set_key_algorithm(&attributes, alg);
104103

105104
zassert_equal(psa_import_key(&attributes, aes_key_buf, sizeof(aes_key_buf), &key_id),
106-
PSA_SUCCESS, "Failed to import key");
105+
PSA_SUCCESS, "Failed to import key");
107106

108107
zassert_equal(psa_aead_encrypt(key_id, alg, aes_nonce_buf, sizeof(aes_nonce_buf),
109-
aes_ad_buf, sizeof(aes_ad_buf), aes_plaintext,
110-
sizeof(aes_plaintext), cipher_tag_buf,
111-
sizeof(cipher_tag_buf), &out_len),
112-
PSA_SUCCESS, "Failed to encrypt");
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");
113112

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

117116
zassert_equal(psa_aead_decrypt(key_id, alg, aes_nonce_buf, sizeof(aes_nonce_buf),
118-
aes_ad_buf, sizeof(aes_ad_buf), cipher_tag_buf, out_len,
119-
decrypted, sizeof(decrypted), &out_len),
120-
PSA_SUCCESS, "Failed to decrypt");
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");
121120

122121
zassert_equal(out_len, sizeof(aes_plaintext));
123122
zassert_mem_equal(decrypted, aes_plaintext, sizeof(aes_plaintext));
@@ -130,7 +129,6 @@ ZTEST(psa_crypto_test, test_aead_chacha20_poly1305)
130129
uint8_t cipher_tag_buf[130]; /* Ciphertext + Tag */
131130
uint8_t decrypted[sizeof(chachapoly_plaintext)] = {0};
132131
size_t out_len;
133-
134132
psa_key_id_t key_id;
135133
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
136134
psa_algorithm_t alg = PSA_ALG_CHACHA20_POLY1305;
@@ -162,6 +160,5 @@ ZTEST(psa_crypto_test, test_aead_chacha20_poly1305)
162160

163161
zassert_equal(out_len, sizeof(chachapoly_plaintext));
164162
zassert_mem_equal(decrypted, chachapoly_plaintext, sizeof(chachapoly_plaintext));
165-
166163
zassert_equal(psa_destroy_key(key_id), PSA_SUCCESS, "Failed to destroy key");
167164
}

tests/crypto/psa_crypto/src/cipher.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ ZTEST(psa_crypto_test, test_cipher_aes_cbc_256_multipart)
5050
PSA_SUCCESS, "Failed to import key");
5151
#endif
5252
psa_reset_key_attributes(&attributes);
53-
5453
zassert_equal(psa_cipher_encrypt_setup(&operation, key_id, alg), PSA_SUCCESS,
5554
"Failed to begin encrypt operation");
5655
zassert_equal(psa_cipher_generate_iv(&operation, iv, sizeof(iv), &iv_len), PSA_SUCCESS,

tests/crypto/psa_crypto/src/key_agreement.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ static const uint8_t server_public_key[] = {
2727
0x8D, 0x49, 0x85, 0x8C, 0x7A, 0x9F, 0xC1, 0x46, 0xDA, 0xCC, 0x96,
2828
0xEF, 0x6E, 0xD4, 0xDA, 0x71, 0xBF, 0xED, 0x32, 0x0D, 0x76,
2929
};
30+
#if defined(CONFIG_TEST_WRAPPED_KEYS)
3031
static const uint8_t expected_shared_secret[] = {
3132
0xF2, 0xE6, 0x0E, 0x1C, 0xB7, 0x64, 0xBC, 0x48, 0xF2, 0x9D, 0xBB,
3233
0x12, 0xFB, 0x12, 0x17, 0x31, 0x32, 0x1D, 0x79, 0xAF, 0x0A, 0x9F,
3334
0xAB, 0xAD, 0x34, 0x05, 0xA2, 0x07, 0x39, 0x9C, 0x5F, 0x15,
3435
};
35-
36+
#endif
3637
ZTEST(psa_crypto_test, test_key_agreement_ecdh_25519)
3738
{
3839
uint8_t shared_secret_buf[32];
@@ -49,14 +50,14 @@ ZTEST(psa_crypto_test, test_key_agreement_ecdh_25519)
4950
PSA_KEY_PERSISTENCE_VOLATILE, 0));
5051
#endif
5152
zassert_equal(psa_import_key(&attributes, client_private_key, sizeof(client_private_key),
52-
&key_id),
53-
PSA_SUCCESS, "Failed to import client key");
53+
&key_id),
54+
PSA_SUCCESS, "Failed to import client key");
5455

5556
/* Perform key agreement with server public key */
5657
zassert_equal(psa_raw_key_agreement(PSA_ALG_ECDH, key_id, server_public_key,
5758
sizeof(server_public_key), shared_secret_buf,
5859
sizeof(shared_secret_buf), &shared_secret_len),
59-
PSA_SUCCESS, "Failed to perform key agreement with server");
60+
PSA_SUCCESS, "Failed to perform key agreement with server");
6061

6162
zassert_equal(psa_destroy_key(key_id), PSA_SUCCESS, "Failed to destroy client key");
6263

@@ -70,7 +71,7 @@ ZTEST(psa_crypto_test, test_key_agreement_ecdh_25519)
7071
PSA_KEY_PERSISTENCE_VOLATILE, 0));
7172
#endif
7273
zassert_equal(psa_import_key(&attributes, server_private_key, sizeof(server_private_key),
73-
&key_id),
74+
&key_id),
7475
PSA_SUCCESS, "Failed to import server key");
7576

7677
/* Perform key agreement with client public key */
@@ -80,7 +81,6 @@ ZTEST(psa_crypto_test, test_key_agreement_ecdh_25519)
8081
PSA_SUCCESS, "Failed to perform key agreement with client");
8182

8283
zassert_equal(psa_destroy_key(key_id), PSA_SUCCESS, "Failed to destroy server key");
83-
8484
#if defined(CONFIG_TEST_WRAPPED_KEYS)
8585
/* Verify shared secret */
8686
zassert_mem_equal(shared_secret_buf, expected_shared_secret, sizeof(expected_shared_secret),

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)