VirtualBox

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

Last change on this file since 63451 was 63451, checked in by vboxsync, 8 years ago

Runtime: warnings

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
  • Property svn:mergeinfo set to (toggle deleted branches)
    /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
File size: 21.4 KB
Line 
1/* $Id: asn1-cursor.cpp 63451 2016-08-15 00:39:40Z vboxsync $ */
2/** @file
3 * IPRT - ASN.1, Basic Operations.
4 */
5
6/*
7 * Copyright (C) 2006-2016 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.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/*********************************************************************************************************************************
29* Header Files *
30*********************************************************************************************************************************/
31#include "internal/iprt.h"
32#include <iprt/asn1.h>
33
34#include <iprt/alloca.h>
35#include <iprt/err.h>
36#include <iprt/string.h>
37#include <iprt/ctype.h>
38
39#include <iprt/formats/asn1.h>
40
41
42/*********************************************************************************************************************************
43* Defined Constants And Macros *
44*********************************************************************************************************************************/
45/** @def RTASN1_MAX_NESTING
46 * The maximum nesting depth we allow. This limit is enforced to avoid running
47 * out of stack due to malformed ASN.1 input.
48 *
49 * For reference, 'RTSignTool verify-exe RTSignTool.exe', requires a value of 15
50 * to work without hitting the limit for signatures with simple timestamps, and
51 * 23 (amd64/rel = ~3KB) for the new microsoft timestamp counter signatures.
52 */
53#ifdef IN_RING3
54# define RTASN1_MAX_NESTING 64
55#else
56# define RTASN1_MAX_NESTING 32
57#endif
58
59
60
61RTDECL(PRTASN1CURSOR) RTAsn1CursorInitPrimary(PRTASN1CURSORPRIMARY pPrimaryCursor, void const *pvFirst, uint32_t cb,
62 PRTERRINFO pErrInfo, PCRTASN1ALLOCATORVTABLE pAllocator, uint32_t fFlags,
63 const char *pszErrorTag)
64{
65 pPrimaryCursor->Cursor.pbCur = (uint8_t const *)pvFirst;
66 pPrimaryCursor->Cursor.cbLeft = cb;
67 pPrimaryCursor->Cursor.fFlags = (uint8_t)fFlags; Assert(fFlags <= UINT8_MAX);
68 pPrimaryCursor->Cursor.cDepth = 0;
69 pPrimaryCursor->Cursor.abReserved[0] = 0;
70 pPrimaryCursor->Cursor.abReserved[1] = 0;
71 pPrimaryCursor->Cursor.pPrimary = pPrimaryCursor;
72 pPrimaryCursor->Cursor.pUp = NULL;
73 pPrimaryCursor->Cursor.pszErrorTag = pszErrorTag;
74 pPrimaryCursor->pErrInfo = pErrInfo;
75 pPrimaryCursor->pAllocator = pAllocator;
76 return &pPrimaryCursor->Cursor;
77}
78
79
80RTDECL(int) RTAsn1CursorInitSub(PRTASN1CURSOR pParent, uint32_t cb, PRTASN1CURSOR pChild, const char *pszErrorTag)
81{
82 AssertReturn(pParent->pPrimary, VERR_ASN1_INTERNAL_ERROR_1);
83 AssertReturn(pParent->pbCur, VERR_ASN1_INTERNAL_ERROR_2);
84
85 pChild->pbCur = pParent->pbCur;
86 pChild->cbLeft = cb;
87 pChild->fFlags = pParent->fFlags;
88 pChild->cDepth = pParent->cDepth + 1;
89 AssertReturn(pChild->cDepth < RTASN1_MAX_NESTING, VERR_ASN1_TOO_DEEPLY_NESTED);
90 pChild->abReserved[0] = 0;
91 pChild->abReserved[1] = 0;
92 pChild->pPrimary = pParent->pPrimary;
93 pChild->pUp = pParent;
94 pChild->pszErrorTag = pszErrorTag;
95
96 AssertReturn(pParent->cbLeft >= cb, VERR_ASN1_INTERNAL_ERROR_3);
97 pParent->pbCur += cb;
98 pParent->cbLeft -= cb;
99
100 return VINF_SUCCESS;
101}
102
103
104RTDECL(int) RTAsn1CursorInitSubFromCore(PRTASN1CURSOR pParent, PRTASN1CORE pAsn1Core,
105 PRTASN1CURSOR pChild, const char *pszErrorTag)
106{
107 AssertReturn(pParent->pPrimary, VERR_ASN1_INTERNAL_ERROR_1);
108 AssertReturn(pParent->pbCur, VERR_ASN1_INTERNAL_ERROR_2);
109
110 pChild->pbCur = pAsn1Core->uData.pu8;
111 pChild->cbLeft = pAsn1Core->cb;
112 pChild->fFlags = pParent->fFlags;
113 pChild->cDepth = pParent->cDepth + 1;
114 AssertReturn(pChild->cDepth < RTASN1_MAX_NESTING, VERR_ASN1_TOO_DEEPLY_NESTED);
115 pChild->abReserved[0] = 0;
116 pChild->abReserved[1] = 0;
117 pChild->pPrimary = pParent->pPrimary;
118 pChild->pUp = pParent;
119 pChild->pszErrorTag = pszErrorTag;
120
121 return VINF_SUCCESS;
122}
123
124
125RTDECL(int) RTAsn1CursorSetInfoV(PRTASN1CURSOR pCursor, int rc, const char *pszMsg, va_list va)
126{
127 PRTERRINFO pErrInfo = pCursor->pPrimary->pErrInfo;
128 if (pErrInfo)
129 {
130 /* Format the message. */
131 RTErrInfoSetV(pErrInfo, rc, pszMsg, va);
132
133 /* Add the prefixes. This isn't the fastest way, but it's the one
134 which eats the least stack. */
135 char *pszBuf = pErrInfo->pszMsg;
136 size_t cbBuf = pErrInfo->cbMsg;
137 if (pszBuf && cbBuf > 32)
138 {
139 size_t cbMove = strlen(pszBuf) + 1;
140
141 /* Make sure there is a ': '. */
142 bool fFirst = false;
143 if (pszMsg[0] != '%' || pszMsg[1] != 's' || pszMsg[2] != ':')
144 {
145 if (cbMove + 2 < cbBuf)
146 {
147 memmove(pszBuf + 2, pszBuf, cbMove);
148 pszBuf[0] = ':';
149 pszBuf[1] = ' ';
150 cbMove += 2;
151 fFirst = true;
152 }
153 }
154
155 /* Add the prefixes from the cursor chain. */
156 while (pCursor)
157 {
158 if (pCursor->pszErrorTag)
159 {
160 size_t cchErrorTag = strlen(pCursor->pszErrorTag);
161 if (cchErrorTag + !fFirst + cbMove > cbBuf)
162 break;
163 memmove(pszBuf + cchErrorTag + !fFirst, pszBuf, cbMove);
164 memcpy(pszBuf, pCursor->pszErrorTag, cchErrorTag);
165 if (!fFirst)
166 pszBuf[cchErrorTag] = '.';
167 cbMove += cchErrorTag + !fFirst;
168 fFirst = false;
169 }
170 pCursor = pCursor->pUp;
171 }
172 }
173 }
174
175 return rc;
176}
177
178
179RTDECL(int) RTAsn1CursorSetInfo(PRTASN1CURSOR pCursor, int rc, const char *pszMsg, ...)
180{
181 va_list va;
182 va_start(va, pszMsg);
183 rc = RTAsn1CursorSetInfoV(pCursor, rc, pszMsg, va);
184 va_end(va);
185 return rc;
186}
187
188
189RTDECL(int) RTAsn1CursorCheckEnd(PRTASN1CURSOR pCursor)
190{
191 if (pCursor->cbLeft == 0)
192 return VINF_SUCCESS;
193 return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_CURSOR_NOT_AT_END,
194 "%u (%#x) bytes left over", pCursor->cbLeft, pCursor->cbLeft);
195}
196
197
198RTDECL(PRTASN1ALLOCATION) RTAsn1CursorInitAllocation(PRTASN1CURSOR pCursor, PRTASN1ALLOCATION pAllocation)
199{
200 pAllocation->cbAllocated = 0;
201 pAllocation->cReallocs = 0;
202 pAllocation->uReserved0 = 0;
203 pAllocation->pAllocator = pCursor->pPrimary->pAllocator;
204 return pAllocation;
205}
206
207
208RTDECL(int) RTAsn1CursorReadHdr(PRTASN1CURSOR pCursor, PRTASN1CORE pAsn1Core, const char *pszErrorTag)
209{
210 /*
211 * Initialize the return structure in case of failure.
212 */
213 pAsn1Core->uTag = 0;
214 pAsn1Core->fClass = 0;
215 pAsn1Core->uRealTag = 0;
216 pAsn1Core->fRealClass = 0;
217 pAsn1Core->cbHdr = 0;
218 pAsn1Core->cb = 0;
219 pAsn1Core->fFlags = 0;
220 pAsn1Core->uData.pv = NULL;
221 pAsn1Core->pOps = NULL;
222
223 /*
224 * The header has at least two bytes: Type & length.
225 */
226 if (pCursor->cbLeft >= 2)
227 {
228 uint32_t uTag = pCursor->pbCur[0];
229 uint32_t cb = pCursor->pbCur[1];
230 pCursor->cbLeft -= 2;
231 pCursor->pbCur += 2;
232
233 pAsn1Core->uRealTag = pAsn1Core->uTag = uTag & ASN1_TAG_MASK;
234 pAsn1Core->fRealClass = pAsn1Core->fClass = uTag & ~ASN1_TAG_MASK;
235 pAsn1Core->cbHdr = 2;
236 if ((uTag & ASN1_TAG_MASK) == ASN1_TAG_USE_LONG_FORM)
237 return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_CURSOR_LONG_TAG,
238 "%s: Implement parsing of tags > 30: %#x (length=%#x)", pszErrorTag, uTag, cb);
239
240 /* Extended length field? */
241 if (cb & RT_BIT(7))
242 {
243 if (cb != RT_BIT(7))
244 {
245 /* Definite form. */
246 uint8_t cbEnc = cb & 0x7f;
247 if (cbEnc > pCursor->cbLeft)
248 return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_CURSOR_BAD_LENGTH_ENCODING,
249 "%s: Extended BER length field longer than available data: %#x vs %#x (uTag=%#x)",
250 pszErrorTag, cbEnc, pCursor->cbLeft, uTag);
251 switch (cbEnc)
252 {
253 case 1:
254 cb = pCursor->pbCur[0];
255 break;
256 case 2:
257 cb = RT_MAKE_U16(pCursor->pbCur[1], pCursor->pbCur[0]);
258 break;
259 case 3:
260 cb = RT_MAKE_U32_FROM_U8(pCursor->pbCur[2], pCursor->pbCur[1], pCursor->pbCur[0], 0);
261 break;
262 case 4:
263 cb = RT_MAKE_U32_FROM_U8(pCursor->pbCur[3], pCursor->pbCur[2], pCursor->pbCur[1], pCursor->pbCur[0]);
264 break;
265 default:
266 return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_CURSOR_BAD_LENGTH_ENCODING,
267 "%s: Too long/short extended BER length field: %#x (uTag=%#x)",
268 pszErrorTag, cbEnc, uTag);
269 }
270 pCursor->cbLeft -= cbEnc;
271 pCursor->pbCur += cbEnc;
272 pAsn1Core->cbHdr += cbEnc;
273
274 /* Check the length encoding efficiency (T-REC-X.690-200811 10.1, 9.1). */
275 if (pCursor->fFlags & (RTASN1CURSOR_FLAGS_DER | RTASN1CURSOR_FLAGS_CER))
276 {
277 if (cb <= 0x7f)
278 return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_CURSOR_BAD_LENGTH_ENCODING,
279 "%s: Invalid DER/CER length encoding: cbEnc=%u cb=%#x uTag=%#x",
280 pszErrorTag, cbEnc, cb, uTag);
281 uint8_t cbNeeded;
282 if (cb <= 0x000000ff) cbNeeded = 1;
283 else if (cb <= 0x0000ffff) cbNeeded = 2;
284 else if (cb <= 0x00ffffff) cbNeeded = 3;
285 else cbNeeded = 4;
286 if (cbNeeded != cbEnc)
287 return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_CURSOR_BAD_LENGTH_ENCODING,
288 "%s: Invalid DER/CER length encoding: cb=%#x uTag=%#x cbEnc=%u cbNeeded=%u",
289 pszErrorTag, cb, uTag, cbEnc, cbNeeded);
290 }
291 }
292 /* Indefinite form. */
293 else if (pCursor->fFlags & RTASN1CURSOR_FLAGS_DER)
294 return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_CURSOR_ILLEGAL_IDEFINITE_LENGTH,
295 "%s: Indefinite length form not allowed in DER mode (uTag=%#x).", pszErrorTag, uTag);
296 else
297 return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_CURSOR_IDEFINITE_LENGTH_NOT_SUP,
298 "%s: Indefinite BER/CER length not supported (uTag=%#x)", pszErrorTag, uTag);
299 }
300
301 /* Check if the length makes sense. */
302 if (cb > pCursor->cbLeft)
303 return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_CURSOR_BAD_LENGTH,
304 "%s: BER value length out of bounds: %#x (max=%#x uTag=%#x)",
305 pszErrorTag, cb, pCursor->cbLeft, uTag);
306
307 pAsn1Core->fFlags |= RTASN1CORE_F_PRESENT | RTASN1CORE_F_DECODED_CONTENT;
308 pAsn1Core->cb = cb;
309 pAsn1Core->uData.pv = (void *)pCursor->pbCur;
310 return VINF_SUCCESS;
311 }
312
313 if (pCursor->cbLeft)
314 return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_CURSOR_TOO_LITTLE_DATA_LEFT,
315 "%s: Too little data left to form a valid BER header", pszErrorTag);
316 return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_CURSOR_NO_MORE_DATA,
317 "%s: No more data reading BER header", pszErrorTag);
318}
319
320
321RTDECL(int) RTAsn1CursorMatchTagClassFlagsEx(PRTASN1CURSOR pCursor, PRTASN1CORE pAsn1Core, uint32_t uTag, uint32_t fClass,
322 bool fString, uint32_t fFlags, const char *pszErrorTag, const char *pszWhat)
323{
324 if (pAsn1Core->uTag == uTag)
325 {
326 if (pAsn1Core->fClass == fClass)
327 return VINF_SUCCESS;
328 if ( fString
329 && pAsn1Core->fClass == (fClass | ASN1_TAGFLAG_CONSTRUCTED))
330 {
331 if (!(pCursor->fFlags & (RTASN1CURSOR_FLAGS_DER | RTASN1CURSOR_FLAGS_CER)))
332 return VINF_SUCCESS;
333 if (pCursor->fFlags & RTASN1CURSOR_FLAGS_CER)
334 {
335 if (pAsn1Core->cb > 1000)
336 return VINF_SUCCESS;
337 return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_CURSOR_ILLEGAL_CONSTRUCTED_STRING,
338 "%s: Constructed %s only allowed for >1000 byte in CER encoding: cb=%#x uTag=%#x fClass=%#x",
339 pszErrorTag, pszWhat, pAsn1Core->cb, pAsn1Core->uTag, pAsn1Core->fClass);
340 }
341 return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_CURSOR_ILLEGAL_CONSTRUCTED_STRING,
342 "%s: DER encoding does not allow constructed %s (cb=%#x uTag=%#x fClass=%#x)",
343 pszErrorTag, pszWhat, pAsn1Core->cb, pAsn1Core->uTag, pAsn1Core->fClass);
344 }
345 }
346
347 if (fFlags & RTASN1CURSOR_GET_F_IMPLICIT)
348 {
349 pAsn1Core->fFlags |= RTASN1CORE_F_TAG_IMPLICIT;
350 pAsn1Core->uRealTag = uTag;
351 pAsn1Core->fRealClass = fClass;
352 return VINF_SUCCESS;
353 }
354
355 return RTAsn1CursorSetInfo(pCursor, pAsn1Core->uTag != uTag ? VERR_ASN1_CURSOR_TAG_MISMATCH : VERR_ASN1_CURSOR_TAG_FLAG_CLASS_MISMATCH,
356 "%s: Unexpected %s type/flags: %#x/%#x (expected %#x/%#x)",
357 pszErrorTag, pszWhat, pAsn1Core->uTag, pAsn1Core->fClass, uTag, fClass);
358}
359
360
361
362static int rtAsn1CursorGetXxxxCursor(PRTASN1CURSOR pCursor, uint32_t fFlags, uint32_t uTag, uint8_t fClass,
363 PRTASN1CORE pAsn1Core, PRTASN1CURSOR pRetCursor,
364 const char *pszErrorTag, const char *pszWhat)
365{
366 int rc = RTAsn1CursorReadHdr(pCursor, pAsn1Core, pszErrorTag);
367 if (RT_SUCCESS(rc))
368 {
369 if ( pAsn1Core->uTag == uTag
370 && pAsn1Core->fClass == fClass)
371 rc = VINF_SUCCESS;
372 else if (fFlags & RTASN1CURSOR_GET_F_IMPLICIT)
373 {
374 pAsn1Core->fFlags |= RTASN1CORE_F_TAG_IMPLICIT;
375 pAsn1Core->uRealTag = uTag;
376 pAsn1Core->fRealClass = fClass;
377 rc = VINF_SUCCESS;
378 }
379 else
380 return RTAsn1CursorSetInfo(pCursor, VERR_ASN1_CURSOR_ILLEGAL_CONSTRUCTED_STRING,
381 "%s: Unexpected %s type/flags: %#x/%#x (expected %#x/%#x)",
382 pszErrorTag, pszWhat, pAsn1Core->uTag, pAsn1Core->fClass, uTag, fClass);
383 rc = RTAsn1CursorInitSub(pCursor, pAsn1Core->cb, pRetCursor, pszErrorTag);
384 if (RT_SUCCESS(rc))
385 {
386 pAsn1Core->fFlags |= RTASN1CORE_F_PRIMITE_TAG_STRUCT;
387 return VINF_SUCCESS;
388 }
389 }
390 return rc;
391}
392
393
394RTDECL(int) RTAsn1CursorGetSequenceCursor(PRTASN1CURSOR pCursor, uint32_t fFlags,
395 PRTASN1SEQUENCECORE pSeqCore, PRTASN1CURSOR pSeqCursor, const char *pszErrorTag)
396{
397 return rtAsn1CursorGetXxxxCursor(pCursor, fFlags, ASN1_TAG_SEQUENCE, ASN1_TAGCLASS_UNIVERSAL | ASN1_TAGFLAG_CONSTRUCTED,
398 &pSeqCore->Asn1Core, pSeqCursor, pszErrorTag, "sequence");
399}
400
401
402RTDECL(int) RTAsn1CursorGetSetCursor(PRTASN1CURSOR pCursor, uint32_t fFlags,
403 PRTASN1SETCORE pSetCore, PRTASN1CURSOR pSetCursor, const char *pszErrorTag)
404{
405 return rtAsn1CursorGetXxxxCursor(pCursor, fFlags, ASN1_TAG_SET, ASN1_TAGCLASS_UNIVERSAL | ASN1_TAGFLAG_CONSTRUCTED,
406 &pSetCore->Asn1Core, pSetCursor, pszErrorTag, "set");
407}
408
409
410RTDECL(int) RTAsn1CursorGetContextTagNCursor(PRTASN1CURSOR pCursor, uint32_t fFlags, uint32_t uExpectedTag,
411 PCRTASN1COREVTABLE pVtable, PRTASN1CONTEXTTAG pCtxTag, PRTASN1CURSOR pCtxTagCursor,
412 const char *pszErrorTag)
413{
414 int rc = rtAsn1CursorGetXxxxCursor(pCursor, fFlags, uExpectedTag, ASN1_TAGCLASS_CONTEXT | ASN1_TAGFLAG_CONSTRUCTED,
415 &pCtxTag->Asn1Core, pCtxTagCursor, pszErrorTag, "ctx tag");
416 pCtxTag->Asn1Core.pOps = pVtable;
417 return rc;
418}
419
420
421RTDECL(int) RTAsn1CursorPeek(PRTASN1CURSOR pCursor, PRTASN1CORE pAsn1Core)
422{
423 uint32_t cbSavedLeft = pCursor->cbLeft;
424 uint8_t const *pbSavedCur = pCursor->pbCur;
425 PRTERRINFO pErrInfo = pCursor->pPrimary->pErrInfo;
426 pCursor->pPrimary->pErrInfo = NULL;
427
428 int rc = RTAsn1CursorReadHdr(pCursor, pAsn1Core, "peek");
429
430 pCursor->pPrimary->pErrInfo = pErrInfo;
431 pCursor->pbCur = pbSavedCur;
432 pCursor->cbLeft = cbSavedLeft;
433 return rc;
434}
435
436
437RTDECL(bool) RTAsn1CursorIsNextEx(PRTASN1CURSOR pCursor, uint32_t uTag, uint8_t fClass)
438{
439 RTASN1CORE Asn1Core;
440 int rc = RTAsn1CursorPeek(pCursor, &Asn1Core);
441 if (RT_SUCCESS(rc))
442 return uTag == Asn1Core.uTag
443 && fClass == Asn1Core.fClass;
444 return false;
445}
446
447
448/** @name Legacy Interfaces.
449 * @{ */
450RTDECL(int) RTAsn1CursorGetCore(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1CORE pAsn1Core, const char *pszErrorTag)
451{
452 return RTAsn1Core_DecodeAsn1(pCursor, fFlags, pAsn1Core, pszErrorTag);
453}
454
455
456RTDECL(int) RTAsn1CursorGetNull(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1NULL pNull, const char *pszErrorTag)
457{
458 return RTAsn1Null_DecodeAsn1(pCursor, fFlags, pNull, pszErrorTag);
459}
460
461
462RTDECL(int) RTAsn1CursorGetInteger(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1INTEGER pInteger, const char *pszErrorTag)
463{
464 return RTAsn1Integer_DecodeAsn1(pCursor, fFlags, pInteger, pszErrorTag);
465}
466
467
468RTDECL(int) RTAsn1CursorGetBoolean(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1BOOLEAN pBoolean, const char *pszErrorTag)
469{
470 return RTAsn1Boolean_DecodeAsn1(pCursor, fFlags, pBoolean, pszErrorTag);
471}
472
473
474RTDECL(int) RTAsn1CursorGetObjId(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1OBJID pObjId, const char *pszErrorTag)
475{
476 return RTAsn1ObjId_DecodeAsn1(pCursor, fFlags, pObjId, pszErrorTag);
477}
478
479
480RTDECL(int) RTAsn1CursorGetTime(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1TIME pTime, const char *pszErrorTag)
481{
482 return RTAsn1Time_DecodeAsn1(pCursor, fFlags, pTime, pszErrorTag);
483}
484
485
486RTDECL(int) RTAsn1CursorGetBitStringEx(PRTASN1CURSOR pCursor, uint32_t fFlags, uint32_t cMaxBits, PRTASN1BITSTRING pBitString,
487 const char *pszErrorTag)
488{
489 return RTAsn1BitString_DecodeAsn1Ex(pCursor, fFlags, cMaxBits, pBitString, pszErrorTag);
490}
491
492
493RTDECL(int) RTAsn1CursorGetBitString(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1BITSTRING pBitString, const char *pszErrorTag)
494{
495 return RTAsn1BitString_DecodeAsn1(pCursor, fFlags, pBitString, pszErrorTag);
496}
497
498
499RTDECL(int) RTAsn1CursorGetOctetString(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1OCTETSTRING pOctetString,
500 const char *pszErrorTag)
501{
502 return RTAsn1OctetString_DecodeAsn1(pCursor, fFlags, pOctetString, pszErrorTag);
503}
504
505
506RTDECL(int) RTAsn1CursorGetString(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1STRING pString, const char *pszErrorTag)
507{
508 return RTAsn1String_DecodeAsn1(pCursor, fFlags, pString, pszErrorTag);
509}
510
511
512RTDECL(int) RTAsn1CursorGetIa5String(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1STRING pString, const char *pszErrorTag)
513{
514 return RTAsn1Ia5String_DecodeAsn1(pCursor, fFlags, pString, pszErrorTag);
515}
516
517
518RTDECL(int) RTAsn1CursorGetUtf8String(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1STRING pString, const char *pszErrorTag)
519{
520 return RTAsn1Utf8String_DecodeAsn1(pCursor, fFlags, pString, pszErrorTag);
521}
522
523
524RTDECL(int) RTAsn1CursorGetBmpString(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1STRING pString, const char *pszErrorTag)
525{
526 return RTAsn1BmpString_DecodeAsn1(pCursor, fFlags, pString, pszErrorTag);
527}
528
529
530RTDECL(int) RTAsn1CursorGetDynType(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1DYNTYPE pDynType, const char *pszErrorTag)
531{
532 return RTAsn1DynType_DecodeAsn1(pCursor, fFlags, pDynType, pszErrorTag);
533}
534/** @} */
535
Note: See TracBrowser for help on using the repository browser.

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