VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/asn1/asn1-cursor.cpp@ 56290

最後變更 在這個檔案從56290是 56290,由 vboxsync 提交於 10 年 前

IPRT: Updated (C) year.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
  • 屬性 svn:mergeinfo 設為 (切換已刪除的分支)
    /branches/VBox-3.0/src/VBox/Runtime/common/asn1/asn1-basics.cpp58652,​70973
    /branches/VBox-3.2/src/VBox/Runtime/common/asn1/asn1-basics.cpp66309,​66318
    /branches/VBox-4.0/src/VBox/Runtime/common/asn1/asn1-basics.cpp70873
    /branches/VBox-4.1/src/VBox/Runtime/common/asn1/asn1-basics.cpp74233,​78414,​78691,​81841,​82127,​85941,​85944-85947,​85949-85950,​85953,​86701,​86728,​87009
    /branches/VBox-4.2/src/VBox/Runtime/common/asn1/asn1-basics.cpp86229-86230,​86234,​86529,​91503-91504,​91506-91508,​91510,​91514-91515,​91521
    /branches/VBox-4.3/src/VBox/Runtime/common/asn1/asn1-basics.cpp91223
    /branches/VBox-4.3/trunk/src/VBox/Runtime/common/asn1/asn1-basics.cpp91223
    /branches/andy/draganddrop/src/VBox/Runtime/common/asn1/asn1-basics.cpp90781-91268
    /branches/andy/guestctrl20/src/VBox/Runtime/common/asn1/asn1-basics.cpp78916,​78930
    /branches/dsen/gui/src/VBox/Runtime/common/asn1/asn1-basics.cpp79076-79078,​79089,​79109-79110,​79112-79113,​79127-79130,​79134,​79141,​79151,​79155,​79157-79159,​79193,​79197
    /branches/dsen/gui2/src/VBox/Runtime/common/asn1/asn1-basics.cpp79224,​79228,​79233,​79235,​79258,​79262-79263,​79273,​79341,​79345,​79354,​79357,​79387-79388,​79559-79569,​79572-79573,​79578,​79581-79582,​79590-79591,​79598-79599,​79602-79603,​79605-79606,​79632,​79635,​79637,​79644
    /branches/dsen/gui3/src/VBox/Runtime/common/asn1/asn1-basics.cpp79645-79692
檔案大小: 21.2 KB
 
1/* $Id: asn1-cursor.cpp 56290 2015-06-09 14:01:31Z vboxsync $ */
2/** @file
3 * IPRT - ASN.1, Basic Operations.
4 */
5
6/*
7 * Copyright (C) 2006-2015 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.alldomusa.eu.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27/*******************************************************************************
28* Header Files *
29*******************************************************************************/
30#include "internal/iprt.h"
31#include <iprt/asn1.h>
32
33#include <iprt/alloca.h>
34#include <iprt/err.h>
35#include <iprt/string.h>
36#include <iprt/ctype.h>
37
38#include <iprt/formats/asn1.h>
39
40
41/*******************************************************************************
42* Defined Constants And Macros *
43*******************************************************************************/
44/** @def RTASN1_MAX_NESTING
45 * The maximum nesting depth we allow. This limit is enforced to avoid running
46 * out of stack due to malformed ASN.1 input.
47 *
48 * For reference, 'RTSignTool verify-exe RTSignTool.exe', requires a value of 15
49 * to work without hitting the limit for signatures with simple timestamps, and
50 * 23 (amd64/rel = ~3KB) for the new microsoft timestamp counter signatures.
51 */
52#ifdef IN_RING3
53# define RTASN1_MAX_NESTING 64
54#else
55# define RTASN1_MAX_NESTING 32
56#endif
57
58
59/*******************************************************************************
60* Global Variables *
61*******************************************************************************/
62static char const g_achDigits[11] = "0123456789";
63
64
65
66RTDECL(PRTASN1CURSOR) RTAsn1CursorInitPrimary(PRTASN1CURSORPRIMARY pPrimaryCursor, void const *pvFirst, uint32_t cb,
67 PRTERRINFO pErrInfo, PCRTASN1ALLOCATORVTABLE pAllocator, uint32_t fFlags,
68 const char *pszErrorTag)
69{
70 pPrimaryCursor->Cursor.pbCur = (uint8_t const *)pvFirst;
71 pPrimaryCursor->Cursor.cbLeft = cb;
72 pPrimaryCursor->Cursor.fFlags = fFlags;
73 pPrimaryCursor->Cursor.cDepth = 0;
74 pPrimaryCursor->Cursor.abReserved[0] = 0;
75 pPrimaryCursor->Cursor.abReserved[1] = 0;
76 pPrimaryCursor->Cursor.pPrimary = pPrimaryCursor;
77 pPrimaryCursor->Cursor.pUp = NULL;
78 pPrimaryCursor->Cursor.pszErrorTag = pszErrorTag;
79 pPrimaryCursor->pErrInfo = pErrInfo;
80 pPrimaryCursor->pAllocator = pAllocator;
81 return &pPrimaryCursor->Cursor;
82}
83
84
85RTDECL(int) RTAsn1CursorInitSub(PRTASN1CURSOR pParent, uint32_t cb, PRTASN1CURSOR pChild, const char *pszErrorTag)
86{
87 AssertReturn(pParent->pPrimary, VERR_ASN1_INTERNAL_ERROR_1);
88 AssertReturn(pParent->pbCur, VERR_ASN1_INTERNAL_ERROR_2);
89
90 pChild->pbCur = pParent->pbCur;
91 pChild->cbLeft = cb;
92 pChild->fFlags = pParent->fFlags;
93 pChild->cDepth = pParent->cDepth + 1;
94 AssertReturn(pChild->cDepth < RTASN1_MAX_NESTING, VERR_ASN1_TOO_DEEPLY_NESTED);
95 pChild->abReserved[0] = 0;
96 pChild->abReserved[1] = 0;
97 pChild->pPrimary = pParent->pPrimary;
98 pChild->pUp = pParent;
99 pChild->pszErrorTag = pszErrorTag;
100
101 AssertReturn(pParent->cbLeft >= cb, VERR_ASN1_INTERNAL_ERROR_3);
102 pParent->pbCur += cb;
103 pParent->cbLeft -= cb;
104
105 return VINF_SUCCESS;
106}
107
108
109RTDECL(int) RTAsn1CursorInitSubFromCore(PRTASN1CURSOR pParent, PRTASN1CORE pAsn1Core,
110 PRTASN1CURSOR pChild, const char *pszErrorTag)
111{
112 AssertReturn(pParent->pPrimary, VERR_ASN1_INTERNAL_ERROR_1);
113 AssertReturn(pParent->pbCur, VERR_ASN1_INTERNAL_ERROR_2);
114
115 pChild->pbCur = pAsn1Core->uData.pu8;
116 pChild->cbLeft = pAsn1Core->cb;
117 pChild->fFlags = pParent->fFlags;
118 pChild->cDepth = pParent->cDepth + 1;
119 AssertReturn(pChild->cDepth < RTASN1_MAX_NESTING, VERR_ASN1_TOO_DEEPLY_NESTED);
120 pChild->abReserved[0] = 0;
121 pChild->abReserved[1] = 0;
122 pChild->pPrimary = pParent->pPrimary;
123 pChild->pUp = pParent;
124 pChild->pszErrorTag = pszErrorTag;
125
126 return VINF_SUCCESS;
127}
128
129
130RTDECL(int) RTAsn1CursorSetInfoV(PRTASN1CURSOR pCursor, int rc, const char *pszMsg, va_list va)
131{
132 PRTERRINFO pErrInfo = pCursor->pPrimary->pErrInfo;
133 if (pErrInfo)
134 {
135 /* Format the message. */
136 RTErrInfoSetV(pErrInfo, rc, pszMsg, va);
137
138 /* Add the prefixes. This isn't the fastest way, but it's the one
139 which eats the least stack. */
140 char *pszBuf = pErrInfo->pszMsg;
141 size_t cbBuf = pErrInfo->cbMsg;
142 if (pszBuf && cbBuf > 32)
143 {
144 size_t cbMove = strlen(pszBuf) + 1;
145
146 /* Make sure there is a ': '. */
147 bool fFirst = false;
148 if (pszMsg[0] != '%' || pszMsg[1] != 's' || pszMsg[2] != ':')
149 {
150 if (cbMove + 2 < cbBuf)
151 {
152 memmove(pszBuf + 2, pszBuf, cbMove);
153 pszBuf[0] = ':';
154 pszBuf[1] = ' ';
155 cbMove += 2;
156 fFirst = true;
157 }
158 }
159
160 /* Add the prefixes from the cursor chain. */
161 while (pCursor)
162 {
163 if (pCursor->pszErrorTag)
164 {
165 size_t cchErrorTag = strlen(pCursor->pszErrorTag);
166 if (cchErrorTag + !fFirst + cbMove > cbBuf)
167 break;
168 memmove(pszBuf + cchErrorTag + !fFirst, pszBuf, cbMove);
169 memcpy(pszBuf, pCursor->pszErrorTag, cchErrorTag);
170 if (!fFirst)
171 pszBuf[cchErrorTag] = '.';
172 cbMove += cchErrorTag + !fFirst;
173 fFirst = false;
174 }
175 pCursor = pCursor->pUp;
176 }
177 }
178 }
179
180 return rc;
181}
182
183
184RTDECL(int) RTAsn1CursorSetInfo(PRTASN1CURSOR pCursor, int rc, const char *pszMsg, ...)
185{
186 va_list va;
187 va_start(va, pszMsg);
188 rc = RTAsn1CursorSetInfoV(pCursor, rc, pszMsg, va);
189 va_end(va);
190 return rc;
191}
192
193
194RTDECL(int) RTAsn1CursorCheckEnd(PRTASN1CURSOR pCursor)
195{
196 if (pCursor->cbLeft == 0)
197 return VINF_SUCCESS;
198 return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_CURSOR_NOT_AT_END,
199 "%u (%#x) bytes left over", pCursor->cbLeft, pCursor->cbLeft);
200}
201
202
203RTDECL(PRTASN1ALLOCATION) RTAsn1CursorInitAllocation(PRTASN1CURSOR pCursor, PRTASN1ALLOCATION pAllocation)
204{
205 pAllocation->cbAllocated = 0;
206 pAllocation->cReallocs = 0;
207 pAllocation->uReserved0 = 0;
208 pAllocation->pAllocator = pCursor->pPrimary->pAllocator;
209 return pAllocation;
210}
211
212
213RTDECL(int) RTAsn1CursorReadHdr(PRTASN1CURSOR pCursor, PRTASN1CORE pAsn1Core, const char *pszErrorTag)
214{
215 /*
216 * Initialize the return structure in case of failure.
217 */
218 pAsn1Core->uTag = 0;
219 pAsn1Core->fClass = 0;
220 pAsn1Core->uRealTag = 0;
221 pAsn1Core->fRealClass = 0;
222 pAsn1Core->cbHdr = 0;
223 pAsn1Core->cb = 0;
224 pAsn1Core->fFlags = 0;
225 pAsn1Core->uData.pv = NULL;
226 pAsn1Core->pOps = NULL;
227
228 /*
229 * The header has at least two bytes: Type & length.
230 */
231 if (pCursor->cbLeft >= 2)
232 {
233 uint32_t uTag = pCursor->pbCur[0];
234 uint32_t cb = pCursor->pbCur[1];
235 pCursor->cbLeft -= 2;
236 pCursor->pbCur += 2;
237
238 pAsn1Core->uRealTag = pAsn1Core->uTag = uTag & ASN1_TAG_MASK;
239 pAsn1Core->fRealClass = pAsn1Core->fClass = uTag & ~ASN1_TAG_MASK;
240 pAsn1Core->cbHdr = 2;
241 if ((uTag & ASN1_TAG_MASK) == ASN1_TAG_USE_LONG_FORM)
242 return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_CURSOR_LONG_TAG,
243 "%s: Implement parsing of tags > 30: %#x (length=%#x)", pszErrorTag, uTag, cb);
244
245 /* Extended length field? */
246 if (cb & RT_BIT(7))
247 {
248 if (cb != RT_BIT(7))
249 {
250 /* Definite form. */
251 uint8_t cbEnc = cb & 0x7f;
252 if (cbEnc > pCursor->cbLeft)
253 return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_CURSOR_BAD_LENGTH_ENCODING,
254 "%s: Extended BER length field longer than available data: %#x vs %#x (uTag=%#x)",
255 pszErrorTag, cbEnc, pCursor->cbLeft, uTag);
256 switch (cbEnc)
257 {
258 case 1:
259 cb = pCursor->pbCur[0];
260 break;
261 case 2:
262 cb = RT_MAKE_U16(pCursor->pbCur[1], pCursor->pbCur[0]);
263 break;
264 case 3:
265 cb = RT_MAKE_U32_FROM_U8(pCursor->pbCur[2], pCursor->pbCur[1], pCursor->pbCur[0], 0);
266 break;
267 case 4:
268 cb = RT_MAKE_U32_FROM_U8(pCursor->pbCur[3], pCursor->pbCur[2], pCursor->pbCur[1], pCursor->pbCur[0]);
269 break;
270 default:
271 return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_CURSOR_BAD_LENGTH_ENCODING,
272 "%s: Too long/short extended BER length field: %#x (uTag=%#x)",
273 pszErrorTag, cbEnc, uTag);
274 }
275 pCursor->cbLeft -= cbEnc;
276 pCursor->pbCur += cbEnc;
277 pAsn1Core->cbHdr += cbEnc;
278
279 /* Check the length encoding efficiency (T-REC-X.690-200811 10.1, 9.1). */
280 if (pCursor->fFlags & (RTASN1CURSOR_FLAGS_DER | RTASN1CURSOR_FLAGS_CER))
281 {
282 if (cb <= 0x7f)
283 return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_CURSOR_BAD_LENGTH_ENCODING,
284 "%s: Invalid DER/CER length encoding: cbEnc=%u cb=%#x uTag=%#x",
285 pszErrorTag, cbEnc, cb, uTag);
286 uint8_t cbNeeded;
287 if (cb <= 0x000000ff) cbNeeded = 1;
288 else if (cb <= 0x0000ffff) cbNeeded = 2;
289 else if (cb <= 0x00ffffff) cbNeeded = 3;
290 else cbNeeded = 4;
291 if (cbNeeded != cbEnc)
292 return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_CURSOR_BAD_LENGTH_ENCODING,
293 "%s: Invalid DER/CER length encoding: cb=%#x uTag=%#x cbEnc=%u cbNeeded=%u",
294 pszErrorTag, cb, uTag, cbEnc, cbNeeded);
295 }
296 }
297 /* Indefinite form. */
298 else if (pCursor->fFlags & RTASN1CURSOR_FLAGS_DER)
299 return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_CURSOR_ILLEGAL_IDEFINITE_LENGTH,
300 "%s: Indefinite length form not allowed in DER mode (uTag=%#x).", pszErrorTag, uTag);
301 else
302 return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_CURSOR_IDEFINITE_LENGTH_NOT_SUP,
303 "%s: Indefinite BER/CER length not supported (uTag=%#x)", pszErrorTag, uTag);
304 }
305
306 /* Check if the length makes sense. */
307 if (cb > pCursor->cbLeft)
308 return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_CURSOR_BAD_LENGTH,
309 "%s: BER value length out of bounds: %#x (max=%#x uTag=%#x)",
310 pszErrorTag, cb, pCursor->cbLeft, uTag);
311
312 pAsn1Core->fFlags |= RTASN1CORE_F_PRESENT | RTASN1CORE_F_DECODED_CONTENT;
313 pAsn1Core->cb = cb;
314 pAsn1Core->uData.pv = (void *)pCursor->pbCur;
315 return VINF_SUCCESS;
316 }
317
318 if (pCursor->cbLeft)
319 return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_CURSOR_TOO_LITTLE_DATA_LEFT,
320 "%s: Too little data left to form a valid BER header", pszErrorTag);
321 return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_CURSOR_NO_MORE_DATA,
322 "%s: No more data reading BER header", pszErrorTag);
323}
324
325
326RTDECL(int) RTAsn1CursorMatchTagClassFlagsEx(PRTASN1CURSOR pCursor, PRTASN1CORE pAsn1Core, uint32_t uTag, uint32_t fClass,
327 bool fString, uint32_t fFlags, const char *pszErrorTag, const char *pszWhat)
328{
329 if (pAsn1Core->uTag == uTag)
330 {
331 if (pAsn1Core->fClass == fClass)
332 return VINF_SUCCESS;
333 if ( fString
334 && pAsn1Core->fClass == (fClass | ASN1_TAGFLAG_CONSTRUCTED))
335 {
336 if (!(pCursor->fFlags & (RTASN1CURSOR_FLAGS_DER | RTASN1CURSOR_FLAGS_CER)))
337 return VINF_SUCCESS;
338 if (pCursor->fFlags & RTASN1CURSOR_FLAGS_CER)
339 {
340 if (pAsn1Core->cb > 1000)
341 return VINF_SUCCESS;
342 return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_CURSOR_ILLEGAL_CONSTRUCTED_STRING,
343 "%s: Constructed %s only allowed for >1000 byte in CER encoding: cb=%#x uTag=%#x fClass=%#x",
344 pszErrorTag, pszWhat, pAsn1Core->cb, pAsn1Core->uTag, pAsn1Core->fClass);
345 }
346 return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_CURSOR_ILLEGAL_CONSTRUCTED_STRING,
347 "%s: DER encoding does not allow constructed %s (cb=%#x uTag=%#x fClass=%#x)",
348 pszErrorTag, pszWhat, pAsn1Core->cb, pAsn1Core->uTag, pAsn1Core->fClass);
349 }
350 }
351
352 if (fFlags & RTASN1CURSOR_GET_F_IMPLICIT)
353 {
354 pAsn1Core->fFlags |= RTASN1CORE_F_TAG_IMPLICIT;
355 pAsn1Core->uRealTag = uTag;
356 pAsn1Core->fRealClass = fClass;
357 return VINF_SUCCESS;
358 }
359
360 return RTAsn1CursorSetInfo(pCursor, pAsn1Core->uTag != uTag ? VERR_ASN1_CURSOR_TAG_MISMATCH : VERR_ASN1_CURSOR_TAG_FLAG_CLASS_MISMATCH,
361 "%s: Unexpected %s type/flags: %#x/%#x (expected %#x/%#x)",
362 pszErrorTag, pszWhat, pAsn1Core->uTag, pAsn1Core->fClass, uTag, fClass);
363}
364
365
366
367static int rtAsn1CursorGetXxxxCursor(PRTASN1CURSOR pCursor, uint32_t fFlags, uint32_t uTag, uint8_t fClass,
368 PRTASN1CORE pAsn1Core, PRTASN1CURSOR pRetCursor,
369 const char *pszErrorTag, const char *pszWhat)
370{
371 int rc = RTAsn1CursorReadHdr(pCursor, pAsn1Core, pszErrorTag);
372 if (RT_SUCCESS(rc))
373 {
374 if ( pAsn1Core->uTag == uTag
375 && pAsn1Core->fClass == fClass)
376 rc = VINF_SUCCESS;
377 else if (fFlags & RTASN1CURSOR_GET_F_IMPLICIT)
378 {
379 pAsn1Core->fFlags |= RTASN1CORE_F_TAG_IMPLICIT;
380 pAsn1Core->uRealTag = uTag;
381 pAsn1Core->fRealClass = fClass;
382 rc = VINF_SUCCESS;
383 }
384 else
385 return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_CURSOR_ILLEGAL_CONSTRUCTED_STRING,
386 "%s: Unexpected %s type/flags: %#x/%#x (expected %#x/%#x)",
387 pszErrorTag, pszWhat, pAsn1Core->uTag, pAsn1Core->fClass, uTag, fClass);
388 rc = RTAsn1CursorInitSub(pCursor, pAsn1Core->cb, pRetCursor, pszErrorTag);
389 if (RT_SUCCESS(rc))
390 {
391 pAsn1Core->fFlags |= RTASN1CORE_F_PRIMITE_TAG_STRUCT;
392 return VINF_SUCCESS;
393 }
394 }
395 return rc;
396}
397
398
399RTDECL(int) RTAsn1CursorGetSequenceCursor(PRTASN1CURSOR pCursor, uint32_t fFlags,
400 PRTASN1SEQUENCECORE pSeqCore, PRTASN1CURSOR pSeqCursor, const char *pszErrorTag)
401{
402 return rtAsn1CursorGetXxxxCursor(pCursor, fFlags, ASN1_TAG_SEQUENCE, ASN1_TAGCLASS_UNIVERSAL | ASN1_TAGFLAG_CONSTRUCTED,
403 &pSeqCore->Asn1Core, pSeqCursor, pszErrorTag, "sequence");
404}
405
406
407RTDECL(int) RTAsn1CursorGetSetCursor(PRTASN1CURSOR pCursor, uint32_t fFlags,
408 PRTASN1SETCORE pSetCore, PRTASN1CURSOR pSetCursor, const char *pszErrorTag)
409{
410 return rtAsn1CursorGetXxxxCursor(pCursor, fFlags, ASN1_TAG_SET, ASN1_TAGCLASS_UNIVERSAL | ASN1_TAGFLAG_CONSTRUCTED,
411 &pSetCore->Asn1Core, pSetCursor, pszErrorTag, "set");
412}
413
414
415RTDECL(int) RTAsn1CursorGetContextTagNCursor(PRTASN1CURSOR pCursor, uint32_t fFlags, uint32_t uExpectedTag,
416 PRTASN1CONTEXTTAG pCtxTag, PRTASN1CURSOR pCtxTagCursor, const char *pszErrorTag)
417{
418 return rtAsn1CursorGetXxxxCursor(pCursor, fFlags, uExpectedTag, ASN1_TAGCLASS_CONTEXT | ASN1_TAGFLAG_CONSTRUCTED,
419 &pCtxTag->Asn1Core, pCtxTagCursor, pszErrorTag, "ctx tag");
420}
421
422
423RTDECL(int) RTAsn1CursorPeek(PRTASN1CURSOR pCursor, PRTASN1CORE pAsn1Core)
424{
425 uint32_t cbSavedLeft = pCursor->cbLeft;
426 uint8_t const *pbSavedCur = pCursor->pbCur;
427 PRTERRINFO pErrInfo = pCursor->pPrimary->pErrInfo;
428 pCursor->pPrimary->pErrInfo = NULL;
429
430 int rc = RTAsn1CursorReadHdr(pCursor, pAsn1Core, "peek");
431
432 pCursor->pPrimary->pErrInfo = pErrInfo;
433 pCursor->pbCur = pbSavedCur;
434 pCursor->cbLeft = cbSavedLeft;
435 return rc;
436}
437
438
439RTDECL(bool) RTAsn1CursorIsNextEx(PRTASN1CURSOR pCursor, uint32_t uTag, uint8_t fClass)
440{
441 RTASN1CORE Asn1Core;
442 int rc = RTAsn1CursorPeek(pCursor, &Asn1Core);
443 if (RT_SUCCESS(rc))
444 return uTag == Asn1Core.uTag
445 && fClass == Asn1Core.fClass;
446 return false;
447}
448
449
450/** @name Legacy Interfaces.
451 * @{ */
452RTDECL(int) RTAsn1CursorGetCore(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1CORE pAsn1Core, const char *pszErrorTag)
453{
454 return RTAsn1Core_DecodeAsn1(pCursor, fFlags, pAsn1Core, pszErrorTag);
455}
456
457
458RTDECL(int) RTAsn1CursorGetNull(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1NULL pNull, const char *pszErrorTag)
459{
460 return RTAsn1Null_DecodeAsn1(pCursor, fFlags, pNull, pszErrorTag);
461}
462
463
464RTDECL(int) RTAsn1CursorGetInteger(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1INTEGER pInteger, const char *pszErrorTag)
465{
466 return RTAsn1Integer_DecodeAsn1(pCursor, fFlags, pInteger, pszErrorTag);
467}
468
469
470RTDECL(int) RTAsn1CursorGetBoolean(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1BOOLEAN pBoolean, const char *pszErrorTag)
471{
472 return RTAsn1Boolean_DecodeAsn1(pCursor, fFlags, pBoolean, pszErrorTag);
473}
474
475
476RTDECL(int) RTAsn1CursorGetObjId(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1OBJID pObjId, const char *pszErrorTag)
477{
478 return RTAsn1ObjId_DecodeAsn1(pCursor, fFlags, pObjId, pszErrorTag);
479}
480
481
482RTDECL(int) RTAsn1CursorGetTime(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1TIME pTime, const char *pszErrorTag)
483{
484 return RTAsn1Time_DecodeAsn1(pCursor, fFlags, pTime, pszErrorTag);
485}
486
487
488RTDECL(int) RTAsn1CursorGetBitStringEx(PRTASN1CURSOR pCursor, uint32_t fFlags, uint32_t cMaxBits, PRTASN1BITSTRING pBitString,
489 const char *pszErrorTag)
490{
491 return RTAsn1BitString_DecodeAsn1Ex(pCursor, fFlags, cMaxBits, pBitString, pszErrorTag);
492}
493
494
495RTDECL(int) RTAsn1CursorGetBitString(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1BITSTRING pBitString, const char *pszErrorTag)
496{
497 return RTAsn1BitString_DecodeAsn1(pCursor, fFlags, pBitString, pszErrorTag);
498}
499
500
501RTDECL(int) RTAsn1CursorGetOctetString(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1OCTETSTRING pOctetString,
502 const char *pszErrorTag)
503{
504 return RTAsn1OctetString_DecodeAsn1(pCursor, fFlags, pOctetString, pszErrorTag);
505}
506
507
508RTDECL(int) RTAsn1CursorGetString(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1STRING pString, const char *pszErrorTag)
509{
510 return RTAsn1String_DecodeAsn1(pCursor, fFlags, pString, pszErrorTag);
511}
512
513
514RTDECL(int) RTAsn1CursorGetIa5String(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1STRING pString, const char *pszErrorTag)
515{
516 return RTAsn1Ia5String_DecodeAsn1(pCursor, fFlags, pString, pszErrorTag);
517}
518
519
520RTDECL(int) RTAsn1CursorGetUtf8String(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1STRING pString, const char *pszErrorTag)
521{
522 return RTAsn1Utf8String_DecodeAsn1(pCursor, fFlags, pString, pszErrorTag);
523}
524
525
526RTDECL(int) RTAsn1CursorGetBmpString(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1STRING pString, const char *pszErrorTag)
527{
528 return RTAsn1BmpString_DecodeAsn1(pCursor, fFlags, pString, pszErrorTag);
529}
530
531
532RTDECL(int) RTAsn1CursorGetDynType(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1DYNTYPE pDynType, const char *pszErrorTag)
533{
534 return RTAsn1DynType_DecodeAsn1(pCursor, fFlags, pDynType, pszErrorTag);
535}
536/** @} */
537
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette