PageRenderTime 39ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/gecko_api/include/secoid.h

http://firefox-mac-pdf.googlecode.com/
C Header | 152 lines | 31 code | 23 blank | 98 comment | 0 complexity | dec9b86eff3dc0cc7330af21f162e3b8 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-2000
  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. #ifndef _SECOID_H_
  37. #define _SECOID_H_
  38. #include "utilrename.h"
  39. /*
  40. * secoid.h - public data structures and prototypes for ASN.1 OID functions
  41. *
  42. * $Id: secoid.h,v 1.9 2008/02/16 04:38:09 julien.pierre.boogz%sun.com Exp $
  43. */
  44. #include "plarena.h"
  45. #include "seccomon.h"
  46. #include "secoidt.h"
  47. #include "secasn1t.h"
  48. SEC_BEGIN_PROTOS
  49. extern const SEC_ASN1Template SECOID_AlgorithmIDTemplate[];
  50. /* This functions simply returns the address of the above-declared template. */
  51. SEC_ASN1_CHOOSER_DECLARE(SECOID_AlgorithmIDTemplate)
  52. /*
  53. * OID handling routines
  54. */
  55. extern SECOidData *SECOID_FindOID( const SECItem *oid);
  56. extern SECOidTag SECOID_FindOIDTag(const SECItem *oid);
  57. extern SECOidData *SECOID_FindOIDByTag(SECOidTag tagnum);
  58. extern SECOidData *SECOID_FindOIDByMechanism(unsigned long mechanism);
  59. /****************************************/
  60. /*
  61. ** Algorithm id handling operations
  62. */
  63. /*
  64. ** Fill in an algorithm-ID object given a tag and some parameters.
  65. ** "aid" where the DER encoded algorithm info is stored (memory
  66. ** is allocated)
  67. ** "tag" the tag number defining the algorithm
  68. ** "params" if not NULL, the parameters to go with the algorithm
  69. */
  70. extern SECStatus SECOID_SetAlgorithmID(PRArenaPool *arena, SECAlgorithmID *aid,
  71. SECOidTag tag, SECItem *params);
  72. /*
  73. ** Copy the "src" object to "dest". Memory is allocated in "dest" for
  74. ** each of the appropriate sub-objects. Memory in "dest" is not freed
  75. ** before memory is allocated (use SECOID_DestroyAlgorithmID(dest, PR_FALSE)
  76. ** to do that).
  77. */
  78. extern SECStatus SECOID_CopyAlgorithmID(PRArenaPool *arena, SECAlgorithmID *dest,
  79. SECAlgorithmID *src);
  80. /*
  81. ** Get the tag number for the given algorithm-id object.
  82. */
  83. extern SECOidTag SECOID_GetAlgorithmTag(SECAlgorithmID *aid);
  84. /*
  85. ** Destroy an algorithm-id object.
  86. ** "aid" the certificate-request to destroy
  87. ** "freeit" if PR_TRUE then free the object as well as its sub-objects
  88. */
  89. extern void SECOID_DestroyAlgorithmID(SECAlgorithmID *aid, PRBool freeit);
  90. /*
  91. ** Compare two algorithm-id objects, returning the difference between
  92. ** them.
  93. */
  94. extern SECComparison SECOID_CompareAlgorithmID(SECAlgorithmID *a,
  95. SECAlgorithmID *b);
  96. extern PRBool SECOID_KnownCertExtenOID (SECItem *extenOid);
  97. /* Given a tag number, return a string describing it.
  98. */
  99. extern const char *SECOID_FindOIDTagDescription(SECOidTag tagnum);
  100. /* Add a dynamic SECOidData to the dynamic OID table.
  101. ** Routine copies the src entry, and returns the new SECOidTag.
  102. ** Returns SEC_OID_INVALID if failed to add for some reason.
  103. */
  104. extern SECOidTag SECOID_AddEntry(const SECOidData * src);
  105. /*
  106. * initialize the oid data structures.
  107. */
  108. extern SECStatus SECOID_Init(void);
  109. /*
  110. * free up the oid data structures.
  111. */
  112. extern SECStatus SECOID_Shutdown(void);
  113. /* if to->data is not NULL, and to->len is large enough to hold the result,
  114. * then the resultant OID will be copyed into to->data, and to->len will be
  115. * changed to show the actual OID length.
  116. * Otherwise, memory for the OID will be allocated (from the caller's
  117. * PLArenaPool, if pool is non-NULL) and to->data will receive the address
  118. * of the allocated data, and to->len will receive the OID length.
  119. * The original value of to->data is not freed when a new buffer is allocated.
  120. *
  121. * The input string may begin with "OID." and this still be ignored.
  122. * The length of the input string is given in len. If len == 0, then
  123. * len will be computed as strlen(from), meaning it must be NUL terminated.
  124. * It is an error if from == NULL, or if *from == '\0'.
  125. */
  126. extern SECStatus SEC_StringToOID(PLArenaPool *pool, SECItem *to,
  127. const char *from, PRUint32 len);
  128. SEC_END_PROTOS
  129. #endif /* _SECOID_H_ */