PageRenderTime 32ms CodeModel.GetById 6ms app.highlight 20ms RepoModel.GetById 1ms app.codeStats 1ms

/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/*
 38 * Templates that are compiled and exported from both libnss3 and libnssutil3.
 39 * They have to be, because they were previously exported from libnss3, and
 40 * there is no way to create data forwarder symbols on Unix.
 41 *
 42 * Please do not add to this file. New shared templates should be exported
 43 * from libnssutil3 only.
 44 *
 45 */
 46
 47#include "utilrename.h"
 48#include "secasn1.h"
 49#include "secder.h"
 50#include "secoid.h"
 51#include "secdig.h"
 52
 53const SEC_ASN1Template SECOID_AlgorithmIDTemplate[] = {
 54    { SEC_ASN1_SEQUENCE,
 55	  0, NULL, sizeof(SECAlgorithmID) },
 56    { SEC_ASN1_OBJECT_ID,
 57	  offsetof(SECAlgorithmID,algorithm), },
 58    { SEC_ASN1_OPTIONAL | SEC_ASN1_ANY,
 59	  offsetof(SECAlgorithmID,parameters), },
 60    { 0, }
 61};
 62
 63SEC_ASN1_CHOOSER_IMPLEMENT(SECOID_AlgorithmIDTemplate)
 64
 65const SEC_ASN1Template SEC_AnyTemplate[] = {
 66    { SEC_ASN1_ANY | SEC_ASN1_MAY_STREAM, 0, NULL, sizeof(SECItem) }
 67};
 68
 69SEC_ASN1_CHOOSER_IMPLEMENT(SEC_AnyTemplate)
 70
 71const SEC_ASN1Template SEC_BMPStringTemplate[] = {
 72    { SEC_ASN1_BMP_STRING | SEC_ASN1_MAY_STREAM, 0, NULL, sizeof(SECItem) }
 73};
 74
 75SEC_ASN1_CHOOSER_IMPLEMENT(SEC_BMPStringTemplate)
 76
 77const SEC_ASN1Template SEC_BitStringTemplate[] = {
 78    { SEC_ASN1_BIT_STRING | SEC_ASN1_MAY_STREAM, 0, NULL, sizeof(SECItem) }
 79};
 80
 81SEC_ASN1_CHOOSER_IMPLEMENT(SEC_BitStringTemplate)
 82
 83const SEC_ASN1Template SEC_BooleanTemplate[] = {
 84    { SEC_ASN1_BOOLEAN, 0, NULL, sizeof(SECItem) }
 85};
 86
 87SEC_ASN1_CHOOSER_IMPLEMENT(SEC_BooleanTemplate)
 88
 89const SEC_ASN1Template SEC_GeneralizedTimeTemplate[] = {
 90    { SEC_ASN1_GENERALIZED_TIME | SEC_ASN1_MAY_STREAM, 0, NULL, sizeof(SECItem)}
 91};
 92
 93SEC_ASN1_CHOOSER_IMPLEMENT(SEC_GeneralizedTimeTemplate)
 94
 95const SEC_ASN1Template SEC_IA5StringTemplate[] = {
 96    { SEC_ASN1_IA5_STRING | SEC_ASN1_MAY_STREAM, 0, NULL, sizeof(SECItem) }
 97};
 98
 99SEC_ASN1_CHOOSER_IMPLEMENT(SEC_IA5StringTemplate)
100
101const SEC_ASN1Template SEC_IntegerTemplate[] = {
102    { SEC_ASN1_INTEGER, 0, NULL, sizeof(SECItem) }
103};
104
105SEC_ASN1_CHOOSER_IMPLEMENT(SEC_IntegerTemplate)
106
107const SEC_ASN1Template SEC_NullTemplate[] = {
108    { SEC_ASN1_NULL, 0, NULL, sizeof(SECItem) }
109};
110
111SEC_ASN1_CHOOSER_IMPLEMENT(SEC_NullTemplate)
112
113const SEC_ASN1Template SEC_ObjectIDTemplate[] = {
114    { SEC_ASN1_OBJECT_ID, 0, NULL, sizeof(SECItem) }
115};
116
117SEC_ASN1_CHOOSER_IMPLEMENT(SEC_ObjectIDTemplate)
118
119const SEC_ASN1Template SEC_OctetStringTemplate[] = {
120    { SEC_ASN1_OCTET_STRING | SEC_ASN1_MAY_STREAM, 0, NULL, sizeof(SECItem) }
121};
122
123SEC_ASN1_CHOOSER_IMPLEMENT(SEC_OctetStringTemplate)
124
125const SEC_ASN1Template SEC_PointerToAnyTemplate[] = {
126    { SEC_ASN1_POINTER, 0, SEC_AnyTemplate }
127};
128
129SEC_ASN1_CHOOSER_IMPLEMENT(SEC_PointerToAnyTemplate)
130
131const SEC_ASN1Template SEC_PointerToOctetStringTemplate[] = {
132    { SEC_ASN1_POINTER | SEC_ASN1_MAY_STREAM, 0, SEC_OctetStringTemplate }
133};
134
135SEC_ASN1_CHOOSER_IMPLEMENT(SEC_PointerToOctetStringTemplate)
136
137const SEC_ASN1Template SEC_SetOfAnyTemplate[] = {
138    { SEC_ASN1_SET_OF, 0, SEC_AnyTemplate }
139};
140
141SEC_ASN1_CHOOSER_IMPLEMENT(SEC_SetOfAnyTemplate)
142
143const SEC_ASN1Template SEC_UTCTimeTemplate[] = {
144    { SEC_ASN1_UTC_TIME | SEC_ASN1_MAY_STREAM, 0, NULL, sizeof(SECItem) }
145};
146
147SEC_ASN1_CHOOSER_IMPLEMENT(SEC_UTCTimeTemplate)
148
149const SEC_ASN1Template SEC_UTF8StringTemplate[] = {
150    { SEC_ASN1_UTF8_STRING | SEC_ASN1_MAY_STREAM, 0, NULL, sizeof(SECItem)}
151};
152
153SEC_ASN1_CHOOSER_IMPLEMENT(SEC_UTF8StringTemplate)
154
155/* XXX See comment below about SGN_DecodeDigestInfo -- keep this static! */
156/* XXX Changed from static -- need to change name? */
157const SEC_ASN1Template sgn_DigestInfoTemplate[] = {
158    { SEC_ASN1_SEQUENCE,
159	  0, NULL, sizeof(SGNDigestInfo) },
160    { SEC_ASN1_INLINE,
161	  offsetof(SGNDigestInfo,digestAlgorithm),
162	  SECOID_AlgorithmIDTemplate },
163    { SEC_ASN1_OCTET_STRING,
164	  offsetof(SGNDigestInfo,digest) },
165    { 0 }
166};
167
168SEC_ASN1_CHOOSER_IMPLEMENT(sgn_DigestInfoTemplate)