3
* "AuthenticationFramework" ASN.1 module encode/decode/extracting/matching/free C src.
4
* This file was generated by modified eSMACC compiler Sat Dec 11 11:22:49 2004
5
* The generated files are supposed to be compiled as a module for OpenLDAP Software
8
#include "certificate.h"
10
BDecComponentCertificateTop( void* mem_op, GenBuf* b, void **v, AsnLen* bytesDecoded,int mode) {
14
tag = BDecTag ( b, bytesDecoded );
15
elmtLen = BDecLen ( b, bytesDecoded );
16
if ( elmtLen <= 0 ) return (-1);
17
if ( tag != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE) ) {
21
return BDecComponentCertificate( mem_op, b, tag, elmtLen, (ComponentCertificate**)v,(AsnLen*)bytesDecoded, mode );
24
void init_module_AuthenticationFramework() {
25
/* Register Certificate OID and its decoder */
26
InstallOidDecoderMapping( "2.5.4.36", NULL,
27
GDecComponentCertificate,
28
BDecComponentCertificateTop,
29
ExtractingComponentCertificate,
30
MatchingComponentCertificate );
31
InitAnyAuthenticationFramework();
34
void InitAnyAuthenticationFramework()
36
AsnOid oid0 ={ 9, "\52\206\110\206\367\15\1\1\4" };
37
AsnOid oid1 ={ 9, "\52\206\110\206\367\15\1\1\1" };
38
AsnOid oid2 ={ 9, "\52\206\110\206\367\15\1\1\5" };
39
AsnOid oid3 ={ 3, "\125\4\3" };
40
AsnOid oid4 ={ 3, "\125\4\6" };
41
AsnOid oid5 ={ 3, "\125\4\7" };
42
AsnOid oid6 ={ 3, "\125\4\10" };
43
AsnOid oid7 ={ 3, "\125\4\12" };
44
AsnOid oid8 ={ 3, "\125\4\13" };
45
AsnOid oid9 ={ 10, "\11\222\46\211\223\362\54\144\1\3" };
46
AsnOid oid10 ={ 9, "\52\206\110\206\367\15\1\11\1" };
47
AsnOid oid11 ={ 3, "\125\35\23" };
48
AsnOid oid12 ={ 9, "\140\206\110\1\206\370\102\1\15" };
49
AsnOid oid13 ={ 3, "\125\35\16" };
50
AsnOid oid14 ={ 3, "\125\35\25" };
51
AsnOid oid15 ={ 3, "\125\35\24" };
52
AsnOid oid17 ={ 3, "\125\35\34" };
55
InstallAnyByComponentOid (nullOid_ANY_ID, &oid0, sizeof (ComponentNull), (EncodeFcn)BEncAsnNull, (gser_decoder_func*)GDecComponentNull, (ber_tag_decoder_func*)BDecComponentNullTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentNull,(FreeFcn)FreeComponentNull, (PrintFcn)NULL);
57
InstallAnyByComponentOid (nullOid2_ANY_ID, &oid1, sizeof (ComponentNull), (EncodeFcn)BEncAsnNull, (gser_decoder_func*)GDecComponentNull, (ber_tag_decoder_func*)BDecComponentNullTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentNull,(FreeFcn)FreeComponentNull, (PrintFcn)NULL);
59
InstallAnyByComponentOid (nullOid3_ANY_ID, &oid2, sizeof (ComponentNull), (EncodeFcn)BEncAsnNull, (gser_decoder_func*)GDecComponentNull, (ber_tag_decoder_func*)BDecComponentNullTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentNull,(FreeFcn)FreeComponentNull, (PrintFcn)NULL);
61
InstallAnyByComponentOid (printableStringOid_ANY_ID, &oid3, sizeof (ComponentPrintableString), (EncodeFcn)BEncPrintableString, (gser_decoder_func*)GDecComponentPrintableString, (ber_tag_decoder_func*)BDecComponentPrintableStringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentPrintableString,(FreeFcn)FreeComponentPrintableString, (PrintFcn)NULL);
63
InstallAnyByComponentOid (printableStringOid2_ANY_ID, &oid4, sizeof (ComponentPrintableString), (EncodeFcn)BEncPrintableString, (gser_decoder_func*)GDecComponentPrintableString, (ber_tag_decoder_func*)BDecComponentPrintableStringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentPrintableString,(FreeFcn)FreeComponentPrintableString, (PrintFcn)NULL);
65
InstallAnyByComponentOid (printableStringOid3_ANY_ID, &oid5, sizeof (ComponentPrintableString), (EncodeFcn)BEncPrintableString, (gser_decoder_func*)GDecComponentPrintableString, (ber_tag_decoder_func*)BDecComponentPrintableStringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentPrintableString,(FreeFcn)FreeComponentPrintableString, (PrintFcn)NULL);
67
InstallAnyByComponentOid (printableStringOid4_ANY_ID, &oid6, sizeof (ComponentPrintableString), (EncodeFcn)BEncPrintableString, (gser_decoder_func*)GDecComponentPrintableString, (ber_tag_decoder_func*)BDecComponentPrintableStringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentPrintableString,(FreeFcn)FreeComponentPrintableString, (PrintFcn)NULL);
69
InstallAnyByComponentOid (printableStringOid5_ANY_ID, &oid7, sizeof (ComponentPrintableString), (EncodeFcn)BEncPrintableString, (gser_decoder_func*)GDecComponentPrintableString, (ber_tag_decoder_func*)BDecComponentPrintableStringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentPrintableString,(FreeFcn)FreeComponentPrintableString, (PrintFcn)NULL);
71
InstallAnyByComponentOid (printableStringOid6_ANY_ID, &oid8, sizeof (ComponentPrintableString), (EncodeFcn)BEncPrintableString, (gser_decoder_func*)GDecComponentPrintableString, (ber_tag_decoder_func*)BDecComponentPrintableStringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentPrintableString,(FreeFcn)FreeComponentPrintableString, (PrintFcn)NULL);
73
InstallAnyByComponentOid (printableStringOid7_ANY_ID, &oid9, sizeof (ComponentTeletexString), (EncodeFcn)BEncTeletexString, (gser_decoder_func*)GDecComponentTeletexString, (ber_tag_decoder_func*)BDecComponentTeletexStringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentTeletexString,(FreeFcn)FreeComponentTeletexString, (PrintFcn)NULL);
75
InstallAnyByComponentOid (iA5StringOid_ANY_ID, &oid10, sizeof (ComponentIA5String), (EncodeFcn)BEncIA5String, (gser_decoder_func*)GDecComponentIA5String, (ber_tag_decoder_func*)BDecComponentIA5StringTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentIA5String,(FreeFcn)FreeComponentIA5String, (PrintFcn)NULL);
77
InstallAnyByComponentOid (octetStringOid_ANY_ID, &oid11, sizeof (ComponentOcts), (EncodeFcn)BEncAsnOcts, (gser_decoder_func*)GDecComponentOcts, (ber_tag_decoder_func*)BDecComponentOctsTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentOcts,(FreeFcn)FreeComponentOcts, (PrintFcn)NULL);
79
InstallAnyByComponentOid (octetStringOid2_ANY_ID, &oid12, sizeof (ComponentOcts), (EncodeFcn)BEncAsnOcts, (gser_decoder_func*)GDecComponentOcts, (ber_tag_decoder_func*)BDecComponentOctsTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentOcts,(FreeFcn)FreeComponentOcts, (PrintFcn)NULL);
81
InstallAnyByComponentOid (octetStringOid3_ANY_ID, &oid13, sizeof (ComponentOcts), (EncodeFcn)BEncAsnOcts, (gser_decoder_func*)GDecComponentOcts, (ber_tag_decoder_func*)BDecComponentOctsTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentOcts,(FreeFcn)FreeComponentOcts, (PrintFcn)NULL);
83
InstallAnyByComponentOid (octetStringOid4_ANY_ID, &oid14, sizeof (ComponentOcts), (EncodeFcn)BEncAsnOcts, (gser_decoder_func*)GDecComponentOcts, (ber_tag_decoder_func*)BDecComponentOctsTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentOcts,(FreeFcn)FreeComponentOcts, (PrintFcn)NULL);
85
InstallAnyByComponentOid (octetStringOid5_ANY_ID, &oid15, sizeof (ComponentOcts), (EncodeFcn)BEncAsnOcts, (gser_decoder_func*)GDecComponentOcts, (ber_tag_decoder_func*)BDecComponentOctsTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentOcts,(FreeFcn)FreeComponentOcts, (PrintFcn)NULL);
87
InstallAnyByComponentOid (octetStringOid7_ANY_ID, &oid17, sizeof (ComponentOcts), (EncodeFcn)BEncAsnOcts, (gser_decoder_func*)GDecComponentOcts, (ber_tag_decoder_func*)BDecComponentOctsTag, (ExtractFcn)NULL,(MatchFcn)MatchingComponentOcts,(FreeFcn)FreeComponentOcts, (PrintFcn)NULL);
89
} /* InitAnyAuthenticationFramework */
92
MatchingComponentAlgorithmIdentifier ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
97
mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
98
if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
102
rc = MatchingComponentOid ( oid, (ComponentSyntaxInfo*)&((ComponentAlgorithmIdentifier*)csi_attr)->algorithm, (ComponentSyntaxInfo*)&((ComponentAlgorithmIdentifier*)csi_assert)->algorithm );
103
if ( rc != LDAP_COMPARE_TRUE )
105
rc = SetAnyTypeByComponentOid ((ComponentSyntaxInfo*)&((ComponentAlgorithmIdentifier*)csi_attr)->parameters, (&((ComponentAlgorithmIdentifier*)csi_attr)->algorithm));
106
rc = MatchingComponentAnyDefinedBy ( oid, (ComponentAny*)&((ComponentAlgorithmIdentifier*)csi_attr)->parameters, (ComponentAny*)&((ComponentAlgorithmIdentifier*)csi_assert)->parameters);
107
if ( rc != LDAP_COMPARE_TRUE )
109
return LDAP_COMPARE_TRUE;
110
} /* BMatchingComponentAlgorithmIdentifier */
113
ExtractingComponentAlgorithmIdentifier ( void* mem_op, ComponentReference* cr, ComponentAlgorithmIdentifier *comp )
116
if ( ( comp->algorithm.identifier.bv_val && strncmp(comp->algorithm.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->algorithm.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
117
if ( cr->cr_curr->ci_next == NULL )
118
return &comp->algorithm;
122
if ( ( comp->parameters.identifier.bv_val && strncmp(comp->parameters.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->parameters.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
123
if ( cr->cr_curr->ci_next == NULL )
124
return &comp->parameters;
125
else if ( cr->cr_curr->ci_next->ci_type == LDAP_COMPREF_CONTENT) {
126
cr->cr_curr = cr->cr_curr->ci_next;
127
return &comp->parameters;
133
} /* ExtractingComponentAlgorithmIdentifier */
136
BDecComponentAlgorithmIdentifier PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
140
AsnLen elmtLen0 _AND_
141
ComponentAlgorithmIdentifier **v _AND_
142
AsnLen *bytesDecoded _AND_
146
AsnLen totalElmtsLen1 = 0;
149
int mandatoryElmtCount1 = 0;
152
ComponentAlgorithmIdentifier *k, *t, c_temp;
155
if ( !(mode & DEC_ALLOC_MODE_1) ) {
156
memset(&c_temp,0,sizeof(c_temp));
160
mode = DEC_ALLOC_MODE_2;
161
tagId1 = BDecTag (b, &totalElmtsLen1 );
163
if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))))
165
elmtLen1 = BDecLen (b, &totalElmtsLen1 );
166
rc = BDecComponentOid (mem_op, b, tagId1, elmtLen1, (&k->algorithm), &totalElmtsLen1, mode);
167
if ( rc != LDAP_SUCCESS ) return rc;
168
(&k->algorithm)->identifier.bv_val = (&k->algorithm)->id_buf;
169
(&k->algorithm)->identifier.bv_len = strlen("algorithm");
170
strcpy( (&k->algorithm)->identifier.bv_val, "algorithm");
171
if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0))
175
tagId1 = BufPeekByte (b);
176
if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID))
178
BDecEoc (b, &totalElmtsLen1 );
189
rc = SetAnyTypeByComponentOid ((&k->parameters), (&k->algorithm));
190
rc = BDecComponentAnyDefinedBy (mem_op,b, (&k->parameters), &totalElmtsLen1, mode );
191
if ( rc != LDAP_SUCCESS ) return rc;
192
(&k->parameters)->identifier.bv_val = (&k->parameters)->id_buf;
193
(&k->parameters)->identifier.bv_len = strlen("parameters");
194
strcpy( (&k->parameters)->identifier.bv_val, "parameters");
196
if (elmtLen0 == INDEFINITE_LEN)
197
BDecEoc (b, &totalElmtsLen1 );
198
else if (totalElmtsLen1 != elmtLen0)
207
if( !(old_mode & DEC_ALLOC_MODE_1) ) {
208
*v = t = (ComponentAlgorithmIdentifier*) CompAlloc( mem_op, sizeof(ComponentAlgorithmIdentifier) );
212
t->syntax = (Syntax*)NULL;
213
t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
214
if ( !t->comp_desc ) {
218
t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentAlgorithmIdentifier ;
219
t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentAlgorithmIdentifier ;
220
t->comp_desc->cd_free = (comp_free_func*)NULL;
221
t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentAlgorithmIdentifier;
222
t->comp_desc->cd_type = ASN_COMPOSITE;
223
t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
224
t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentAlgorithmIdentifier;
225
(*bytesDecoded) += totalElmtsLen1;
227
} /* BDecAlgorithmIdentifier*/
230
GDecComponentAlgorithmIdentifier PARAMS (( mem_op,b, v, bytesDecoded, mode),
233
ComponentAlgorithmIdentifier **v _AND_
234
AsnLen *bytesDecoded _AND_
237
char* peek_head,*peek_head2;
238
int i, strLen,strLen2, rc, old_mode = mode;
239
ComponentAlgorithmIdentifier *k,*t, c_temp;
242
if ( !(mode & DEC_ALLOC_MODE_1) ) {
243
memset(&c_temp,0,sizeof(c_temp));
247
mode = DEC_ALLOC_MODE_2;
249
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
250
Asn1Error("Error during Reading { in encoded data");
251
return LDAP_PROTOCOL_ERROR;
253
if(*peek_head != '{'){
254
Asn1Error("Missing { in encoded data");
255
return LDAP_PROTOCOL_ERROR;
258
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
259
Asn1Error("Error during Reading identifier");
260
return LDAP_PROTOCOL_ERROR;
262
if ( strncmp( peek_head, "algorithm", strlen("algorithm") ) == 0 ) {
263
rc = GDecComponentOid (mem_op, b, (&k->algorithm), bytesDecoded, mode);
264
if ( rc != LDAP_SUCCESS ) return rc;
265
(&k->algorithm)->identifier.bv_val = peek_head;
266
(&k->algorithm)->identifier.bv_len = strLen;
267
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
268
Asn1Error("Error during Reading , ");
269
return LDAP_PROTOCOL_ERROR;
271
if(*peek_head != ','){
272
Asn1Error("Missing , in encoding");
273
return LDAP_PROTOCOL_ERROR;
275
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
276
Asn1Error("Error during Reading identifier");
277
return LDAP_PROTOCOL_ERROR;
280
if ( strncmp( peek_head, "parameters", strlen("parameters") ) == 0 ) {
281
rc = rc = SetAnyTypeByComponentOid ((&k->parameters), (&k->algorithm));
282
rc = GDecComponentAnyDefinedBy (mem_op, b, (&k->parameters), bytesDecoded, mode );
283
if ( rc != LDAP_SUCCESS ) return rc;
284
(&k->parameters)->identifier.bv_val = peek_head;
285
(&k->parameters)->identifier.bv_len = strLen;
287
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {
288
Asn1Error("Error during Reading } in encoding");
289
return LDAP_PROTOCOL_ERROR;
291
if(*peek_head != '}'){
292
Asn1Error("Missing } in encoding");
293
return LDAP_PROTOCOL_ERROR;
295
if( !(old_mode & DEC_ALLOC_MODE_1) ) {
296
*v = t = (ComponentAlgorithmIdentifier*) CompAlloc( mem_op, sizeof(ComponentAlgorithmIdentifier) );
300
t->syntax = (Syntax*)NULL;
301
t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
302
if ( !t->comp_desc ) {
306
t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentAlgorithmIdentifier ;
307
t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentAlgorithmIdentifier ;
308
t->comp_desc->cd_free = (comp_free_func*)NULL;
309
t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentAlgorithmIdentifier;
310
t->comp_desc->cd_type = ASN_COMPOSITE;
311
t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
312
t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentAlgorithmIdentifier;
314
} /* GDecAlgorithmIdentifier*/
318
MatchingComponentTime ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
321
ComponentTime *v1, *v2;
324
v1 = (ComponentTime*)csi_attr;
325
v2 = (ComponentTime*)csi_assert;
327
mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
328
if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
331
if( (v1->choiceId != v2->choiceId ) )
332
return LDAP_COMPARE_FALSE;
333
switch( v1->choiceId )
336
rc = MatchingComponentUTCTime ( oid, (ComponentSyntaxInfo*)(v1->a.utcTime), (ComponentSyntaxInfo*)(v2->a.utcTime) );
338
case TIME_GENERALIZEDTIME :
339
rc = MatchingComponentGeneralizedTime ( oid, (ComponentSyntaxInfo*)(v1->a.generalizedTime), (ComponentSyntaxInfo*)(v2->a.generalizedTime) );
342
return LDAP_PROTOCOL_ERROR;
345
} /* BMatchingComponentTimeContent */
348
ExtractingComponentTime ( void* mem_op, ComponentReference* cr, ComponentTime *comp )
352
if( (comp->choiceId) == TIME_UTCTIME &&
353
(( comp->a.utcTime->identifier.bv_val && strncmp(comp->a.utcTime->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) ||
354
( strncmp(comp->a.utcTime->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) {
355
if ( cr->cr_curr->ci_next == NULL )
356
return (comp->a.utcTime);
358
cr->cr_curr = cr->cr_curr->ci_next;
359
return ExtractingComponentUTCTime ( mem_op, cr, (comp->a.utcTime) );
362
if( (comp->choiceId) == TIME_GENERALIZEDTIME &&
363
(( comp->a.generalizedTime->identifier.bv_val && strncmp(comp->a.generalizedTime->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) ||
364
( strncmp(comp->a.generalizedTime->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) {
365
if ( cr->cr_curr->ci_next == NULL )
366
return (comp->a.generalizedTime);
368
cr->cr_curr = cr->cr_curr->ci_next;
369
return ExtractingComponentGeneralizedTime ( mem_op, cr, (comp->a.generalizedTime) );
373
} /* ExtractingComponentTime */
376
BDecComponentTime PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
380
AsnLen elmtLen0 _AND_
381
ComponentTime **v _AND_
382
AsnLen *bytesDecoded _AND_
386
AsnLen totalElmtsLen1 = 0;
389
int mandatoryElmtCount1 = 0;
392
ComponentTime *k, *t, c_temp;
395
if ( !(mode & DEC_ALLOC_MODE_1) ) {
396
memset(&c_temp,0,sizeof(c_temp));
400
mode = DEC_ALLOC_MODE_2;
403
case MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE):
404
case MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE):
405
(k->choiceId) = TIME_UTCTIME;
406
rc = BDecComponentUTCTime (mem_op, b, tagId0, elmtLen0, (&k->a.utcTime), &totalElmtsLen1, DEC_ALLOC_MODE_0 );
407
if ( rc != LDAP_SUCCESS ) return rc;
408
(k->a.utcTime)->identifier.bv_val = (k->a.utcTime)->id_buf;
409
(k->a.utcTime)->identifier.bv_len = strlen("utcTime");
410
strcpy( (k->a.utcTime)->identifier.bv_val, "utcTime");
413
case MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE):
414
case MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE):
415
(k->choiceId) = TIME_GENERALIZEDTIME;
416
rc = BDecComponentGeneralizedTime (mem_op, b, tagId0, elmtLen0, (&k->a.generalizedTime), &totalElmtsLen1, DEC_ALLOC_MODE_0 );
417
if ( rc != LDAP_SUCCESS ) return rc;
418
(k->a.generalizedTime)->identifier.bv_val = (k->a.generalizedTime)->id_buf;
419
(k->a.generalizedTime)->identifier.bv_len = strlen("generalizedTime");
420
strcpy( (k->a.generalizedTime)->identifier.bv_val, "generalizedTime");
424
Asn1Error ("ERROR - unexpected tag in CHOICE\n");
428
if( !(old_mode & DEC_ALLOC_MODE_1) ) {
429
*v = t = (ComponentTime*) CompAlloc( mem_op, sizeof(ComponentTime) );
433
t->syntax = (Syntax*)NULL;
434
t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
435
if ( !t->comp_desc ) {
439
t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentTime ;
440
t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentTime ;
441
t->comp_desc->cd_free = (comp_free_func*)NULL;
442
t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentTime;
443
t->comp_desc->cd_type = ASN_COMPOSITE;
444
t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
445
t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentTime;
446
(*bytesDecoded) += totalElmtsLen1;
448
} /* BDecTimeContent */
451
GDecComponentTime PARAMS (( mem_op,b, v, bytesDecoded, mode),
454
ComponentTime **v _AND_
455
AsnLen *bytesDecoded _AND_
458
char* peek_head,*peek_head2;
459
int i, strLen,strLen2, rc, old_mode = mode;
460
ComponentTime *k,*t, c_temp;
463
if ( !(mode & DEC_ALLOC_MODE_1) ) {
464
memset(&c_temp,0,sizeof(c_temp));
468
mode = DEC_ALLOC_MODE_2;
469
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
470
Asn1Error("Error during Reading identifier");
471
return LDAP_PROTOCOL_ERROR;
473
if( !(strLen2 = LocateNextGSERToken(mem_op,b,&peek_head2,GSER_NO_COPY)) ){
474
Asn1Error("Error during Reading identifier");
475
return LDAP_PROTOCOL_ERROR;
477
if(*peek_head2 != ':'){
478
Asn1Error("Missing : in encoded data");
479
return LDAP_PROTOCOL_ERROR;
481
if( strncmp("utcTime",peek_head, strlen("utcTime")) == 0){
482
(k->choiceId) = TIME_UTCTIME;
483
rc = GDecComponentUTCTime (mem_op, b, (&k->a.utcTime), bytesDecoded, DEC_ALLOC_MODE_0 );
484
if ( rc != LDAP_SUCCESS ) return rc;
485
(k->a.utcTime)->identifier.bv_val = peek_head;
486
(k->a.utcTime)->identifier.bv_len = strLen;
488
else if( strncmp("generalizedTime",peek_head,strlen("generalizedTime")) == 0){
489
(k->choiceId) = TIME_GENERALIZEDTIME;
490
rc = GDecComponentGeneralizedTime (mem_op, b, (&k->a.generalizedTime), bytesDecoded, DEC_ALLOC_MODE_0 );
491
if ( rc != LDAP_SUCCESS ) return rc;
492
(k->a.generalizedTime)->identifier.bv_val = peek_head;
493
(k->a.generalizedTime)->identifier.bv_len = strLen;
496
Asn1Error("Undefined Identifier");
497
return LDAP_PROTOCOL_ERROR;
499
if( !(old_mode & DEC_ALLOC_MODE_1) ) {
500
*v = t = (ComponentTime*) CompAlloc( mem_op, sizeof(ComponentTime) );
504
t->syntax = (Syntax*)NULL;
505
t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
506
if ( !t->comp_desc ) {
510
t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentTime ;
511
t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentTime ;
512
t->comp_desc->cd_free = (comp_free_func*)NULL;
513
t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentTime;
514
t->comp_desc->cd_type = ASN_COMPOSITE;
515
t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
516
t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentTime;
518
} /* GDecTimeContent */
522
MatchingComponentExtension ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
527
mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
528
if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
532
rc = MatchingComponentOid ( oid, (ComponentSyntaxInfo*)&((ComponentExtension*)csi_attr)->extnID, (ComponentSyntaxInfo*)&((ComponentExtension*)csi_assert)->extnID );
533
if ( rc != LDAP_COMPARE_TRUE )
535
rc = MatchingComponentBool ( oid, (ComponentSyntaxInfo*)((ComponentExtension*)csi_attr)->critical, (ComponentSyntaxInfo*)((ComponentExtension*)csi_assert)->critical );
536
if ( rc != LDAP_COMPARE_TRUE )
538
rc = MatchingComponentOcts ( oid, (ComponentSyntaxInfo*)&((ComponentExtension*)csi_attr)->extnValue, (ComponentSyntaxInfo*)&((ComponentExtension*)csi_assert)->extnValue );
539
if ( rc != LDAP_COMPARE_TRUE )
541
return LDAP_COMPARE_TRUE;
542
} /* BMatchingComponentExtension */
545
ExtractingComponentExtension ( void* mem_op, ComponentReference* cr, ComponentExtension *comp )
548
if ( ( comp->extnID.identifier.bv_val && strncmp(comp->extnID.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->extnID.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
549
if ( cr->cr_curr->ci_next == NULL )
550
return &comp->extnID;
554
if ( ( comp->critical->identifier.bv_val && strncmp(comp->critical->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->critical->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
555
if ( cr->cr_curr->ci_next == NULL )
556
return comp->critical;
558
cr->cr_curr = cr->cr_curr->ci_next;
559
return ExtractingComponentBool ( mem_op, cr, comp->critical );
562
if ( ( comp->extnValue.identifier.bv_val && strncmp(comp->extnValue.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->extnValue.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
563
if ( cr->cr_curr->ci_next == NULL )
564
return &comp->extnValue;
565
else if ( cr->cr_curr->ci_next->ci_type == LDAP_COMPREF_CONTENT) {
566
cr->cr_curr = cr->cr_curr->ci_next;
567
return &comp->extnValue;
573
} /* ExtractingComponentExtension */
576
BDecComponentExtension PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
580
AsnLen elmtLen0 _AND_
581
ComponentExtension **v _AND_
582
AsnLen *bytesDecoded _AND_
586
AsnLen totalElmtsLen1 = 0;
589
int mandatoryElmtCount1 = 0;
592
ComponentExtension *k, *t, c_temp;
595
if ( !(mode & DEC_ALLOC_MODE_1) ) {
596
memset(&c_temp,0,sizeof(c_temp));
600
mode = DEC_ALLOC_MODE_2;
601
tagId1 = BDecTag (b, &totalElmtsLen1 );
603
if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))))
605
elmtLen1 = BDecLen (b, &totalElmtsLen1 );
606
rc = BDecComponentOid (mem_op, b, tagId1, elmtLen1, (&k->extnID), &totalElmtsLen1, mode);
607
if ( rc != LDAP_SUCCESS ) return rc;
608
(&k->extnID)->identifier.bv_val = (&k->extnID)->id_buf;
609
(&k->extnID)->identifier.bv_len = strlen("extnID");
610
strcpy( (&k->extnID)->identifier.bv_val, "extnID");
611
tagId1 = BDecTag (b, &totalElmtsLen1);
618
if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, BOOLEAN_TAG_CODE))))
620
elmtLen1 = BDecLen (b, &totalElmtsLen1 );
621
rc = BDecComponentBool (mem_op, b, tagId1, elmtLen1, (&k->critical), &totalElmtsLen1, DEC_ALLOC_MODE_0 );
622
if ( rc != LDAP_SUCCESS ) return rc;
623
(k->critical)->identifier.bv_val = (k->critical)->id_buf;
624
(k->critical)->identifier.bv_len = strlen("critical");
625
strcpy( (k->critical)->identifier.bv_val, "critical");
626
tagId1 = BDecTag (b, &totalElmtsLen1);
630
if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) ||
631
(tagId1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))))
633
elmtLen1 = BDecLen (b, &totalElmtsLen1 );
634
rc = BDecComponentOcts (mem_op, b, tagId1, elmtLen1, (&k->extnValue), &totalElmtsLen1, mode);
635
if ( rc != LDAP_SUCCESS ) return rc;
636
(&k->extnValue)->identifier.bv_val = (&k->extnValue)->id_buf;
637
(&k->extnValue)->identifier.bv_len = strlen("extnValue");
638
strcpy( (&k->extnValue)->identifier.bv_val, "extnValue");
640
if (elmtLen0 == INDEFINITE_LEN)
641
BDecEoc (b, &totalElmtsLen1 );
642
else if (totalElmtsLen1 != elmtLen0)
654
if(!COMPONENTNOT_NULL ((k->critical)))
656
(k->critical) = CompAlloc( mem_op, sizeof(ComponentBool));
657
(k->critical)->identifier.bv_val = (k->critical)->id_buf;
658
(k->critical)->identifier.bv_len = strlen("critical");
659
strcpy( (k->critical)->identifier.bv_val, "critical");
660
(k->critical)->value = 0;
662
if( !(old_mode & DEC_ALLOC_MODE_1) ) {
663
*v = t = (ComponentExtension*) CompAlloc( mem_op, sizeof(ComponentExtension) );
667
t->syntax = (Syntax*)NULL;
668
t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
669
if ( !t->comp_desc ) {
673
t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentExtension ;
674
t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentExtension ;
675
t->comp_desc->cd_free = (comp_free_func*)NULL;
676
t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentExtension;
677
t->comp_desc->cd_type = ASN_COMPOSITE;
678
t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
679
t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentExtension;
680
(*bytesDecoded) += totalElmtsLen1;
685
GDecComponentExtension PARAMS (( mem_op,b, v, bytesDecoded, mode),
688
ComponentExtension **v _AND_
689
AsnLen *bytesDecoded _AND_
692
char* peek_head,*peek_head2;
693
int i, strLen,strLen2, rc, old_mode = mode;
694
ComponentExtension *k,*t, c_temp;
697
if ( !(mode & DEC_ALLOC_MODE_1) ) {
698
memset(&c_temp,0,sizeof(c_temp));
702
mode = DEC_ALLOC_MODE_2;
704
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
705
Asn1Error("Error during Reading { in encoded data");
706
return LDAP_PROTOCOL_ERROR;
708
if(*peek_head != '{'){
709
Asn1Error("Missing { in encoded data");
710
return LDAP_PROTOCOL_ERROR;
713
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
714
Asn1Error("Error during Reading identifier");
715
return LDAP_PROTOCOL_ERROR;
717
if ( strncmp( peek_head, "extnID", strlen("extnID") ) == 0 ) {
718
rc = GDecComponentOid (mem_op, b, (&k->extnID), bytesDecoded, mode);
719
if ( rc != LDAP_SUCCESS ) return rc;
720
(&k->extnID)->identifier.bv_val = peek_head;
721
(&k->extnID)->identifier.bv_len = strLen;
722
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
723
Asn1Error("Error during Reading , ");
724
return LDAP_PROTOCOL_ERROR;
726
if(*peek_head != ','){
727
Asn1Error("Missing , in encoding");
728
return LDAP_PROTOCOL_ERROR;
730
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
731
Asn1Error("Error during Reading identifier");
732
return LDAP_PROTOCOL_ERROR;
735
if ( strncmp( peek_head, "critical", strlen("critical") ) == 0 ) {
736
rc = GDecComponentBool (mem_op, b, (&k->critical), bytesDecoded, DEC_ALLOC_MODE_0 );
737
if ( rc != LDAP_SUCCESS ) return rc;
738
( k->critical)->identifier.bv_val = peek_head;
739
( k->critical)->identifier.bv_len = strLen;
740
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
741
Asn1Error("Error during Reading , ");
742
return LDAP_PROTOCOL_ERROR;
744
if(*peek_head != ','){
745
Asn1Error("Missing , in encoding");
746
return LDAP_PROTOCOL_ERROR;
748
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
749
Asn1Error("Error during Reading identifier");
750
return LDAP_PROTOCOL_ERROR;
754
(k->critical) = CompAlloc( mem_op, sizeof(ComponentBool));
755
(k->critical)->value = 0;
757
if ( strncmp( peek_head, "extnValue", strlen("extnValue") ) == 0 ) {
758
rc = GDecComponentOcts (mem_op, b, (&k->extnValue), bytesDecoded, mode);
759
if ( rc != LDAP_SUCCESS ) return rc;
760
(&k->extnValue)->identifier.bv_val = peek_head;
761
(&k->extnValue)->identifier.bv_len = strLen;
763
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {
764
Asn1Error("Error during Reading } in encoding");
765
return LDAP_PROTOCOL_ERROR;
767
if(*peek_head != '}'){
768
Asn1Error("Missing } in encoding");
769
return LDAP_PROTOCOL_ERROR;
771
if( !(old_mode & DEC_ALLOC_MODE_1) ) {
772
*v = t = (ComponentExtension*) CompAlloc( mem_op, sizeof(ComponentExtension) );
776
t->syntax = (Syntax*)NULL;
777
t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
778
if ( !t->comp_desc ) {
782
t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentExtension ;
783
t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentExtension ;
784
t->comp_desc->cd_free = (comp_free_func*)NULL;
785
t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentExtension;
786
t->comp_desc->cd_type = ASN_COMPOSITE;
787
t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
788
t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentExtension;
794
MatchingComponentAttributeTypeAndValue ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
799
mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
800
if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
804
rc = MatchingComponentAttributeType ( oid, (ComponentSyntaxInfo*)&((ComponentAttributeTypeAndValue*)csi_attr)->type, (ComponentSyntaxInfo*)&((ComponentAttributeTypeAndValue*)csi_assert)->type );
805
if ( rc != LDAP_COMPARE_TRUE )
807
rc = SetAnyTypeByComponentOid ((ComponentSyntaxInfo*)&((ComponentAttributeTypeAndValue*)csi_attr)->value, (&((ComponentAttributeTypeAndValue*)csi_attr)->type));
808
rc = MatchingComponentAnyDefinedBy ( oid, (ComponentAny*)&((ComponentAttributeTypeAndValue*)csi_attr)->value, (ComponentAny*)&((ComponentAttributeTypeAndValue*)csi_assert)->value);
809
if ( rc != LDAP_COMPARE_TRUE )
811
return LDAP_COMPARE_TRUE;
812
} /* BMatchingComponentAttributeTypeAndValue */
815
ExtractingComponentAttributeTypeAndValue ( void* mem_op, ComponentReference* cr, ComponentAttributeTypeAndValue *comp )
818
if ( ( comp->type.identifier.bv_val && strncmp(comp->type.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->type.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
819
if ( cr->cr_curr->ci_next == NULL )
824
if ( ( comp->value.identifier.bv_val && strncmp(comp->value.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->value.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
825
if ( cr->cr_curr->ci_next == NULL )
827
else if ( cr->cr_curr->ci_next->ci_type == LDAP_COMPREF_SELECT ) {
828
cr->cr_curr = cr->cr_curr->ci_next;
835
} /* ExtractingComponentAttributeTypeAndValue */
838
BDecComponentAttributeTypeAndValue PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
842
AsnLen elmtLen0 _AND_
843
ComponentAttributeTypeAndValue **v _AND_
844
AsnLen *bytesDecoded _AND_
848
AsnLen totalElmtsLen1 = 0;
851
int mandatoryElmtCount1 = 0;
854
ComponentAttributeTypeAndValue *k, *t, c_temp;
857
if ( !(mode & DEC_ALLOC_MODE_1) ) {
858
memset(&c_temp,0,sizeof(c_temp));
862
mode = DEC_ALLOC_MODE_2;
863
tagId1 = BDecTag (b, &totalElmtsLen1 );
865
if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))))
867
elmtLen1 = BDecLen (b, &totalElmtsLen1 );
868
rc = BDecComponentAttributeType (mem_op, b, tagId1, elmtLen1, (&k->type), &totalElmtsLen1, mode);
869
if ( rc != LDAP_SUCCESS ) return rc;
870
(&k->type)->identifier.bv_val = (&k->type)->id_buf;
871
(&k->type)->identifier.bv_len = strlen("type");
872
strcpy( (&k->type)->identifier.bv_val, "type");
880
rc = SetAnyTypeByComponentOid ((&k->value), (&k->type));
881
rc = BDecComponentAnyDefinedBy (mem_op,b, (&k->value), &totalElmtsLen1, mode );
882
if ( rc != LDAP_SUCCESS ) return rc;
883
(&k->value)->identifier.bv_val = (&k->value)->id_buf;
884
(&k->value)->identifier.bv_len = strlen("value");
885
strcpy( (&k->value)->identifier.bv_val, "value");
887
if (elmtLen0 == INDEFINITE_LEN)
888
BDecEoc (b, &totalElmtsLen1 );
889
else if (totalElmtsLen1 != elmtLen0)
898
if( !(old_mode & DEC_ALLOC_MODE_1) ) {
899
*v = t = (ComponentAttributeTypeAndValue*) CompAlloc( mem_op, sizeof(ComponentAttributeTypeAndValue) );
903
t->syntax = (Syntax*)NULL;
904
t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
905
if ( !t->comp_desc ) {
909
t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentAttributeTypeAndValue ;
910
t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentAttributeTypeAndValue ;
911
t->comp_desc->cd_free = (comp_free_func*)NULL;
912
t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentAttributeTypeAndValue;
913
t->comp_desc->cd_type = ASN_COMPOSITE;
914
t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
915
t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentAttributeTypeAndValue;
916
(*bytesDecoded) += totalElmtsLen1;
918
} /* BDecAttributeTypeAndValue*/
921
GDecComponentAttributeTypeAndValue PARAMS (( mem_op,b, v, bytesDecoded, mode),
924
ComponentAttributeTypeAndValue **v _AND_
925
AsnLen *bytesDecoded _AND_
928
char* peek_head,*peek_head2;
929
int i, strLen,strLen2, rc, old_mode = mode;
930
ComponentAttributeTypeAndValue *k,*t, c_temp;
933
if ( !(mode & DEC_ALLOC_MODE_1) ) {
934
memset(&c_temp,0,sizeof(c_temp));
938
mode = DEC_ALLOC_MODE_2;
940
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
941
Asn1Error("Error during Reading { in encoded data");
942
return LDAP_PROTOCOL_ERROR;
944
if(*peek_head != '{'){
945
Asn1Error("Missing { in encoded data");
946
return LDAP_PROTOCOL_ERROR;
949
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
950
Asn1Error("Error during Reading identifier");
951
return LDAP_PROTOCOL_ERROR;
953
if ( strncmp( peek_head, "type", strlen("type") ) == 0 ) {
954
rc = GDecComponentAttributeType (mem_op, b, (&k->type), bytesDecoded, mode);
955
if ( rc != LDAP_SUCCESS ) return rc;
956
(&k->type)->identifier.bv_val = peek_head;
957
(&k->type)->identifier.bv_len = strLen;
958
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
959
Asn1Error("Error during Reading , ");
960
return LDAP_PROTOCOL_ERROR;
962
if(*peek_head != ','){
963
Asn1Error("Missing , in encoding");
964
return LDAP_PROTOCOL_ERROR;
966
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
967
Asn1Error("Error during Reading identifier");
968
return LDAP_PROTOCOL_ERROR;
971
if ( strncmp( peek_head, "value", strlen("value") ) == 0 ) {
972
rc = rc = SetAnyTypeByComponentOid ((&k->value), (&k->type));
973
rc = GDecComponentAnyDefinedBy (mem_op, b, (&k->value), bytesDecoded, mode );
974
if ( rc != LDAP_SUCCESS ) return rc;
975
(&k->value)->identifier.bv_val = peek_head;
976
(&k->value)->identifier.bv_len = strLen;
978
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {
979
Asn1Error("Error during Reading } in encoding");
980
return LDAP_PROTOCOL_ERROR;
982
if(*peek_head != '}'){
983
Asn1Error("Missing } in encoding");
984
return LDAP_PROTOCOL_ERROR;
986
if( !(old_mode & DEC_ALLOC_MODE_1) ) {
987
*v = t = (ComponentAttributeTypeAndValue*) CompAlloc( mem_op, sizeof(ComponentAttributeTypeAndValue) );
991
t->syntax = (Syntax*)NULL;
992
t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
993
if ( !t->comp_desc ) {
997
t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentAttributeTypeAndValue ;
998
t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentAttributeTypeAndValue ;
999
t->comp_desc->cd_free = (comp_free_func*)NULL;
1000
t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentAttributeTypeAndValue;
1001
t->comp_desc->cd_type = ASN_COMPOSITE;
1002
t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
1003
t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentAttributeTypeAndValue;
1004
return LDAP_SUCCESS;
1005
} /* GDecAttributeTypeAndValue*/
1009
MatchingComponentValidity ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
1014
mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
1015
if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
1019
rc = MatchingComponentTime ( oid, (ComponentSyntaxInfo*)((ComponentValidity*)csi_attr)->notBefore, (ComponentSyntaxInfo*)((ComponentValidity*)csi_assert)->notBefore );
1020
if ( rc != LDAP_COMPARE_TRUE )
1022
rc = MatchingComponentTime ( oid, (ComponentSyntaxInfo*)((ComponentValidity*)csi_attr)->notAfter, (ComponentSyntaxInfo*)((ComponentValidity*)csi_assert)->notAfter );
1023
if ( rc != LDAP_COMPARE_TRUE )
1025
return LDAP_COMPARE_TRUE;
1026
} /* BMatchingComponentValidity */
1029
ExtractingComponentValidity ( void* mem_op, ComponentReference* cr, ComponentValidity *comp )
1032
if ( ( comp->notBefore->identifier.bv_val && strncmp(comp->notBefore->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->notBefore->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
1033
if ( cr->cr_curr->ci_next == NULL )
1034
return comp->notBefore;
1036
cr->cr_curr = cr->cr_curr->ci_next;
1037
return ExtractingComponentTime ( mem_op, cr, comp->notBefore );
1040
if ( ( comp->notAfter->identifier.bv_val && strncmp(comp->notAfter->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->notAfter->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
1041
if ( cr->cr_curr->ci_next == NULL )
1042
return comp->notAfter;
1044
cr->cr_curr = cr->cr_curr->ci_next;
1045
return ExtractingComponentTime ( mem_op, cr, comp->notAfter );
1049
} /* ExtractingComponentValidity */
1052
BDecComponentValidity PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
1056
AsnLen elmtLen0 _AND_
1057
ComponentValidity **v _AND_
1058
AsnLen *bytesDecoded _AND_
1061
int seqDone = FALSE;
1062
AsnLen totalElmtsLen1 = 0;
1065
int mandatoryElmtCount1 = 0;
1066
AsnLen totalElmtsLen2 = 0;
1069
int old_mode = mode;
1071
ComponentValidity *k, *t, c_temp;
1074
if ( !(mode & DEC_ALLOC_MODE_1) ) {
1075
memset(&c_temp,0,sizeof(c_temp));
1079
mode = DEC_ALLOC_MODE_2;
1080
tagId1 = BDecTag (b, &totalElmtsLen1 );
1082
if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE)) ||
1083
(tagId1 == MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE)) ||
1084
(tagId1 ==MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE))||
1085
(tagId1 == MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE))))
1087
elmtLen1 = BDecLen (b, &totalElmtsLen1 );
1088
rc = BDecComponentTime (mem_op, b, tagId1, elmtLen1, (&k->notBefore), &totalElmtsLen1, mode);
1089
if ( rc != LDAP_SUCCESS ) return rc;
1090
(k->notBefore)->identifier.bv_val = (k->notBefore)->id_buf;
1091
(k->notBefore)->identifier.bv_len = strlen("notBefore");
1092
strcpy( (k->notBefore)->identifier.bv_val, "notBefore");
1093
tagId1 = BDecTag (b, &totalElmtsLen1);
1100
if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE)) ||
1101
(tagId1 == MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE)) ||
1102
(tagId1 ==MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE))||
1103
(tagId1 == MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE))))
1105
elmtLen1 = BDecLen (b, &totalElmtsLen1 );
1106
rc = BDecComponentTime (mem_op, b, tagId1, elmtLen1, (&k->notAfter), &totalElmtsLen1, mode);
1107
if ( rc != LDAP_SUCCESS ) return rc;
1108
(k->notAfter)->identifier.bv_val = (k->notAfter)->id_buf;
1109
(k->notAfter)->identifier.bv_len = strlen("notAfter");
1110
strcpy( (k->notAfter)->identifier.bv_val, "notAfter");
1112
if (elmtLen0 == INDEFINITE_LEN)
1113
BDecEoc (b, &totalElmtsLen1 );
1114
else if (totalElmtsLen1 != elmtLen0)
1126
if( !(old_mode & DEC_ALLOC_MODE_1) ) {
1127
*v = t = (ComponentValidity*) CompAlloc( mem_op, sizeof(ComponentValidity) );
1128
if ( !t ) return -1;
1131
t->syntax = (Syntax*)NULL;
1132
t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
1133
if ( !t->comp_desc ) {
1137
t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentValidity ;
1138
t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentValidity ;
1139
t->comp_desc->cd_free = (comp_free_func*)NULL;
1140
t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentValidity;
1141
t->comp_desc->cd_type = ASN_COMPOSITE;
1142
t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
1143
t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentValidity;
1144
(*bytesDecoded) += totalElmtsLen1;
1145
return LDAP_SUCCESS;
1149
GDecComponentValidity PARAMS (( mem_op,b, v, bytesDecoded, mode),
1152
ComponentValidity **v _AND_
1153
AsnLen *bytesDecoded _AND_
1156
char* peek_head,*peek_head2;
1157
int i, strLen,strLen2, rc, old_mode = mode;
1158
ComponentValidity *k,*t, c_temp;
1161
if ( !(mode & DEC_ALLOC_MODE_1) ) {
1162
memset(&c_temp,0,sizeof(c_temp));
1166
mode = DEC_ALLOC_MODE_2;
1168
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
1169
Asn1Error("Error during Reading { in encoded data");
1170
return LDAP_PROTOCOL_ERROR;
1172
if(*peek_head != '{'){
1173
Asn1Error("Missing { in encoded data");
1174
return LDAP_PROTOCOL_ERROR;
1177
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
1178
Asn1Error("Error during Reading identifier");
1179
return LDAP_PROTOCOL_ERROR;
1181
if ( strncmp( peek_head, "notBefore", strlen("notBefore") ) == 0 ) {
1182
rc = GDecComponentTime (mem_op, b, (&k->notBefore), bytesDecoded, mode);
1183
if ( rc != LDAP_SUCCESS ) return rc;
1184
( k->notBefore)->identifier.bv_val = peek_head;
1185
( k->notBefore)->identifier.bv_len = strLen;
1186
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
1187
Asn1Error("Error during Reading , ");
1188
return LDAP_PROTOCOL_ERROR;
1190
if(*peek_head != ','){
1191
Asn1Error("Missing , in encoding");
1192
return LDAP_PROTOCOL_ERROR;
1194
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
1195
Asn1Error("Error during Reading identifier");
1196
return LDAP_PROTOCOL_ERROR;
1199
if ( strncmp( peek_head, "notAfter", strlen("notAfter") ) == 0 ) {
1200
rc = GDecComponentTime (mem_op, b, (&k->notAfter), bytesDecoded, mode);
1201
if ( rc != LDAP_SUCCESS ) return rc;
1202
( k->notAfter)->identifier.bv_val = peek_head;
1203
( k->notAfter)->identifier.bv_len = strLen;
1205
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {
1206
Asn1Error("Error during Reading } in encoding");
1207
return LDAP_PROTOCOL_ERROR;
1209
if(*peek_head != '}'){
1210
Asn1Error("Missing } in encoding");
1211
return LDAP_PROTOCOL_ERROR;
1213
if( !(old_mode & DEC_ALLOC_MODE_1) ) {
1214
*v = t = (ComponentValidity*) CompAlloc( mem_op, sizeof(ComponentValidity) );
1215
if ( !t ) return -1;
1218
t->syntax = (Syntax*)NULL;
1219
t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
1220
if ( !t->comp_desc ) {
1224
t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentValidity ;
1225
t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentValidity ;
1226
t->comp_desc->cd_free = (comp_free_func*)NULL;
1227
t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentValidity;
1228
t->comp_desc->cd_type = ASN_COMPOSITE;
1229
t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
1230
t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentValidity;
1231
return LDAP_SUCCESS;
1236
MatchingComponentSubjectPublicKeyInfo ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
1241
mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
1242
if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
1246
rc = MatchingComponentAlgorithmIdentifier ( oid, (ComponentSyntaxInfo*)((ComponentSubjectPublicKeyInfo*)csi_attr)->algorithm, (ComponentSyntaxInfo*)((ComponentSubjectPublicKeyInfo*)csi_assert)->algorithm );
1247
if ( rc != LDAP_COMPARE_TRUE )
1249
rc = MatchingComponentBits ( oid, (ComponentSyntaxInfo*)&((ComponentSubjectPublicKeyInfo*)csi_attr)->subjectPublicKey, (ComponentSyntaxInfo*)&((ComponentSubjectPublicKeyInfo*)csi_assert)->subjectPublicKey );
1250
if ( rc != LDAP_COMPARE_TRUE )
1252
return LDAP_COMPARE_TRUE;
1253
} /* BMatchingComponentSubjectPublicKeyInfo */
1256
ExtractingComponentSubjectPublicKeyInfo ( void* mem_op, ComponentReference* cr, ComponentSubjectPublicKeyInfo *comp )
1259
if ( ( comp->algorithm->identifier.bv_val && strncmp(comp->algorithm->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->algorithm->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
1260
if ( cr->cr_curr->ci_next == NULL )
1261
return comp->algorithm;
1263
cr->cr_curr = cr->cr_curr->ci_next;
1264
return ExtractingComponentAlgorithmIdentifier ( mem_op, cr, comp->algorithm );
1267
if ( ( comp->subjectPublicKey.identifier.bv_val && strncmp(comp->subjectPublicKey.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->subjectPublicKey.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
1268
if ( cr->cr_curr->ci_next == NULL )
1269
return &comp->subjectPublicKey;
1270
else if ( cr->cr_curr->ci_next->ci_type == LDAP_COMPREF_CONTENT) {
1271
cr->cr_curr = cr->cr_curr->ci_next;
1272
return &comp->subjectPublicKey;
1278
} /* ExtractingComponentSubjectPublicKeyInfo */
1281
BDecComponentSubjectPublicKeyInfo PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
1285
AsnLen elmtLen0 _AND_
1286
ComponentSubjectPublicKeyInfo **v _AND_
1287
AsnLen *bytesDecoded _AND_
1290
int seqDone = FALSE;
1291
AsnLen totalElmtsLen1 = 0;
1294
int mandatoryElmtCount1 = 0;
1295
int old_mode = mode;
1297
ComponentSubjectPublicKeyInfo *k, *t, c_temp;
1300
if ( !(mode & DEC_ALLOC_MODE_1) ) {
1301
memset(&c_temp,0,sizeof(c_temp));
1305
mode = DEC_ALLOC_MODE_2;
1306
tagId1 = BDecTag (b, &totalElmtsLen1 );
1308
if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
1310
elmtLen1 = BDecLen (b, &totalElmtsLen1 );
1311
rc = BDecComponentAlgorithmIdentifier (mem_op, b, tagId1, elmtLen1, (&k->algorithm), &totalElmtsLen1, mode);
1312
if ( rc != LDAP_SUCCESS ) return rc;
1313
(k->algorithm)->identifier.bv_val = (k->algorithm)->id_buf;
1314
(k->algorithm)->identifier.bv_len = strlen("algorithm");
1315
strcpy( (k->algorithm)->identifier.bv_val, "algorithm");
1316
tagId1 = BDecTag (b, &totalElmtsLen1);
1323
if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE)) ||
1324
(tagId1 == MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE))))
1326
elmtLen1 = BDecLen (b, &totalElmtsLen1 );
1327
rc = BDecComponentBits (mem_op, b, tagId1, elmtLen1, (&k->subjectPublicKey), &totalElmtsLen1, mode);
1328
if ( rc != LDAP_SUCCESS ) return rc;
1329
(&k->subjectPublicKey)->identifier.bv_val = (&k->subjectPublicKey)->id_buf;
1330
(&k->subjectPublicKey)->identifier.bv_len = strlen("subjectPublicKey");
1331
strcpy( (&k->subjectPublicKey)->identifier.bv_val, "subjectPublicKey");
1333
if (elmtLen0 == INDEFINITE_LEN)
1334
BDecEoc (b, &totalElmtsLen1 );
1335
else if (totalElmtsLen1 != elmtLen0)
1347
if( !(old_mode & DEC_ALLOC_MODE_1) ) {
1348
*v = t = (ComponentSubjectPublicKeyInfo*) CompAlloc( mem_op, sizeof(ComponentSubjectPublicKeyInfo) );
1349
if ( !t ) return -1;
1352
t->syntax = (Syntax*)NULL;
1353
t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
1354
if ( !t->comp_desc ) {
1358
t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentSubjectPublicKeyInfo ;
1359
t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentSubjectPublicKeyInfo ;
1360
t->comp_desc->cd_free = (comp_free_func*)NULL;
1361
t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentSubjectPublicKeyInfo;
1362
t->comp_desc->cd_type = ASN_COMPOSITE;
1363
t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
1364
t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentSubjectPublicKeyInfo;
1365
(*bytesDecoded) += totalElmtsLen1;
1366
return LDAP_SUCCESS;
1367
} /* BDecSubjectPublicKeyInfo*/
1370
GDecComponentSubjectPublicKeyInfo PARAMS (( mem_op,b, v, bytesDecoded, mode),
1373
ComponentSubjectPublicKeyInfo **v _AND_
1374
AsnLen *bytesDecoded _AND_
1377
char* peek_head,*peek_head2;
1378
int i, strLen,strLen2, rc, old_mode = mode;
1379
ComponentSubjectPublicKeyInfo *k,*t, c_temp;
1382
if ( !(mode & DEC_ALLOC_MODE_1) ) {
1383
memset(&c_temp,0,sizeof(c_temp));
1387
mode = DEC_ALLOC_MODE_2;
1389
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
1390
Asn1Error("Error during Reading { in encoded data");
1391
return LDAP_PROTOCOL_ERROR;
1393
if(*peek_head != '{'){
1394
Asn1Error("Missing { in encoded data");
1395
return LDAP_PROTOCOL_ERROR;
1398
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
1399
Asn1Error("Error during Reading identifier");
1400
return LDAP_PROTOCOL_ERROR;
1402
if ( strncmp( peek_head, "algorithm", strlen("algorithm") ) == 0 ) {
1403
rc = GDecComponentAlgorithmIdentifier (mem_op, b, (&k->algorithm), bytesDecoded, mode);
1404
if ( rc != LDAP_SUCCESS ) return rc;
1405
( k->algorithm)->identifier.bv_val = peek_head;
1406
( k->algorithm)->identifier.bv_len = strLen;
1407
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
1408
Asn1Error("Error during Reading , ");
1409
return LDAP_PROTOCOL_ERROR;
1411
if(*peek_head != ','){
1412
Asn1Error("Missing , in encoding");
1413
return LDAP_PROTOCOL_ERROR;
1415
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
1416
Asn1Error("Error during Reading identifier");
1417
return LDAP_PROTOCOL_ERROR;
1420
if ( strncmp( peek_head, "subjectPublicKey", strlen("subjectPublicKey") ) == 0 ) {
1421
rc = GDecComponentBits (mem_op, b, (&k->subjectPublicKey), bytesDecoded, mode);
1422
if ( rc != LDAP_SUCCESS ) return rc;
1423
(&k->subjectPublicKey)->identifier.bv_val = peek_head;
1424
(&k->subjectPublicKey)->identifier.bv_len = strLen;
1426
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {
1427
Asn1Error("Error during Reading } in encoding");
1428
return LDAP_PROTOCOL_ERROR;
1430
if(*peek_head != '}'){
1431
Asn1Error("Missing } in encoding");
1432
return LDAP_PROTOCOL_ERROR;
1434
if( !(old_mode & DEC_ALLOC_MODE_1) ) {
1435
*v = t = (ComponentSubjectPublicKeyInfo*) CompAlloc( mem_op, sizeof(ComponentSubjectPublicKeyInfo) );
1436
if ( !t ) return -1;
1439
t->syntax = (Syntax*)NULL;
1440
t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
1441
if ( !t->comp_desc ) {
1445
t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentSubjectPublicKeyInfo ;
1446
t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentSubjectPublicKeyInfo ;
1447
t->comp_desc->cd_free = (comp_free_func*)NULL;
1448
t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentSubjectPublicKeyInfo;
1449
t->comp_desc->cd_type = ASN_COMPOSITE;
1450
t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
1451
t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentSubjectPublicKeyInfo;
1452
return LDAP_SUCCESS;
1453
} /* GDecSubjectPublicKeyInfo*/
1457
MatchingComponentExtensions ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
1460
void* component1, *component2;
1461
AsnList *v1, *v2, t_list;
1465
mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
1466
if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
1469
v1 = &((ComponentExtensions*)csi_attr)->comp_list;
1470
v2 = &((ComponentExtensions*)csi_assert)->comp_list;
1471
FOR_EACH_LIST_PAIR_ELMT(component1, component2, v1, v2)
1473
if( MatchingComponentExtension(oid, (ComponentSyntaxInfo*)component1, (ComponentSyntaxInfo*)component2) == LDAP_COMPARE_FALSE) {
1474
return LDAP_COMPARE_FALSE;
1480
if( (!component1 && component2) || (component1 && !component2))
1481
return LDAP_COMPARE_FALSE;
1483
return LDAP_COMPARE_TRUE;
1484
} /* BMatchingComponentExtensionsContent */
1487
ExtractingComponentExtensions ( void* mem_op, ComponentReference* cr, ComponentExtensions *comp )
1491
AsnList *v = &comp->comp_list;
1493
ComponentExtension *component;
1496
switch ( cr->cr_curr->ci_type ) {
1497
case LDAP_COMPREF_FROM_BEGINNING :
1498
count = cr->cr_curr->ci_val.ci_from_beginning;
1499
FOR_EACH_LIST_ELMT( component , v ) {
1500
if( --count == 0 ) {
1501
if( cr->cr_curr->ci_next == NULL )
1504
cr->cr_curr = cr->cr_curr->ci_next;
1505
return ExtractingComponentExtension ( mem_op, cr, component );
1510
case LDAP_COMPREF_FROM_END :
1511
total = AsnListCount ( v );
1512
count = cr->cr_curr->ci_val.ci_from_end;
1513
count = total + count +1;
1514
FOR_EACH_LIST_ELMT ( component, v ) {
1515
if( --count == 0 ) {
1516
if( cr->cr_curr->ci_next == NULL )
1519
cr->cr_curr = cr->cr_curr->ci_next;
1520
return ExtractingComponentExtension ( mem_op, cr, component );
1525
case LDAP_COMPREF_ALL :
1527
case LDAP_COMPREF_COUNT :
1528
k = (ComponentInt*)CompAlloc( mem_op, sizeof(ComponentInt));
1529
k->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
1530
k->comp_desc->cd_tag = (-1);
1531
k->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentInt;
1532
k->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentInt;
1533
k->comp_desc->cd_extract_i = (extract_component_from_id_func*)NULL;
1534
k->comp_desc->cd_type = ASN_BASIC;
1535
k->comp_desc->cd_type_id = BASICTYPE_INTEGER;
1536
k->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentInt;
1537
k->value = AsnListCount(v);
1542
} /* ExtractingComponentExtensions */
1545
BDecComponentExtensions PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
1549
AsnLen elmtLen0 _AND_
1550
ComponentExtensions **v _AND_
1551
AsnLen *bytesDecoded _AND_
1554
int seqDone = FALSE;
1555
AsnLen totalElmtsLen1 = 0;
1558
int mandatoryElmtCount1 = 0;
1559
int old_mode = mode;
1561
ComponentExtensions *k, *t, c_temp;
1564
if ( !(mode & DEC_ALLOC_MODE_1) ) {
1565
memset(&c_temp,0,sizeof(c_temp));
1569
mode = DEC_ALLOC_MODE_2;
1570
AsnListInit(&k->comp_list,sizeof(ComponentExtension));
1571
for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);)
1573
ComponentExtension **tmpVar;
1574
tagId1 = BDecTag (b, &totalElmtsLen1 );
1576
if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
1578
BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )
1579
break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/
1581
if ((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
1583
elmtLen1 = BDecLen (b, &totalElmtsLen1 );
1584
tmpVar = (ComponentExtension**) CompAsnListAppend (mem_op,&k->comp_list);
1585
rc = BDecComponentExtension (mem_op, b, tagId1, elmtLen1, tmpVar, &totalElmtsLen1, mode);
1586
if ( rc != LDAP_SUCCESS ) return rc;
1587
} /* end of tag check if */
1588
else /* wrong tag */
1590
Asn1Error ("Unexpected Tag\n");
1595
if( !(old_mode & DEC_ALLOC_MODE_1) ) {
1596
*v = t = (ComponentExtensions*) CompAlloc( mem_op, sizeof(ComponentExtensions) );
1597
if ( !t ) return -1;
1600
t->syntax = (Syntax*)NULL;
1601
t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
1602
if ( !t->comp_desc ) {
1606
t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentExtensions ;
1607
t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentExtensions ;
1608
t->comp_desc->cd_free = (comp_free_func*)NULL;
1609
t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentExtensions;
1610
t->comp_desc->cd_type = ASN_COMPOSITE;
1611
t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
1612
t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentExtensions;
1613
(*bytesDecoded) += totalElmtsLen1;
1614
return LDAP_SUCCESS;
1615
} /* BDecExtensionsContent */
1618
GDecComponentExtensions PARAMS (( mem_op,b, v, bytesDecoded, mode),
1621
ComponentExtensions **v _AND_
1622
AsnLen *bytesDecoded _AND_
1625
char* peek_head,*peek_head2;
1626
int i, strLen,strLen2, rc, old_mode = mode;
1627
ComponentExtensions *k,*t, c_temp;
1631
if ( !(mode & DEC_ALLOC_MODE_1) ) {
1632
memset(&c_temp,0,sizeof(c_temp));
1636
mode = DEC_ALLOC_MODE_2;
1637
AsnListInit( &k->comp_list, sizeof( ComponentExtension ) );
1639
if( !(strLen = LocateNextGSERToken(mem_op,b, &peek_head, GSER_PEEK)) ){
1640
Asn1Error("Error during Reading { in encoding");
1641
return LDAP_PROTOCOL_ERROR;
1643
if(*peek_head != '{'){
1644
Asn1Error("Missing { in encoded data");
1645
return LDAP_PROTOCOL_ERROR;
1648
for (ElmtsLen1 = 0; ElmtsLen1 >= INDEFINITE_LEN; ElmtsLen1++)
1650
ComponentExtension **tmpVar;
1651
if( !(strLen = LocateNextGSERToken(mem_op,b, &peek_head, GSER_NO_COPY)) ){
1652
Asn1Error("Error during Reading{ in encoding");
1653
return LDAP_PROTOCOL_ERROR;
1655
if(*peek_head == '}') break;
1656
if( !(*peek_head == '{' || *peek_head ==',') ) {
1657
return LDAP_PROTOCOL_ERROR;
1659
tmpVar = (ComponentExtension**) CompAsnListAppend (mem_op, &k->comp_list);
1660
if ( tmpVar == NULL ) {
1661
Asn1Error("Error during Reading{ in encoding");
1662
return LDAP_PROTOCOL_ERROR;
1664
rc = GDecComponentExtension (mem_op, b, tmpVar, bytesDecoded, mode);
1665
if ( rc != LDAP_SUCCESS ) return rc;
1668
if( !(old_mode & DEC_ALLOC_MODE_1) ) {
1669
*v = t = (ComponentExtensions*) CompAlloc( mem_op, sizeof(ComponentExtensions) );
1670
if ( !t ) return -1;
1673
t->syntax = (Syntax*)NULL;
1674
t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
1675
if ( !t->comp_desc ) {
1679
t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentExtensions ;
1680
t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentExtensions ;
1681
t->comp_desc->cd_free = (comp_free_func*)NULL;
1682
t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentExtensions;
1683
t->comp_desc->cd_type = ASN_COMPOSITE;
1684
t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
1685
t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentExtensions;
1686
return LDAP_SUCCESS;
1687
} /* GDecExtensionsContent */
1691
MatchingComponentRelativeDistinguishedName ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
1694
void* component1, *component2;
1695
AsnList *v1, *v2, t_list;
1699
mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
1700
if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
1703
v1 = &((ComponentRelativeDistinguishedName*)csi_attr)->comp_list;
1704
v2 = &((ComponentRelativeDistinguishedName*)csi_assert)->comp_list;
1705
AsnListInit( &t_list, 0 );
1706
if( AsnListCount( v1 ) != AsnListCount( v2 ) )
1707
return LDAP_COMPARE_FALSE;
1708
FOR_EACH_LIST_ELMT (component1, v1)
1710
FOR_EACH_LIST_ELMT(component2, v2)
1712
if( MatchingComponentAttributeTypeAndValue(oid, (ComponentSyntaxInfo*)component1,(ComponentSyntaxInfo*)component2) == LDAP_COMPARE_TRUE ) {
1713
AsnElmtMove( v2, &t_list );
1716
} /* end of inner for */
1717
} /* end of outer for */
1719
if( AsnListCount( v2 ) == 0 )
1720
rc = LDAP_COMPARE_TRUE;
1722
rc = LDAP_COMPARE_FALSE;
1723
AsnListMove( &t_list, v2 );
1727
} /* BMatchingComponentRelativeDistinguishedNameContent */
1730
ExtractingComponentRelativeDistinguishedName ( void* mem_op, ComponentReference* cr, ComponentRelativeDistinguishedName *comp )
1734
AsnList *v = &comp->comp_list;
1736
ComponentAttributeTypeAndValue *component;
1739
switch ( cr->cr_curr->ci_type ) {
1740
case LDAP_COMPREF_FROM_BEGINNING :
1741
count = cr->cr_curr->ci_val.ci_from_beginning;
1742
FOR_EACH_LIST_ELMT( component , v ) {
1743
if( --count == 0 ) {
1744
if( cr->cr_curr->ci_next == NULL )
1747
cr->cr_curr = cr->cr_curr->ci_next;
1748
return ExtractingComponentAttributeTypeAndValue ( mem_op, cr, component );
1753
case LDAP_COMPREF_FROM_END :
1754
total = AsnListCount ( v );
1755
count = cr->cr_curr->ci_val.ci_from_end;
1756
count = total + count +1;
1757
FOR_EACH_LIST_ELMT ( component, v ) {
1758
if( --count == 0 ) {
1759
if( cr->cr_curr->ci_next == NULL )
1762
cr->cr_curr = cr->cr_curr->ci_next;
1763
return ExtractingComponentAttributeTypeAndValue ( mem_op, cr, component );
1768
case LDAP_COMPREF_ALL :
1770
case LDAP_COMPREF_COUNT :
1771
k = (ComponentInt*)CompAlloc( mem_op, sizeof(ComponentInt));
1772
k->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
1773
k->comp_desc->cd_tag = (-1);
1774
k->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentInt;
1775
k->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentInt;
1776
k->comp_desc->cd_extract_i = (extract_component_from_id_func*)NULL;
1777
k->comp_desc->cd_type = ASN_BASIC;
1778
k->comp_desc->cd_type_id = BASICTYPE_INTEGER;
1779
k->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentInt;
1780
k->value = AsnListCount(v);
1785
} /* ExtractingComponentRelativeDistinguishedName */
1788
BDecComponentRelativeDistinguishedName PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
1792
AsnLen elmtLen0 _AND_
1793
ComponentRelativeDistinguishedName **v _AND_
1794
AsnLen *bytesDecoded _AND_
1797
int seqDone = FALSE;
1798
AsnLen totalElmtsLen1 = 0;
1801
int mandatoryElmtCount1 = 0;
1802
int old_mode = mode;
1804
ComponentRelativeDistinguishedName *k, *t, c_temp;
1807
if ( !(mode & DEC_ALLOC_MODE_1) ) {
1808
memset(&c_temp,0,sizeof(c_temp));
1812
mode = DEC_ALLOC_MODE_2;
1813
AsnListInit(&k->comp_list,sizeof(ComponentAttributeTypeAndValue));
1814
for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);)
1816
ComponentAttributeTypeAndValue **tmpVar;
1817
tagId1 = BDecTag (b, &totalElmtsLen1 );
1819
if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
1821
BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )
1822
break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/
1824
if ((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
1826
elmtLen1 = BDecLen (b, &totalElmtsLen1 );
1827
tmpVar = (ComponentAttributeTypeAndValue**) CompAsnListAppend (mem_op,&k->comp_list);
1828
rc = BDecComponentAttributeTypeAndValue (mem_op, b, tagId1, elmtLen1, tmpVar, &totalElmtsLen1, mode);
1829
if ( rc != LDAP_SUCCESS ) return rc;
1830
} /* end of tag check if */
1831
else /* wrong tag */
1833
Asn1Error ("Unexpected Tag\n");
1838
if( !(old_mode & DEC_ALLOC_MODE_1) ) {
1839
*v = t = (ComponentRelativeDistinguishedName*) CompAlloc( mem_op, sizeof(ComponentRelativeDistinguishedName) );
1840
if ( !t ) return -1;
1843
t->syntax = (Syntax*)NULL;
1844
t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
1845
if ( !t->comp_desc ) {
1850
t->comp_desc->cd_gser_encoder = (encoder_func*)NULL;
1851
t->comp_desc->cd_ber_encoder = (encoder_func*)NULL;
1852
t->comp_desc->cd_ldap_encoder = (encoder_func*)ConvertRDN2RFC2253;
1853
t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentRelativeDistinguishedName ;
1854
t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentRelativeDistinguishedName ;
1855
t->comp_desc->cd_free = (comp_free_func*)NULL;
1856
t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentRelativeDistinguishedName;
1857
t->comp_desc->cd_type = ASN_COMPOSITE;
1858
t->comp_desc->cd_type_id = RelativeDistinguishedName;
1859
t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentRelativeDistinguishedName;
1860
(*bytesDecoded) += totalElmtsLen1;
1861
return LDAP_SUCCESS;
1862
} /* BDecRelativeDistinguishedNameContent */
1865
GDecComponentRelativeDistinguishedName PARAMS (( mem_op,b, v, bytesDecoded, mode),
1868
ComponentRelativeDistinguishedName **v _AND_
1869
AsnLen *bytesDecoded _AND_
1872
char* peek_head,*peek_head2;
1873
int i, strLen,strLen2, rc, old_mode = mode;
1874
ComponentRelativeDistinguishedName *k,*t, c_temp;
1878
if ( !(mode & DEC_ALLOC_MODE_1) ) {
1879
memset(&c_temp,0,sizeof(c_temp));
1883
mode = DEC_ALLOC_MODE_2;
1884
AsnListInit( &k->comp_list, sizeof( ComponentAttributeTypeAndValue ) );
1886
if( !(strLen = LocateNextGSERToken(mem_op,b, &peek_head, GSER_PEEK)) ){
1887
Asn1Error("Error during Reading { in encoding");
1888
return LDAP_PROTOCOL_ERROR;
1890
if(*peek_head != '{'){
1891
Asn1Error("Missing { in encoded data");
1892
return LDAP_PROTOCOL_ERROR;
1895
for (ElmtsLen1 = 0; ElmtsLen1 >= INDEFINITE_LEN; ElmtsLen1++)
1897
ComponentAttributeTypeAndValue **tmpVar;
1898
if( !(strLen = LocateNextGSERToken(mem_op,b, &peek_head, GSER_NO_COPY)) ){
1899
Asn1Error("Error during Reading{ in encoding");
1900
return LDAP_PROTOCOL_ERROR;
1902
if(*peek_head == '}') break;
1903
if( !(*peek_head == '{' || *peek_head ==',') ) {
1904
return LDAP_PROTOCOL_ERROR;
1906
tmpVar = (ComponentAttributeTypeAndValue**) CompAsnListAppend (mem_op, &k->comp_list);
1907
if ( tmpVar == NULL ) {
1908
Asn1Error("Error during Reading{ in encoding");
1909
return LDAP_PROTOCOL_ERROR;
1911
rc = GDecComponentAttributeTypeAndValue (mem_op, b, tmpVar, bytesDecoded, mode);
1912
if ( rc != LDAP_SUCCESS ) return rc;
1915
if( !(old_mode & DEC_ALLOC_MODE_1) ) {
1916
*v = t = (ComponentRelativeDistinguishedName*) CompAlloc( mem_op, sizeof(ComponentRelativeDistinguishedName) );
1917
if ( !t ) return -1;
1920
t->syntax = (Syntax*)NULL;
1921
t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
1922
if ( !t->comp_desc ) {
1926
t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentRelativeDistinguishedName ;
1927
t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentRelativeDistinguishedName ;
1928
t->comp_desc->cd_free = (comp_free_func*)NULL;
1929
t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentRelativeDistinguishedName;
1930
t->comp_desc->cd_type = ASN_COMPOSITE;
1931
t->comp_desc->cd_type_id = RelativeDistinguishedName;
1932
t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentRelativeDistinguishedName;
1933
return LDAP_SUCCESS;
1934
} /* GDecRelativeDistinguishedNameContent */
1938
MatchingComponentRDNSequence ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
1941
void* component1, *component2;
1942
AsnList *v1, *v2, t_list;
1946
mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
1947
if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
1950
v1 = &((ComponentRDNSequence*)csi_attr)->comp_list;
1951
v2 = &((ComponentRDNSequence*)csi_assert)->comp_list;
1952
FOR_EACH_LIST_PAIR_ELMT(component1, component2, v1, v2)
1954
if( MatchingComponentRelativeDistinguishedName(oid, (ComponentSyntaxInfo*)component1, (ComponentSyntaxInfo*)component2) == LDAP_COMPARE_FALSE) {
1955
return LDAP_COMPARE_FALSE;
1961
if( (!component1 && component2) || (component1 && !component2))
1962
return LDAP_COMPARE_FALSE;
1964
return LDAP_COMPARE_TRUE;
1965
} /* BMatchingComponentRDNSequenceContent */
1968
ExtractingComponentRDNSequence ( void* mem_op, ComponentReference* cr, ComponentRDNSequence *comp )
1972
AsnList *v = &comp->comp_list;
1974
ComponentRelativeDistinguishedName *component;
1977
switch ( cr->cr_curr->ci_type ) {
1978
case LDAP_COMPREF_FROM_BEGINNING :
1979
count = cr->cr_curr->ci_val.ci_from_beginning;
1980
FOR_EACH_LIST_ELMT( component , v ) {
1981
if( --count == 0 ) {
1982
if( cr->cr_curr->ci_next == NULL )
1985
cr->cr_curr = cr->cr_curr->ci_next;
1986
return ExtractingComponentRelativeDistinguishedName ( mem_op, cr, component );
1991
case LDAP_COMPREF_FROM_END :
1992
total = AsnListCount ( v );
1993
count = cr->cr_curr->ci_val.ci_from_end;
1994
count = total + count +1;
1995
FOR_EACH_LIST_ELMT ( component, v ) {
1996
if( --count == 0 ) {
1997
if( cr->cr_curr->ci_next == NULL )
2000
cr->cr_curr = cr->cr_curr->ci_next;
2001
return ExtractingComponentRelativeDistinguishedName ( mem_op, cr, component );
2006
case LDAP_COMPREF_ALL :
2008
case LDAP_COMPREF_COUNT :
2009
k = (ComponentInt*)CompAlloc( mem_op, sizeof(ComponentInt));
2010
k->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
2011
k->comp_desc->cd_tag = (-1);
2012
k->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentInt;
2013
k->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentInt;
2014
k->comp_desc->cd_extract_i = (extract_component_from_id_func*)NULL;
2015
k->comp_desc->cd_type = ASN_BASIC;
2016
k->comp_desc->cd_type_id = BASICTYPE_INTEGER;
2017
k->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentInt;
2018
k->value = AsnListCount(v);
2023
} /* ExtractingComponentRDNSequence */
2026
BDecComponentRDNSequence PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
2030
AsnLen elmtLen0 _AND_
2031
ComponentRDNSequence **v _AND_
2032
AsnLen *bytesDecoded _AND_
2035
int seqDone = FALSE;
2036
AsnLen totalElmtsLen1 = 0;
2039
int mandatoryElmtCount1 = 0;
2040
int old_mode = mode;
2042
ComponentRDNSequence *k, *t, c_temp;
2045
if ( !(mode & DEC_ALLOC_MODE_1) ) {
2046
memset(&c_temp,0,sizeof(c_temp));
2050
mode = DEC_ALLOC_MODE_2;
2051
AsnListInit(&k->comp_list,sizeof(ComponentRelativeDistinguishedName));
2052
for (totalElmtsLen1 = 0; (totalElmtsLen1 < elmtLen0) || (elmtLen0 == INDEFINITE_LEN);)
2054
ComponentRelativeDistinguishedName **tmpVar;
2055
tagId1 = BDecTag (b, &totalElmtsLen1 );
2057
if ((tagId1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
2059
BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )
2060
break; /* got EOC so can exit this SET OF/SEQ OF's for loop*/
2062
if ((tagId1 == MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE)))
2064
elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2065
tmpVar = (ComponentRelativeDistinguishedName**) CompAsnListAppend (mem_op,&k->comp_list);
2066
rc = BDecComponentRelativeDistinguishedName (mem_op, b, tagId1, elmtLen1, tmpVar, &totalElmtsLen1, mode);
2067
if ( rc != LDAP_SUCCESS ) return rc;
2068
} /* end of tag check if */
2069
else /* wrong tag */
2071
Asn1Error ("Unexpected Tag\n");
2076
if( !(old_mode & DEC_ALLOC_MODE_1) ) {
2077
*v = t = (ComponentRDNSequence*) CompAlloc( mem_op, sizeof(ComponentRDNSequence) );
2078
if ( !t ) return -1;
2081
t->syntax = (Syntax*)NULL;
2082
t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
2083
if ( !t->comp_desc ) {
2088
t->comp_desc->cd_gser_encoder = (encoder_func*)NULL;
2089
t->comp_desc->cd_ber_encoder = (encoder_func*)NULL;
2090
t->comp_desc->cd_ldap_encoder = (encoder_func*) ConvertRDNSequence2RFC2253;
2091
t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentRDNSequence ;
2092
t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentRDNSequence ;
2093
t->comp_desc->cd_free = (comp_free_func*)NULL;
2094
t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentRDNSequence;
2095
t->comp_desc->cd_type = ASN_COMPOSITE;
2096
t->comp_desc->cd_type_id = RDNSequence;
2097
t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentRDNSequence;
2098
(*bytesDecoded) += totalElmtsLen1;
2099
return LDAP_SUCCESS;
2100
} /* BDecRDNSequenceContent */
2103
GDecComponentRDNSequence PARAMS (( mem_op,b, v, bytesDecoded, mode),
2106
ComponentRDNSequence **v _AND_
2107
AsnLen *bytesDecoded _AND_
2110
char* peek_head,*peek_head2;
2111
int i, strLen,strLen2, rc, old_mode = mode;
2112
ComponentRDNSequence *k,*t, c_temp;
2116
if ( !(mode & DEC_ALLOC_MODE_1) ) {
2117
memset(&c_temp,0,sizeof(c_temp));
2121
mode = DEC_ALLOC_MODE_2;
2122
AsnListInit( &k->comp_list, sizeof( ComponentRelativeDistinguishedName ) );
2124
if( !(strLen = LocateNextGSERToken(mem_op,b, &peek_head, GSER_PEEK)) ){
2125
Asn1Error("Error during Reading { in encoding");
2126
return LDAP_PROTOCOL_ERROR;
2128
if(*peek_head != '{'){
2129
Asn1Error("Missing { in encoded data");
2130
return LDAP_PROTOCOL_ERROR;
2133
for (ElmtsLen1 = 0; ElmtsLen1 >= INDEFINITE_LEN; ElmtsLen1++)
2135
ComponentRelativeDistinguishedName **tmpVar;
2136
if( !(strLen = LocateNextGSERToken(mem_op,b, &peek_head, GSER_NO_COPY)) ){
2137
Asn1Error("Error during Reading{ in encoding");
2138
return LDAP_PROTOCOL_ERROR;
2140
if(*peek_head == '}') break;
2141
if( !(*peek_head == '{' || *peek_head ==',') ) {
2142
return LDAP_PROTOCOL_ERROR;
2144
tmpVar = (ComponentRelativeDistinguishedName**) CompAsnListAppend (mem_op, &k->comp_list);
2145
if ( tmpVar == NULL ) {
2146
Asn1Error("Error during Reading{ in encoding");
2147
return LDAP_PROTOCOL_ERROR;
2149
rc = GDecComponentRelativeDistinguishedName (mem_op, b, tmpVar, bytesDecoded, mode);
2150
if ( rc != LDAP_SUCCESS ) return rc;
2153
if( !(old_mode & DEC_ALLOC_MODE_1) ) {
2154
*v = t = (ComponentRDNSequence*) CompAlloc( mem_op, sizeof(ComponentRDNSequence) );
2155
if ( !t ) return -1;
2158
t->syntax = (Syntax*)NULL;
2159
t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
2160
if ( !t->comp_desc ) {
2164
t->comp_desc->cd_gser_encoder = (encoder_func*)NULL;
2165
t->comp_desc->cd_ber_encoder = (encoder_func*)NULL;
2166
t->comp_desc->cd_ldap_encoder = (encoder_func*)ConvertRDNSequence2RFC2253;
2167
t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentRDNSequence ;
2168
t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentRDNSequence ;
2169
t->comp_desc->cd_free = (comp_free_func*)NULL;
2170
t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentRDNSequence;
2171
t->comp_desc->cd_type = ASN_COMPOSITE;
2172
t->comp_desc->cd_type_id = RDNSequence ;
2173
t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentRDNSequence;
2174
return LDAP_SUCCESS;
2175
} /* GDecRDNSequenceContent */
2179
MatchingComponentName ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
2182
ComponentName *v1, *v2;
2185
v1 = (ComponentName*)csi_attr;
2186
v2 = (ComponentName*)csi_assert;
2188
mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
2189
if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
2192
if( (v1->choiceId != v2->choiceId ) )
2193
return LDAP_COMPARE_FALSE;
2194
switch( v1->choiceId )
2196
case NAME_RDNSEQUENCE :
2197
rc = MatchingComponentRDNSequence ( oid, (ComponentSyntaxInfo*)(v1->a.rdnSequence), (ComponentSyntaxInfo*)(v2->a.rdnSequence) );
2200
return LDAP_PROTOCOL_ERROR;
2203
} /* BMatchingComponentNameContent */
2206
ExtractingComponentName ( void* mem_op, ComponentReference* cr, ComponentName *comp )
2210
if( (comp->choiceId) == NAME_RDNSEQUENCE &&
2211
(( comp->a.rdnSequence->identifier.bv_val && strncmp(comp->a.rdnSequence->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0) ||
2212
( strncmp(comp->a.rdnSequence->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0))) {
2213
if ( cr->cr_curr->ci_next == NULL )
2214
return (comp->a.rdnSequence);
2216
cr->cr_curr = cr->cr_curr->ci_next;
2217
return ExtractingComponentRDNSequence ( mem_op, cr, (comp->a.rdnSequence) );
2221
} /* ExtractingComponentName */
2224
BDecComponentName PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
2228
AsnLen elmtLen0 _AND_
2229
ComponentName **v _AND_
2230
AsnLen *bytesDecoded _AND_
2233
int seqDone = FALSE;
2234
AsnLen totalElmtsLen1 = 0;
2237
int mandatoryElmtCount1 = 0;
2238
int old_mode = mode;
2240
ComponentName *k, *t, c_temp;
2243
if ( !(mode & DEC_ALLOC_MODE_1) ) {
2244
memset(&c_temp,0,sizeof(c_temp));
2248
mode = DEC_ALLOC_MODE_2;
2251
case MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE):
2252
(k->choiceId) = NAME_RDNSEQUENCE;
2253
rc = BDecComponentRDNSequence (mem_op, b, tagId0, elmtLen0, (&k->a.rdnSequence), &totalElmtsLen1, mode);
2254
if ( rc != LDAP_SUCCESS ) return rc;
2255
(k->a.rdnSequence)->identifier.bv_val = (k->a.rdnSequence)->id_buf;
2256
(k->a.rdnSequence)->identifier.bv_len = strlen("rdnSequence");
2257
strcpy( (k->a.rdnSequence)->identifier.bv_val, "rdnSequence");
2261
Asn1Error ("ERROR - unexpected tag in CHOICE\n");
2265
if( !(old_mode & DEC_ALLOC_MODE_1) ) {
2266
*v = t = (ComponentName*) CompAlloc( mem_op, sizeof(ComponentName) );
2267
if ( !t ) return -1;
2270
t->syntax = (Syntax*)NULL;
2271
t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
2272
if ( !t->comp_desc ) {
2276
t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentName ;
2277
t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentName ;
2278
t->comp_desc->cd_free = (comp_free_func*)NULL;
2279
t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentName;
2280
t->comp_desc->cd_type = ASN_COMPOSITE;
2281
t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
2282
t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentName;
2283
(*bytesDecoded) += totalElmtsLen1;
2284
return LDAP_SUCCESS;
2285
} /* BDecNameContent */
2288
GDecComponentName PARAMS (( mem_op,b, v, bytesDecoded, mode),
2291
ComponentName **v _AND_
2292
AsnLen *bytesDecoded _AND_
2295
char* peek_head,*peek_head2;
2296
int i, strLen,strLen2, rc, old_mode = mode;
2297
ComponentName *k,*t, c_temp;
2300
if ( !(mode & DEC_ALLOC_MODE_1) ) {
2301
memset(&c_temp,0,sizeof(c_temp));
2305
mode = DEC_ALLOC_MODE_2;
2306
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2307
Asn1Error("Error during Reading identifier");
2308
return LDAP_PROTOCOL_ERROR;
2310
if( !(strLen2 = LocateNextGSERToken(mem_op,b,&peek_head2,GSER_NO_COPY)) ){
2311
Asn1Error("Error during Reading identifier");
2312
return LDAP_PROTOCOL_ERROR;
2314
if(*peek_head2 != ':'){
2315
Asn1Error("Missing : in encoded data");
2316
return LDAP_PROTOCOL_ERROR;
2318
if( strncmp("rdnSequence",peek_head, strlen("rdnSequence")) == 0){
2319
(k->choiceId) = NAME_RDNSEQUENCE;
2320
rc = GDecComponentRDNSequence (mem_op, b, (&k->a.rdnSequence), bytesDecoded, mode);
2321
if ( rc != LDAP_SUCCESS ) return rc;
2322
(k->a.rdnSequence)->identifier.bv_val = peek_head;
2323
(k->a.rdnSequence)->identifier.bv_len = strLen;
2326
Asn1Error("Undefined Identifier");
2327
return LDAP_PROTOCOL_ERROR;
2329
if( !(old_mode & DEC_ALLOC_MODE_1) ) {
2330
*v = t = (ComponentName*) CompAlloc( mem_op, sizeof(ComponentName) );
2331
if ( !t ) return -1;
2334
t->syntax = (Syntax*)NULL;
2335
t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
2336
if ( !t->comp_desc ) {
2340
t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentName ;
2341
t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentName ;
2342
t->comp_desc->cd_free = (comp_free_func*)NULL;
2343
t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentName;
2344
t->comp_desc->cd_type = ASN_COMPOSITE;
2345
t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
2346
t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentName;
2347
return LDAP_SUCCESS;
2348
} /* GDecNameContent */
2352
MatchingComponentTBSCertificate ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
2357
mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
2358
if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
2362
rc = MatchingComponentVersion ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_attr)->version, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_assert)->version );
2363
if ( rc != LDAP_COMPARE_TRUE )
2365
rc = MatchingComponentCertificateSerialNumber ( oid, (ComponentSyntaxInfo*)&((ComponentTBSCertificate*)csi_attr)->serialNumber, (ComponentSyntaxInfo*)&((ComponentTBSCertificate*)csi_assert)->serialNumber );
2366
if ( rc != LDAP_COMPARE_TRUE )
2368
rc = MatchingComponentAlgorithmIdentifier ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_attr)->signature, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_assert)->signature );
2369
if ( rc != LDAP_COMPARE_TRUE )
2371
rc = MatchingComponentName ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_attr)->issuer, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_assert)->issuer );
2372
if ( rc != LDAP_COMPARE_TRUE )
2374
rc = MatchingComponentValidity ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_attr)->validity, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_assert)->validity );
2375
if ( rc != LDAP_COMPARE_TRUE )
2377
rc = MatchingComponentName ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_attr)->subject, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_assert)->subject );
2378
if ( rc != LDAP_COMPARE_TRUE )
2380
rc = MatchingComponentSubjectPublicKeyInfo ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_attr)->subjectPublicKeyInfo, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_assert)->subjectPublicKeyInfo );
2381
if ( rc != LDAP_COMPARE_TRUE )
2383
rc = MatchingComponentUniqueIdentifier ( oid, (ComponentSyntaxInfo*)&((ComponentTBSCertificate*)csi_attr)->issuerUniqueIdentifier, (ComponentSyntaxInfo*)&((ComponentTBSCertificate*)csi_assert)->issuerUniqueIdentifier );
2384
if ( rc != LDAP_COMPARE_TRUE )
2386
rc = MatchingComponentUniqueIdentifier ( oid, (ComponentSyntaxInfo*)&((ComponentTBSCertificate*)csi_attr)->subjectUniqueIdentifier, (ComponentSyntaxInfo*)&((ComponentTBSCertificate*)csi_assert)->subjectUniqueIdentifier );
2387
if ( rc != LDAP_COMPARE_TRUE )
2389
if(COMPONENTNOT_NULL( ((ComponentTBSCertificate*)csi_attr)->extensions ) ) {
2390
rc = MatchingComponentExtensions ( oid, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_attr)->extensions, (ComponentSyntaxInfo*)((ComponentTBSCertificate*)csi_assert)->extensions );
2391
if ( rc != LDAP_COMPARE_TRUE )
2394
return LDAP_COMPARE_TRUE;
2395
} /* BMatchingComponentTBSCertificate */
2398
ExtractingComponentTBSCertificate ( void* mem_op, ComponentReference* cr, ComponentTBSCertificate *comp )
2401
if ( ( comp->version->identifier.bv_val && strncmp(comp->version->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->version->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
2402
if ( cr->cr_curr->ci_next == NULL )
2403
return comp->version;
2405
cr->cr_curr = cr->cr_curr->ci_next;
2406
return ExtractingComponentVersion ( mem_op, cr, comp->version );
2409
if ( ( comp->serialNumber.identifier.bv_val && strncmp(comp->serialNumber.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->serialNumber.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
2410
if ( cr->cr_curr->ci_next == NULL )
2411
return &comp->serialNumber;
2415
if ( ( comp->signature->identifier.bv_val && strncmp(comp->signature->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->signature->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
2416
if ( cr->cr_curr->ci_next == NULL )
2417
return comp->signature;
2419
cr->cr_curr = cr->cr_curr->ci_next;
2420
return ExtractingComponentAlgorithmIdentifier ( mem_op, cr, comp->signature );
2423
if ( ( comp->issuer->identifier.bv_val && strncmp(comp->issuer->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->issuer->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
2424
if ( cr->cr_curr->ci_next == NULL )
2425
return comp->issuer;
2427
cr->cr_curr = cr->cr_curr->ci_next;
2428
return ExtractingComponentName ( mem_op, cr, comp->issuer );
2431
if ( ( comp->validity->identifier.bv_val && strncmp(comp->validity->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->validity->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
2432
if ( cr->cr_curr->ci_next == NULL )
2433
return comp->validity;
2435
cr->cr_curr = cr->cr_curr->ci_next;
2436
return ExtractingComponentValidity ( mem_op, cr, comp->validity );
2439
if ( ( comp->subject->identifier.bv_val && strncmp(comp->subject->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->subject->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
2440
if ( cr->cr_curr->ci_next == NULL )
2441
return comp->subject;
2443
cr->cr_curr = cr->cr_curr->ci_next;
2444
return ExtractingComponentName ( mem_op, cr, comp->subject );
2447
if ( ( comp->subjectPublicKeyInfo->identifier.bv_val && strncmp(comp->subjectPublicKeyInfo->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->subjectPublicKeyInfo->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
2448
if ( cr->cr_curr->ci_next == NULL )
2449
return comp->subjectPublicKeyInfo;
2451
cr->cr_curr = cr->cr_curr->ci_next;
2452
return ExtractingComponentSubjectPublicKeyInfo ( mem_op, cr, comp->subjectPublicKeyInfo );
2455
if ( ( comp->issuerUniqueIdentifier.identifier.bv_val && strncmp(comp->issuerUniqueIdentifier.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->issuerUniqueIdentifier.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
2456
if ( cr->cr_curr->ci_next == NULL )
2457
return &comp->issuerUniqueIdentifier;
2458
else if ( cr->cr_curr->ci_next->ci_type == LDAP_COMPREF_CONTENT) {
2459
cr->cr_curr = cr->cr_curr->ci_next;
2460
return &comp->issuerUniqueIdentifier;
2465
if ( ( comp->subjectUniqueIdentifier.identifier.bv_val && strncmp(comp->subjectUniqueIdentifier.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->subjectUniqueIdentifier.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
2466
if ( cr->cr_curr->ci_next == NULL )
2467
return &comp->subjectUniqueIdentifier;
2468
else if ( cr->cr_curr->ci_next->ci_type == LDAP_COMPREF_CONTENT) {
2469
cr->cr_curr = cr->cr_curr->ci_next;
2470
return &comp->subjectUniqueIdentifier;
2475
if ( ( comp->extensions->identifier.bv_val && strncmp(comp->extensions->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->extensions->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
2476
if ( cr->cr_curr->ci_next == NULL )
2477
return comp->extensions;
2479
cr->cr_curr = cr->cr_curr->ci_next;
2480
return ExtractingComponentExtensions ( mem_op, cr, comp->extensions );
2484
} /* ExtractingComponentTBSCertificate */
2487
BDecComponentTBSCertificate PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
2491
AsnLen elmtLen0 _AND_
2492
ComponentTBSCertificate **v _AND_
2493
AsnLen *bytesDecoded _AND_
2496
int seqDone = FALSE;
2497
AsnLen totalElmtsLen1 = 0;
2500
int mandatoryElmtCount1 = 0;
2501
AsnLen totalElmtsLen2 = 0;
2504
int old_mode = mode;
2506
ComponentTBSCertificate *k, *t, c_temp;
2509
if ( !(mode & DEC_ALLOC_MODE_1) ) {
2510
memset(&c_temp,0,sizeof(c_temp));
2514
mode = DEC_ALLOC_MODE_2;
2515
tagId1 = BDecTag (b, &totalElmtsLen1 );
2517
if (((tagId1 == MAKE_TAG_ID (CNTX, CONS, 0))))
2519
elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2520
tagId2 = BDecTag (b, &totalElmtsLen1 );
2522
if (tagId2 != MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))
2524
Asn1Error ("Unexpected Tag\n");
2528
elmtLen2 = BDecLen (b, &totalElmtsLen1 );
2529
rc = BDecComponentVersion (mem_op, b, tagId2, elmtLen2, (&k->version), &totalElmtsLen1, DEC_ALLOC_MODE_0 );
2530
if ( rc != LDAP_SUCCESS ) return rc;
2531
(k->version)->identifier.bv_val = (k->version)->id_buf;
2532
(k->version)->identifier.bv_len = strlen("version");
2533
strcpy( (k->version)->identifier.bv_val, "version");
2534
if (elmtLen1 == INDEFINITE_LEN)
2535
BDecEoc (b, &totalElmtsLen1 );
2536
tagId1 = BDecTag (b, &totalElmtsLen1);
2540
if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))))
2542
elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2543
rc = BDecComponentCertificateSerialNumber (mem_op, b, tagId1, elmtLen1, (&k->serialNumber), &totalElmtsLen1, mode);
2544
if ( rc != LDAP_SUCCESS ) return rc;
2545
(&k->serialNumber)->identifier.bv_val = (&k->serialNumber)->id_buf;
2546
(&k->serialNumber)->identifier.bv_len = strlen("serialNumber");
2547
strcpy( (&k->serialNumber)->identifier.bv_val, "serialNumber");
2548
tagId1 = BDecTag (b, &totalElmtsLen1);
2555
if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
2557
elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2558
rc = BDecComponentAlgorithmIdentifier (mem_op, b, tagId1, elmtLen1, (&k->signature), &totalElmtsLen1, mode);
2559
if ( rc != LDAP_SUCCESS ) return rc;
2560
(k->signature)->identifier.bv_val = (k->signature)->id_buf;
2561
(k->signature)->identifier.bv_len = strlen("signature");
2562
strcpy( (k->signature)->identifier.bv_val, "signature");
2563
tagId1 = BDecTag (b, &totalElmtsLen1);
2570
if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
2572
elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2573
rc = BDecComponentName (mem_op, b, tagId1, elmtLen1, (&k->issuer), &totalElmtsLen1, mode);
2574
if ( rc != LDAP_SUCCESS ) return rc;
2575
(k->issuer)->identifier.bv_val = (k->issuer)->id_buf;
2576
(k->issuer)->identifier.bv_len = strlen("issuer");
2577
strcpy( (k->issuer)->identifier.bv_val, "issuer");
2578
tagId1 = BDecTag (b, &totalElmtsLen1);
2585
if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
2587
elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2588
rc = BDecComponentValidity (mem_op, b, tagId1, elmtLen1, (&k->validity), &totalElmtsLen1, mode);
2589
if ( rc != LDAP_SUCCESS ) return rc;
2590
(k->validity)->identifier.bv_val = (k->validity)->id_buf;
2591
(k->validity)->identifier.bv_len = strlen("validity");
2592
strcpy( (k->validity)->identifier.bv_val, "validity");
2593
tagId1 = BDecTag (b, &totalElmtsLen1);
2600
if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
2602
elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2603
rc = BDecComponentName (mem_op, b, tagId1, elmtLen1, (&k->subject), &totalElmtsLen1, mode);
2604
if ( rc != LDAP_SUCCESS ) return rc;
2605
(k->subject)->identifier.bv_val = (k->subject)->id_buf;
2606
(k->subject)->identifier.bv_len = strlen("subject");
2607
strcpy( (k->subject)->identifier.bv_val, "subject");
2608
tagId1 = BDecTag (b, &totalElmtsLen1);
2615
if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
2617
elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2618
rc = BDecComponentSubjectPublicKeyInfo (mem_op, b, tagId1, elmtLen1, (&k->subjectPublicKeyInfo), &totalElmtsLen1, mode);
2619
if ( rc != LDAP_SUCCESS ) return rc;
2620
(k->subjectPublicKeyInfo)->identifier.bv_val = (k->subjectPublicKeyInfo)->id_buf;
2621
(k->subjectPublicKeyInfo)->identifier.bv_len = strlen("subjectPublicKeyInfo");
2622
strcpy( (k->subjectPublicKeyInfo)->identifier.bv_val, "subjectPublicKeyInfo");
2623
if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0))
2627
tagId1 = BDecTag (b, &totalElmtsLen1 );
2629
if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID))
2631
BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )
2641
if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 1)) ||
2642
(tagId1 == MAKE_TAG_ID (CNTX, CONS, 1))))
2644
elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2645
rc = BDecComponentUniqueIdentifier (mem_op, b, tagId1, elmtLen1, (&k->issuerUniqueIdentifier), &totalElmtsLen1, mode);
2646
if ( rc != LDAP_SUCCESS ) return rc;
2647
(&k->issuerUniqueIdentifier)->identifier.bv_val = (&k->issuerUniqueIdentifier)->id_buf;
2648
(&k->issuerUniqueIdentifier)->identifier.bv_len = strlen("issuerUniqueIdentifier");
2649
strcpy( (&k->issuerUniqueIdentifier)->identifier.bv_val, "issuerUniqueIdentifier");
2650
if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0))
2654
tagId1 = BDecTag (b, &totalElmtsLen1 );
2656
if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID))
2658
BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )
2665
if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (CNTX, PRIM, 2)) ||
2666
(tagId1 == MAKE_TAG_ID (CNTX, CONS, 2))))
2668
elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2669
rc = BDecComponentUniqueIdentifier (mem_op, b, tagId1, elmtLen1, (&k->subjectUniqueIdentifier), &totalElmtsLen1, mode);
2670
if ( rc != LDAP_SUCCESS ) return rc;
2671
(&k->subjectUniqueIdentifier)->identifier.bv_val = (&k->subjectUniqueIdentifier)->id_buf;
2672
(&k->subjectUniqueIdentifier)->identifier.bv_len = strlen("subjectUniqueIdentifier");
2673
strcpy( (&k->subjectUniqueIdentifier)->identifier.bv_val, "subjectUniqueIdentifier");
2674
if ((elmtLen0 != INDEFINITE_LEN) && (totalElmtsLen1 == elmtLen0))
2678
tagId1 = BDecTag (b, &totalElmtsLen1 );
2680
if ((elmtLen0 == INDEFINITE_LEN) && (tagId1 == EOC_TAG_ID))
2682
BDEC_2ND_EOC_OCTET (b, &totalElmtsLen1 )
2689
if ((!seqDone) && ((tagId1 == MAKE_TAG_ID (CNTX, CONS, 3))))
2691
elmtLen1 = BDecLen (b, &totalElmtsLen1 );
2692
tagId2 = BDecTag (b, &totalElmtsLen1 );
2694
if (tagId2 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
2696
Asn1Error ("Unexpected Tag\n");
2700
elmtLen2 = BDecLen (b, &totalElmtsLen1 );
2701
rc = BDecComponentExtensions (mem_op, b, tagId2, elmtLen2, (&k->extensions), &totalElmtsLen1, mode);
2702
if ( rc != LDAP_SUCCESS ) return rc;
2703
(k->extensions)->identifier.bv_val = (k->extensions)->id_buf;
2704
(k->extensions)->identifier.bv_len = strlen("extensions");
2705
strcpy( (k->extensions)->identifier.bv_val, "extensions");
2706
if (elmtLen1 == INDEFINITE_LEN)
2707
BDecEoc (b, &totalElmtsLen1 );
2709
if (elmtLen0 == INDEFINITE_LEN)
2710
BDecEoc (b, &totalElmtsLen1 );
2711
else if (totalElmtsLen1 != elmtLen0)
2720
if(!COMPONENTNOT_NULL ((k->version)))
2722
(k->version) = CompAlloc( mem_op, sizeof(ComponentVersion));
2723
(k->version)->identifier.bv_val = (k->version)->id_buf;
2724
(k->version)->identifier.bv_len = strlen("version");
2725
strcpy( (k->version)->identifier.bv_val, "version");
2726
(k->version)->value = 0;
2728
if( !(old_mode & DEC_ALLOC_MODE_1) ) {
2729
*v = t = (ComponentTBSCertificate*) CompAlloc( mem_op, sizeof(ComponentTBSCertificate) );
2730
if ( !t ) return -1;
2733
t->syntax = (Syntax*)NULL;
2734
t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
2735
if ( !t->comp_desc ) {
2739
t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentTBSCertificate ;
2740
t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentTBSCertificate ;
2741
t->comp_desc->cd_free = (comp_free_func*)NULL;
2742
t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentTBSCertificate;
2743
t->comp_desc->cd_type = ASN_COMPOSITE;
2744
t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
2745
t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentTBSCertificate;
2746
(*bytesDecoded) += totalElmtsLen1;
2747
return LDAP_SUCCESS;
2748
} /* BDecTBSCertificate*/
2751
GDecComponentTBSCertificate PARAMS (( mem_op,b, v, bytesDecoded, mode),
2754
ComponentTBSCertificate **v _AND_
2755
AsnLen *bytesDecoded _AND_
2758
char* peek_head,*peek_head2;
2759
int i, strLen,strLen2, rc, old_mode = mode;
2760
ComponentTBSCertificate *k,*t, c_temp;
2763
if ( !(mode & DEC_ALLOC_MODE_1) ) {
2764
memset(&c_temp,0,sizeof(c_temp));
2768
mode = DEC_ALLOC_MODE_2;
2770
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2771
Asn1Error("Error during Reading { in encoded data");
2772
return LDAP_PROTOCOL_ERROR;
2774
if(*peek_head != '{'){
2775
Asn1Error("Missing { in encoded data");
2776
return LDAP_PROTOCOL_ERROR;
2779
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2780
Asn1Error("Error during Reading identifier");
2781
return LDAP_PROTOCOL_ERROR;
2783
if ( strncmp( peek_head, "version", strlen("version") ) == 0 ) {
2784
rc = GDecComponentVersion (mem_op, b, (&k->version), bytesDecoded, DEC_ALLOC_MODE_0 );
2785
if ( rc != LDAP_SUCCESS ) return rc;
2786
( k->version)->identifier.bv_val = peek_head;
2787
( k->version)->identifier.bv_len = strLen;
2788
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2789
Asn1Error("Error during Reading , ");
2790
return LDAP_PROTOCOL_ERROR;
2792
if(*peek_head != ','){
2793
Asn1Error("Missing , in encoding");
2794
return LDAP_PROTOCOL_ERROR;
2796
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2797
Asn1Error("Error during Reading identifier");
2798
return LDAP_PROTOCOL_ERROR;
2802
(k->version) = CompAlloc( mem_op, sizeof(ComponentVersion));
2803
(k->version)->value = 0;
2805
if ( strncmp( peek_head, "serialNumber", strlen("serialNumber") ) == 0 ) {
2806
rc = GDecComponentCertificateSerialNumber (mem_op, b, (&k->serialNumber), bytesDecoded, mode);
2807
if ( rc != LDAP_SUCCESS ) return rc;
2808
(&k->serialNumber)->identifier.bv_val = peek_head;
2809
(&k->serialNumber)->identifier.bv_len = strLen;
2810
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2811
Asn1Error("Error during Reading , ");
2812
return LDAP_PROTOCOL_ERROR;
2814
if(*peek_head != ','){
2815
Asn1Error("Missing , in encoding");
2816
return LDAP_PROTOCOL_ERROR;
2818
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2819
Asn1Error("Error during Reading identifier");
2820
return LDAP_PROTOCOL_ERROR;
2823
if ( strncmp( peek_head, "signature", strlen("signature") ) == 0 ) {
2824
rc = GDecComponentAlgorithmIdentifier (mem_op, b, (&k->signature), bytesDecoded, mode);
2825
if ( rc != LDAP_SUCCESS ) return rc;
2826
( k->signature)->identifier.bv_val = peek_head;
2827
( k->signature)->identifier.bv_len = strLen;
2828
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2829
Asn1Error("Error during Reading , ");
2830
return LDAP_PROTOCOL_ERROR;
2832
if(*peek_head != ','){
2833
Asn1Error("Missing , in encoding");
2834
return LDAP_PROTOCOL_ERROR;
2836
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2837
Asn1Error("Error during Reading identifier");
2838
return LDAP_PROTOCOL_ERROR;
2841
if ( strncmp( peek_head, "issuer", strlen("issuer") ) == 0 ) {
2842
rc = GDecComponentName (mem_op, b, (&k->issuer), bytesDecoded, mode);
2843
if ( rc != LDAP_SUCCESS ) return rc;
2844
( k->issuer)->identifier.bv_val = peek_head;
2845
( k->issuer)->identifier.bv_len = strLen;
2846
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2847
Asn1Error("Error during Reading , ");
2848
return LDAP_PROTOCOL_ERROR;
2850
if(*peek_head != ','){
2851
Asn1Error("Missing , in encoding");
2852
return LDAP_PROTOCOL_ERROR;
2854
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2855
Asn1Error("Error during Reading identifier");
2856
return LDAP_PROTOCOL_ERROR;
2859
if ( strncmp( peek_head, "validity", strlen("validity") ) == 0 ) {
2860
rc = GDecComponentValidity (mem_op, b, (&k->validity), bytesDecoded, mode);
2861
if ( rc != LDAP_SUCCESS ) return rc;
2862
( k->validity)->identifier.bv_val = peek_head;
2863
( k->validity)->identifier.bv_len = strLen;
2864
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2865
Asn1Error("Error during Reading , ");
2866
return LDAP_PROTOCOL_ERROR;
2868
if(*peek_head != ','){
2869
Asn1Error("Missing , in encoding");
2870
return LDAP_PROTOCOL_ERROR;
2872
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2873
Asn1Error("Error during Reading identifier");
2874
return LDAP_PROTOCOL_ERROR;
2877
if ( strncmp( peek_head, "subject", strlen("subject") ) == 0 ) {
2878
rc = GDecComponentName (mem_op, b, (&k->subject), bytesDecoded, mode);
2879
if ( rc != LDAP_SUCCESS ) return rc;
2880
( k->subject)->identifier.bv_val = peek_head;
2881
( k->subject)->identifier.bv_len = strLen;
2882
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2883
Asn1Error("Error during Reading , ");
2884
return LDAP_PROTOCOL_ERROR;
2886
if(*peek_head != ','){
2887
Asn1Error("Missing , in encoding");
2888
return LDAP_PROTOCOL_ERROR;
2890
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2891
Asn1Error("Error during Reading identifier");
2892
return LDAP_PROTOCOL_ERROR;
2895
if ( strncmp( peek_head, "subjectPublicKeyInfo", strlen("subjectPublicKeyInfo") ) == 0 ) {
2896
rc = GDecComponentSubjectPublicKeyInfo (mem_op, b, (&k->subjectPublicKeyInfo), bytesDecoded, mode);
2897
if ( rc != LDAP_SUCCESS ) return rc;
2898
( k->subjectPublicKeyInfo)->identifier.bv_val = peek_head;
2899
( k->subjectPublicKeyInfo)->identifier.bv_len = strLen;
2900
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2901
Asn1Error("Error during Reading , ");
2902
return LDAP_PROTOCOL_ERROR;
2904
if(*peek_head != ','){
2905
Asn1Error("Missing , in encoding");
2906
return LDAP_PROTOCOL_ERROR;
2908
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2909
Asn1Error("Error during Reading identifier");
2910
return LDAP_PROTOCOL_ERROR;
2913
if ( strncmp( peek_head, "issuerUniqueIdentifier", strlen("issuerUniqueIdentifier") ) == 0 ) {
2914
rc = GDecComponentUniqueIdentifier (mem_op, b, (&k->issuerUniqueIdentifier), bytesDecoded, mode);
2915
if ( rc != LDAP_SUCCESS ) return rc;
2916
(&k->issuerUniqueIdentifier)->identifier.bv_val = peek_head;
2917
(&k->issuerUniqueIdentifier)->identifier.bv_len = strLen;
2918
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2919
Asn1Error("Error during Reading , ");
2920
return LDAP_PROTOCOL_ERROR;
2922
if(*peek_head != ','){
2923
Asn1Error("Missing , in encoding");
2924
return LDAP_PROTOCOL_ERROR;
2926
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2927
Asn1Error("Error during Reading identifier");
2928
return LDAP_PROTOCOL_ERROR;
2931
if ( strncmp( peek_head, "subjectUniqueIdentifier", strlen("subjectUniqueIdentifier") ) == 0 ) {
2932
rc = GDecComponentUniqueIdentifier (mem_op, b, (&k->subjectUniqueIdentifier), bytesDecoded, mode);
2933
if ( rc != LDAP_SUCCESS ) return rc;
2934
(&k->subjectUniqueIdentifier)->identifier.bv_val = peek_head;
2935
(&k->subjectUniqueIdentifier)->identifier.bv_len = strLen;
2936
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2937
Asn1Error("Error during Reading , ");
2938
return LDAP_PROTOCOL_ERROR;
2940
if(*peek_head != ','){
2941
Asn1Error("Missing , in encoding");
2942
return LDAP_PROTOCOL_ERROR;
2944
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
2945
Asn1Error("Error during Reading identifier");
2946
return LDAP_PROTOCOL_ERROR;
2949
if ( strncmp( peek_head, "extensions", strlen("extensions") ) == 0 ) {
2950
rc = GDecComponentExtensions (mem_op, b, (&k->extensions), bytesDecoded, mode);
2951
if ( rc != LDAP_SUCCESS ) return rc;
2952
( k->extensions)->identifier.bv_val = peek_head;
2953
( k->extensions)->identifier.bv_len = strLen;
2955
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {
2956
Asn1Error("Error during Reading } in encoding");
2957
return LDAP_PROTOCOL_ERROR;
2959
if(*peek_head != '}'){
2960
Asn1Error("Missing } in encoding");
2961
return LDAP_PROTOCOL_ERROR;
2963
if( !(old_mode & DEC_ALLOC_MODE_1) ) {
2964
*v = t = (ComponentTBSCertificate*) CompAlloc( mem_op, sizeof(ComponentTBSCertificate) );
2965
if ( !t ) return -1;
2968
t->syntax = (Syntax*)NULL;
2969
t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
2970
if ( !t->comp_desc ) {
2974
t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentTBSCertificate ;
2975
t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentTBSCertificate ;
2976
t->comp_desc->cd_free = (comp_free_func*)NULL;
2977
t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentTBSCertificate;
2978
t->comp_desc->cd_type = ASN_COMPOSITE;
2979
t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
2980
t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentTBSCertificate;
2981
return LDAP_SUCCESS;
2982
} /* GDecTBSCertificate*/
2986
MatchingComponentCertificate ( char* oid, ComponentSyntaxInfo* csi_attr, ComponentSyntaxInfo* csi_assert ) {
2991
mr = retrieve_matching_rule( oid, csi_attr->csi_comp_desc->cd_type_id);
2992
if ( mr ) return component_value_match( mr, csi_attr, csi_assert );
2996
rc = MatchingComponentTBSCertificate ( oid, (ComponentSyntaxInfo*)((ComponentCertificate*)csi_attr)->toBeSigned, (ComponentSyntaxInfo*)((ComponentCertificate*)csi_assert)->toBeSigned );
2997
if ( rc != LDAP_COMPARE_TRUE )
2999
rc = MatchingComponentAlgorithmIdentifier ( oid, (ComponentSyntaxInfo*)((ComponentCertificate*)csi_attr)->signatureAlgorithm, (ComponentSyntaxInfo*)((ComponentCertificate*)csi_assert)->signatureAlgorithm );
3000
if ( rc != LDAP_COMPARE_TRUE )
3002
rc = MatchingComponentBits ( oid, (ComponentSyntaxInfo*)&((ComponentCertificate*)csi_attr)->signature, (ComponentSyntaxInfo*)&((ComponentCertificate*)csi_assert)->signature );
3003
if ( rc != LDAP_COMPARE_TRUE )
3005
return LDAP_COMPARE_TRUE;
3006
} /* BMatchingComponentCertificate */
3009
ExtractingComponentCertificate ( void* mem_op, ComponentReference* cr, ComponentCertificate *comp )
3012
if ( ( comp->toBeSigned->identifier.bv_val && strncmp(comp->toBeSigned->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->toBeSigned->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
3013
if ( cr->cr_curr->ci_next == NULL )
3014
return comp->toBeSigned;
3016
cr->cr_curr = cr->cr_curr->ci_next;
3017
return ExtractingComponentTBSCertificate ( mem_op, cr, comp->toBeSigned );
3020
if ( ( comp->signatureAlgorithm->identifier.bv_val && strncmp(comp->signatureAlgorithm->identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->signatureAlgorithm->id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
3021
if ( cr->cr_curr->ci_next == NULL )
3022
return comp->signatureAlgorithm;
3024
cr->cr_curr = cr->cr_curr->ci_next;
3025
return ExtractingComponentAlgorithmIdentifier ( mem_op, cr, comp->signatureAlgorithm );
3028
if ( ( comp->signature.identifier.bv_val && strncmp(comp->signature.identifier.bv_val, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) || ( strncmp(comp->signature.id_buf, cr->cr_curr->ci_val.ci_identifier.bv_val,cr->cr_curr->ci_val.ci_identifier.bv_len) == 0 ) ) {
3029
if ( cr->cr_curr->ci_next == NULL )
3030
return &comp->signature;
3031
else if ( cr->cr_curr->ci_next->ci_type == LDAP_COMPREF_CONTENT) {
3032
cr->cr_curr = cr->cr_curr->ci_next;
3033
return &comp->signature;
3039
} /* ExtractingComponentCertificate */
3042
BDecComponentCertificate PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, mode),
3046
AsnLen elmtLen0 _AND_
3047
ComponentCertificate **v _AND_
3048
AsnLen *bytesDecoded _AND_
3051
int seqDone = FALSE;
3052
AsnLen totalElmtsLen1 = 0;
3055
int mandatoryElmtCount1 = 0;
3056
int old_mode = mode;
3058
ComponentCertificate *k, *t, c_temp;
3061
if ( !(mode & DEC_ALLOC_MODE_1) ) {
3062
memset(&c_temp,0,sizeof(c_temp));
3066
mode = DEC_ALLOC_MODE_2;
3067
tagId1 = BDecTag (b, &totalElmtsLen1 );
3069
if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
3071
elmtLen1 = BDecLen (b, &totalElmtsLen1 );
3072
rc = BDecComponentTBSCertificate (mem_op, b, tagId1, elmtLen1, (&k->toBeSigned), &totalElmtsLen1, mode);
3073
if ( rc != LDAP_SUCCESS ) return rc;
3074
(k->toBeSigned)->identifier.bv_val = (k->toBeSigned)->id_buf;
3075
(k->toBeSigned)->identifier.bv_len = strlen("toBeSigned");
3076
strcpy( (k->toBeSigned)->identifier.bv_val, "toBeSigned");
3077
tagId1 = BDecTag (b, &totalElmtsLen1);
3084
if (((tagId1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))))
3086
elmtLen1 = BDecLen (b, &totalElmtsLen1 );
3087
rc = BDecComponentAlgorithmIdentifier (mem_op, b, tagId1, elmtLen1, (&k->signatureAlgorithm), &totalElmtsLen1, mode);
3088
if ( rc != LDAP_SUCCESS ) return rc;
3089
(k->signatureAlgorithm)->identifier.bv_val = (k->signatureAlgorithm)->id_buf;
3090
(k->signatureAlgorithm)->identifier.bv_len = strlen("signatureAlgorithm");
3091
strcpy( (k->signatureAlgorithm)->identifier.bv_val, "signatureAlgorithm");
3092
tagId1 = BDecTag (b, &totalElmtsLen1);
3099
if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE)) ||
3100
(tagId1 == MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE))))
3102
elmtLen1 = BDecLen (b, &totalElmtsLen1 );
3103
rc = BDecComponentBits (mem_op, b, tagId1, elmtLen1, (&k->signature), &totalElmtsLen1, mode);
3104
if ( rc != LDAP_SUCCESS ) return rc;
3105
(&k->signature)->identifier.bv_val = (&k->signature)->id_buf;
3106
(&k->signature)->identifier.bv_len = strlen("signature");
3107
strcpy( (&k->signature)->identifier.bv_val, "signature");
3109
if (elmtLen0 == INDEFINITE_LEN)
3110
BDecEoc (b, &totalElmtsLen1 );
3111
else if (totalElmtsLen1 != elmtLen0)
3123
if( !(old_mode & DEC_ALLOC_MODE_1) ) {
3124
*v = t = (ComponentCertificate*) CompAlloc( mem_op, sizeof(ComponentCertificate) );
3125
if ( !t ) return -1;
3128
t->syntax = (Syntax*)NULL;
3129
t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
3130
if ( !t->comp_desc ) {
3134
t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentCertificate ;
3135
t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentCertificate ;
3136
t->comp_desc->cd_free = (comp_free_func*)NULL;
3137
t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentCertificate;
3138
t->comp_desc->cd_type = ASN_COMPOSITE;
3139
t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
3140
t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentCertificate;
3141
(*bytesDecoded) += totalElmtsLen1;
3142
return LDAP_SUCCESS;
3143
} /* BDecCertificate*/
3146
GDecComponentCertificate PARAMS (( mem_op,b, v, bytesDecoded, mode),
3149
ComponentCertificate **v _AND_
3150
AsnLen *bytesDecoded _AND_
3153
char* peek_head,*peek_head2;
3154
int i, strLen,strLen2, rc, old_mode = mode;
3155
ComponentCertificate *k,*t, c_temp;
3158
if ( !(mode & DEC_ALLOC_MODE_1) ) {
3159
memset(&c_temp,0,sizeof(c_temp));
3163
mode = DEC_ALLOC_MODE_2;
3165
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
3166
Asn1Error("Error during Reading { in encoded data");
3167
return LDAP_PROTOCOL_ERROR;
3169
if(*peek_head != '{'){
3170
Asn1Error("Missing { in encoded data");
3171
return LDAP_PROTOCOL_ERROR;
3174
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
3175
Asn1Error("Error during Reading identifier");
3176
return LDAP_PROTOCOL_ERROR;
3178
if ( strncmp( peek_head, "toBeSigned", strlen("toBeSigned") ) == 0 ) {
3179
rc = GDecComponentTBSCertificate (mem_op, b, (&k->toBeSigned), bytesDecoded, mode);
3180
if ( rc != LDAP_SUCCESS ) return rc;
3181
( k->toBeSigned)->identifier.bv_val = peek_head;
3182
( k->toBeSigned)->identifier.bv_len = strLen;
3183
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
3184
Asn1Error("Error during Reading , ");
3185
return LDAP_PROTOCOL_ERROR;
3187
if(*peek_head != ','){
3188
Asn1Error("Missing , in encoding");
3189
return LDAP_PROTOCOL_ERROR;
3191
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
3192
Asn1Error("Error during Reading identifier");
3193
return LDAP_PROTOCOL_ERROR;
3196
if ( strncmp( peek_head, "signatureAlgorithm", strlen("signatureAlgorithm") ) == 0 ) {
3197
rc = GDecComponentAlgorithmIdentifier (mem_op, b, (&k->signatureAlgorithm), bytesDecoded, mode);
3198
if ( rc != LDAP_SUCCESS ) return rc;
3199
( k->signatureAlgorithm)->identifier.bv_val = peek_head;
3200
( k->signatureAlgorithm)->identifier.bv_len = strLen;
3201
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
3202
Asn1Error("Error during Reading , ");
3203
return LDAP_PROTOCOL_ERROR;
3205
if(*peek_head != ','){
3206
Asn1Error("Missing , in encoding");
3207
return LDAP_PROTOCOL_ERROR;
3209
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ){
3210
Asn1Error("Error during Reading identifier");
3211
return LDAP_PROTOCOL_ERROR;
3214
if ( strncmp( peek_head, "signature", strlen("signature") ) == 0 ) {
3215
rc = GDecComponentBits (mem_op, b, (&k->signature), bytesDecoded, mode);
3216
if ( rc != LDAP_SUCCESS ) return rc;
3217
(&k->signature)->identifier.bv_val = peek_head;
3218
(&k->signature)->identifier.bv_len = strLen;
3220
if( !(strLen = LocateNextGSERToken(mem_op,b,&peek_head,GSER_NO_COPY)) ) {
3221
Asn1Error("Error during Reading } in encoding");
3222
return LDAP_PROTOCOL_ERROR;
3224
if(*peek_head != '}'){
3225
Asn1Error("Missing } in encoding");
3226
return LDAP_PROTOCOL_ERROR;
3228
if( !(old_mode & DEC_ALLOC_MODE_1) ) {
3229
*v = t = (ComponentCertificate*) CompAlloc( mem_op, sizeof(ComponentCertificate) );
3230
if ( !t ) return -1;
3233
t->syntax = (Syntax*)NULL;
3234
t->comp_desc = CompAlloc( mem_op, sizeof( ComponentDesc ) );
3235
if ( !t->comp_desc ) {
3239
t->comp_desc->cd_gser_decoder = (gser_decoder_func*)GDecComponentCertificate ;
3240
t->comp_desc->cd_ber_decoder = (ber_decoder_func*)BDecComponentCertificate ;
3241
t->comp_desc->cd_free = (comp_free_func*)NULL;
3242
t->comp_desc->cd_extract_i = (extract_component_from_id_func*)ExtractingComponentCertificate;
3243
t->comp_desc->cd_type = ASN_COMPOSITE;
3244
t->comp_desc->cd_type_id = COMPOSITE_ASN1_TYPE;
3245
t->comp_desc->cd_all_match = (allcomponent_matching_func*)MatchingComponentCertificate;
3246
return LDAP_SUCCESS;
3247
} /* GDecCertificate*/