BeeCrypt 4.2.1
|
00001 /* 00002 * Copyright (c) 2000, 2001, 2002 X-Way Rights BV 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this library; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 */ 00019 00026 #ifndef _DLDP_H 00027 #define _DLDP_H 00028 00029 #include "beecrypt/mpbarrett.h" 00030 00031 /* 00032 * Discrete Logarithm Domain Parameters - Prime 00033 * 00034 * Standard definition where p = qr+1; in case where p=2q+1, r=2 00035 * 00036 * In IEEE P1363 naming is p = rk+1 00037 * 00038 * Hence, IEEE prime r = q and cofactor k = r 00039 * 00040 * Make sure q is large enough to foil Pohlig-Hellman attacks 00041 * See: "Handbook of Applied Cryptography", Chapter 3.6.4 00042 * 00043 * g is either a generator of a subgroup of order q, or a generator of order 00044 * n = (p-1) 00045 */ 00046 00053 #ifdef __cplusplus 00054 struct BEECRYPTAPI dldp_p 00055 #else 00056 struct _dldp_p 00057 #endif 00058 { 00063 mpbarrett p; 00069 mpbarrett q; 00074 mpnumber r; 00081 mpnumber g; 00086 mpbarrett n; 00087 #ifdef __cplusplus 00088 dldp_p(); 00089 dldp_p(const dldp_p&); 00090 ~dldp_p(); 00091 #endif 00092 }; 00093 00094 #ifndef __cplusplus 00095 typedef struct _dldp_p dldp_p; 00096 #endif 00097 00098 #ifdef __cplusplus 00099 extern "C" { 00100 #endif 00101 00102 /* 00103 * Functions for setting up and copying 00104 */ 00105 00106 BEECRYPTAPI 00107 int dldp_pInit(dldp_p*); 00108 BEECRYPTAPI 00109 int dldp_pFree(dldp_p*); 00110 BEECRYPTAPI 00111 int dldp_pCopy(dldp_p*, const dldp_p*); 00112 00113 /* 00114 * Functions for generating keys 00115 */ 00116 00117 BEECRYPTAPI 00118 int dldp_pPrivate (const dldp_p*, randomGeneratorContext*, mpnumber*); 00119 BEECRYPTAPI 00120 int dldp_pPrivate_s(const dldp_p*, randomGeneratorContext*, mpnumber*, size_t); 00121 BEECRYPTAPI 00122 int dldp_pPublic (const dldp_p*, const mpnumber*, mpnumber*); 00123 BEECRYPTAPI 00124 int dldp_pPair (const dldp_p*, randomGeneratorContext*, mpnumber* x, mpnumber* y); 00125 BEECRYPTAPI 00126 int dldp_pPair_s (const dldp_p*, randomGeneratorContext*, mpnumber* x, mpnumber* y, size_t); 00127 00128 /* 00129 * Function for comparing domain parameters 00130 */ 00131 00132 BEECRYPTAPI 00133 int dldp_pEqual (const dldp_p*, const dldp_p*); 00134 00135 /* 00136 * Functions for generating and validating dldp_pgoq variant domain parameters 00137 */ 00138 00139 BEECRYPTAPI 00140 int dldp_pgoqMake (dldp_p*, randomGeneratorContext*, size_t, size_t, int); 00141 BEECRYPTAPI 00142 int dldp_pgoqMakeSafe (dldp_p*, randomGeneratorContext*, size_t); 00143 BEECRYPTAPI 00144 int dldp_pgoqGenerator(dldp_p*, randomGeneratorContext*); 00145 BEECRYPTAPI 00146 int dldp_pgoqValidate (const dldp_p*, randomGeneratorContext*, int); 00147 00148 /* 00149 * Functions for generating and validating dldp_pgon variant domain parameters 00150 */ 00151 00152 BEECRYPTAPI 00153 int dldp_pgonMake (dldp_p*, randomGeneratorContext*, size_t, size_t); 00154 BEECRYPTAPI 00155 int dldp_pgonMakeSafe (dldp_p*, randomGeneratorContext*, size_t); 00156 BEECRYPTAPI 00157 int dldp_pgonGenerator(dldp_p*, randomGeneratorContext*); 00158 BEECRYPTAPI 00159 int dldp_pgonValidate (const dldp_p*, randomGeneratorContext*); 00160 00161 #ifdef __cplusplus 00162 } 00163 #endif 00164 00165 #endif