secdig.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * secdig.h - public prototypes for digest-info functions
  3. *
  4. * This Source Code Form is subject to the terms of the Mozilla Public
  5. * License, v. 2.0. If a copy of the MPL was not distributed with this
  6. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  7. #ifndef _SECDIG_H_
  8. #define _SECDIG_H_
  9. #include "utilrename.h"
  10. #include "secdigt.h"
  11. #include "seccomon.h"
  12. #include "secasn1t.h"
  13. #include "secdert.h"
  14. SEC_BEGIN_PROTOS
  15. extern const SEC_ASN1Template sgn_DigestInfoTemplate[];
  16. SEC_ASN1_CHOOSER_DECLARE(sgn_DigestInfoTemplate)
  17. /****************************************/
  18. /*
  19. ** Digest-info functions
  20. */
  21. /*
  22. ** Create a new digest-info object
  23. ** "algorithm" one of SEC_OID_MD2, SEC_OID_MD5, or SEC_OID_SHA1
  24. ** "sig" the raw signature data (from MD2 or MD5)
  25. ** "sigLen" the length of the signature data
  26. **
  27. ** NOTE: this is a low level routine used to prepare some data for PKCS#1
  28. ** digital signature formatting.
  29. **
  30. ** XXX It might be nice to combine the create and encode functions.
  31. ** I think that is all anybody ever wants to do anyway.
  32. */
  33. extern SGNDigestInfo *SGN_CreateDigestInfo(SECOidTag algorithm,
  34. const unsigned char *sig,
  35. unsigned int sigLen);
  36. /*
  37. ** Destroy a digest-info object
  38. */
  39. extern void SGN_DestroyDigestInfo(SGNDigestInfo *info);
  40. /*
  41. ** Encode a digest-info object
  42. ** "poolp" is where to allocate the result from; it can be NULL in
  43. ** which case generic heap allocation (XP_ALLOC) will be used
  44. ** "dest" is where to store the result; it can be NULL, in which case
  45. ** it will be allocated (from poolp or heap, as explained above)
  46. ** "diginfo" is the object to be encoded
  47. ** The return value is NULL if any error occurred, otherwise it is the
  48. ** resulting SECItem (either allocated or the same as the "dest" parameter).
  49. **
  50. ** XXX It might be nice to combine the create and encode functions.
  51. ** I think that is all anybody ever wants to do anyway.
  52. */
  53. extern SECItem *SGN_EncodeDigestInfo(PLArenaPool *poolp, SECItem *dest,
  54. SGNDigestInfo *diginfo);
  55. /*
  56. ** Decode a DER encoded digest info objct.
  57. ** didata is thr source of the encoded digest.
  58. ** The return value is NULL if an error occurs. Otherwise, a
  59. ** digest info object which is allocated within it's own
  60. ** pool is returned. The digest info should be deleted
  61. ** by later calling SGN_DestroyDigestInfo.
  62. */
  63. extern SGNDigestInfo *SGN_DecodeDigestInfo(SECItem *didata);
  64. /*
  65. ** Copy digest info.
  66. ** poolp is the arena to which the digest will be copied.
  67. ** a is the destination digest, it must be non-NULL.
  68. ** b is the source digest
  69. ** This function is for copying digests. It allows digests
  70. ** to be copied into a specified pool. If the digest is in
  71. ** the same pool as other data, you do not want to delete
  72. ** the digest by calling SGN_DestroyDigestInfo.
  73. ** A return value of SECFailure indicates an error. A return
  74. ** of SECSuccess indicates no error occurred.
  75. */
  76. extern SECStatus SGN_CopyDigestInfo(PLArenaPool *poolp,
  77. SGNDigestInfo *a,
  78. SGNDigestInfo *b);
  79. /*
  80. ** Compare two digest-info objects, returning the difference between
  81. ** them.
  82. */
  83. extern SECComparison SGN_CompareDigestInfo(SGNDigestInfo *a, SGNDigestInfo *b);
  84. SEC_END_PROTOS
  85. #endif /* _SECDIG_H_ */