mirror of
https://github.com/kmackay/micro-ecc.git
synced 2026-10-05 07:17:36 +00:00
Fix code formatting and document the fact that input arrays must be word
aligned
This commit is contained in:
@@ -161,10 +161,10 @@ static void bcopy(uint8_t *dst,
|
|||||||
const uint8_t *src,
|
const uint8_t *src,
|
||||||
unsigned num_bytes)
|
unsigned num_bytes)
|
||||||
{
|
{
|
||||||
while (0 != num_bytes) {
|
while (0 != num_bytes) {
|
||||||
num_bytes--;
|
num_bytes--;
|
||||||
dst[num_bytes] = src[num_bytes];
|
dst[num_bytes] = src[num_bytes];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static cmpresult_t uECC_vli_cmp_unsafe(const uECC_word_t *left,
|
static cmpresult_t uECC_vli_cmp_unsafe(const uECC_word_t *left,
|
||||||
@@ -996,8 +996,8 @@ int uECC_make_key(uint8_t *public_key,
|
|||||||
uint8_t *private_key,
|
uint8_t *private_key,
|
||||||
uECC_Curve curve) {
|
uECC_Curve curve) {
|
||||||
#if uECC_VLI_NATIVE_LITTLE_ENDIAN
|
#if uECC_VLI_NATIVE_LITTLE_ENDIAN
|
||||||
uECC_word_t *private = (uECC_word_t *) private_key;
|
uECC_word_t *private = (uECC_word_t *)private_key;
|
||||||
uECC_word_t *public = (uECC_word_t *) public_key;
|
uECC_word_t *public = (uECC_word_t *)public_key;
|
||||||
#else
|
#else
|
||||||
uECC_word_t private[uECC_MAX_WORDS];
|
uECC_word_t private[uECC_MAX_WORDS];
|
||||||
uECC_word_t public[uECC_MAX_WORDS * 2];
|
uECC_word_t public[uECC_MAX_WORDS * 2];
|
||||||
@@ -1082,7 +1082,7 @@ void uECC_compress(const uint8_t *public_key, uint8_t *compressed, uECC_Curve cu
|
|||||||
|
|
||||||
void uECC_decompress(const uint8_t *compressed, uint8_t *public_key, uECC_Curve curve) {
|
void uECC_decompress(const uint8_t *compressed, uint8_t *public_key, uECC_Curve curve) {
|
||||||
#if uECC_VLI_NATIVE_LITTLE_ENDIAN
|
#if uECC_VLI_NATIVE_LITTLE_ENDIAN
|
||||||
uECC_word_t *point = (uECC_word_t *) public_key;
|
uECC_word_t *point = (uECC_word_t *)public_key;
|
||||||
#else
|
#else
|
||||||
uECC_word_t point[uECC_MAX_WORDS * 2];
|
uECC_word_t point[uECC_MAX_WORDS * 2];
|
||||||
#endif
|
#endif
|
||||||
@@ -1131,7 +1131,7 @@ int uECC_valid_point(const uECC_word_t *point, uECC_Curve curve) {
|
|||||||
|
|
||||||
int uECC_valid_public_key(const uint8_t *public_key, uECC_Curve curve) {
|
int uECC_valid_public_key(const uint8_t *public_key, uECC_Curve curve) {
|
||||||
#if uECC_VLI_NATIVE_LITTLE_ENDIAN
|
#if uECC_VLI_NATIVE_LITTLE_ENDIAN
|
||||||
uECC_word_t *public = (uECC_word_t *) public_key;
|
uECC_word_t *public = (uECC_word_t *)public_key;
|
||||||
#else
|
#else
|
||||||
uECC_word_t public[uECC_MAX_WORDS * 2];
|
uECC_word_t public[uECC_MAX_WORDS * 2];
|
||||||
#endif
|
#endif
|
||||||
@@ -1146,8 +1146,8 @@ int uECC_valid_public_key(const uint8_t *public_key, uECC_Curve curve) {
|
|||||||
|
|
||||||
int uECC_compute_public_key(const uint8_t *private_key, uint8_t *public_key, uECC_Curve curve) {
|
int uECC_compute_public_key(const uint8_t *private_key, uint8_t *public_key, uECC_Curve curve) {
|
||||||
#if uECC_VLI_NATIVE_LITTLE_ENDIAN
|
#if uECC_VLI_NATIVE_LITTLE_ENDIAN
|
||||||
uECC_word_t *private = (uECC_word_t *) private_key;
|
uECC_word_t *private = (uECC_word_t *)private_key;
|
||||||
uECC_word_t *public = (uECC_word_t *) public_key;
|
uECC_word_t *public = (uECC_word_t *)public_key;
|
||||||
#else
|
#else
|
||||||
uECC_word_t private[uECC_MAX_WORDS];
|
uECC_word_t private[uECC_MAX_WORDS];
|
||||||
uECC_word_t public[uECC_MAX_WORDS * 2];
|
uECC_word_t public[uECC_MAX_WORDS * 2];
|
||||||
@@ -1231,7 +1231,7 @@ static int uECC_sign_with_k(const uint8_t *private_key,
|
|||||||
uECC_word_t s[uECC_MAX_WORDS];
|
uECC_word_t s[uECC_MAX_WORDS];
|
||||||
uECC_word_t *k2[2] = {tmp, s};
|
uECC_word_t *k2[2] = {tmp, s};
|
||||||
#if uECC_VLI_NATIVE_LITTLE_ENDIAN
|
#if uECC_VLI_NATIVE_LITTLE_ENDIAN
|
||||||
uECC_word_t *p = (uECC_word_t *) signature;
|
uECC_word_t *p = (uECC_word_t *)signature;
|
||||||
#else
|
#else
|
||||||
uECC_word_t p[uECC_MAX_WORDS * 2];
|
uECC_word_t p[uECC_MAX_WORDS * 2];
|
||||||
#endif
|
#endif
|
||||||
@@ -1460,7 +1460,7 @@ int uECC_verify(const uint8_t *public_key,
|
|||||||
bitcount_t num_bits;
|
bitcount_t num_bits;
|
||||||
bitcount_t i;
|
bitcount_t i;
|
||||||
#if uECC_VLI_NATIVE_LITTLE_ENDIAN
|
#if uECC_VLI_NATIVE_LITTLE_ENDIAN
|
||||||
uECC_word_t *public = (uECC_word_t *) public_key;
|
uECC_word_t *public = (uECC_word_t *)public_key;
|
||||||
#else
|
#else
|
||||||
uECC_word_t public[uECC_MAX_WORDS * 2];
|
uECC_word_t public[uECC_MAX_WORDS * 2];
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -39,7 +39,10 @@ faster somewhat faster, but increases the code size. */
|
|||||||
little-endian format for *all* arrays passed in and out of the public API. This includes public
|
little-endian format for *all* arrays passed in and out of the public API. This includes public
|
||||||
and private keys, shared secrets, signatures and message hashes.
|
and private keys, shared secrets, signatures and message hashes.
|
||||||
Using this switch reduces the amount of call stack memory used by uECC, since less intermediate
|
Using this switch reduces the amount of call stack memory used by uECC, since less intermediate
|
||||||
translations are required. Note that this will *only* work on native little-endian processors. */
|
translations are required.
|
||||||
|
Note that this will *only* work on native little-endian processors and it will treat the uint8_t
|
||||||
|
arrays passed into the public API as word arrays, therefore requiring the provided byte arrays
|
||||||
|
to be word aligned on architectures that do not support unaligned accesses. */
|
||||||
#ifndef uECC_VLI_NATIVE_LITTLE_ENDIAN
|
#ifndef uECC_VLI_NATIVE_LITTLE_ENDIAN
|
||||||
#define uECC_VLI_NATIVE_LITTLE_ENDIAN 0
|
#define uECC_VLI_NATIVE_LITTLE_ENDIAN 0
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user