Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages  

beecrypt/dlkp.c

Go to the documentation of this file.
00001 
00007 /*
00008  * <conformance statement for IEEE P1363 needed here>
00009  *
00010  * Copyright (c) 2000, 2001 Virtual Unlimited B.V.
00011  *
00012  * Author: Bob Deblier <bob@virtualunlimited.com>
00013  *
00014  * This library is free software; you can redistribute it and/or
00015  * modify it under the terms of the GNU Lesser General Public
00016  * License as published by the Free Software Foundation; either
00017  * version 2.1 of the License, or (at your option) any later version.
00018  *
00019  * This library is distributed in the hope that it will be useful,
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00022  * Lesser General Public License for more details.
00023  *
00024  * You should have received a copy of the GNU Lesser General Public
00025  * License along with this library; if not, write to the Free Software
00026  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00027  *
00028  */
00029 
00030 #include "system.h"
00031 #include "dlkp.h"
00032 #include "debug.h"
00033 
00034 int dlkp_pPair(dlkp_p* kp, randomGeneratorContext* rgc, const dldp_p* param)
00035 {
00036         /* copy the parameters */
00037         if (dldp_pCopy(&kp->param, param) < 0)
00038                 return -1;
00039 
00040         if (dldp_pPair(param, rgc, &kp->x, &kp->y) < 0)
00041                 return -1;
00042 
00043         return 0;
00044 }
00045 
00046 int dlkp_pInit(dlkp_p* kp)
00047 {
00048         if (dldp_pInit(&kp->param) < 0)
00049                 return -1;
00050 
00051         mp32nzero(&kp->y);
00052         mp32nzero(&kp->x);
00053 
00054         return 0;
00055 }
00056 
00057 int dlkp_pFree(dlkp_p* kp)
00058 {
00059         /*@-usereleased -compdef @*/ /* kp->param.{p,q,n}.modl is OK */
00060         if (dldp_pFree(&kp->param) < 0)
00061                 return -1;
00062 
00063         mp32nfree(&kp->y);
00064         mp32nfree(&kp->x);
00065 
00066         return 0;
00067         /*@=usereleased =compdef @*/
00068 }
00069 
00070 int dlkp_pCopy(dlkp_p* dst, const dlkp_p* src)
00071 {
00072         if (dldp_pCopy(&dst->param, &src->param) < 0)
00073                 return -1;
00074 
00075         mp32ncopy(&dst->y, &src->y);
00076         mp32ncopy(&dst->x, &src->x);
00077 
00078         return 0;
00079 }

Generated on Tue Sep 17 15:56:36 2002 for rpm by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002