PageRenderTime 44ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/gecko_api/include/pk11pqg.h

http://firefox-mac-pdf.googlecode.com/
C Header | 155 lines | 28 code | 22 blank | 105 comment | 0 complexity | 19c80c7492a750e7431a6ed382234e12 MD5 | raw file
  1. /* ***** BEGIN LICENSE BLOCK *****
  2. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3. *
  4. * The contents of this file are subject to the Mozilla Public License Version
  5. * 1.1 (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. * http://www.mozilla.org/MPL/
  8. *
  9. * Software distributed under the License is distributed on an "AS IS" basis,
  10. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. * for the specific language governing rights and limitations under the
  12. * License.
  13. *
  14. * The Original Code is the Netscape security libraries.
  15. *
  16. * The Initial Developer of the Original Code is
  17. * Netscape Communications Corporation.
  18. * Portions created by the Initial Developer are Copyright (C) 1994-2001
  19. * the Initial Developer. All Rights Reserved.
  20. *
  21. * Contributor(s):
  22. *
  23. * Alternatively, the contents of this file may be used under the terms of
  24. * either the GNU General Public License Version 2 or later (the "GPL"), or
  25. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  26. * in which case the provisions of the GPL or the LGPL are applicable instead
  27. * of those above. If you wish to allow use of your version of this file only
  28. * under the terms of either the GPL or the LGPL, and not to allow others to
  29. * use your version of this file under the terms of the MPL, indicate your
  30. * decision by deleting the provisions above and replace them with the notice
  31. * and other provisions required by the GPL or the LGPL. If you do not delete
  32. * the provisions above, a recipient may use your version of this file under
  33. * the terms of any one of the MPL, the GPL or the LGPL.
  34. *
  35. * ***** END LICENSE BLOCK ***** */
  36. /* Thse functions are stub functions which will get replaced with calls through
  37. * PKCS #11.
  38. */
  39. #ifndef _PK11PQG_H_
  40. #define _PK11PQG_H_ 1
  41. #include "blapit.h"
  42. SEC_BEGIN_PROTOS
  43. /* Generate PQGParams and PQGVerify structs.
  44. * Length of seed and length of h both equal length of P.
  45. * All lengths are specified by "j", according to the table above.
  46. */
  47. extern SECStatus PK11_PQG_ParamGen(unsigned int j, PQGParams **pParams,
  48. PQGVerify **pVfy);
  49. /* Generate PQGParams and PQGVerify structs.
  50. * Length of P specified by j. Length of h will match length of P.
  51. * Length of SEED in bytes specified in seedBytes.
  52. * seedBbytes must be in the range [20..255] or an error will result.
  53. */
  54. extern SECStatus PK11_PQG_ParamGenSeedLen( unsigned int j,
  55. unsigned int seedBytes, PQGParams **pParams, PQGVerify **pVfy);
  56. /* Test PQGParams for validity as DSS PQG values.
  57. * If vfy is non-NULL, test PQGParams to make sure they were generated
  58. * using the specified seed, counter, and h values.
  59. *
  60. * Return value indicates whether Verification operation ran succesfully
  61. * to completion, but does not indicate if PQGParams are valid or not.
  62. * If return value is SECSuccess, then *pResult has these meanings:
  63. * SECSuccess: PQGParams are valid.
  64. * SECFailure: PQGParams are invalid.
  65. *
  66. * Verify the following 12 facts about PQG counter SEED g and h
  67. * 1. Q is 160 bits long.
  68. * 2. P is one of the 9 valid lengths.
  69. * 3. G < P
  70. * 4. P % Q == 1
  71. * 5. Q is prime
  72. * 6. P is prime
  73. * Steps 7-12 are done only if the optional PQGVerify is supplied.
  74. * 7. counter < 4096
  75. * 8. g >= 160 and g < 2048 (g is length of seed in bits)
  76. * 9. Q generated from SEED matches Q in PQGParams.
  77. * 10. P generated from (L, counter, g, SEED, Q) matches P in PQGParams.
  78. * 11. 1 < h < P-1
  79. * 12. G generated from h matches G in PQGParams.
  80. */
  81. extern SECStatus PK11_PQG_VerifyParams(const PQGParams *params,
  82. const PQGVerify *vfy, SECStatus *result);
  83. extern void PK11_PQG_DestroyParams(PQGParams *params);
  84. extern void PK11_PQG_DestroyVerify(PQGVerify *vfy);
  85. /**************************************************************************
  86. * Return a pointer to a new PQGParams struct that is constructed from *
  87. * copies of the arguments passed in. *
  88. * Return NULL on failure. *
  89. **************************************************************************/
  90. extern PQGParams * PK11_PQG_NewParams(const SECItem * prime, const
  91. SECItem * subPrime, const SECItem * base);
  92. /**************************************************************************
  93. * Fills in caller's "prime" SECItem with the prime value in params.
  94. * Contents can be freed by calling SECITEM_FreeItem(prime, PR_FALSE);
  95. **************************************************************************/
  96. extern SECStatus PK11_PQG_GetPrimeFromParams(const PQGParams *params,
  97. SECItem * prime);
  98. /**************************************************************************
  99. * Fills in caller's "subPrime" SECItem with the prime value in params.
  100. * Contents can be freed by calling SECITEM_FreeItem(subPrime, PR_FALSE);
  101. **************************************************************************/
  102. extern SECStatus PK11_PQG_GetSubPrimeFromParams(const PQGParams *params,
  103. SECItem * subPrime);
  104. /**************************************************************************
  105. * Fills in caller's "base" SECItem with the base value in params.
  106. * Contents can be freed by calling SECITEM_FreeItem(base, PR_FALSE);
  107. **************************************************************************/
  108. extern SECStatus PK11_PQG_GetBaseFromParams(const PQGParams *params,
  109. SECItem *base);
  110. /**************************************************************************
  111. * Return a pointer to a new PQGVerify struct that is constructed from *
  112. * copies of the arguments passed in. *
  113. * Return NULL on failure. *
  114. **************************************************************************/
  115. extern PQGVerify * PK11_PQG_NewVerify(unsigned int counter,
  116. const SECItem * seed, const SECItem * h);
  117. /**************************************************************************
  118. * Returns "counter" value from the PQGVerify.
  119. **************************************************************************/
  120. extern unsigned int PK11_PQG_GetCounterFromVerify(const PQGVerify *verify);
  121. /**************************************************************************
  122. * Fills in caller's "seed" SECItem with the seed value in verify.
  123. * Contents can be freed by calling SECITEM_FreeItem(seed, PR_FALSE);
  124. **************************************************************************/
  125. extern SECStatus PK11_PQG_GetSeedFromVerify(const PQGVerify *verify,
  126. SECItem *seed);
  127. /**************************************************************************
  128. * Fills in caller's "h" SECItem with the h value in verify.
  129. * Contents can be freed by calling SECITEM_FreeItem(h, PR_FALSE);
  130. **************************************************************************/
  131. extern SECStatus PK11_PQG_GetHFromVerify(const PQGVerify *verify, SECItem * h);
  132. SEC_END_PROTOS
  133. #endif