ndn-lite
tc_ecc_dh.h
Go to the documentation of this file.
1 /* ecc_dh.h - TinyCrypt interface to EC-DH implementation */
2 
3 /*
4  * Copyright (c) 2014, Kenneth MacKay
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * * Redistributions of source code must retain the above copyright notice, this
11  * list of conditions and the following disclaimer.
12  *
13  * * Redistributions in binary form must reproduce the above copyright notice,
14  * this list of conditions and the following disclaimer in the documentation
15  * and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 /* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.
31  *
32  * Redistribution and use in source and binary forms, with or without
33  * modification, are permitted provided that the following conditions are met:
34  *
35  * - Redistributions of source code must retain the above copyright notice,
36  * this list of conditions and the following disclaimer.
37  *
38  * - Redistributions in binary form must reproduce the above copyright
39  * notice, this list of conditions and the following disclaimer in the
40  * documentation and/or other materials provided with the distribution.
41  *
42  * - Neither the name of Intel Corporation nor the names of its contributors
43  * may be used to endorse or promote products derived from this software
44  * without specific prior written permission.
45  *
46  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
47  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
48  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
49  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
50  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
51  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
52  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
53  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
54  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
55  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
56  * POSSIBILITY OF SUCH DAMAGE.
57  */
58 
69 #ifndef __TC_ECC_DH_H__
70 #define __TC_ECC_DH_H__
71 
72 #include "tc_ecc.h"
73 
74 #ifdef __cplusplus
75 extern "C" {
76 #endif
77 
94 int tc_uECC_make_key(uint8_t *p_public_key, uint8_t *p_private_key, tc_uECC_Curve curve);
95 
96 #ifdef ENABLE_TESTS
97 
104 int tc_uECC_make_key_with_d(uint8_t *p_public_key, uint8_t *p_private_key,
105  unsigned int *d, tc_uECC_Curve curve);
106 #endif
107 
124 int tc_uECC_shared_secret(const uint8_t *p_public_key, const uint8_t *p_private_key,
125  uint8_t *p_secret, tc_uECC_Curve curve);
126 
127 #ifdef __cplusplus
128 }
129 #endif
130 
131 #endif /* __TC_ECC_DH_H__ */
int tc_uECC_make_key_with_d(uint8_t *public_key, uint8_t *private_key, unsigned int *d, tc_uECC_Curve curve)
Definition: tc_ecc_dh.c:68
int tc_uECC_shared_secret(const uint8_t *p_public_key, const uint8_t *p_private_key, uint8_t *p_secret, tc_uECC_Curve curve)
Compute a shared secret given your secret key and someone else's public key.
Definition: tc_ecc_dh.c:144
Definition: tc_ecc.h:112
– Interface to common ECC functions.
int tc_uECC_make_key(uint8_t *p_public_key, uint8_t *p_private_key, tc_uECC_Curve curve)
Create a public/private key pair.
Definition: tc_ecc_dh.c:102