Alexandre Lision | 7fd5d3d | 2013-12-04 13:06:40 -0500 | [diff] [blame] | 1 | /* |
| 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 |
| 18 | extern "C" |
| 19 | { |
| 20 | #endif |
| 21 | |
| 22 | /** |
| 23 | * @brief Takes a secret large random number and computes the public EC point. |
| 24 | * |
| 25 | * @param curve is the curve to use. |
| 26 | * |
| 27 | * @param Q the functions writes the computed public point in this parameter. |
| 28 | * |
| 29 | * @param d is the secret random number. |
| 30 | * |
| 31 | * @return @c true (!0) if public key was computed, @c false otherwise. |
| 32 | * |
| 33 | * @sa ecGenerateRandomNumber |
| 34 | */ |
| 35 | int ecdhGeneratePublic(const EcCurve *curve, EcPoint *Q, const BigNum *d); |
| 36 | |
| 37 | /** |
| 38 | * @brief Computes the key agreement value. |
| 39 | * |
| 40 | * Takes the public EC point of the other party and applies the EC DH algorithm |
| 41 | * to compute the agreed value. |
| 42 | * |
| 43 | * @param curve is the curve to use, must be the same curve as used in |
| 44 | * @c ecdhGeneratePublic. |
| 45 | * |
| 46 | * @param agreemtn the functions writes the computed agreed value in this parameter. |
| 47 | * |
| 48 | * @param Q is the other party's public point. |
| 49 | * |
| 50 | * @param d is the secret random number. |
| 51 | */ |
| 52 | int ecdhComputeAgreement(const EcCurve *curve, BigNum *agreement, const EcPoint *Q, const BigNum *d); |
| 53 | |
| 54 | #ifdef __cplusplus |
| 55 | } |
| 56 | #endif |
| 57 | /** |
| 58 | * @} |
| 59 | */ |
| 60 | |
| 61 | #endif |