PageRenderTime 33ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/gecko_api/include/secdig.h

http://firefox-mac-pdf.googlecode.com/
C Header | 136 lines | 23 code | 18 blank | 95 comment | 0 complexity | 4b8c0c25917711c93012815ed131b764 MD5 | raw file
  1. /*
  2. * crypto.h - public data structures and prototypes for the crypto library
  3. *
  4. * ***** BEGIN LICENSE BLOCK *****
  5. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  6. *
  7. * The contents of this file are subject to the Mozilla Public License Version
  8. * 1.1 (the "License"); you may not use this file except in compliance with
  9. * the License. You may obtain a copy of the License at
  10. * http://www.mozilla.org/MPL/
  11. *
  12. * Software distributed under the License is distributed on an "AS IS" basis,
  13. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  14. * for the specific language governing rights and limitations under the
  15. * License.
  16. *
  17. * The Original Code is the Netscape security libraries.
  18. *
  19. * The Initial Developer of the Original Code is
  20. * Netscape Communications Corporation.
  21. * Portions created by the Initial Developer are Copyright (C) 1994-2000
  22. * the Initial Developer. All Rights Reserved.
  23. *
  24. * Contributor(s):
  25. *
  26. * Alternatively, the contents of this file may be used under the terms of
  27. * either the GNU General Public License Version 2 or later (the "GPL"), or
  28. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  29. * in which case the provisions of the GPL or the LGPL are applicable instead
  30. * of those above. If you wish to allow use of your version of this file only
  31. * under the terms of either the GPL or the LGPL, and not to allow others to
  32. * use your version of this file under the terms of the MPL, indicate your
  33. * decision by deleting the provisions above and replace them with the notice
  34. * and other provisions required by the GPL or the LGPL. If you do not delete
  35. * the provisions above, a recipient may use your version of this file under
  36. * the terms of any one of the MPL, the GPL or the LGPL.
  37. *
  38. * ***** END LICENSE BLOCK ***** */
  39. /* $Id: secdig.h,v 1.7 2007/11/07 02:37:22 julien.pierre.boogz%sun.com Exp $ */
  40. #ifndef _SECDIG_H_
  41. #define _SECDIG_H_
  42. #include "utilrename.h"
  43. #include "secdigt.h"
  44. #include "seccomon.h"
  45. #include "secasn1t.h"
  46. #include "secdert.h"
  47. SEC_BEGIN_PROTOS
  48. extern const SEC_ASN1Template sgn_DigestInfoTemplate[];
  49. SEC_ASN1_CHOOSER_DECLARE(sgn_DigestInfoTemplate)
  50. /****************************************/
  51. /*
  52. ** Digest-info functions
  53. */
  54. /*
  55. ** Create a new digest-info object
  56. ** "algorithm" one of SEC_OID_MD2, SEC_OID_MD5, or SEC_OID_SHA1
  57. ** "sig" the raw signature data (from MD2 or MD5)
  58. ** "sigLen" the length of the signature data
  59. **
  60. ** NOTE: this is a low level routine used to prepare some data for PKCS#1
  61. ** digital signature formatting.
  62. **
  63. ** XXX It might be nice to combine the create and encode functions.
  64. ** I think that is all anybody ever wants to do anyway.
  65. */
  66. extern SGNDigestInfo *SGN_CreateDigestInfo(SECOidTag algorithm,
  67. unsigned char *sig,
  68. unsigned int sigLen);
  69. /*
  70. ** Destroy a digest-info object
  71. */
  72. extern void SGN_DestroyDigestInfo(SGNDigestInfo *info);
  73. /*
  74. ** Encode a digest-info object
  75. ** "poolp" is where to allocate the result from; it can be NULL in
  76. ** which case generic heap allocation (XP_ALLOC) will be used
  77. ** "dest" is where to store the result; it can be NULL, in which case
  78. ** it will be allocated (from poolp or heap, as explained above)
  79. ** "diginfo" is the object to be encoded
  80. ** The return value is NULL if any error occurred, otherwise it is the
  81. ** resulting SECItem (either allocated or the same as the "dest" parameter).
  82. **
  83. ** XXX It might be nice to combine the create and encode functions.
  84. ** I think that is all anybody ever wants to do anyway.
  85. */
  86. extern SECItem *SGN_EncodeDigestInfo(PRArenaPool *poolp, SECItem *dest,
  87. SGNDigestInfo *diginfo);
  88. /*
  89. ** Decode a DER encoded digest info objct.
  90. ** didata is thr source of the encoded digest.
  91. ** The return value is NULL if an error occurs. Otherwise, a
  92. ** digest info object which is allocated within it's own
  93. ** pool is returned. The digest info should be deleted
  94. ** by later calling SGN_DestroyDigestInfo.
  95. */
  96. extern SGNDigestInfo *SGN_DecodeDigestInfo(SECItem *didata);
  97. /*
  98. ** Copy digest info.
  99. ** poolp is the arena to which the digest will be copied.
  100. ** a is the destination digest, it must be non-NULL.
  101. ** b is the source digest
  102. ** This function is for copying digests. It allows digests
  103. ** to be copied into a specified pool. If the digest is in
  104. ** the same pool as other data, you do not want to delete
  105. ** the digest by calling SGN_DestroyDigestInfo.
  106. ** A return value of SECFailure indicates an error. A return
  107. ** of SECSuccess indicates no error occured.
  108. */
  109. extern SECStatus SGN_CopyDigestInfo(PRArenaPool *poolp,
  110. SGNDigestInfo *a,
  111. SGNDigestInfo *b);
  112. /*
  113. ** Compare two digest-info objects, returning the difference between
  114. ** them.
  115. */
  116. extern SECComparison SGN_CompareDigestInfo(SGNDigestInfo *a, SGNDigestInfo *b);
  117. SEC_END_PROTOS
  118. #endif /* _SECDIG_H_ */