/security/nss/lib/util/templates.c

http://github.com/zpao/v8monkey · C · 168 lines · 86 code · 36 blank · 46 comment · 0 complexity · 64b4f2f0d8bd7a75c2a75b60632f1d8d 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 Network Security Services libraries.
  15. *
  16. * The Initial Developer of the Original Code is
  17. * Sun Microsystems, Inc.
  18. * Portions created by the Initial Developer are Copyright (C) 2007
  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. /*
  37. * Templates that are compiled and exported from both libnss3 and libnssutil3.
  38. * They have to be, because they were previously exported from libnss3, and
  39. * there is no way to create data forwarder symbols on Unix.
  40. *
  41. * Please do not add to this file. New shared templates should be exported
  42. * from libnssutil3 only.
  43. *
  44. */
  45. #include "utilrename.h"
  46. #include "secasn1.h"
  47. #include "secder.h"
  48. #include "secoid.h"
  49. #include "secdig.h"
  50. const SEC_ASN1Template SECOID_AlgorithmIDTemplate[] = {
  51. { SEC_ASN1_SEQUENCE,
  52. 0, NULL, sizeof(SECAlgorithmID) },
  53. { SEC_ASN1_OBJECT_ID,
  54. offsetof(SECAlgorithmID,algorithm), },
  55. { SEC_ASN1_OPTIONAL | SEC_ASN1_ANY,
  56. offsetof(SECAlgorithmID,parameters), },
  57. { 0, }
  58. };
  59. SEC_ASN1_CHOOSER_IMPLEMENT(SECOID_AlgorithmIDTemplate)
  60. const SEC_ASN1Template SEC_AnyTemplate[] = {
  61. { SEC_ASN1_ANY | SEC_ASN1_MAY_STREAM, 0, NULL, sizeof(SECItem) }
  62. };
  63. SEC_ASN1_CHOOSER_IMPLEMENT(SEC_AnyTemplate)
  64. const SEC_ASN1Template SEC_BMPStringTemplate[] = {
  65. { SEC_ASN1_BMP_STRING | SEC_ASN1_MAY_STREAM, 0, NULL, sizeof(SECItem) }
  66. };
  67. SEC_ASN1_CHOOSER_IMPLEMENT(SEC_BMPStringTemplate)
  68. const SEC_ASN1Template SEC_BitStringTemplate[] = {
  69. { SEC_ASN1_BIT_STRING | SEC_ASN1_MAY_STREAM, 0, NULL, sizeof(SECItem) }
  70. };
  71. SEC_ASN1_CHOOSER_IMPLEMENT(SEC_BitStringTemplate)
  72. const SEC_ASN1Template SEC_BooleanTemplate[] = {
  73. { SEC_ASN1_BOOLEAN, 0, NULL, sizeof(SECItem) }
  74. };
  75. SEC_ASN1_CHOOSER_IMPLEMENT(SEC_BooleanTemplate)
  76. const SEC_ASN1Template SEC_GeneralizedTimeTemplate[] = {
  77. { SEC_ASN1_GENERALIZED_TIME | SEC_ASN1_MAY_STREAM, 0, NULL, sizeof(SECItem)}
  78. };
  79. SEC_ASN1_CHOOSER_IMPLEMENT(SEC_GeneralizedTimeTemplate)
  80. const SEC_ASN1Template SEC_IA5StringTemplate[] = {
  81. { SEC_ASN1_IA5_STRING | SEC_ASN1_MAY_STREAM, 0, NULL, sizeof(SECItem) }
  82. };
  83. SEC_ASN1_CHOOSER_IMPLEMENT(SEC_IA5StringTemplate)
  84. const SEC_ASN1Template SEC_IntegerTemplate[] = {
  85. { SEC_ASN1_INTEGER, 0, NULL, sizeof(SECItem) }
  86. };
  87. SEC_ASN1_CHOOSER_IMPLEMENT(SEC_IntegerTemplate)
  88. const SEC_ASN1Template SEC_NullTemplate[] = {
  89. { SEC_ASN1_NULL, 0, NULL, sizeof(SECItem) }
  90. };
  91. SEC_ASN1_CHOOSER_IMPLEMENT(SEC_NullTemplate)
  92. const SEC_ASN1Template SEC_ObjectIDTemplate[] = {
  93. { SEC_ASN1_OBJECT_ID, 0, NULL, sizeof(SECItem) }
  94. };
  95. SEC_ASN1_CHOOSER_IMPLEMENT(SEC_ObjectIDTemplate)
  96. const SEC_ASN1Template SEC_OctetStringTemplate[] = {
  97. { SEC_ASN1_OCTET_STRING | SEC_ASN1_MAY_STREAM, 0, NULL, sizeof(SECItem) }
  98. };
  99. SEC_ASN1_CHOOSER_IMPLEMENT(SEC_OctetStringTemplate)
  100. const SEC_ASN1Template SEC_PointerToAnyTemplate[] = {
  101. { SEC_ASN1_POINTER, 0, SEC_AnyTemplate }
  102. };
  103. SEC_ASN1_CHOOSER_IMPLEMENT(SEC_PointerToAnyTemplate)
  104. const SEC_ASN1Template SEC_PointerToOctetStringTemplate[] = {
  105. { SEC_ASN1_POINTER | SEC_ASN1_MAY_STREAM, 0, SEC_OctetStringTemplate }
  106. };
  107. SEC_ASN1_CHOOSER_IMPLEMENT(SEC_PointerToOctetStringTemplate)
  108. const SEC_ASN1Template SEC_SetOfAnyTemplate[] = {
  109. { SEC_ASN1_SET_OF, 0, SEC_AnyTemplate }
  110. };
  111. SEC_ASN1_CHOOSER_IMPLEMENT(SEC_SetOfAnyTemplate)
  112. const SEC_ASN1Template SEC_UTCTimeTemplate[] = {
  113. { SEC_ASN1_UTC_TIME | SEC_ASN1_MAY_STREAM, 0, NULL, sizeof(SECItem) }
  114. };
  115. SEC_ASN1_CHOOSER_IMPLEMENT(SEC_UTCTimeTemplate)
  116. const SEC_ASN1Template SEC_UTF8StringTemplate[] = {
  117. { SEC_ASN1_UTF8_STRING | SEC_ASN1_MAY_STREAM, 0, NULL, sizeof(SECItem)}
  118. };
  119. SEC_ASN1_CHOOSER_IMPLEMENT(SEC_UTF8StringTemplate)
  120. /* XXX See comment below about SGN_DecodeDigestInfo -- keep this static! */
  121. /* XXX Changed from static -- need to change name? */
  122. const SEC_ASN1Template sgn_DigestInfoTemplate[] = {
  123. { SEC_ASN1_SEQUENCE,
  124. 0, NULL, sizeof(SGNDigestInfo) },
  125. { SEC_ASN1_INLINE,
  126. offsetof(SGNDigestInfo,digestAlgorithm),
  127. SECOID_AlgorithmIDTemplate },
  128. { SEC_ASN1_OCTET_STRING,
  129. offsetof(SGNDigestInfo,digest) },
  130. { 0 }
  131. };
  132. SEC_ASN1_CHOOSER_IMPLEMENT(sgn_DigestInfoTemplate)