blob: 0cf083aa79fccbf1cd97dcbbf60c0af98ee96a82 [file] [log] [blame]
Alexandre Lision7fd5d3d2013-12-04 13:06:40 -05001/*
2 * Copyright (C) 2012 Werner Dittmann
3 * All rights reserved. For licensing and other legal details, see the file legal.c.
4 *
5 * @author Werner Dittmann <Werner.Dittmann@t-online.de>
6 *
7 */
8#ifndef _ECDH_H_
9#define _ECDH_H_
10/**
11 * @file ec.h
12 * @brief Elliptic Diffie-Hellman functions for bnlib
13 * @defgroup BNLIB_EC Elliptic curve functions
14 * @{
15 */
16
17#ifdef __cplusplus
18extern "C"
19{
20#endif
21
22/**
23 * @brief Takes a secret large random number and computes the public EC point.
24 *
Alexandre Lisionddd731e2014-01-31 11:50:08 -050025 * @param curve is the NIST curve to use.
Alexandre Lision7fd5d3d2013-12-04 13:06:40 -050026 *
27 * @param Q the functions writes the computed public point in this parameter.
28 *
29 * @param d is the secret random number.
30 *
Alexandre Lision7fd5d3d2013-12-04 13:06:40 -050031 * @sa ecGenerateRandomNumber
32 */
Alexandre Lisionddd731e2014-01-31 11:50:08 -050033int ecdhGeneratePublic(const NistECpCurve *curve, EcPoint *Q, const BigNum *d);
Alexandre Lision7fd5d3d2013-12-04 13:06:40 -050034
35/**
36 * @brief Computes the key agreement value.
37 *
38 * Takes the public EC point of the other party and applies the EC DH algorithm
39 * to compute the agreed value.
40 *
Alexandre Lisionddd731e2014-01-31 11:50:08 -050041 * @param curve is the NIST curve to use, must be the same curve as used in
Alexandre Lision7fd5d3d2013-12-04 13:06:40 -050042 * @c ecdhGeneratePublic.
43 *
44 * @param agreemtn the functions writes the computed agreed value in this parameter.
45 *
46 * @param Q is the other party's public point.
47 *
48 * @param d is the secret random number.
49 */
Alexandre Lisionddd731e2014-01-31 11:50:08 -050050int ecdhComputeAgreement(const NistECpCurve *curve, BigNum *agreement, const EcPoint *Q, const BigNum *d);
Alexandre Lision7fd5d3d2013-12-04 13:06:40 -050051
52#ifdef __cplusplus
53}
54#endif
55/**
56 * @}
57 */
58
59#endif