Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | /* Thse functions are stub functions which will get replaced with calls through |
michael@0 | 5 | * PKCS #11. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | #ifndef _PK11PQG_H_ |
michael@0 | 9 | #define _PK11PQG_H_ 1 |
michael@0 | 10 | |
michael@0 | 11 | #include "blapit.h" |
michael@0 | 12 | |
michael@0 | 13 | SEC_BEGIN_PROTOS |
michael@0 | 14 | |
michael@0 | 15 | /* Generate PQGParams and PQGVerify structs. |
michael@0 | 16 | * Length of seed and length of h both equal length of P. |
michael@0 | 17 | * All lengths are specified by "j", according to the table above. |
michael@0 | 18 | */ |
michael@0 | 19 | extern SECStatus PK11_PQG_ParamGen(unsigned int j, PQGParams **pParams, |
michael@0 | 20 | PQGVerify **pVfy); |
michael@0 | 21 | |
michael@0 | 22 | /* Generate PQGParams and PQGVerify structs. |
michael@0 | 23 | * Length of P specified by j. Length of h will match length of P. |
michael@0 | 24 | * Length of SEED in bytes specified in seedBytes. |
michael@0 | 25 | * seedBbytes must be in the range [20..255] or an error will result. |
michael@0 | 26 | */ |
michael@0 | 27 | extern SECStatus PK11_PQG_ParamGenSeedLen( unsigned int j, |
michael@0 | 28 | unsigned int seedBytes, PQGParams **pParams, PQGVerify **pVfy); |
michael@0 | 29 | |
michael@0 | 30 | |
michael@0 | 31 | /* Generate PQGParams and PQGVerify structs. |
michael@0 | 32 | * Length of P specified by L. |
michael@0 | 33 | * if L is greater than 1024 then the resulting verify parameters will be |
michael@0 | 34 | * DSA2. |
michael@0 | 35 | * Length of Q specified by N. If zero, The PKCS #11 module will |
michael@0 | 36 | * pick an appropriately sized Q for L. If N is specified and L = 1024, then |
michael@0 | 37 | * the resulting verify parameters will be DSA2, Otherwise DSA1 parameters |
michael@0 | 38 | * will be returned. |
michael@0 | 39 | * Length of SEED in bytes specified in seedBytes. |
michael@0 | 40 | * |
michael@0 | 41 | * The underlying PKCS #11 module will check the values for L, N, |
michael@0 | 42 | * and seedBytes. The rules for softoken are: |
michael@0 | 43 | * |
michael@0 | 44 | * If L <= 1024, then L must be between 512 and 1024 in increments of 64 bits. |
michael@0 | 45 | * If L <= 1024, then N must be 0 or 160. |
michael@0 | 46 | * If L >= 1024, then L and N must match the following table: |
michael@0 | 47 | * L=1024 N=0 or 160 |
michael@0 | 48 | * L=2048 N=0 or 224 |
michael@0 | 49 | * L=2048 N=256 |
michael@0 | 50 | * L=3072 N=0 or 256 |
michael@0 | 51 | * if L <= 1024 |
michael@0 | 52 | * seedBbytes must be in the range [20..256]. |
michael@0 | 53 | * if L >= 1024 |
michael@0 | 54 | * seedBbytes must be in the range [20..L/16]. |
michael@0 | 55 | */ |
michael@0 | 56 | extern SECStatus |
michael@0 | 57 | PK11_PQG_ParamGenV2(unsigned int L, unsigned int N, unsigned int seedBytes, |
michael@0 | 58 | PQGParams **pParams, PQGVerify **pVfy); |
michael@0 | 59 | |
michael@0 | 60 | /* Test PQGParams for validity as DSS PQG values. |
michael@0 | 61 | * If vfy is non-NULL, test PQGParams to make sure they were generated |
michael@0 | 62 | * using the specified seed, counter, and h values. |
michael@0 | 63 | * |
michael@0 | 64 | * Return value indicates whether Verification operation ran successfully |
michael@0 | 65 | * to completion, but does not indicate if PQGParams are valid or not. |
michael@0 | 66 | * If return value is SECSuccess, then *pResult has these meanings: |
michael@0 | 67 | * SECSuccess: PQGParams are valid. |
michael@0 | 68 | * SECFailure: PQGParams are invalid. |
michael@0 | 69 | * |
michael@0 | 70 | * Verify the following 12 facts about PQG counter SEED g and h |
michael@0 | 71 | * These tests are specified in FIPS 186-3 Appendix A.1.1.1, A.1.1.3, and A.2.2 |
michael@0 | 72 | * PQG_VerifyParams in softoken/freebl will automatically choose the |
michael@0 | 73 | * appropriate test. |
michael@0 | 74 | */ |
michael@0 | 75 | extern SECStatus PK11_PQG_VerifyParams(const PQGParams *params, |
michael@0 | 76 | const PQGVerify *vfy, SECStatus *result); |
michael@0 | 77 | extern void PK11_PQG_DestroyParams(PQGParams *params); |
michael@0 | 78 | extern void PK11_PQG_DestroyVerify(PQGVerify *vfy); |
michael@0 | 79 | |
michael@0 | 80 | /************************************************************************** |
michael@0 | 81 | * Return a pointer to a new PQGParams struct that is constructed from * |
michael@0 | 82 | * copies of the arguments passed in. * |
michael@0 | 83 | * Return NULL on failure. * |
michael@0 | 84 | **************************************************************************/ |
michael@0 | 85 | extern PQGParams * PK11_PQG_NewParams(const SECItem * prime, const |
michael@0 | 86 | SECItem * subPrime, const SECItem * base); |
michael@0 | 87 | |
michael@0 | 88 | |
michael@0 | 89 | /************************************************************************** |
michael@0 | 90 | * Fills in caller's "prime" SECItem with the prime value in params. |
michael@0 | 91 | * Contents can be freed by calling SECITEM_FreeItem(prime, PR_FALSE); |
michael@0 | 92 | **************************************************************************/ |
michael@0 | 93 | extern SECStatus PK11_PQG_GetPrimeFromParams(const PQGParams *params, |
michael@0 | 94 | SECItem * prime); |
michael@0 | 95 | |
michael@0 | 96 | |
michael@0 | 97 | /************************************************************************** |
michael@0 | 98 | * Fills in caller's "subPrime" SECItem with the prime value in params. |
michael@0 | 99 | * Contents can be freed by calling SECITEM_FreeItem(subPrime, PR_FALSE); |
michael@0 | 100 | **************************************************************************/ |
michael@0 | 101 | extern SECStatus PK11_PQG_GetSubPrimeFromParams(const PQGParams *params, |
michael@0 | 102 | SECItem * subPrime); |
michael@0 | 103 | |
michael@0 | 104 | |
michael@0 | 105 | /************************************************************************** |
michael@0 | 106 | * Fills in caller's "base" SECItem with the base value in params. |
michael@0 | 107 | * Contents can be freed by calling SECITEM_FreeItem(base, PR_FALSE); |
michael@0 | 108 | **************************************************************************/ |
michael@0 | 109 | extern SECStatus PK11_PQG_GetBaseFromParams(const PQGParams *params, |
michael@0 | 110 | SECItem *base); |
michael@0 | 111 | |
michael@0 | 112 | |
michael@0 | 113 | /************************************************************************** |
michael@0 | 114 | * Return a pointer to a new PQGVerify struct that is constructed from * |
michael@0 | 115 | * copies of the arguments passed in. * |
michael@0 | 116 | * Return NULL on failure. * |
michael@0 | 117 | **************************************************************************/ |
michael@0 | 118 | extern PQGVerify * PK11_PQG_NewVerify(unsigned int counter, |
michael@0 | 119 | const SECItem * seed, const SECItem * h); |
michael@0 | 120 | |
michael@0 | 121 | |
michael@0 | 122 | /************************************************************************** |
michael@0 | 123 | * Returns "counter" value from the PQGVerify. |
michael@0 | 124 | **************************************************************************/ |
michael@0 | 125 | extern unsigned int PK11_PQG_GetCounterFromVerify(const PQGVerify *verify); |
michael@0 | 126 | |
michael@0 | 127 | /************************************************************************** |
michael@0 | 128 | * Fills in caller's "seed" SECItem with the seed value in verify. |
michael@0 | 129 | * Contents can be freed by calling SECITEM_FreeItem(seed, PR_FALSE); |
michael@0 | 130 | **************************************************************************/ |
michael@0 | 131 | extern SECStatus PK11_PQG_GetSeedFromVerify(const PQGVerify *verify, |
michael@0 | 132 | SECItem *seed); |
michael@0 | 133 | |
michael@0 | 134 | /************************************************************************** |
michael@0 | 135 | * Fills in caller's "h" SECItem with the h value in verify. |
michael@0 | 136 | * Contents can be freed by calling SECITEM_FreeItem(h, PR_FALSE); |
michael@0 | 137 | **************************************************************************/ |
michael@0 | 138 | extern SECStatus PK11_PQG_GetHFromVerify(const PQGVerify *verify, SECItem * h); |
michael@0 | 139 | |
michael@0 | 140 | SEC_END_PROTOS |
michael@0 | 141 | |
michael@0 | 142 | #endif |