Blame nss/lib/pk11wrap/pk11pqg.h

Packit 40b132
/* This Source Code Form is subject to the terms of the Mozilla Public
Packit 40b132
 * License, v. 2.0. If a copy of the MPL was not distributed with this
Packit 40b132
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Packit 40b132
/* Thse functions are stub functions which will get replaced with calls through
Packit 40b132
 * PKCS #11.
Packit 40b132
 */
Packit 40b132
Packit 40b132
#ifndef _PK11PQG_H_
Packit 40b132
#define  _PK11PQG_H_ 1
Packit 40b132
Packit 40b132
#include "blapit.h"
Packit 40b132
Packit 40b132
SEC_BEGIN_PROTOS
Packit 40b132
Packit 40b132
/* Generate PQGParams and PQGVerify structs.
Packit 40b132
 * Length of seed and length of h both equal length of P. 
Packit 40b132
 * All lengths are specified by "j", according to the table above.
Packit 40b132
 */
Packit 40b132
extern SECStatus PK11_PQG_ParamGen(unsigned int j, PQGParams **pParams, 
Packit 40b132
							PQGVerify **pVfy);
Packit 40b132
Packit 40b132
/* Generate PQGParams and PQGVerify structs.
Packit 40b132
 * Length of P specified by j.  Length of h will match length of P.
Packit 40b132
 * Length of SEED in bytes specified in seedBytes.
Packit 40b132
 * seedBbytes must be in the range [20..255] or an error will result.
Packit 40b132
 */
Packit 40b132
extern SECStatus PK11_PQG_ParamGenSeedLen( unsigned int j, 
Packit 40b132
	unsigned int seedBytes, PQGParams **pParams, PQGVerify **pVfy);
Packit 40b132
Packit 40b132
Packit 40b132
/* Generate PQGParams and PQGVerify structs.
Packit 40b132
 * Length of P specified by L.
Packit 40b132
 *   if L is greater than 1024 then the resulting verify parameters will be
Packit 40b132
 *   DSA2.
Packit 40b132
 * Length of Q specified by N. If zero, The PKCS #11 module will
Packit 40b132
 *   pick an appropriately sized Q for L. If N is specified and L = 1024, then
Packit 40b132
 *   the resulting verify parameters will be DSA2, Otherwise DSA1 parameters 
Packit 40b132
 *   will be returned.
Packit 40b132
 * Length of SEED in bytes specified in seedBytes.
Packit 40b132
 *
Packit 40b132
 * The underlying PKCS #11 module will check the values for L, N, 
Packit 40b132
 * and seedBytes. The rules for softoken are:
Packit 40b132
 * 
Packit 40b132
 * If L <= 1024, then L must be between 512 and 1024 in increments of 64 bits.
Packit 40b132
 * If L <= 1024, then N must be 0 or 160.
Packit 40b132
 * If L >= 1024, then L and N must match the following table:
Packit 40b132
 *   L=1024   N=0 or 160
Packit 40b132
 *   L=2048   N=0 or 224
Packit 40b132
 *   L=2048   N=256
Packit 40b132
 *   L=3072   N=0 or 256
Packit 40b132
 * if L <= 1024
Packit 40b132
 *   seedBbytes must be in the range [20..256].
Packit 40b132
 * if L >= 1024
Packit 40b132
 *   seedBbytes must be in the range [20..L/16].
Packit 40b132
 */
Packit 40b132
extern SECStatus
Packit 40b132
PK11_PQG_ParamGenV2(unsigned int L, unsigned int N, unsigned int seedBytes,
Packit 40b132
		    PQGParams **pParams, PQGVerify **pVfy);
Packit 40b132
Packit 40b132
/*  Test PQGParams for validity as DSS PQG values.
Packit 40b132
 *  If vfy is non-NULL, test PQGParams to make sure they were generated
Packit 40b132
 *       using the specified seed, counter, and h values.
Packit 40b132
 *
Packit 40b132
 *  Return value indicates whether Verification operation ran successfully
Packit 40b132
 *  to completion, but does not indicate if PQGParams are valid or not.
Packit 40b132
 *  If return value is SECSuccess, then *pResult has these meanings:
Packit 40b132
 *       SECSuccess: PQGParams are valid.
Packit 40b132
 *       SECFailure: PQGParams are invalid.
Packit 40b132
 *
Packit 40b132
 * Verify the following 12 facts about PQG counter SEED g and h
Packit 40b132
 * These tests are specified in FIPS 186-3 Appendix A.1.1.1, A.1.1.3, and A.2.2
Packit 40b132
 * PQG_VerifyParams in softoken/freebl will automatically choose the 
Packit 40b132
 * appropriate test.
Packit 40b132
 */
Packit 40b132
extern SECStatus PK11_PQG_VerifyParams(const PQGParams *params, 
Packit 40b132
                                    const PQGVerify *vfy, SECStatus *result);
Packit 40b132
extern void PK11_PQG_DestroyParams(PQGParams *params);
Packit 40b132
extern void PK11_PQG_DestroyVerify(PQGVerify *vfy);
Packit 40b132
Packit 40b132
/**************************************************************************
Packit 40b132
 *  Return a pointer to a new PQGParams struct that is constructed from   *
Packit 40b132
 *  copies of the arguments passed in.                                    *
Packit 40b132
 *  Return NULL on failure.                                               *
Packit 40b132
 **************************************************************************/
Packit 40b132
extern PQGParams * PK11_PQG_NewParams(const SECItem * prime, const 
Packit 40b132
				SECItem * subPrime, const SECItem * base);
Packit 40b132
Packit 40b132
Packit 40b132
/**************************************************************************
Packit 40b132
 * Fills in caller's "prime" SECItem with the prime value in params.
Packit 40b132
 * Contents can be freed by calling SECITEM_FreeItem(prime, PR_FALSE);	
Packit 40b132
 **************************************************************************/
Packit 40b132
extern SECStatus PK11_PQG_GetPrimeFromParams(const PQGParams *params, 
Packit 40b132
							SECItem * prime);
Packit 40b132
Packit 40b132
Packit 40b132
/**************************************************************************
Packit 40b132
 * Fills in caller's "subPrime" SECItem with the prime value in params.
Packit 40b132
 * Contents can be freed by calling SECITEM_FreeItem(subPrime, PR_FALSE);	
Packit 40b132
 **************************************************************************/
Packit 40b132
extern SECStatus PK11_PQG_GetSubPrimeFromParams(const PQGParams *params, 
Packit 40b132
							SECItem * subPrime);
Packit 40b132
Packit 40b132
Packit 40b132
/**************************************************************************
Packit 40b132
 * Fills in caller's "base" SECItem with the base value in params.
Packit 40b132
 * Contents can be freed by calling SECITEM_FreeItem(base, PR_FALSE);	
Packit 40b132
 **************************************************************************/
Packit 40b132
extern SECStatus PK11_PQG_GetBaseFromParams(const PQGParams *params, 
Packit 40b132
							SECItem *base);
Packit 40b132
Packit 40b132
Packit 40b132
/**************************************************************************
Packit 40b132
 *  Return a pointer to a new PQGVerify struct that is constructed from   *
Packit 40b132
 *  copies of the arguments passed in.                                    *
Packit 40b132
 *  Return NULL on failure.                                               *
Packit 40b132
 **************************************************************************/
Packit 40b132
extern PQGVerify * PK11_PQG_NewVerify(unsigned int counter, 
Packit 40b132
				const SECItem * seed, const SECItem * h);
Packit 40b132
Packit 40b132
Packit 40b132
/**************************************************************************
Packit 40b132
 * Returns "counter" value from the PQGVerify.
Packit 40b132
 **************************************************************************/
Packit 40b132
extern unsigned int PK11_PQG_GetCounterFromVerify(const PQGVerify *verify);
Packit 40b132
Packit 40b132
/**************************************************************************
Packit 40b132
 * Fills in caller's "seed" SECItem with the seed value in verify.
Packit 40b132
 * Contents can be freed by calling SECITEM_FreeItem(seed, PR_FALSE);	
Packit 40b132
 **************************************************************************/
Packit 40b132
extern SECStatus PK11_PQG_GetSeedFromVerify(const PQGVerify *verify, 
Packit 40b132
							SECItem *seed);
Packit 40b132
Packit 40b132
/**************************************************************************
Packit 40b132
 * Fills in caller's "h" SECItem with the h value in verify.
Packit 40b132
 * Contents can be freed by calling SECITEM_FreeItem(h, PR_FALSE);	
Packit 40b132
 **************************************************************************/
Packit 40b132
extern SECStatus PK11_PQG_GetHFromVerify(const PQGVerify *verify, SECItem * h);
Packit 40b132
Packit 40b132
SEC_END_PROTOS
Packit 40b132
Packit 40b132
#endif