00001 // $Id: PC3.hh 22437 2008-03-04 14:35:16Z rdm $ 00002 /* ----------------------------------------------------------------------- * 00003 * * 00004 * PC3.cc * 00005 * * 00006 * C++ adaptation of PKEP implementation written by Alexander PUKALL 1991. * 00007 * * 00008 * PKEP ( Pukall Key Exchange Protocol (c) Alexander PUKALL 1997 * 00009 * * 00010 * Reference: http://membres.lycos.fr/pc1/ * 00011 * * 00012 * Description: * 00013 * Algorithm allowing the secure exchange of a random password using the * 00014 * PC3 cipher for random number generation based on a 160-bit seed. * 00015 * Initialization creates private and public parts; exponentiation builds * 00016 * the key using the received public part. * 00017 * * 00018 * Created Key length is 256 bits (32 bytes). Input random string can be * 00019 * up to 256 bytes, but 32 or 64 should be typically enough. * 00020 * Buffers for private and public parts should be of length kPC3SLEN * 00021 * * 00022 * Fro the author: * 00023 * Free code no restriction to use please include the name of the Author * 00024 * in the final software * 00025 * * 00026 * Adapted by G. Ganis (g.ganis@cern.ch), February 2005 * 00027 * ----------------------------------------------------------------------- */ 00028 00029 typedef unsigned char uchar; 00030 00031 #define kPC3SLEN 33 00032 #define kPC3MAXRPWLEN 256 00033 #define kPC3MINBITS 128 00034 #define kPC3KEYLEN 32 00035 00036 int PC3InitDiPuk(uchar *rpwd, unsigned int lrpw, uchar *pub, uchar *priv); 00037 int PC3DiPukExp(uchar *pub, uchar *priv, uchar *key);