ecdh.h
Go to the documentation of this file.
1 /**
2  * @file ecdh.h
3  * @brief ECDH (Elliptic Curve Diffie-Hellman) key exchange
4  *
5  * @section License
6  *
7  * Copyright (C) 2010-2018 Oryx Embedded SARL. All rights reserved.
8  *
9  * This file is part of CycloneCrypto Open.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24  *
25  * @author Oryx Embedded SARL (www.oryx-embedded.com)
26  * @version 1.9.0
27  **/
28 
29 #ifndef _ECDH_H
30 #define _ECDH_H
31 
32 //Dependencies
33 #include "core/crypto.h"
34 #include "ecc/ec.h"
35 
36 //C++ guard
37 #ifdef __cplusplus
38  extern "C" {
39 #endif
40 
41 
42 /**
43  * @brief ECDH context
44  **/
45 
46 typedef struct
47 {
48  EcDomainParameters params; //EC domain parameters
49  Mpi da; ///<One's own private key
50  EcPoint qa; ///<One's own public key
51  EcPoint qb; ///<Peer's public key
52 } EcdhContext;
53 
54 
55 //ECDH related functions
56 void ecdhInit(EcdhContext *context);
57 void ecdhFree(EcdhContext *context);
58 
60  const PrngAlgo *prngAlgo, void *prngContext);
61 
62 error_t ecdhCheckPublicKey(const EcDomainParameters *params, EcPoint *publicKey);
63 
65  uint8_t *output, size_t outputSize, size_t *outputLen);
66 
67 //C++ guard
68 #ifdef __cplusplus
69  }
70 #endif
71 
72 #endif
ECC (Elliptic Curve Cryptography)
EC domain parameters.
Definition: ec.h:61
Arbitrary precision integer.
Definition: mpi.h:67
void ecdhFree(EcdhContext *context)
Release ECDH context.
Definition: ecdh.c:65
General definitions for cryptographic algorithms.
Mpi da
One&#39;s own private key.
Definition: ecdh.h:49
EcDomainParameters params
Definition: ecdh.h:48
EcPoint qb
Peer&#39;s public key.
Definition: ecdh.h:51
void ecdhInit(EcdhContext *context)
Initialize ECDH context.
Definition: ecdh.c:48
ECDH context.
Definition: ecdh.h:46
Elliptic curve point.
Definition: ec.h:49
error_t ecdhGenerateKeyPair(EcdhContext *context, const PrngAlgo *prngAlgo, void *prngContext)
ECDH key pair generation.
Definition: ecdh.c:85
error_t ecdhComputeSharedSecret(EcdhContext *context, uint8_t *output, size_t outputSize, size_t *outputLen)
Compute ECDH shared secret.
Definition: ecdh.c:383
error_t
Error codes.
Definition: error.h:40
EcPoint qa
One&#39;s own public key.
Definition: ecdh.h:50
Common interface for pseudo-random number generators.
Definition: crypto.h:1091
error_t ecdhCheckPublicKey(const EcDomainParameters *params, EcPoint *publicKey)
Check ECDH public key.
Definition: ecdh.c:270