aboutsummaryrefslogtreecommitdiffstats
path: root/tests/include/test_ecc_utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/include/test_ecc_utils.h')
-rw-r--r--tests/include/test_ecc_utils.h86
1 files changed, 52 insertions, 34 deletions
diff --git a/tests/include/test_ecc_utils.h b/tests/include/test_ecc_utils.h
index 97c183c..4e29054 100644
--- a/tests/include/test_ecc_utils.h
+++ b/tests/include/test_ecc_utils.h
@@ -1,7 +1,30 @@
/* test_ecc_utils.h - TinyCrypt interface to common functions for ECC tests */
+/* Copyright (c) 2014, Kenneth MacKay
+ * All rights reserved.
+ *
+ * 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 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 SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.*/
+
/*
- * Copyright (C) 2015 by Intel Corporation, All Rights Reserved.
+ * Copyright (C) 2017 by Intel Corporation, All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -35,48 +58,43 @@
#ifndef __TEST_ECC_UTILS_H__
#define __TEST_ECC_UTILS_H__
-#include <stdlib.h>
-#include <stdbool.h>
-#include <tinycrypt/constants.h>
+#include <tinycrypt/ecc_dh.h>
+#include <tinycrypt/ecc.h>
+#include <test_utils.h>
-EccPoint keygen_vectors(char **d_vec,
- char **qx_vec,
- char **qy_vec,
- int tests,
- bool verbose);
+int hex2int (char hex);
-void getRandomBytes(void *p_dest, unsigned p_size);
-void string2host(uint32_t *native, const uint8_t *bytes, size_t len);
+/*
+ * Convert hex string to byte string
+ * Return number of bytes written to buf, or 0 on error
+ */
+int hex2bin(uint8_t *buf, const size_t buflen, const char *hex,
+ const size_t hexlen);
-int hex2int (char hex);
+/*
+ * Convert hex string to zero-padded nanoECC scalar
+ */
+void string2scalar(unsigned int * scalar, unsigned int num_word32, char *str);
+
+
+void print_ecc_scalar(const char *label, const unsigned int * p_vli,
+ unsigned int num_word32);
-int hex2bin(
- uint8_t *buf,
- const size_t buflen,
- const char *hex,
- const size_t hexlen);
+int check_ecc_result(const int num, const char *name,
+ const unsigned int *expected,
+ const unsigned int *computed,
+ const unsigned int num_word32, const bool verbose);
-void string2scalar(uint32_t * scalar, uint32_t num_word32, char *str);
+/* Test ecc_make_keys, and also as keygen part of other tests */
+int keygen_vectors(char **d_vec, char **qx_vec, char **qy_vec, int tests, bool verbose);
-void vli_print(uint32_t *p_vli, unsigned int p_size);
+void vli_print_bytes(uint8_t *vli, unsigned int size);
-void print_ecc_scalar(
- const char *label,
- const uint32_t * p_vli,
- uint32_t num_word32);
-void check_code(const int num,
- const char *name,
- const int expected,
- const int computed,
- const int verbose);
+int check_code(const int num, const char *name, const int expected,
+ const int computed, const int verbose);
-void check_ecc_result(const int num, const char *name,
- const uint32_t *expected,
- const uint32_t *computed,
- const uint32_t num_word32,
- const bool verbose);
-#endif
+#endif /* __TEST_ECC_UTILS_H__ */