X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilccrypt%2Fsilcdh.h;h=6b04b3bfcf862bae1ef50790e4a5e66b44732fdb;hb=a818c5b5411bbc4436d1c5f011236985c96bb787;hp=02f1129e3020482e8075216a5532f7e5201cccbf;hpb=89329650d986e09749d9c6a039797aaccfb30f27;p=silc.git diff --git a/lib/silccrypt/silcdh.h b/lib/silccrypt/silcdh.h index 02f1129e..6b04b3bf 100644 --- a/lib/silccrypt/silcdh.h +++ b/lib/silccrypt/silcdh.h @@ -1,36 +1,35 @@ +/* + + silcdh.h + + Author: Pekka Riikonen + + Copyright (C) 2001 Pekka Riikonen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + +*/ + /****h* silccrypt/SilcDH/silcdh.h - * - * NAME - * - * silcdh.h - * - * COPYRIGHT - * - * Author: Pekka Riikonen - * - * Copyright (C) 2001 Pekka Riikonen - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. * * DESCRIPTION * * PKCS #3 compliant Diffie Hellman key agreement protocol implementation. * This is used as part of SKE (SILC Key Exchange) protocol. + * ***/ #ifndef SILCDH_H #define SILCDH_H #include "silcmp.h" -#include "silcrng.h" /****s* silccrypt/SilcDH/SilcDH * @@ -50,35 +49,33 @@ typedef struct SilcDHStruct *SilcDH; /* Diffie Hellman context. This includes the DH parameters including the negotiated key material. */ struct SilcDHStruct { - SilcInt *g; /* Global base (generator) */ - SilcInt *p; /* Global prime (modulus, prime) */ - SilcInt *lpf; /* Largest prime factor (prime) */ - SilcInt *my_x; /* x, My private value (random) */ - SilcInt *my_y; /* y, My public value (y = g ^ x mod p) */ - SilcInt *your_y; /* y', Your public value (y' = g ^ x' mod p) */ - SilcInt *z; /* The computed secret key (z = y' ^ x mod p) */ - - SilcRng rng; /* RNG */ + SilcMPInt *g; /* Global base (generator) */ + SilcMPInt *p; /* Global prime (modulus, prime) */ + SilcMPInt *lpf; /* Largest prime factor (prime) */ + SilcMPInt *my_x; /* x, My private value (random) */ + SilcMPInt *my_y; /* y, My public value (y = g ^ x mod p) */ + SilcMPInt *your_y; /* y', Your public value (y' = g ^ x' mod p) */ + SilcMPInt *z; /* The computed secret key (z = y' ^ x mod p) */ }; /****f* silccrypt/SilcDH/silc_dh_alloc * * SYNOPSIS * - * SilcDH silc_dh_alloc(SilcRng rng, SilcInt *g, SilcInt *p, SilcInt *lpf); + * SilcDH silc_dh_alloc(SilcMPInt *g, SilcMPInt *p, SilcMPInt *lpf); * * DESCRIPTION * - * Allocate SilcDH context. The `rng' must be initialized random number - * generator context, the `g' is the public base generator used in the - * negotiation, the `p' is the public prime used in the negotiation and - * the `lpf' is largest prime factor of p defined publicly as well. The - * `lpf' is optional and if it is not supplied then the private values - * generated satifies 0 < x < p - 1 instead of 0 < x < lpf. Returns NULL - * on error or allocated SilcDH context on success. + * Allocate SilcDH context. The `g' is the public base generator used + * in the negotiation, the `p' is the public prime used in the + * negotiation and the `lpf' is largest prime factor of p defined + * publicly as well. The `lpf' is optional and if it is not supplied + * then the private values generated satifies 0 < x < p - 1 instead + * of 0 < x < lpf. Returns NULL on error or allocated SilcDH context + * on success. * ***/ -SilcDH silc_dh_alloc(SilcRng rng, SilcInt *g, SilcInt *p, SilcInt *lpf); +SilcDH silc_dh_alloc(SilcMPInt *g, SilcMPInt *p, SilcMPInt *lpf); /****f* silccrypt/SilcDH/silc_dh_free * @@ -88,8 +85,8 @@ SilcDH silc_dh_alloc(SilcRng rng, SilcInt *g, SilcInt *p, SilcInt *lpf); * * DESCRIPTION * - * Frees the SilcDH context. Does not free the RNG context given in the - * allocation. Frees all the allocated data inside the SilcDH context. + * Free the SilcDH context. Frees all the allocated data inside the + * SilcDH context. * ***/ void silc_dh_free(SilcDH dh); @@ -98,23 +95,23 @@ void silc_dh_free(SilcDH dh); * * SYNOPSIS * - * int silc_dh_generate_private(SilcDH dh, SilcInt **x); + * bool silc_dh_generate_private(SilcDH dh, const SilcMPInt **x); * * DESCRIPTION * * Generates random private value `x' such that 0 < x < lpf at most of * length of lpf. Returns FALSE if the random number could not be generated. * Returns the generated value into `x' pointer sent as argument, unless - * the `x' is NULL. The returned `x' must no be freed by the caller. + * the `x' is NULL. The returned `x' must not be freed by the caller. * ***/ -int silc_dh_generate_private(SilcDH dh, SilcInt **x); +bool silc_dh_generate_private(SilcDH dh, const SilcMPInt **x); /****f* silccrypt/SilcDH/silc_dh_compute_public * * SYNOPSIS * - * int silc_dh_compute_public(SilcDH dh, SilcInt **y); + * bool silc_dh_compute_public(SilcDH dh, const SilcMPInt **y); * * DESCRIPTION * @@ -124,13 +121,13 @@ int silc_dh_generate_private(SilcDH dh, SilcInt **x); * freed by the caller. * ***/ -int silc_dh_compute_public(SilcDH dh, SilcInt **y); +bool silc_dh_compute_public(SilcDH dh, const SilcMPInt **y); /****f* silccrypt/SilcDH/silc_dh_remote_public * * SYNOPSIS * - * int silc_dh_compute_public(SilcDH dh, SilcInt **y); + * bool silc_dh_compute_public(SilcDH dh, SilcMPInt *y); * * DESCRIPTION * @@ -139,13 +136,13 @@ int silc_dh_compute_public(SilcDH dh, SilcInt **y); * on error. * ***/ -int silc_dh_set_remote_public(SilcDH dh, SilcInt *y); +bool silc_dh_set_remote_public(SilcDH dh, SilcMPInt *y); /****f* silccrypt/SilcDH/silc_dh_compute_key * * SYNOPSIS * - * int silc_dh_compute_key(SilcDH dh, SilcInt **z); + * bool silc_dh_compute_key(SilcDH dh, const SilcMPInt **z); * * DESCRIPTION * @@ -155,22 +152,22 @@ int silc_dh_set_remote_public(SilcDH dh, SilcInt *y); * freed by the caller. * ***/ -int silc_dh_compute_key(SilcDH dh, SilcInt **z); +bool silc_dh_compute_key(SilcDH dh, const SilcMPInt **z); /****f* silccrypt/SilcDH/silc_dh_remote_public * * SYNOPSIS * - * int silc_dh_compute_key_data(SilcDH dh, unsigned char **z, - * uint32 *z_len); + * bool silc_dh_compute_key_data(SilcDH dh, unsigned char **z, + * SilcUInt32 *z_len); * * DESCRIPTION * * Same as above but returns the computed secret key as octet binary - * string. + * string. The caller must free the returned binary string. * ***/ -int silc_dh_compute_key_data(SilcDH dh, unsigned char **z, - uint32 *z_len); +bool silc_dh_compute_key_data(SilcDH dh, unsigned char **z, + SilcUInt32 *z_len); #endif