1 /*
2 * Copyright (c) 1999, 2000, 2001, 2002 X-Way Rights BV
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 */
19
20 /*!\file dlsvdp-dh.c
21 * \brief Diffie-Hellman algorithm.
22 *
23 * The IEEE P.1363 designation is:
24 * Discrete Logarithm Secret Value Derivation Primitive, Diffie-Hellman style.
25 *
26 * \author Bob Deblier <bob.deblier@telenet.be>
27 * \ingroup DL_m DL_dh_m
28 */
29
30 #define BEECRYPT_DLL_EXPORT
31
32 #if HAVE_CONFIG_H
33 # include "config.h"
34 #endif
35
36 #include "beecrypt/dlsvdp-dh.h"
37
38 /*!\addtogroup DL_dh_m
39 * \{
40 */
41
42 /*!\fn dlsvdp_pDHSecret(const dhparam* dp, const mpnumber* x, const mpnumber* y, mpnumber* s)
43 * \brief Computes the shared secret.
44 *
45 * Equation:
46 *
47 * \li \f$s=y^{x}\ \textrm{mod}\ p\f$
48 *
49 * \param dp The domain parameters.
50 * \param x The private value.
51 * \param y The public value (of the peer).
52 * \param s The computed secret value.
53 *
54 * \retval 0 on success.
55 * \retval -1 on failure.
56 */
dlsvdp_pDHSecret(const dhparam * dp,const mpnumber * x,const mpnumber * y,mpnumber * s)57 int dlsvdp_pDHSecret(const dhparam* dp, const mpnumber* x, const mpnumber* y, mpnumber* s)
58 {
59 mpbnpowmod(&dp->p, y, x, s);
60
61 return 0;
62 }
63
64 /*!\}
65 */
66