FreeCalypso > hg > fc-selenite
comparison src/gpf/ccd/asn1_objid.c @ 5:1ea54a97e831
src/gpf: import of Magnetite src/gpf3
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 15 Jul 2018 08:11:07 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
4:6e457872f745 | 5:1ea54a97e831 |
---|---|
1 | |
2 /* | |
3 +------------------------------------------------------------------------------ | |
4 | File: asn1_objid.c | |
5 +------------------------------------------------------------------------------ | |
6 | Copyright 2002 Texas Instruments Berlin, AG | |
7 | All rights reserved. | |
8 | | |
9 | This file is confidential and a trade secret of Texas | |
10 | Instruments Berlin, AG. | |
11 | The receipt of or possession of this file does not convey | |
12 | any rights to reproduce or disclose its contents or to | |
13 | manufacture, use, or sell anything it may describe, in | |
14 | whole, or in part, without the specific written consent of | |
15 | Texas Instruments Berlin, AG. | |
16 +------------------------------------------------------------------------------ | |
17 | Purpose: Encoding and decoding functions for ASN1_OBJ_ID type | |
18 | | |
19 | $Identity:$ | |
20 +------------------------------------------------------------------------------ | |
21 */ | |
22 | |
23 /* | |
24 * Standard definitions like UCHAR, ERROR etc. | |
25 */ | |
26 #include "typedefs.h" | |
27 #include "header.h" | |
28 | |
29 /* | |
30 * Prototypes of ccd (USE_DRIVER EQ undef) for prototypes only | |
31 * look at ccdapi.h | |
32 */ | |
33 #undef USE_DRIVER | |
34 #include "ccdapi.h" | |
35 | |
36 /* | |
37 * Types and functions for bit access and manipulation | |
38 */ | |
39 #include "ccd_globs.h" | |
40 #include "bitfun.h" | |
41 | |
42 /* | |
43 * Prototypes and constants in the common part of ccd | |
44 */ | |
45 #include "ccd.h" | |
46 | |
47 /* | |
48 * Declaration of coder/decoder tables | |
49 */ | |
50 #include "ccdtable.h" | |
51 #include "ccddata.h" | |
52 | |
53 #ifndef RUN_INT_RAM | |
54 /* | |
55 +------------------------------------------------------------------------+ | |
56 | PROJECT : CCD (6144) MODULE : asn1_objid | | |
57 | STATE : code ROUTINE : cdc_asn1_obj_id_decode | | |
58 +------------------------------------------------------------------------+ | |
59 | |
60 PURPOSE : Decode PER OBJECT IDENTIFIER type | |
61 | |
62 The PER encoding of an object identifier type uses the | |
63 content octets of BER preceded by a length determinant | |
64 that will in practice be a single octet. | |
65 */ | |
66 SHORT cdc_asn1_obj_id_decode (const ULONG c_ref, const ULONG e_ref, T_CCD_Globs *globs) | |
67 { | |
68 U8 BER_Len; | |
69 | |
70 #ifdef DEBUG_CCD | |
71 #ifndef CCD_SYMBOLS | |
72 TRACE_CCD (globs, "cdc_asn1_obj_id_decode()"); | |
73 #else | |
74 TRACE_CCD (globs, "cdc_asn1_obj_id_decode() %s", mcomp[melem[e_ref].elemRef].name); | |
75 #endif | |
76 #endif | |
77 | |
78 globs->pstructOffs = melem[e_ref].structOffs; | |
79 | |
80 /* For optional elements we have already set the valid flag in the | |
81 * C-structure. We have done it while processing ASN1_SEQ. | |
82 */ | |
83 if ( ! cdc_isPresent(e_ref, globs) ) { | |
84 return 1; | |
85 } | |
86 | |
87 /* | |
88 * Skip over PER length octet and BER tag octet. | |
89 */ | |
90 bf_incBitpos (16, globs); | |
91 | |
92 /* | |
93 * For unknown extension read the length and skip over the octets. | |
94 */ | |
95 BER_Len = (U8) bf_getBits (8, globs); | |
96 *(U8 *)(globs->pstruct + globs->pstructOffs++) = BER_Len; | |
97 | |
98 /* | |
99 * Copy the content of object identifier bytes into the C-Structure. | |
100 */ | |
101 #ifdef _TMS470 | |
102 bf_incBitpos (8 * BER_Len, globs); | |
103 #else | |
104 { | |
105 int i; | |
106 for (i=0; i < BER_Len; i++) | |
107 *(U8 *)(globs->pstruct + globs->pstructOffs++) = (U8) bf_getBits (8, globs); | |
108 } | |
109 #endif | |
110 | |
111 return 1; | |
112 } | |
113 #endif /* !RUN_INT_RAM */ | |
114 | |
115 #ifndef RUN_INT_RAM | |
116 /* | |
117 +------------------------------------------------------------------------+ | |
118 | PROJECT : CCD (6144) MODULE : asn1_objid | | |
119 | STATE : code ROUTINE : cdc_asn1_obj_id_encode | | |
120 +------------------------------------------------------------------------+ | |
121 | |
122 PURPOSE : Encode PER OBJECT IDENTIFIER type | |
123 | |
124 The PER encoding of an object identifier type uses the | |
125 content octets of BER preceded by a length determinant | |
126 that will in practice be a single octet. | |
127 */ | |
128 SHORT cdc_asn1_obj_id_encode (const ULONG c_ref, const ULONG e_ref, T_CCD_Globs *globs) | |
129 { | |
130 | |
131 #ifdef DEBUG_CCD | |
132 #ifndef CCD_SYMBOLS | |
133 TRACE_CCD (globs, "cdc_asn1_obj_id_encode()"); | |
134 #else | |
135 TRACE_CCD (globs, "cdc_asn1_obj_id_encode() %s", mcomp[melem[e_ref].elemRef].name); | |
136 #endif | |
137 #endif | |
138 | |
139 return 1; | |
140 } | |
141 #endif /* !RUN_INT_RAM */ |