1
/**************************************************************************
2
*** COPYRIGHT (c) 2002 by TransNexus, Inc. ***
4
*** This software is property of TransNexus, Inc. ***
5
*** This software is freely available under license from TransNexus. ***
6
*** The license terms and conditions for free use of this software by ***
7
*** third parties are defined in the OSP Toolkit Software License ***
8
*** Agreement (LICENSE.txt). Any use of this software by third ***
9
*** parties, which does not comply with the terms and conditions of the ***
10
*** OSP Toolkit Software License Agreement is prohibited without ***
11
*** the prior, express, written consent of TransNexus, Inc. ***
13
*** Thank you for using the OSP ToolKit(TM). Please report any bugs, ***
14
*** suggestions or feedback to support@transnexus.com ***
16
**************************************************************************/
26
* ospasn1parse.c - Member functions for ASN1 parsing library
30
#include "osp/ospasn1.h"
31
#include "osp/osptnlog.h"
33
/* ---------------------------------------------------------*/
34
/* Member functions */
35
/* ---------------------------------------------------------*/
40
THE PARSE RESULTS TABLE WILL HAVE:
41
The parse results table will provide a cross reference for values found in
42
the element info list (derived from breaking down the asn1 encoded data)
43
Only the fields found will be included. It will be the respsibility of the
44
program that called the parser to handle missing fields correctly. The
45
parseing program must also handle multiple occurrances of a field. This
46
table will only be returned if the parse is error free.
48
datafieldid Number referenceing the data structure field data is stored in.
50
This will come from the parse table for an entry.
52
Scan table looking for this reference number when trying to
53
populate data structure fields. Scanning program must know
54
if field is required, whether it can have multiple
57
datafieldindex If a data field id can have multiple occurances, then this
58
value indicates which occurance it is. 0 indicates it is
61
treeAddress Tree address to the data.
63
Format is 1.2.3: Last index should be a primitive. Other
64
indexes must be constructed.
66
Count index following next pointers. Follow child pointer at
69
null indicates not found.
71
use this value to walk the tree to find the eInfo element.
73
used for diagnostics only.
76
eInfoPtr Pointer to eInfo structure that contains the element
77
related to the data structure field. Extractor can access
78
data by value, element, or element content.
80
null indicates not found.
82
defaultValuePtr Null indicates eInfoPtr should be followed for data. If
83
not null, then a void pointer is set to point to the
84
default data contained in the parse table. It is
85
appliation dependent what is actually stored there.
87
THE PARSING TABLE WILL HAVE:
88
A complete description of the structure being parsed. Default fields, etc
89
must be described. All elements will be described. The description will
90
Fields must be in the order they occur in the table.
92
componentname Used for diagnostics.
94
Textual description of the expected element.
96
parsetableid Enum indicating a parse table to use for recursive parse.
97
if PRIMITIVE, (datafieldid != NONE), then no parsetable should
98
be followed - generate a parse result record and write it to
101
If constructed, recursively parse current element using
102
parsetableid to reference the appropriate parse table for the
105
If SEQUENCE, then get subsequent elements in parse table.
107
If SET, then get subsequent elements in table, repeat according to the min/max fields.
109
If SET_OF, then get subsequent elements in table, repeat
110
according to min/max fields
119
datafieldid Field reference (context specific) to used by calling
120
routine to reference the fields in the data structure.
121
When a parse result record is written, this datafieldid is
122
written to it so the calling program will have something to
123
search for to find data for a particular data structure
125
ex: When the calling program is ready to populate the
126
version number field for a certificate. It would look
127
for a record in the parse results table whose
128
datafieldid is OSPE_ASN1_X509_CERT_FIELD_ID_VERSION.
129
If it finds the record, it can go to the data through
130
the eInfo pointer field, or if the eInfo pointer field
131
is empty, it can get default data from the defaultvalue
132
field in the parse results table.
134
minimumnumber Minimum number of this type of element
136
maximumnumber Maximum number of this type of element
138
defaultvaluePtr If null, then no default data is provided. If not null,
139
then it is a void pointer to something. pointer to a
140
number, pointer to a string (ASN1 encoding of the defualt value.
141
Initialize the parse table as necessary. Assume the
142
reading application will figure out what to do with the
143
pointer it finds. If not null, then a parse error occurs
144
when an element is not found if a minimum is required.
146
BOOLEAN TYPE IS A PRIMITIVE 0x01 0x01 0xFF(TRUE) 0x00(FALSE)
150
static OSPTASN1PARSETABLE ospgParseTable_NotDefined[] =
152
{"NotDefined", OSPC_TAG_TYPE_NULL,
153
OSPEPTID_NOTDEFINED, 0x0, 0, 0, 0, 0},
158
static OSPTASN1PARSETABLE ospgParseTable_Certificate[] =
160
{"Certificate", OSPC_TAG_TYPE_SEQUENCE,
161
OSPEPTID_NOTDEFINED, 0x0, 1, 1, 0, 0},
162
{"tbsCertificate", OSPC_TAG_TYPE_DERIVED,
163
OSPEPTID_TBSCERTIFICATE,0x1, 1, 1, 0, 0},
164
{"signatureAlgorithm", OSPC_TAG_TYPE_DERIVED,
165
OSPEPTID_DERALGORITHMID,0x2, 1, 1, 0, 0},
166
{"signature", OSPC_TAG_TYPE_BIT_STRING,
167
OSPEPTID_NOTDEFINED, 0x3, 1, 1, 0, 0},
171
static OSPTASN1PARSETABLE ospgParseTable_TBSCertificate[] =
173
{"TBSCertificate", OSPC_TAG_TYPE_SEQUENCE,
174
OSPEPTID_NOTDEFINED, 0x0, 1, 1, 0, 0},
175
{"version", OSPC_TAG_TYPE_DERIVED,
176
OSPEPTID_EXPLICIT_VERSION,
178
{"serialNumber", OSPC_TAG_TYPE_DERIVED,
179
OSPEPTID_CERTSERIALNUM, 0x2, 1, 1, 0, 0},
180
{"signature", OSPC_TAG_TYPE_DERIVED,
181
OSPEPTID_DERALGORITHMID,0x3, 1, 1, 0, 0},
182
{"issuer", OSPC_TAG_TYPE_DERIVED,
183
OSPEPTID_RDNSEQUENCE, 0x4, 1, 1, 0, 0},
184
{"validity", OSPC_TAG_TYPE_DERIVED,
185
OSPEPTID_VALIDITY, 0x5, 1, 1, 0, 0},
186
{"subject", OSPC_TAG_TYPE_DERIVED,
187
OSPEPTID_RDNSEQUENCE, 0x6, 1, 1, 0, 0},
188
{"subjectPublicKeyInfo",OSPC_TAG_TYPE_DERIVED,
189
OSPEPTID_SUBJPUBKEYINFO,0x7, 1, 1, 0, 0},
190
{"issuerUniqueID", OSPC_TAG_TYPE_DERIVED,
191
OSPEPTID_ISSUERUNIQUEID,
193
{"subjectUniqueID", OSPC_TAG_TYPE_DERIVED,
194
OSPEPTID_SUBJECTUNIQUEID,
196
{"extensions", OSPC_TAG_TYPE_DERIVED,
197
OSPEPTID_EXPLICIT_EXTENSIONS,
203
static OSPTASN1PARSETABLE ospgParseTable_SignatureAlgorithm[] =
205
{"SignatureAlgorithm", OSPC_TAG_TYPE_DERIVED,
206
OSPEPTID_DERALGORITHMID,0x0, 1, 1, 0, 0},
210
static OSPTASN1PARSETABLE ospgParseTable_DERAlgorithmId[] =
212
{"AlgorithmId", OSPC_TAG_TYPE_DER_FORMAT,
213
OSPEPTID_NOTDEFINED, 0x0,1, 1, 0, 0},
215
/* May need to expand this definition to get all the pieces. */
218
static OSPTASN1PARSETABLE ospgParseTable_Explicit_Version[] =
220
{"ExplicitVersion", OSPM_TAG_TYPE_EXPLICIT_TAG(0),
221
OSPEPTID_NOTDEFINED, 0x0, 1, 1, 1, 0},
222
{"version", OSPC_TAG_TYPE_DERIVED,
223
OSPEPTID_NOTDEFINED, 0x1, 1, 1, 1, 0},
228
static OSPTASN1PARSETABLE ospgParseTable_Version[] =
230
{"Version", OSPC_TAG_TYPE_INTEGER,
231
OSPEPTID_NOTDEFINED, 0x0, 1, 1, 1, 0},
236
static OSPTASN1PARSETABLE ospgParseTable_CertSerialNum[] =
238
{"CertSerialNum", OSPC_TAG_TYPE_INTEGER,
239
OSPEPTID_NOTDEFINED, 0x0, 1, 1, 0, 0},
243
static OSPTASN1PARSETABLE ospgParseTable_Name[] =
245
{"Name", OSPC_TAG_TYPE_DERIVED,
246
OSPEPTID_RDNSEQUENCE, 0x0, 1, 1, 0, 0},
249
/* This definition is strange because Name is a CHOICE of RDNSequence.
250
Choice does not generate an element. Special handling at beginning
251
of element parse to handle parse tables with first entry of Type
252
Tag "CONSTRUCTED" to have it immediately parse new element. */
257
static OSPTASN1PARSETABLE ospgParseTable_RDNSequence[] =
259
{"RDNSequence", OSPC_TAG_TYPE_SEQUENCE,
260
OSPEPTID_NOTDEFINED, 0x0, 1, 0xff, 0, 0},
261
{"relDisName", OSPC_TAG_TYPE_DERIVED,
262
OSPEPTID_RELDISNAME, 0x1, 0, 0xff, 0, 0},
267
static OSPTASN1PARSETABLE ospgParseTable_RelDisName[] =
269
{"RelDisName", OSPC_TAG_TYPE_SET,
270
OSPEPTID_NOTDEFINED, 0x0, 1, 0xff, 0, 0},
271
{"attrTypeAndVal", OSPC_TAG_TYPE_DERIVED,
272
OSPEPTID_ATTRTYPEANDVAL,0x1, 1, 0xff, 0, 0},
276
static OSPTASN1PARSETABLE ospgParseTable_AttrTypeAndValue[] =
278
{"AttrTypeAndVal", OSPC_TAG_TYPE_SEQUENCE,
279
OSPEPTID_NOTDEFINED, 0x0, 0, 1, 0, 0},
280
{"type", OSPC_TAG_TYPE_DERIVED,
281
OSPEPTID_ATTRIBUTETYPE, 0x1, 1, 1, 0, 0},
282
{"value", OSPC_TAG_TYPE_DERIVED,
283
OSPEPTID_ATTRIBUTEVALUE,0x2, 1, 1, 0, 0},
289
static OSPTASN1PARSETABLE ospgParseTable_AttributeType[] =
291
{"AttributeType", OSPC_TAG_TYPE_OBJECT_IDENTIFIER,
292
OSPEPTID_NOTDEFINED, 0x0, 1, 1, 0, 0},
297
static OSPTASN1PARSETABLE ospgParseTable_AttributeValue[] =
299
{"AttributeValue", OSPC_TAG_TYPE_PRINTABLESTRING,
300
OSPEPTID_NOTDEFINED, 0x0, 0, 1, 0, 0},
301
{"AttributeValue", OSPC_TAG_TYPE_T61STRING,
302
OSPEPTID_NOTDEFINED, 0x0, 0, 1, 0, 0},
303
{"AttributeValue", OSPC_TAG_TYPE_IA5STRING,
304
OSPEPTID_NOTDEFINED, 0x0, 0, 1, 0, 0},
310
static OSPTASN1PARSETABLE ospgParseTable_Validity[] =
312
{"Validity", OSPC_TAG_TYPE_SEQUENCE,
313
OSPEPTID_NOTDEFINED, 0x0, 1, 1, 0, 0},
314
{"notBefore", OSPC_TAG_TYPE_DERIVED,
315
OSPEPTID_UTCTIME, 0x1, 1, 1, 0, 0},
316
{"notAfter", OSPC_TAG_TYPE_DERIVED,
317
OSPEPTID_UTCTIME, 0x2, 1, 1, 0, 0},
322
static OSPTASN1PARSETABLE ospgParseTable_Time[] =
324
{"Time", OSPC_TAG_TYPE_DERIVED,
325
OSPEPTID_UTCTIME, 0x0, 1, 1, 0, 0},
328
/* This definition is strange because Time is a CHOICE of RDNSequence. Choice does not generate an
329
element. Special handling at beginning of element parse to handle parse tables with first entry of Type
330
Tag "CONSTRUCTED" to have it immediately parse new element. */
333
static OSPTASN1PARSETABLE ospgParseTable_UTCTime[] =
335
{"UTCTime", OSPC_TAG_TYPE_UTCTIME,
336
OSPEPTID_NOTDEFINED, 0x0, 1, 1, 0, 0},
339
/* This one is a little strange because UTCTIME is a named type as well as a primitive type.
340
Made it a named type as well so that the Time choice would have someplace to go. */
345
static OSPTASN1PARSETABLE ospgParseTable_SubjPubKeyInfo[] =
347
{"SubjPubKeyInfo", OSPC_TAG_TYPE_SEQUENCE,
348
OSPEPTID_NOTDEFINED, 0x0, 1, 1, 0, 0},
349
{"algorithm", OSPC_TAG_TYPE_DERIVED,
350
OSPEPTID_DERALGORITHMID,0x1, 1, 1, 0, 0},
351
{"subjPubKey", OSPC_TAG_TYPE_BIT_STRING,
352
OSPEPTID_NOTDEFINED, 0x2, 1, 1, 0, 0},
357
static OSPTASN1PARSETABLE ospgParseTable_IssuerUniqueId[] =
359
{"IssuerUniqueId", OSPM_TAG_TYPE_IMPLICIT_TAG(1),
360
OSPEPTID_NOTDEFINED, 0x0, 0, 1, 0, 1},
361
{"issuerUniqueId", OSPC_TAG_TYPE_DERIVED,
362
OSPEPTID_UNIQUEID, 0x1, 0, 1, 0, 0},
367
static OSPTASN1PARSETABLE ospgParseTable_SubjectUniqueId[] =
369
{"SubjectUniqueId", OSPM_TAG_TYPE_IMPLICIT_TAG(2),
370
OSPEPTID_NOTDEFINED, 0x0, 0, 1, 0, 2},
371
{"subjectUniqueId", OSPC_TAG_TYPE_DERIVED,
372
OSPEPTID_UNIQUEID, 0x1, 0, 1, 0, 0},
377
static OSPTASN1PARSETABLE ospgParseTable_UniqueId[] =
379
{"UniqueId", OSPC_TAG_TYPE_BIT_STRING,
380
OSPEPTID_NOTDEFINED, 0x0, 0, 1, 0, 0},
385
static OSPTASN1PARSETABLE ospgParseTable_Explicit_Extensions[] =
387
{"ExplicitExtensions", OSPM_TAG_TYPE_EXPLICIT_TAG(3),
388
OSPEPTID_NOTDEFINED, 0x0, 0, 1, 0, 3},
389
{"explicitExtensions", OSPC_TAG_TYPE_DERIVED,
390
OSPEPTID_EXTENSION, 0x1, 1, 0xff, 0},
395
static OSPTASN1PARSETABLE ospgParseTable_Extensions[] =
397
{"Extensions", OSPC_TAG_TYPE_SEQUENCE,
398
OSPEPTID_NOTDEFINED, 0x0, 0, 1, 0, 0},
399
{"extension", OSPC_TAG_TYPE_DERIVED,
400
OSPEPTID_EXTENSION, 0x1, 1, 0xff, 0},
405
static OSPTASN1PARSETABLE ospgParseTable_Extension[] =
407
{"Extension", OSPC_TAG_TYPE_SEQUENCE,
408
OSPEPTID_NOTDEFINED, 0x0, 1, 1, 0, 0},
409
{"extnID", OSPC_TAG_TYPE_OBJECT_IDENTIFIER,
410
OSPEPTID_NOTDEFINED, 0x1, 1, 1, 0, 0},
411
{"critical", OSPC_TAG_TYPE_BOOLEAN,
412
OSPEPTID_NOTDEFINED, 0x2, 1, 1, 0, 0},
413
{"extnValue", OSPC_TAG_TYPE_OCTET_STRING,
414
OSPEPTID_NOTDEFINED, 0x3, 1, 1, 0, 0},
419
static OSPTASN1PARSETABLE ospgParseTable_ContentInfo_Data[] =
421
{"ContentInfo", OSPC_TAG_TYPE_SEQUENCE,
422
OSPEPTID_NOTDEFINED, 0x0, 1, 1, 0, 0},
423
{"contentType", OSPC_TAG_TYPE_OBJECT_IDENTIFIER,
424
OSPEPTID_NOTDEFINED, 0x1, 1, 1, 0, 0},
425
{"data", OSPC_TAG_TYPE_DERIVED,
426
OSPEPTID_EXPLICIT_DATA, 0x2, 0, 1, 0, 0},
430
static OSPTASN1PARSETABLE ospgParseTable_ContentInfo_SignedData[] =
432
{"ContentInfo", OSPC_TAG_TYPE_SEQUENCE,
433
OSPEPTID_NOTDEFINED, 0x0, 1, 1, 0, 0},
434
{"contentType", OSPC_TAG_TYPE_OBJECT_IDENTIFIER,
435
OSPEPTID_NOTDEFINED, 0x1, 1, 1, 0, 0},
436
{"signedData", OSPC_TAG_TYPE_DERIVED,
437
OSPEPTID_EXPLICIT_SIGNEDDATA,
444
static OSPTASN1PARSETABLE ospgParseTable_Explicit_Data[] =
446
{"ExplicitData", OSPM_TAG_TYPE_EXPLICIT_TAG(0),
447
OSPEPTID_NOTDEFINED, 0x0, 0, 1, 0, 0},
448
{"explicitData", OSPC_TAG_TYPE_DERIVED,
449
OSPEPTID_DATA, 0x1, 0, 1, 0, 0},
453
static OSPTASN1PARSETABLE ospgParseTable_Explicit_SignedData[] =
455
{"ExplicitSignedData", OSPM_TAG_TYPE_EXPLICIT_TAG(0),
456
OSPEPTID_NOTDEFINED, 0x0, 1, 1, 0, 0},
457
{"explicitSignedData", OSPC_TAG_TYPE_DERIVED,
458
OSPEPTID_SIGNEDDATA, 0x1, 1, 1, 0, 0},
462
static OSPTASN1PARSETABLE ospgParseTable_Data[] =
464
{"Data", OSPC_TAG_TYPE_OCTET_STRING,
465
OSPEPTID_NOTDEFINED, 0x0, 1, 1, 0, 0},
469
static OSPTASN1PARSETABLE ospgParseTable_SignedData[] =
471
{"SignedData", OSPC_TAG_TYPE_SEQUENCE,
472
OSPEPTID_NOTDEFINED, 0x0, 1, 1, 0, 0},
473
{"version", OSPC_TAG_TYPE_INTEGER,
474
OSPEPTID_NOTDEFINED, 0x1, 1, 1, 0, 0},
475
{"digestAlgorithms", OSPC_TAG_TYPE_DERIVED,
476
OSPEPTID_DIGESTALGORITHMS,
478
{"contentInfo", OSPC_TAG_TYPE_DERIVED,
479
OSPEPTID_CONTENTINFO_DATA,
481
{"certificates", OSPC_TAG_TYPE_DERIVED,
482
OSPEPTID_CERTIFICATES,
484
{"crls", OSPC_TAG_TYPE_DERIVED,
485
OSPEPTID_CERTREVLISTS, 0x5, 0, 1, 0, 0},
486
{"signerInfos", OSPC_TAG_TYPE_DERIVED,
487
OSPEPTID_SIGNERINFOS, 0x6, 1, 1, 0, 0},
491
static OSPTASN1PARSETABLE ospgParseTable_DigestAlgorithms[] =
493
{"DigestAlgorithms", OSPC_TAG_TYPE_SET,
494
OSPEPTID_NOTDEFINED, 0x0, 1, 1, 0, 0},
495
{"digestAlgorithmId", OSPC_TAG_TYPE_DERIVED,
496
OSPEPTID_DERALGORITHMID,0x1, 1, 0xff, 0, 0},
500
static OSPTASN1PARSETABLE ospgParseTable_Certificates[] =
502
{"Certificates", OSPM_TAG_TYPE_IMPLICIT_TAG(0),
503
OSPEPTID_NOTDEFINED, 0x0, 1, 1, 0, 0},
504
{"certificate", OSPC_TAG_TYPE_DERIVED,
505
OSPEPTID_CERTIFICATE, 0x1, 1, 0xff, 0, 0},
509
static OSPTASN1PARSETABLE ospgParseTable_CertRevLists[] =
511
{"CertRevLists", OSPM_TAG_TYPE_IMPLICIT_TAG(1),
512
OSPEPTID_NOTDEFINED, 0x0, 0, 1, 0, 1},
513
{"certRevList", OSPC_TAG_TYPE_DERIVED,
514
OSPEPTID_CERTREVLIST, 0x1, 1, 0xff, 0, 0},
518
static OSPTASN1PARSETABLE ospgParseTable_CertRevList[] =
520
{"CertRevList", OSPC_TAG_TYPE_DER_FORMAT,
521
OSPEPTID_NOTDEFINED, 0x0, 1, 1, 0, 0},
525
static OSPTASN1PARSETABLE ospgParseTable_SignerInfos[] =
527
{"SignerInfos", OSPC_TAG_TYPE_SET,
528
OSPEPTID_NOTDEFINED, 0x0, 1, 1, 0, 0},
529
{"signerInfo", OSPC_TAG_TYPE_DERIVED,
530
OSPEPTID_SIGNERINFO, 0x1, 1, 0xff, 0, 0},
533
static OSPTASN1PARSETABLE ospgParseTable_SignerInfo[] =
535
{"SignerInfo", OSPC_TAG_TYPE_SEQUENCE,
536
OSPEPTID_NOTDEFINED, 0x0, 1, 1, 0, 0},
537
{"version", OSPC_TAG_TYPE_INTEGER,
538
OSPEPTID_NOTDEFINED, 0x1, 1, 1, 0, 0},
539
{"issuerAndSerNum", OSPC_TAG_TYPE_DERIVED,
540
OSPEPTID_ISSUERANDSERNUM,
542
{"digestAlgorithm", OSPC_TAG_TYPE_DERIVED,
543
OSPEPTID_DERALGORITHMID,0x3, 1, 1, 0, 0},
544
{"authAttributes", OSPC_TAG_TYPE_DERIVED,
545
OSPEPTID_AUTHATTRIBUTES,
547
{"digEncryptAlgorithm", OSPC_TAG_TYPE_DERIVED,
548
OSPEPTID_DERALGORITHMID,0x5, 1, 1, 0, 0},
549
{"encryptedDigest", OSPC_TAG_TYPE_DERIVED,
550
OSPEPTID_ENCRYPTEDDIGEST,
552
{"unauthAttributes", OSPC_TAG_TYPE_DERIVED,
553
OSPEPTID_UNAUTHATTRIBUTES,
558
static OSPTASN1PARSETABLE ospgParseTable_IssuerAndSerNum[] =
560
{"IssuerAndSerNum", OSPC_TAG_TYPE_SEQUENCE,
561
OSPEPTID_NOTDEFINED, 0x0, 1, 1, 0, 0},
562
{"issuer", OSPC_TAG_TYPE_DERIVED,
563
OSPEPTID_NAME, 0x1, 1, 1, 0, 0},
564
{"serialNumber", OSPC_TAG_TYPE_DERIVED,
565
OSPEPTID_CERTSERIALNUM, 0x2, 1, 1, 0, 0},
569
static OSPTASN1PARSETABLE ospgParseTable_AuthAttributes[] =
571
{"AuthenticatedAttributes",OSPM_TAG_TYPE_IMPLICIT_TAG(0),
572
OSPEPTID_NOTDEFINED, 0x0, 0, 1, 0, 0},
573
{"authenticatedAttribute",OSPC_TAG_TYPE_DERIVED,
574
OSPEPTID_ATTRTYPEANDVAL,0x1, 1, 0xff, 0, 0},
578
static OSPTASN1PARSETABLE ospgParseTable_UnauthAttributes[] =
580
{"UnauthenticatedAttributes",OSPM_TAG_TYPE_IMPLICIT_TAG(1),
581
OSPEPTID_NOTDEFINED, 0x0, 0, 1, 0, 0},
582
{"unauthenticatedAttribute",OSPC_TAG_TYPE_DERIVED,
583
OSPEPTID_ATTRTYPEANDVAL,0x1, 1, 0xff, 0, 0},
587
static OSPTASN1PARSETABLE ospgParseTable_EncryptedDigest[] =
589
{"EncryptedDigest", OSPC_TAG_TYPE_OCTET_STRING,
590
OSPEPTID_NOTDEFINED, 0x0, 1, 1, 0, 0},
594
static OSPTASN1PARSETABLE ospgParseTable_DigestInfo[] =
596
{"DigestInfo", OSPC_TAG_TYPE_SEQUENCE,
597
OSPEPTID_NOTDEFINED, 0x0, 1, 1, 0, 0},
598
{"digestAlgorithm", OSPC_TAG_TYPE_DER_FORMAT,
599
OSPEPTID_NOTDEFINED, 0x1, 1, 1, 0, 0},
600
{"digest", OSPC_TAG_TYPE_OCTET_STRING,
601
OSPEPTID_NOTDEFINED, 0x2, 1, 1, 0, 0},
606
static OSPTASN1PARSETABLE ospgParseTable_AlgorithmId[] =
608
{"AlgorithmId", OSPC_TAG_TYPE_SEQUENCE,
609
OSPEPTID_NOTDEFINED, 0x0, 1, 1, 0, 0},
610
{"algorithmOID", OSPC_TAG_TYPE_OBJECT_IDENTIFIER,
611
OSPEPTID_NOTDEFINED, 0x1, 1, 1, 0, 0},
612
{"attrTypeAndVal", OSPC_TAG_TYPE_DERIVED,
613
OSPEPTID_ATTRTYPEANDVAL,0x2, 0, 0xff, 0, 0},
614
{"terminator", OSPC_TAG_TYPE_NULL,
615
OSPEPTID_NOTDEFINED, 0x3, 1, 1, 0, 0},
621
static OSPTASN1PARSETABLE ospgParseTable_PrivateKeyInfo[] =
623
{"PrivateKeyInfo", OSPC_TAG_TYPE_SEQUENCE,
624
OSPEPTID_NOTDEFINED, 0x0, 1, 1, 0, 0},
625
{"version", OSPC_TAG_TYPE_INTEGER,
626
OSPEPTID_NOTDEFINED, 0x1, 1, 1, 0, 0},
627
{"algorithm", OSPC_TAG_TYPE_DERIVED,
628
OSPEPTID_DERALGORITHMID, 0x2, 1, 1, 0, 0},
629
{"privateKey", OSPC_TAG_TYPE_OCTET_STRING,
630
OSPEPTID_NOTDEFINED, 0x3, 1, 1, 0, 0},
631
{"attributes", OSPC_TAG_TYPE_DERIVED,
632
OSPEPTID_PRIVATEKEYINFO_ATTRIBUTES,
637
static OSPTASN1PARSETABLE ospgParseTable_PrivateKeyInfo_Attributes[] =
639
{"UnauthenticatedAttributes",OSPM_TAG_TYPE_IMPLICIT_TAG(0),
640
OSPEPTID_NOTDEFINED, 0x0, 0, 1, 0, 0},
641
{"unauthenticatedAttribute",OSPC_TAG_TYPE_DERIVED,
642
OSPEPTID_ATTRTYPEANDVAL,0x1, 1, 0xff, 0, 0},
646
static OSPTASN1PARSETABLE ospgParseTable_CertReq[] =
648
{"CertReq", OSPC_TAG_TYPE_SEQUENCE,
649
OSPEPTID_NOTDEFINED, 0x0, 1, 1, 0, 0 },
650
{"certReqInfo", OSPC_TAG_TYPE_DERIVED,
651
OSPEPTID_CERTREQINFO, 0x1, 1, 1, 0, 0 },
652
{"signatureAlgorithm", OSPC_TAG_TYPE_DERIVED,
653
OSPEPTID_SIGNATUREALGORITHM, 0x2, 1, 1, 0, 0 },
654
{"signature", OSPC_TAG_TYPE_BIT_STRING,
655
OSPEPTID_NOTDEFINED, 0x3, 1, 1, 0, 0 },
659
static OSPTASN1PARSETABLE ospgParseTable_CertReqInfo[] =
661
{"CertReqInfo", OSPC_TAG_TYPE_SEQUENCE,
662
OSPEPTID_NOTDEFINED, 0x0, 1, 1, 0, 0 },
663
{"version", OSPC_TAG_TYPE_INTEGER,
664
OSPEPTID_NOTDEFINED, 0x1, 1, 1, 0, 0 },
665
{"Subject", OSPC_TAG_TYPE_DERIVED,
666
OSPEPTID_RDNSEQUENCE, 0x2, 1, 1, 0, 0 },
667
{"subjectPubKeyInfo", OSPC_TAG_TYPE_DERIVED,
668
OSPEPTID_SUBJPUBKEYINFO, 0x3, 1, 1, 0, 0 },
669
{"attributes", OSPM_TAG_TYPE_EXPLICIT_TAG(0),
670
OSPEPTID_NOTDEFINED, 0x4, 0, 1, 0, 0 },
675
/* NOTE: THE OSPEASN1PARSETABLEID enum list must stay in sync with ospgParseTableIndex[]. The enum
676
values are the index into the ParseTableIndex for the parse table array.
678
static OSPTASN1PARSETABLE *ospgParseTableIndex[] =
680
/* TO NOT CHANGE THIS TABLE WITHOUT UPDATING THE ENUM VALUES IN OSPEASN1PARSETABLEID */
681
/* CERTIFICATE ELEMENTS */
682
ospgParseTable_NotDefined,
683
ospgParseTable_Certificate,
684
ospgParseTable_TBSCertificate,
685
ospgParseTable_SignatureAlgorithm,
686
ospgParseTable_DERAlgorithmId,
687
ospgParseTable_Explicit_Version,
688
ospgParseTable_Version,
689
ospgParseTable_CertSerialNum,
691
ospgParseTable_RDNSequence,
692
ospgParseTable_RelDisName,
693
ospgParseTable_AttrTypeAndValue,
694
ospgParseTable_AttributeType,
695
ospgParseTable_AttributeValue,
696
ospgParseTable_Validity,
698
ospgParseTable_UTCTime,
699
ospgParseTable_SubjPubKeyInfo,
700
ospgParseTable_IssuerUniqueId,
701
ospgParseTable_SubjectUniqueId,
702
ospgParseTable_UniqueId,
703
ospgParseTable_Explicit_Extensions,
704
ospgParseTable_Extensions,
705
ospgParseTable_Extension,
706
ospgParseTable_ContentInfo_Data,
707
ospgParseTable_Explicit_Data,
709
ospgParseTable_ContentInfo_SignedData,
710
ospgParseTable_Explicit_SignedData,
711
ospgParseTable_SignedData,
712
ospgParseTable_DigestAlgorithms,
713
ospgParseTable_Certificates,
714
ospgParseTable_CertRevLists,
715
ospgParseTable_CertRevList,
716
ospgParseTable_SignerInfos,
717
ospgParseTable_SignerInfo,
718
ospgParseTable_EncryptedDigest,
719
ospgParseTable_AuthAttributes,
720
ospgParseTable_UnauthAttributes,
721
ospgParseTable_IssuerAndSerNum,
722
ospgParseTable_DigestInfo,
723
ospgParseTable_AlgorithmId,
724
ospgParseTable_PrivateKeyInfo,
725
ospgParseTable_PrivateKeyInfo_Attributes,
726
ospgParseTable_CertReq,
727
ospgParseTable_CertReqInfo,
731
/* NOTE: THE OSPEASN1DATAREFID enum list must stay in sync with ospgDataReferenceIdIndex[]. The enum
732
values are the index into the DataReferenceIdIndex. */
734
static unsigned char ospgDataRefId_NotDefined[] = { 0xff };
736
static unsigned char ospgDataRefId_Certificate[] = {
737
OSPC_ASN1_DATAREFID_CERTIFICATE, 0xff };
739
static unsigned char ospgDataRefId_Cert_TBSCertificate[] = {
740
OSPC_ASN1_DATAREFID_CERTIFICATE,
741
OSPC_ASN1_DATAREFID_CERT_TBSCERTIFICATE, 0xff };
742
static unsigned char ospgDataRefId_Cert_SignatureAlgorithm[] = {
743
OSPC_ASN1_DATAREFID_CERTIFICATE,
744
OSPC_ASN1_DATAREFID_CERT_SIGNATUREALGORITHM, 0xff };
745
static unsigned char ospgDataRefId_Cert_Signature[] = {
746
OSPC_ASN1_DATAREFID_CERTIFICATE,
747
OSPC_ASN1_DATAREFID_CERT_SIGNATURE, 0xff };
749
static unsigned char ospgDataRefId_Cert_Explicit_Version[] = {
750
OSPC_ASN1_DATAREFID_CERTIFICATE,
751
OSPC_ASN1_DATAREFID_CERT_TBSCERTIFICATE,
752
OSPC_ASN1_DATAREFID_CERT_EXPLICIT_VERSION, 0xff };
753
static unsigned char ospgDataRefId_Cert_Version[] = {
754
OSPC_ASN1_DATAREFID_CERTIFICATE,
755
OSPC_ASN1_DATAREFID_CERT_TBSCERTIFICATE,
756
OSPC_ASN1_DATAREFID_CERT_VERSION, 0xff };
757
static unsigned char ospgDataRefId_Cert_SerialNumber[] = {
758
OSPC_ASN1_DATAREFID_CERTIFICATE,
759
OSPC_ASN1_DATAREFID_CERT_TBSCERTIFICATE,
760
OSPC_ASN1_DATAREFID_CERT_SERIALNUMBER, 0xff };
761
static unsigned char ospgDataRefId_Cert_Signature_TBS[] = {
762
OSPC_ASN1_DATAREFID_CERTIFICATE,
763
OSPC_ASN1_DATAREFID_CERT_TBSCERTIFICATE,
764
OSPC_ASN1_DATAREFID_CERT_SIGNATURE_TBS, 0xff };
765
static unsigned char ospgDataRefId_Cert_Issuer[] = {
766
OSPC_ASN1_DATAREFID_CERTIFICATE,
767
OSPC_ASN1_DATAREFID_CERT_TBSCERTIFICATE,
768
OSPC_ASN1_DATAREFID_CERT_ISSUER, 0xff };
769
static unsigned char ospgDataRefId_Cert_NotBefore[] = {
770
OSPC_ASN1_DATAREFID_CERTIFICATE,
771
OSPC_ASN1_DATAREFID_CERT_TBSCERTIFICATE,
772
OSPC_ASN1_DATAREFID_CERT_VALIDITY,
773
OSPC_ASN1_DATAREFID_CERT_NOTBEFORE, 0xff };
774
static unsigned char ospgDataRefId_Cert_NotAfter[] = {
775
OSPC_ASN1_DATAREFID_CERTIFICATE,
776
OSPC_ASN1_DATAREFID_CERT_TBSCERTIFICATE,
777
OSPC_ASN1_DATAREFID_CERT_VALIDITY,
778
OSPC_ASN1_DATAREFID_CERT_NOTAFTER, 0xff };
779
static unsigned char ospgDataRefId_Cert_Subject[] = {
780
OSPC_ASN1_DATAREFID_CERTIFICATE,
781
OSPC_ASN1_DATAREFID_CERT_TBSCERTIFICATE,
782
OSPC_ASN1_DATAREFID_CERT_SUBJECT, 0xff };
783
static unsigned char ospgDataRefId_Cert_SubjPubKeyInfo[] = {
784
OSPC_ASN1_DATAREFID_CERTIFICATE,
785
OSPC_ASN1_DATAREFID_CERT_TBSCERTIFICATE,
786
OSPC_ASN1_DATAREFID_CERT_SUBJPUBKEYINFO, 0xff };
787
static unsigned char ospgDataRefId_Cert_PublicKeyAlg[] = {
788
OSPC_ASN1_DATAREFID_CERTIFICATE,
789
OSPC_ASN1_DATAREFID_CERT_TBSCERTIFICATE,
790
OSPC_ASN1_DATAREFID_CERT_SUBJPUBKEYINFO,
791
OSPC_ASN1_DATAREFID_CERT_PUBLICKEYALG, 0xff };
792
static unsigned char ospgDataRefId_Cert_PublicKey[] = {
793
OSPC_ASN1_DATAREFID_CERTIFICATE,
794
OSPC_ASN1_DATAREFID_CERT_TBSCERTIFICATE,
795
OSPC_ASN1_DATAREFID_CERT_SUBJPUBKEYINFO,
796
OSPC_ASN1_DATAREFID_CERT_PUBLICKEY, 0xff };
797
static unsigned char ospgDataRefId_Cert_IssuerUniqueId[] = {
798
OSPC_ASN1_DATAREFID_CERTIFICATE,
799
OSPC_ASN1_DATAREFID_CERT_TBSCERTIFICATE,
800
OSPC_ASN1_DATAREFID_CERT_ISSUERUNIQUEID, 0xff };
801
static unsigned char ospgDataRefId_Cert_SubjectUniqueId[] = {
802
OSPC_ASN1_DATAREFID_CERTIFICATE,
803
OSPC_ASN1_DATAREFID_CERT_TBSCERTIFICATE,
804
OSPC_ASN1_DATAREFID_CERT_SUBJECTUNIQUEID, 0xff };
805
static unsigned char ospgDataRefId_Cert_Explicit_Extensions[] = {
806
OSPC_ASN1_DATAREFID_CERTIFICATE,
807
OSPC_ASN1_DATAREFID_CERT_TBSCERTIFICATE,
808
OSPC_ASN1_DATAREFID_CERT_EXPLICIT_EXTENSIONS, 0xff };
809
static unsigned char ospgDataRefId_Cert_Extensions[] = {
810
OSPC_ASN1_DATAREFID_CERTIFICATE,
811
OSPC_ASN1_DATAREFID_CERT_TBSCERTIFICATE,
812
OSPC_ASN1_DATAREFID_CERT_EXPLICIT_EXTENSIONS,
813
OSPC_ASN1_DATAREFID_CERT_EXTENSIONS, 0xff };
814
static unsigned char ospgDataRefId_Cert_Extension[] = {
815
OSPC_ASN1_DATAREFID_CERTIFICATE,
816
OSPC_ASN1_DATAREFID_CERT_TBSCERTIFICATE,
817
OSPC_ASN1_DATAREFID_CERT_EXPLICIT_EXTENSIONS,
818
OSPC_ASN1_DATAREFID_CERT_EXTENSIONS,
819
OSPC_ASN1_DATAREFID_CERT_EXTENSION, 0xff };
821
static unsigned char ospgDataRefId_SignedData[] = {
822
OSPC_ASN1_DATAREFID_SIGNEDDATA, 0xff };
823
static unsigned char ospgDataRefId_SgnDat_Version[] = {
824
OSPC_ASN1_DATAREFID_SIGNEDDATA,
825
OSPC_ASN1_DATAREFID_SGNDAT_VERSION, 0xff };
826
static unsigned char ospgDataRefId_SgnDat_DigestAlgorithms[] = {
827
OSPC_ASN1_DATAREFID_SIGNEDDATA,
828
OSPC_ASN1_DATAREFID_SGNDAT_DIGESTALGORITHMS, 0xff };
829
static unsigned char ospgDataRefId_SgnDat_DigestAlgorithm[] = {
830
OSPC_ASN1_DATAREFID_SIGNEDDATA,
831
OSPC_ASN1_DATAREFID_SGNDAT_DIGESTALGORITHMS,
832
OSPC_ASN1_DATAREFID_SGNDAT_DIGESTALGORITHM, 0xff };
833
static unsigned char ospgDataRefId_SgnDat_Content[] = {
834
OSPC_ASN1_DATAREFID_SIGNEDDATA,
835
OSPC_ASN1_DATAREFID_SGNDAT_CONTENTINFO, 0xff };
836
static unsigned char ospgDataRefId_SgnDat_Certificates[] = {
837
OSPC_ASN1_DATAREFID_SIGNEDDATA,
838
OSPC_ASN1_DATAREFID_SGNDAT_CERTIFICATES, 0xff };
839
static unsigned char ospgDataRefId_SgnDat_Certificate[] = {
840
OSPC_ASN1_DATAREFID_SIGNEDDATA,
841
OSPC_ASN1_DATAREFID_SGNDAT_CERTIFICATES,
842
OSPC_ASN1_DATAREFID_SGNDAT_CERTIFICATE, 0xff };
843
static unsigned char ospgDataRefId_SgnDat_Certificate_SubjPubKeyInfo[] = {
844
OSPC_ASN1_DATAREFID_SIGNEDDATA,
845
OSPC_ASN1_DATAREFID_SGNDAT_CERTIFICATES,
846
OSPC_ASN1_DATAREFID_SGNDAT_CERTIFICATE,
847
OSPC_ASN1_DATAREFID_CERTIFICATE,
848
OSPC_ASN1_DATAREFID_CERT_TBSCERTIFICATE,
849
OSPC_ASN1_DATAREFID_CERT_SUBJPUBKEYINFO, 0xff};
850
static unsigned char ospgDataRefId_SgnDat_CertRevLists[] = {
851
OSPC_ASN1_DATAREFID_SIGNEDDATA,
852
OSPC_ASN1_DATAREFID_SGNDAT_CERTREVLISTS, 0xff };
853
static unsigned char ospgDataRefId_SgnDat_CertRevList[] = {
854
OSPC_ASN1_DATAREFID_SIGNEDDATA,
855
OSPC_ASN1_DATAREFID_SGNDAT_CERTREVLISTS,
856
OSPC_ASN1_DATAREFID_SGNDAT_CERTREVLIST, 0xff };
857
static unsigned char ospgDataRefId_SgnDat_SignerInfos[] = {
858
OSPC_ASN1_DATAREFID_SIGNEDDATA,
859
OSPC_ASN1_DATAREFID_SGNDAT_SIGNERINFOS, 0xff };
860
static unsigned char ospgDataRefId_SgnDat_SignerInfo[] = {
861
OSPC_ASN1_DATAREFID_SIGNEDDATA,
862
OSPC_ASN1_DATAREFID_SGNDAT_SIGNERINFOS,
863
OSPC_ASN1_DATAREFID_SGNDAT_SIGNERINFO, 0xff };
865
static unsigned char ospgDataRefId_SignerInfo [] = {
866
OSPC_ASN1_DATAREFID_SIGNERINFO, 0xff};
867
static unsigned char ospgDataRefId_SgnInf_Version[] = {
868
OSPC_ASN1_DATAREFID_SIGNERINFO,
869
OSPC_ASN1_DATAREFID_SGNINF_VERSION, 0xff };
870
static unsigned char ospgDataRefId_SgnInf_Issuer [] = {
871
OSPC_ASN1_DATAREFID_SIGNERINFO,
872
OSPC_ASN1_DATAREFID_SGNINF_ISSUERANDSERNUM,
873
OSPC_ASN1_DATAREFID_SGNINF_ISSUER, 0xff };
874
static unsigned char ospgDataRefId_SgnInf_SerialNumber [] = {
875
OSPC_ASN1_DATAREFID_SIGNERINFO,
876
OSPC_ASN1_DATAREFID_SGNINF_ISSUERANDSERNUM,
877
OSPC_ASN1_DATAREFID_SGNINF_SERIALNUMBER, 0xff };
878
static unsigned char ospgDataRefId_SgnInf_DigestAlgorithm [] = {
879
OSPC_ASN1_DATAREFID_SIGNERINFO,
880
OSPC_ASN1_DATAREFID_SGNINF_DIGESTALGORITHM, 0xff };
881
static unsigned char ospgDataRefId_SgnInf_AuthAttributes[] = {
882
OSPC_ASN1_DATAREFID_SIGNERINFO,
883
OSPC_ASN1_DATAREFID_SGNINF_AUTHATTRIBUTES, 0xff };
884
static unsigned char ospgDataRefId_SgnInf_DigEncryptAlg [] = {
885
OSPC_ASN1_DATAREFID_SIGNERINFO,
886
OSPC_ASN1_DATAREFID_SGNINF_DIGENCRYPTALG, 0xff };
887
static unsigned char ospgDataRefId_SgnInf_EncryptedDigest [] = {
888
OSPC_ASN1_DATAREFID_SIGNERINFO,
889
OSPC_ASN1_DATAREFID_SGNINF_ENCRYPTEDDIGEST, 0xff };
890
static unsigned char ospgDataRefId_SgnInf_UnauthAttributes [] = {
891
OSPC_ASN1_DATAREFID_SIGNERINFO,
892
OSPC_ASN1_DATAREFID_SGNINF_UNAUTHATTRIBUTES, 0xff };
894
static unsigned char ospgDataRefId_ContentInfo[] = {
895
OSPC_ASN1_DATAREFID_CONTENTINFO, 0xff };
896
static unsigned char ospgDataRefId_CntInf_ContentType[] = {
897
OSPC_ASN1_DATAREFID_CONTENTINFO,
898
OSPC_ASN1_DATAREFID_CNTINF_CONTENTTYPE, 0xff };
899
static unsigned char ospgDataRefId_CntInf_Explicit_Content[] = {
900
OSPC_ASN1_DATAREFID_CONTENTINFO,
901
OSPC_ASN1_DATAREFID_CNTINF_EXPLICIT_CONTENT, 0xff };
902
static unsigned char ospgDataRefId_CntInf_Content[] = {
903
OSPC_ASN1_DATAREFID_CONTENTINFO,
904
OSPC_ASN1_DATAREFID_CNTINF_EXPLICIT_CONTENT,
905
OSPC_ASN1_DATAREFID_CNTINF_CONTENT, 0xff };
907
static unsigned char ospgDataRefId_DigestInfo[] = {
908
OSPC_ASN1_DATAREFID_DIGESTINFO, 0xff };
909
static unsigned char ospgDataRefId_DigInf_DigestAlgorithm[] = {
910
OSPC_ASN1_DATAREFID_DIGESTINFO,
911
OSPC_ASN1_DATAREFID_DIGINF_DIGESTALGORITHM, 0xff };
912
static unsigned char ospgDataRefId_DigInf_Digest[] = {
913
OSPC_ASN1_DATAREFID_DIGESTINFO,
914
OSPC_ASN1_DATAREFID_DIGINF_DIGEST, 0xff };
916
static unsigned char ospgDataRefId_AlgorithmId[] = {
917
OSPC_ASN1_DATAREFID_ALGORITHMID, 0xff };
918
static unsigned char ospgDataRefId_AlgId_OID[] = {
919
OSPC_ASN1_DATAREFID_ALGORITHMID,
920
OSPC_ASN1_DATAREFID_ALGID_OID, 0xff };
921
static unsigned char ospgDataRefId_AlgId_AttrTypeAndVal[] = {
922
OSPC_ASN1_DATAREFID_ALGORITHMID,
923
OSPC_ASN1_DATAREFID_ALGID_ATTRTYPEANDVAL, 0xff };
924
static unsigned char ospgDataRefId_AlgId_Terminator[] = {
925
OSPC_ASN1_DATAREFID_ALGORITHMID,
926
OSPC_ASN1_DATAREFID_ALGID_TERMINATOR, 0xff };
929
static unsigned char ospgDataRefId_PrivateKeyInfo[] = {
930
OSPC_ASN1_DATAREFID_PRIVATEKEYINFO, 0xff };
931
static unsigned char ospgDataRefId_PvtKeyInf_Version[] = {
932
OSPC_ASN1_DATAREFID_PRIVATEKEYINFO,
933
OSPC_ASN1_DATAREFID_PVTKEYINF_VERSION, 0xff };
934
static unsigned char ospgDataRefId_PvtKeyInf_Algorithm[] = {
935
OSPC_ASN1_DATAREFID_PRIVATEKEYINFO,
936
OSPC_ASN1_DATAREFID_PVTKEYINF_ALGORITHM, 0xff };
937
static unsigned char ospgDataRefId_PvtKeyInf_PrivateKey[] = {
938
OSPC_ASN1_DATAREFID_PRIVATEKEYINFO,
939
OSPC_ASN1_DATAREFID_PVTKEYINF_PRIVATEKEY, 0xff };
940
static unsigned char ospgDataRefId_PvtKeyInf_Attributes[] = {
941
OSPC_ASN1_DATAREFID_PRIVATEKEYINFO,
942
OSPC_ASN1_DATAREFID_PVTKEYINF_ATTRIBUTES, 0xff };
943
static unsigned char ospgDataRefId_PvtKeyInf_Attribute[] = {
944
OSPC_ASN1_DATAREFID_PRIVATEKEYINFO,
945
OSPC_ASN1_DATAREFID_PVTKEYINF_ATTRIBUTES,
946
OSPC_ASN1_DATAREFID_PVTKEYINF_ATTRIBUTE, 0xff };
949
static unsigned char ospgDataRefId_Signature[] = {
950
OSPC_ASN1_DATAREFID_CONTENTINFO, 0xff };
951
static unsigned char ospgDataRefId_Sig_ContentType[] = {
952
OSPC_ASN1_DATAREFID_CONTENTINFO,
953
OSPC_ASN1_DATAREFID_CNTINF_CONTENTTYPE, 0xff };
954
static unsigned char ospgDataRefId_Sig_SignedData[] = {
955
OSPC_ASN1_DATAREFID_CONTENTINFO,
956
OSPC_ASN1_DATAREFID_CNTINF_EXPLICIT_CONTENT,
957
OSPC_ASN1_DATAREFID_CNTINF_CONTENT, 0xff };
958
static unsigned char ospgDataRefId_Sig_SgnDat_Version[] = {
959
OSPC_ASN1_DATAREFID_CONTENTINFO,
960
OSPC_ASN1_DATAREFID_CNTINF_EXPLICIT_CONTENT,
961
OSPC_ASN1_DATAREFID_CNTINF_CONTENT,
962
OSPC_ASN1_DATAREFID_SGNDAT_VERSION, 0xff };
963
static unsigned char ospgDataRefId_Sig_SgnDat_DigestAlgorithm[] = {
964
OSPC_ASN1_DATAREFID_CONTENTINFO,
965
OSPC_ASN1_DATAREFID_CNTINF_EXPLICIT_CONTENT,
966
OSPC_ASN1_DATAREFID_CNTINF_CONTENT,
967
OSPC_ASN1_DATAREFID_SGNDAT_DIGESTALGORITHMS,
968
OSPC_ASN1_DATAREFID_SGNDAT_DIGESTALGORITHM, 0xff };
969
static unsigned char ospgDataRefId_Sig_SgnDat_Data[] = {
970
OSPC_ASN1_DATAREFID_CONTENTINFO,
971
OSPC_ASN1_DATAREFID_CNTINF_EXPLICIT_CONTENT,
972
OSPC_ASN1_DATAREFID_CNTINF_CONTENT,
973
OSPC_ASN1_DATAREFID_SGNDAT_CONTENTINFO,
974
OSPC_ASN1_DATAREFID_CNTINF_EXPLICIT_CONTENT,
975
OSPC_ASN1_DATAREFID_CNTINF_CONTENT, 0xff };
976
static unsigned char ospgDataRefId_Sig_SgnDat_Certificate[] = {
977
OSPC_ASN1_DATAREFID_CONTENTINFO,
978
OSPC_ASN1_DATAREFID_CNTINF_EXPLICIT_CONTENT,
979
OSPC_ASN1_DATAREFID_CNTINF_CONTENT,
980
OSPC_ASN1_DATAREFID_SGNDAT_CERTIFICATES,
981
OSPC_ASN1_DATAREFID_SGNDAT_CERTIFICATE, 0xff };
982
static unsigned char ospgDataRefId_Sig_SgnDat_Certificate_SubjPubKeyInfo[] = {
983
OSPC_ASN1_DATAREFID_CONTENTINFO,
984
OSPC_ASN1_DATAREFID_CNTINF_EXPLICIT_CONTENT,
985
OSPC_ASN1_DATAREFID_CNTINF_CONTENT,
986
OSPC_ASN1_DATAREFID_SGNDAT_CERTIFICATES,
987
OSPC_ASN1_DATAREFID_SGNDAT_CERTIFICATE,
988
OSPC_ASN1_DATAREFID_CERT_TBSCERTIFICATE,
989
OSPC_ASN1_DATAREFID_CERT_SUBJPUBKEYINFO, 0xff };
990
static unsigned char ospgDataRefId_Sig_SgnDat_CertRevList[] = {
991
OSPC_ASN1_DATAREFID_CONTENTINFO,
992
OSPC_ASN1_DATAREFID_CNTINF_EXPLICIT_CONTENT,
993
OSPC_ASN1_DATAREFID_CNTINF_CONTENT,
994
OSPC_ASN1_DATAREFID_SGNDAT_CERTREVLISTS,
995
OSPC_ASN1_DATAREFID_SGNDAT_CERTREVLIST, 0xff };
996
static unsigned char ospgDataRefId_Sig_SgnDat_SignerInfo[] = {
997
OSPC_ASN1_DATAREFID_CONTENTINFO,
998
OSPC_ASN1_DATAREFID_CNTINF_EXPLICIT_CONTENT,
999
OSPC_ASN1_DATAREFID_CNTINF_CONTENT,
1000
OSPC_ASN1_DATAREFID_SGNDAT_SIGNERINFOS,
1001
OSPC_ASN1_DATAREFID_SGNDAT_SIGNERINFO, 0xff };
1002
static unsigned char ospgDataRefId_Sig_SgnDat_SgnInf_DigestAlgorithm[] = {
1003
OSPC_ASN1_DATAREFID_CONTENTINFO,
1004
OSPC_ASN1_DATAREFID_CNTINF_EXPLICIT_CONTENT,
1005
OSPC_ASN1_DATAREFID_CNTINF_CONTENT,
1006
OSPC_ASN1_DATAREFID_SGNDAT_SIGNERINFOS,
1007
OSPC_ASN1_DATAREFID_SGNDAT_SIGNERINFO,
1008
OSPC_ASN1_DATAREFID_SGNINF_DIGESTALGORITHM, 0xff };
1009
static unsigned char ospgDataRefId_Sig_SgnDat_SgnInf_DigEncryptAlg[] = {
1010
OSPC_ASN1_DATAREFID_CONTENTINFO,
1011
OSPC_ASN1_DATAREFID_CNTINF_EXPLICIT_CONTENT,
1012
OSPC_ASN1_DATAREFID_CNTINF_CONTENT,
1013
OSPC_ASN1_DATAREFID_SGNDAT_SIGNERINFOS,
1014
OSPC_ASN1_DATAREFID_SGNDAT_SIGNERINFO,
1015
OSPC_ASN1_DATAREFID_SGNINF_DIGENCRYPTALG, 0xff };
1016
static unsigned char ospgDataRefId_Sig_SgnDat_SgnInf_EncryptedDigest[] = {
1017
OSPC_ASN1_DATAREFID_CONTENTINFO,
1018
OSPC_ASN1_DATAREFID_CNTINF_EXPLICIT_CONTENT,
1019
OSPC_ASN1_DATAREFID_CNTINF_CONTENT,
1020
OSPC_ASN1_DATAREFID_SGNDAT_SIGNERINFOS,
1021
OSPC_ASN1_DATAREFID_SGNDAT_SIGNERINFO,
1022
OSPC_ASN1_DATAREFID_SGNINF_ENCRYPTEDDIGEST, 0xff };
1024
/* These are defined for parsing certificate requests; all possible
1025
* elements of a certificate request ( with the exception of the possible
1026
* values of the optional attributes list, which is unknown at compile
1027
* time anyway ) is given here. This listing is based off of PKCS#10.
1029
static unsigned char ospgDataRefId_CertReq[] = {
1030
OSPC_ASN1_DATAREFID_CERTREQ,
1033
/* Define the location of the certificate request info of a PKCS#10
1034
* certificate request; this structure will contain the version, subject,
1035
* public key, and optional attributes that are then signed afterwards
1038
static unsigned char ospgDataRefId_CertReqInfo[] = {
1039
OSPC_ASN1_DATAREFID_CERTREQ,
1040
OSPC_ASN1_DATAREFID_CERTREQINFO,
1043
/* Define the location of the version for a
1044
* PKCS#10 certificate request info:
1046
static unsigned char ospgDataRefId_CertReqInfo_Version[] = {
1047
OSPC_ASN1_DATAREFID_CERTREQ,
1048
OSPC_ASN1_DATAREFID_CERTREQINFO,
1049
OSPC_ASN1_DATAREFID_CERTREQINFO_VERSION,
1052
/* Define the location of the subject for a
1053
* PKCS#10 certificate request info:
1055
static unsigned char ospgDataRefId_CertReqInfo_Subject[] = {
1056
OSPC_ASN1_DATAREFID_CERTREQ,
1057
OSPC_ASN1_DATAREFID_CERTREQINFO,
1058
OSPC_ASN1_DATAREFID_CERTREQINFO_SUBJECT,
1061
/* Define the location of the subjectPublicKeyInfo for a
1062
* PKCS#10 certificate request info:
1064
static unsigned char ospgDataRefId_CertReqInfo_SubjPubKeyInfo[] = {
1065
OSPC_ASN1_DATAREFID_CERTREQ,
1066
OSPC_ASN1_DATAREFID_CERTREQINFO,
1067
OSPC_ASN1_DATAREFID_CERTREQINFO_SUBJPUBKEYINFO,
1070
/* Define the location of the optional attributes for a
1071
* PKCS#10 certificate request info:
1073
static unsigned char ospgDataRefId_CertReqInfo_Attributes[] = {
1074
OSPC_ASN1_DATAREFID_CERTREQ,
1075
OSPC_ASN1_DATAREFID_CERTREQINFO,
1076
OSPC_ASN1_DATAREFID_CERTREQINFO_ATTRIBUTES,
1079
/* Define the location of the signature algorithm id for
1080
* a PKCS#10 certificate request:
1082
static unsigned char ospgDataRefId_CertReq_Signature_Algorithm[] = {
1083
OSPC_ASN1_DATAREFID_CERTREQ,
1084
OSPC_ASN1_DATAREFID_CERTREQ_SIGNATURE_ALGORITHM,
1087
/* Define the location of the signature for PKCS#10 a certificate request: */
1088
static unsigned char ospgDataRefId_CertReq_Signature[] = {
1089
OSPC_ASN1_DATAREFID_CERTREQ,
1090
OSPC_ASN1_DATAREFID_CERTREQ_SIGNATURE,
1093
static unsigned char *ospgDataRefIdIndex[] =
1095
/* TO NOT CHANGE THIS TABLE WITHOUT UPDATING THE ENUM VALUES IN OSPEASN1DATAREFID */
1096
ospgDataRefId_Certificate,
1097
ospgDataRefId_Cert_TBSCertificate,
1098
ospgDataRefId_Cert_SignatureAlgorithm,
1099
ospgDataRefId_Cert_Signature,
1100
ospgDataRefId_Cert_Explicit_Version,
1101
ospgDataRefId_Cert_Version,
1102
ospgDataRefId_Cert_SerialNumber,
1103
ospgDataRefId_Cert_Signature_TBS,
1104
ospgDataRefId_Cert_Issuer,
1105
ospgDataRefId_Cert_NotBefore,
1106
ospgDataRefId_Cert_NotAfter,
1107
ospgDataRefId_Cert_Subject,
1108
ospgDataRefId_Cert_SubjPubKeyInfo,
1109
ospgDataRefId_Cert_PublicKeyAlg,
1110
ospgDataRefId_Cert_PublicKey,
1111
ospgDataRefId_Cert_IssuerUniqueId,
1112
ospgDataRefId_Cert_SubjectUniqueId,
1113
ospgDataRefId_Cert_Explicit_Extensions,
1114
ospgDataRefId_Cert_Extensions,
1115
ospgDataRefId_Cert_Extension,
1117
ospgDataRefId_SignedData,
1118
ospgDataRefId_SgnDat_Version,
1119
ospgDataRefId_SgnDat_DigestAlgorithms,
1120
ospgDataRefId_SgnDat_DigestAlgorithm,
1121
ospgDataRefId_SgnDat_Content,
1122
ospgDataRefId_SgnDat_Certificates,
1123
ospgDataRefId_SgnDat_Certificate,
1124
ospgDataRefId_SgnDat_Certificate_SubjPubKeyInfo,
1125
ospgDataRefId_SgnDat_CertRevLists,
1126
ospgDataRefId_SgnDat_CertRevList,
1127
ospgDataRefId_SgnDat_SignerInfos,
1128
ospgDataRefId_SgnDat_SignerInfo,
1130
ospgDataRefId_SignerInfo,
1131
ospgDataRefId_SgnInf_Version,
1132
ospgDataRefId_SgnInf_Issuer ,
1133
ospgDataRefId_SgnInf_SerialNumber,
1134
ospgDataRefId_SgnInf_DigestAlgorithm ,
1135
ospgDataRefId_SgnInf_AuthAttributes,
1136
ospgDataRefId_SgnInf_DigEncryptAlg ,
1137
ospgDataRefId_SgnInf_EncryptedDigest ,
1138
ospgDataRefId_SgnInf_UnauthAttributes ,
1140
ospgDataRefId_ContentInfo,
1141
ospgDataRefId_CntInf_ContentType,
1142
ospgDataRefId_CntInf_Explicit_Content,
1143
ospgDataRefId_CntInf_Content,
1145
ospgDataRefId_DigestInfo,
1146
ospgDataRefId_DigInf_DigestAlgorithm,
1147
ospgDataRefId_DigInf_Digest,
1149
ospgDataRefId_AlgorithmId,
1150
ospgDataRefId_AlgId_OID,
1151
ospgDataRefId_AlgId_AttrTypeAndVal,
1152
ospgDataRefId_AlgId_Terminator,
1154
ospgDataRefId_PrivateKeyInfo,
1155
ospgDataRefId_PvtKeyInf_Version,
1156
ospgDataRefId_PvtKeyInf_Algorithm,
1157
ospgDataRefId_PvtKeyInf_PrivateKey,
1158
ospgDataRefId_PvtKeyInf_Attributes,
1159
ospgDataRefId_PvtKeyInf_Attribute,
1161
ospgDataRefId_Signature,
1162
ospgDataRefId_Sig_ContentType,
1163
ospgDataRefId_Sig_SignedData,
1164
ospgDataRefId_Sig_SgnDat_Version,
1165
ospgDataRefId_Sig_SgnDat_DigestAlgorithm,
1166
ospgDataRefId_Sig_SgnDat_Data,
1167
ospgDataRefId_Sig_SgnDat_Certificate,
1168
ospgDataRefId_Sig_SgnDat_Certificate_SubjPubKeyInfo,
1169
ospgDataRefId_Sig_SgnDat_CertRevList,
1170
ospgDataRefId_Sig_SgnDat_SignerInfo,
1171
ospgDataRefId_Sig_SgnDat_SgnInf_DigestAlgorithm,
1172
ospgDataRefId_Sig_SgnDat_SgnInf_DigEncryptAlg,
1173
ospgDataRefId_Sig_SgnDat_SgnInf_EncryptedDigest,
1175
/* These are defined for parsing certificate requests; all possible
1176
* elements of a certificate request ( with the exception of the possible
1177
* values of the optional attributes list, which is unknown at compile
1178
* time anyway ) is given here. This listing is based off of PKCS#10.
1180
ospgDataRefId_CertReq,
1181
ospgDataRefId_CertReqInfo,
1182
ospgDataRefId_CertReqInfo_Version,
1183
ospgDataRefId_CertReqInfo_Subject,
1184
ospgDataRefId_CertReqInfo_SubjPubKeyInfo,
1185
ospgDataRefId_CertReqInfo_Attributes,
1186
ospgDataRefId_CertReq_Signature_Algorithm,
1187
ospgDataRefId_CertReq_Signature,
1189
ospgDataRefId_NotDefined,
1193
/* IMPLEMENTATION */
1197
OSPTASN1PARSERULE *ospvParseRule,
1198
OSPTASN1ELEMENTINFO *ospvElementInfo,
1199
OSPTASN1PARSERESULT **ospvParseResult,
1200
unsigned char ospvDataRef)
1202
int errorcode = OSPC_ERR_NO_ERROR;
1203
OSPTASN1PARSERESULT *parseResult = OSPC_OSNULL;
1204
OSPTASN1ELEMENTINFO *eInfo = OSPC_OSNULL;
1207
eInfo = ospvElementInfo;
1209
OSPM_ARGUSED(ospvParseRule);
1211
/* Malloc space for a result */
1212
OSPM_MALLOC(parseResult, OSPTASN1PARSERESULT, sizeof(OSPTASN1PARSERESULT));
1213
if (parseResult == OSPC_OSNULL)
1215
errorcode = OSPC_ERR_ASN1_UNABLE_TO_ALLOCATE_SPACE;
1216
OSPM_DBGERRORLOG( errorcode,
1217
"Unable to allocate space for parse result");
1220
if (errorcode == OSPC_ERR_NO_ERROR)
1222
OSPM_MEMSET(parseResult, 0, sizeof(OSPTASN1PARSERESULT));
1224
/* Update parse result */
1225
OSPM_MEMSET(parseResult->DataReference, 0xff,
1226
OSPC_ASN1_DATAREF_MAXLENGTH);
1227
if (ospvDataRef != 0)
1229
parseResult->DataReference[0] = ospvDataRef;
1232
/* Attach the element info object */
1233
parseResult->ElementInfo = ospvElementInfo;
1236
if (errorcode != OSPC_ERR_NO_ERROR)
1238
PTPResultsDelete(ospvParseResult);
1242
*ospvParseResult = parseResult;
1250
OSPEASN1PARSETABLEID ospvParseTableId,
1251
OSPTASN1PARSETABLE *ospvParseTable[])
1253
int errorcode = OSPC_ERR_NO_ERROR;
1255
*ospvParseTable = ospgParseTableIndex[ospvParseTableId];
1263
OSPEASN1PARSETABLEID ospvParseTableId,
1264
OSPTASN1PARSERULE **ospvParseRule,
1265
unsigned int *ospvRuleIndex) /* Updated to point to next rule */
1267
int errorcode = OSPC_ERR_NO_ERROR;
1268
OSPTASN1PARSETABLE *parseTable = OSPC_OSNULL;
1270
errorcode = PTPTableGet(ospvParseTableId, &parseTable );
1271
if (errorcode == OSPC_ERR_NO_ERROR)
1273
*ospvParseRule = &(parseTable[*ospvRuleIndex]);
1276
if ( *ospvParseRule != OSPC_OSNULL )
1278
if ((*ospvParseRule)->Name == OSPC_OSNULL)
1280
*ospvParseRule = OSPC_OSNULL;
1281
errorcode = OSPC_ERR_ASN1_PARSE_COMPLETE;
1292
OSPTASN1PARSERULE *ospvParseRule)
1294
return (ospvParseRule->MinimumCount == 0);
1300
OSPTASN1PARSERULE *ospvParseRule)
1302
int is_primitive = 0;
1304
switch(ospvParseRule->Tag)
1306
case OSPC_TAG_TYPE_SEQUENCE:
1307
case OSPC_TAG_TYPE_SET:
1308
/* These types are always NOT primitive */
1311
case OSPC_TAG_TYPE_DER_FORMAT:
1312
/* This one is always primitive - used to stop parsing for
1317
/* Probably primitive unless tag type is EXPLICIT */
1318
is_primitive = !(OSPM_IS_EXPLICIT(ospvParseRule->Tag));
1321
return is_primitive;
1326
OSPTASN1PARSERULE *ospvParseRule)
1328
return(ospvParseRule->Tag == OSPC_TAG_TYPE_DERIVED);
1333
OSPTASN1PARSERULE *ospvParseRule)
1335
return(ospvParseRule->Tag == OSPC_TAG_TYPE_DER_FORMAT);
1339
PTPRuleGetParseTableId(
1340
OSPTASN1PARSERULE *ospvParseRule,
1341
OSPEASN1PARSETABLEID *ospvParseTableId)
1343
int errorcode = OSPC_ERR_NO_ERROR;
1345
*ospvParseTableId = ospvParseRule->ParseTableId;
1353
OSPTASN1PARSERESULT **ospvParseResult)
1355
OSPTASN1PARSERESULT *thisResult = OSPC_OSNULL;
1356
OSPTASN1PARSERESULT *nextResult = OSPC_OSNULL;
1358
if (ospvParseResult != OSPC_OSNULL)
1360
for ( thisResult = *ospvParseResult;
1361
thisResult != OSPC_OSNULL;
1362
thisResult = nextResult)
1364
/* Point at the next element */
1365
nextResult = thisResult->NextResult;
1367
/* Remove the current list node */
1368
OSPM_FREE(thisResult);
1371
*ospvParseResult = OSPC_OSNULL;
1377
PTPDataReferencesMatch(
1378
unsigned char *ospvDataReferenceId1,
1379
unsigned char *ospvDataReferenceId2)
1381
unsigned char *ptr1 = OSPC_OSNULL;
1382
unsigned char *ptr2 = OSPC_OSNULL;
1384
/* Data reference ids are unsigned char arrays terminated with 0xff */
1386
for(ptr1 = ospvDataReferenceId1, ptr2 = ospvDataReferenceId2;
1387
ptr1 && ptr2 && (*ptr1 == *ptr2) && (*ptr1 != 0xff) && (*ptr2 != 0xff);
1390
return ((*ptr1 == 0xff) && (*ptr2 == 0xff));
1394
PTPResultIsRuleComponent(
1395
unsigned char *ospvRuleDataReference,
1396
unsigned char *ospvResultDataReference)
1398
unsigned char *ptr1 = OSPC_OSNULL;
1399
unsigned char *ptr2 = OSPC_OSNULL;
1401
/* Data reference ids are unsigned char arrays terminated with 0xff, if
1402
hit the end of the rule DataReference, then the result data reference
1403
must match up to the end of the rule data reference. */
1405
for(ptr1 = ospvRuleDataReference, ptr2 = ospvResultDataReference;
1406
ptr1 && ptr2 && (*ptr1 == *ptr2) && (*ptr1 != 0xff) && (*ptr2 != 0xff);
1409
return (*ptr1 == 0xff);
1414
PTPDataRefIdGetValue(
1415
OSPEASN1DATAREFID ospvDataRefId,
1416
unsigned char **ospvDataRefValue)
1418
int errorcode = OSPC_ERR_NO_ERROR;
1420
if (ospvDataRefId >= OSPEDRID_LAST_DRID)
1422
errorcode = OSPC_ERR_ASN1_INVALID_DATAREFID;
1423
OSPM_DBGERRORLOG(errorcode, "Invalid data reference id value");
1427
*ospvDataRefValue = ospgDataRefIdIndex[ospvDataRefId];
1434
PTPResultsGetElement(
1435
OSPEASN1DATAREFID ospvDataReferenceId,
1436
OSPTASN1PARSERESULT *ospvParseResult,
1437
OSPTASN1ELEMENTINFO **ospvFoundElement)
1439
int errorcode = OSPC_ERR_NO_ERROR;
1440
OSPTASN1PARSERESULT *thisResult = OSPC_OSNULL;
1441
unsigned char *dataReference = OSPC_OSNULL;
1443
errorcode = PTPDataRefIdGetValue(ospvDataReferenceId, &dataReference);
1445
if (errorcode == OSPC_ERR_NO_ERROR)
1447
for ( thisResult = ospvParseResult, *ospvFoundElement = OSPC_OSNULL;
1448
(thisResult != OSPC_OSNULL) &&
1449
(*ospvFoundElement == OSPC_OSNULL);
1450
thisResult = thisResult->NextResult)
1452
if (PTPDataReferencesMatch(dataReference,
1453
thisResult->DataReference))
1455
*ospvFoundElement = thisResult->ElementInfo;
1465
PTPResultUpdateDataRef(
1466
unsigned char ospvParentDataRef,
1467
OSPTASN1PARSERESULT *ospvParseResult)
1470
unsigned char *ucptr = OSPC_OSNULL;
1471
OSPTASN1PARSERESULT *nextResult = OSPC_OSNULL;
1473
/* Updates the data references in all of the parse results from the
1474
head to the tail by prefixing them with the value retrieved for the
1475
supplied DataRefId. */
1477
if (ospvParseResult == OSPC_OSNULL)
1479
OSPM_DBGERRORLOG(-1, "WARNING: ospvParseResult=NULL in UpdateDataRef");
1483
for (nextResult = ospvParseResult ; nextResult != OSPC_OSNULL;
1484
nextResult = nextResult->NextResult)
1486
ucptr = nextResult->DataReference;
1489
/* Make space for the new reference */
1490
for (i = (OSPC_ASN1_DATAREF_MAXLENGTH-1) ; ucptr && (i > 0) ; i--)
1492
ucptr[i] = ucptr[i-1];
1495
*ucptr = ospvParentDataRef;
1497
/* Test Data Reference to make sure it is terminated,
1499
if (ucptr[OSPC_ASN1_DATAREF_MAXLENGTH-1] != 0xff)
1501
/* The Data Reference overflowed - should always
1502
terminate with 0xff, set to 0xff when adding result */
1514
OSPTASN1PARSERESULT **ospvParseResult,
1515
OSPTASN1ELEMENTINFO *ospvElement,
1516
OSPEASN1DATAREFID ospvDataRefId)
1518
int errorcode = OSPC_ERR_NO_ERROR;
1519
OSPTASN1PARSERESULT *parseResults = OSPC_OSNULL;
1520
unsigned char *dataReference = OSPC_OSNULL;
1522
OSPM_MALLOC(parseResults, OSPTASN1PARSERESULT, sizeof(OSPTASN1PARSERESULT));
1524
if (parseResults == OSPC_OSNULL)
1526
errorcode = OSPC_ERR_ASN1_UNABLE_TO_ALLOCATE_SPACE;
1527
OSPM_DBGERRORLOG(errorcode,
1528
"Unable to allocate space for new parse result");
1532
OSPM_MEMSET(parseResults, 0, sizeof(OSPTASN1PARSERESULT));
1535
if (errorcode != OSPC_ERR_NO_ERROR)
1537
OSPM_FREE(parseResults);
1541
errorcode = PTPDataRefIdGetValue(ospvDataRefId, &dataReference);
1544
if (errorcode == OSPC_ERR_NO_ERROR)
1546
OSPM_MEMCPY(parseResults->DataReference,
1547
dataReference, OSPC_ASN1_DATAREF_MAXLENGTH);
1548
parseResults->ElementInfo = ospvElement;
1550
*ospvParseResult = parseResults;
1558
OSPTASN1PARSERESULT **ospvDstResults,
1559
OSPTASN1PARSERESULT *ospvSrcResults)
1561
int errorcode = OSPC_ERR_NO_ERROR;
1563
OSPTASN1PARSERESULT *parseResults = OSPC_OSNULL;
1565
OSPM_MALLOC(parseResults, OSPTASN1PARSERESULT, sizeof(OSPTASN1PARSERESULT));
1567
if (parseResults == OSPC_OSNULL)
1569
errorcode = OSPC_ERR_ASN1_UNABLE_TO_ALLOCATE_SPACE;
1570
OSPM_DBGERRORLOG(errorcode,
1571
"Unable to allocate space for new parse result");
1575
OSPM_MEMSET(parseResults, 0, sizeof(parseResults));
1578
if (errorcode != OSPC_ERR_NO_ERROR)
1580
OSPM_FREE(parseResults);
1584
OSPM_MEMCPY(parseResults->DataReference,
1585
ospvSrcResults->DataReference, OSPC_ASN1_DATAREF_MAXLENGTH);
1587
errorcode = OSPPASN1ElementCopy(&(parseResults->ElementInfo),
1588
ospvSrcResults->ElementInfo);
1589
parseResults->NextResult = OSPC_OSNULL;
1591
*ospvDstResults = parseResults;
1599
unsigned char ospvDataReference[OSPC_ASN1_DATAREF_MAXLENGTH],
1600
unsigned char ospvNewReference)
1602
int errorcode = OSPC_ERR_NO_ERROR;
1605
if (ospvNewReference > 0) /* Don't add zeros - primitive as top rule */
1607
/* Data reference must be an array of MAXLENGTH SIZE */
1608
for (i = 0 ; (i < (OSPC_ASN1_DATAREF_MAXLENGTH-1)) &&
1609
(ospvDataReference[i] != 0xff); i++);
1611
if (i == (OSPC_ASN1_DATAREF_MAXLENGTH-1))
1613
errorcode = OSPC_ERR_ASN1_BUFFER_OVERFLOW;
1614
OSPM_DBGERRORLOG(errorcode,
1615
"Increase the size of OSPC_ASN1_DATAREF_MAXLENGTH");
1618
if (errorcode == OSPC_ERR_NO_ERROR)
1620
ospvDataReference[i++] = ospvNewReference;
1621
ospvDataReference[i] = 0xff; /* Has to have a terminator */
1628
OSPTASN1PARSERESULT *
1629
PTPResultsEndOfList(
1630
OSPTASN1PARSERESULT *ospvParseResult)
1632
OSPTASN1PARSERESULT *lastResult = OSPC_OSNULL;
1634
for ( lastResult = ospvParseResult;
1635
(lastResult != OSPC_OSNULL) &&
1636
(lastResult->NextResult != OSPC_OSNULL);
1637
lastResult = lastResult->NextResult);