Formatting changes
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
diff --git a/tinycrypt/ecc_dh.c b/tinycrypt/ecc_dh.c
index 08805eb..197a61a 100644
--- a/tinycrypt/ecc_dh.c
+++ b/tinycrypt/ecc_dh.c
@@ -12,10 +12,10 @@
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
+ * this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -36,16 +36,16 @@
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
*
- * - Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
*
- * - Neither the name of Intel Corporation nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
+ * - Neither the name of Intel Corporation nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -91,14 +91,14 @@
/* Converting buffers to correct bit order: */
uECC_vli_nativeToBytes(private_key,
- BITS_TO_BYTES(NUM_ECC_BITS),
- _private);
+ BITS_TO_BYTES(NUM_ECC_BITS),
+ _private);
uECC_vli_nativeToBytes(public_key,
- NUM_ECC_BYTES,
- _public);
+ NUM_ECC_BYTES,
+ _public);
uECC_vli_nativeToBytes(public_key + NUM_ECC_BYTES,
- NUM_ECC_BYTES,
- _public + NUM_ECC_WORDS);
+ NUM_ECC_BYTES,
+ _public + NUM_ECC_WORDS);
exit:
/* erasing temporary buffer used to store secret: */
@@ -122,7 +122,7 @@
uECC_RNG_Function rng_function = uECC_get_rng();
if (!rng_function ||
rng_function((uint8_t *)_random, 2 * NUM_ECC_WORDS*uECC_WORD_SIZE) != 2 * NUM_ECC_WORDS*uECC_WORD_SIZE) {
- return UECC_FAILURE;
+ return UECC_FAILURE;
}
/* computing modular reduction of _random (see FIPS 186.4 B.4.1): */
@@ -138,30 +138,29 @@
/* Converting buffers to correct bit order: */
uECC_vli_nativeToBytes(private_key,
- BITS_TO_BYTES(NUM_ECC_BITS),
- _private);
+ BITS_TO_BYTES(NUM_ECC_BITS),
+ _private);
uECC_vli_nativeToBytes(public_key,
- NUM_ECC_BYTES,
- _public);
+ NUM_ECC_BYTES,
+ _public);
uECC_vli_nativeToBytes(public_key + NUM_ECC_BYTES,
- NUM_ECC_BYTES,
- _public + NUM_ECC_WORDS);
+ NUM_ECC_BYTES,
+ _public + NUM_ECC_WORDS);
/* erasing temporary buffer that stored secret: */
mbedtls_platform_memset(_private, 0, NUM_ECC_BYTES);
- if(private_key == private_key_dup &&
- public_key == public_key_dup){
- return UECC_SUCCESS;
+ if (private_key == private_key_dup && public_key == public_key_dup) {
+ return UECC_SUCCESS;
}
return UECC_FAULT_DETECTED;
- }
+ }
}
return UECC_FAILURE;
}
int uECC_shared_secret(const uint8_t *public_key, const uint8_t *private_key,
- uint8_t *secret)
+ uint8_t *secret)
{
uECC_word_t _public[NUM_ECC_WORDS * 2];
@@ -173,27 +172,25 @@
volatile const uint8_t *private_key_dup = private_key;
volatile const uint8_t *secret_dup = secret;
-
/* Converting buffers to correct bit order: */
uECC_vli_bytesToNative(_private,
- private_key,
- BITS_TO_BYTES(NUM_ECC_BITS));
+ private_key,
+ BITS_TO_BYTES(NUM_ECC_BITS));
uECC_vli_bytesToNative(_public,
- public_key,
- num_bytes);
+ public_key,
+ num_bytes);
uECC_vli_bytesToNative(_public + num_words,
- public_key + num_bytes,
- num_bytes);
+ public_key + num_bytes,
+ num_bytes);
r = EccPoint_mult_safer(_public, _public, _private);
uECC_vli_nativeToBytes(secret, num_bytes, _public);
/* erasing temporary buffer used to store secret: */
mbedtls_platform_zeroize(_private, sizeof(_private));
- if(public_key_dup != public_key || private_key_dup != private_key ||
- secret_dup != secret){
- return UECC_FAULT_DETECTED;
- }
+ if (public_key_dup != public_key || private_key_dup != private_key || secret_dup != secret) {
+ return UECC_FAULT_DETECTED;
+ }
return r;
}