Back to index

lightning-sunbird  0.9+nobinonly
pk11pqg.h
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is the Netscape security libraries.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Netscape Communications Corporation.
00018  * Portions created by the Initial Developer are Copyright (C) 1994-2001
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *
00023  * Alternatively, the contents of this file may be used under the terms of
00024  * either the GNU General Public License Version 2 or later (the "GPL"), or
00025  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00026  * in which case the provisions of the GPL or the LGPL are applicable instead
00027  * of those above. If you wish to allow use of your version of this file only
00028  * under the terms of either the GPL or the LGPL, and not to allow others to
00029  * use your version of this file under the terms of the MPL, indicate your
00030  * decision by deleting the provisions above and replace them with the notice
00031  * and other provisions required by the GPL or the LGPL. If you do not delete
00032  * the provisions above, a recipient may use your version of this file under
00033  * the terms of any one of the MPL, the GPL or the LGPL.
00034  *
00035  * ***** END LICENSE BLOCK ***** */
00036 /* Thse functions are stub functions which will get replaced with calls through
00037  * PKCS #11.
00038  */
00039 
00040 #ifndef _PK11PQG_H_
00041 #define  _PK11PQG_H_ 1
00042 
00043 #include "blapit.h"
00044 
00045 SEC_BEGIN_PROTOS
00046 
00047 /* Generate PQGParams and PQGVerify structs.
00048  * Length of seed and length of h both equal length of P. 
00049  * All lengths are specified by "j", according to the table above.
00050  */
00051 extern SECStatus PK11_PQG_ParamGen(unsigned int j, PQGParams **pParams, 
00052                                                  PQGVerify **pVfy);
00053 
00054 /* Generate PQGParams and PQGVerify structs.
00055  * Length of P specified by j.  Length of h will match length of P.
00056  * Length of SEED in bytes specified in seedBytes.
00057  * seedBbytes must be in the range [20..255] or an error will result.
00058  */
00059 extern SECStatus PK11_PQG_ParamGenSeedLen( unsigned int j, 
00060        unsigned int seedBytes, PQGParams **pParams, PQGVerify **pVfy);
00061 
00062 /*  Test PQGParams for validity as DSS PQG values.
00063  *  If vfy is non-NULL, test PQGParams to make sure they were generated
00064  *       using the specified seed, counter, and h values.
00065  *
00066  *  Return value indicates whether Verification operation ran succesfully
00067  *  to completion, but does not indicate if PQGParams are valid or not.
00068  *  If return value is SECSuccess, then *pResult has these meanings:
00069  *       SECSuccess: PQGParams are valid.
00070  *       SECFailure: PQGParams are invalid.
00071  *
00072  * Verify the following 12 facts about PQG counter SEED g and h
00073  * 1.  Q is 160 bits long.
00074  * 2.  P is one of the 9 valid lengths.
00075  * 3.  G < P
00076  * 4.  P % Q == 1
00077  * 5.  Q is prime
00078  * 6.  P is prime
00079  * Steps 7-12 are done only if the optional PQGVerify is supplied.
00080  * 7.  counter < 4096
00081  * 8.  g >= 160 and g < 2048   (g is length of seed in bits)
00082  * 9.  Q generated from SEED matches Q in PQGParams.
00083  * 10. P generated from (L, counter, g, SEED, Q) matches P in PQGParams.
00084  * 11. 1 < h < P-1
00085  * 12. G generated from h matches G in PQGParams.
00086  */
00087 
00088 extern SECStatus PK11_PQG_VerifyParams(const PQGParams *params, 
00089                                     const PQGVerify *vfy, SECStatus *result);
00090 extern void PK11_PQG_DestroyParams(PQGParams *params);
00091 extern void PK11_PQG_DestroyVerify(PQGVerify *vfy);
00092 
00093 /**************************************************************************
00094  *  Return a pointer to a new PQGParams struct that is constructed from   *
00095  *  copies of the arguments passed in.                                    *
00096  *  Return NULL on failure.                                               *
00097  **************************************************************************/
00098 extern PQGParams * PK11_PQG_NewParams(const SECItem * prime, const 
00099                             SECItem * subPrime, const SECItem * base);
00100 
00101 
00102 /**************************************************************************
00103  * Fills in caller's "prime" SECItem with the prime value in params.
00104  * Contents can be freed by calling SECITEM_FreeItem(prime, PR_FALSE);       
00105  **************************************************************************/
00106 extern SECStatus PK11_PQG_GetPrimeFromParams(const PQGParams *params, 
00107                                                  SECItem * prime);
00108 
00109 
00110 /**************************************************************************
00111  * Fills in caller's "subPrime" SECItem with the prime value in params.
00112  * Contents can be freed by calling SECITEM_FreeItem(subPrime, PR_FALSE);    
00113  **************************************************************************/
00114 extern SECStatus PK11_PQG_GetSubPrimeFromParams(const PQGParams *params, 
00115                                                  SECItem * subPrime);
00116 
00117 
00118 /**************************************************************************
00119  * Fills in caller's "base" SECItem with the base value in params.
00120  * Contents can be freed by calling SECITEM_FreeItem(base, PR_FALSE); 
00121  **************************************************************************/
00122 extern SECStatus PK11_PQG_GetBaseFromParams(const PQGParams *params, 
00123                                                  SECItem *base);
00124 
00125 
00126 /**************************************************************************
00127  *  Return a pointer to a new PQGVerify struct that is constructed from   *
00128  *  copies of the arguments passed in.                                    *
00129  *  Return NULL on failure.                                               *
00130  **************************************************************************/
00131 extern PQGVerify * PK11_PQG_NewVerify(unsigned int counter, 
00132                             const SECItem * seed, const SECItem * h);
00133 
00134 
00135 /**************************************************************************
00136  * Returns "counter" value from the PQGVerify.
00137  **************************************************************************/
00138 extern unsigned int PK11_PQG_GetCounterFromVerify(const PQGVerify *verify);
00139 
00140 /**************************************************************************
00141  * Fills in caller's "seed" SECItem with the seed value in verify.
00142  * Contents can be freed by calling SECITEM_FreeItem(seed, PR_FALSE); 
00143  **************************************************************************/
00144 extern SECStatus PK11_PQG_GetSeedFromVerify(const PQGVerify *verify, 
00145                                                  SECItem *seed);
00146 
00147 /**************************************************************************
00148  * Fills in caller's "h" SECItem with the h value in verify.
00149  * Contents can be freed by calling SECITEM_FreeItem(h, PR_FALSE);    
00150  **************************************************************************/
00151 extern SECStatus PK11_PQG_GetHFromVerify(const PQGVerify *verify, SECItem * h);
00152 
00153 SEC_END_PROTOS
00154 
00155 #endif