PageRenderTime 62ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/gecko_api/include/secdert.h

http://firefox-mac-pdf.googlecode.com/
C Header | 163 lines | 51 code | 17 blank | 95 comment | 0 complexity | 9cc0fced0ab70fe1f7a99486783f80ca 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 _SECDERT_H_
  37. #define _SECDERT_H_
  38. /*
  39. * secdert.h - public data structures for the DER encoding and
  40. * decoding utilities library
  41. *
  42. * $Id: secdert.h,v 1.5 2007/10/12 01:44:51 julien.pierre.boogz%sun.com Exp $
  43. */
  44. #include "utilrename.h"
  45. #include "seccomon.h"
  46. typedef struct DERTemplateStr DERTemplate;
  47. /*
  48. ** An array of these structures defines an encoding for an object using DER.
  49. ** The array usually starts with a dummy entry whose kind is DER_SEQUENCE;
  50. ** such an array is terminated with an entry where kind == 0. (An array
  51. ** which consists of a single component does not require a second dummy
  52. ** entry -- the array is only searched as long as previous component(s)
  53. ** instruct it.)
  54. */
  55. struct DERTemplateStr {
  56. /*
  57. ** Kind of item being decoded/encoded, including tags and modifiers.
  58. */
  59. unsigned long kind;
  60. /*
  61. ** Offset from base of structure to field that holds the value
  62. ** being decoded/encoded.
  63. */
  64. unsigned int offset;
  65. /*
  66. ** When kind suggests it (DER_POINTER, DER_INDEFINITE, DER_INLINE),
  67. ** this points to a sub-template for nested encoding/decoding.
  68. */
  69. DERTemplate *sub;
  70. /*
  71. ** Argument value, dependent on "kind" and/or template placement
  72. ** within an array of templates:
  73. ** - In the first element of a template array, the value is the
  74. ** size of the structure to allocate when this template is being
  75. ** referenced by another template via DER_POINTER or DER_INDEFINITE.
  76. ** - In a component of a DER_SET or DER_SEQUENCE which is *not* a
  77. ** DER_UNIVERSAL type (that is, it has a class tag for either
  78. ** DER_APPLICATION, DER_CONTEXT_SPECIFIC, or DER_PRIVATE), the
  79. ** value is the underlying type of item being decoded/encoded.
  80. */
  81. unsigned long arg;
  82. };
  83. /************************************************************************/
  84. /* default chunksize for arenas used for DER stuff */
  85. #define DER_DEFAULT_CHUNKSIZE (2048)
  86. /*
  87. ** BER/DER values for ASN.1 identifier octets.
  88. */
  89. #define DER_TAG_MASK 0xff
  90. /*
  91. * BER/DER universal type tag numbers.
  92. * The values are defined by the X.208 standard; do not change them!
  93. * NOTE: if you add anything to this list, you must add code to derdec.c
  94. * to accept the tag, and probably also to derenc.c to encode it.
  95. */
  96. #define DER_TAGNUM_MASK 0x1f
  97. #define DER_BOOLEAN 0x01
  98. #define DER_INTEGER 0x02
  99. #define DER_BIT_STRING 0x03
  100. #define DER_OCTET_STRING 0x04
  101. #define DER_NULL 0x05
  102. #define DER_OBJECT_ID 0x06
  103. #define DER_SEQUENCE 0x10
  104. #define DER_SET 0x11
  105. #define DER_PRINTABLE_STRING 0x13
  106. #define DER_T61_STRING 0x14
  107. #define DER_IA5_STRING 0x16
  108. #define DER_UTC_TIME 0x17
  109. #define DER_VISIBLE_STRING 0x1a
  110. #define DER_HIGH_TAG_NUMBER 0x1f
  111. /*
  112. ** Modifiers to type tags. These are also specified by a/the
  113. ** standard, and must not be changed.
  114. */
  115. #define DER_METHOD_MASK 0x20
  116. #define DER_PRIMITIVE 0x00
  117. #define DER_CONSTRUCTED 0x20
  118. #define DER_CLASS_MASK 0xc0
  119. #define DER_UNIVERSAL 0x00
  120. #define DER_APPLICATION 0x40
  121. #define DER_CONTEXT_SPECIFIC 0x80
  122. #define DER_PRIVATE 0xc0
  123. /*
  124. ** Our additions, used for templates.
  125. ** These are not defined by any standard; the values are used internally only.
  126. ** Just be careful to keep them out of the low 8 bits.
  127. */
  128. #define DER_OPTIONAL 0x00100
  129. #define DER_EXPLICIT 0x00200
  130. #define DER_ANY 0x00400
  131. #define DER_INLINE 0x00800
  132. #define DER_POINTER 0x01000
  133. #define DER_INDEFINITE 0x02000
  134. #define DER_DERPTR 0x04000
  135. #define DER_SKIP 0x08000
  136. #define DER_FORCE 0x10000
  137. #define DER_OUTER 0x40000 /* for DER_DERPTR */
  138. /*
  139. ** Macro to convert der decoded bit string into a decoded octet
  140. ** string. All it needs to do is fiddle with the length code.
  141. */
  142. #define DER_ConvertBitString(item) \
  143. { \
  144. (item)->len = ((item)->len + 7) >> 3; \
  145. }
  146. #endif /* _SECDERT_H_ */