VirtualBox

source: vbox/trunk/include/iprt/asn1.h@ 74295

Last change on this file since 74295 was 74295, checked in by vboxsync, 6 years ago

IPRT/crypto: Wrapped SSL, alleged RC4, and RSA key generation. Added methods for quering someRSA key components. Exposed big numbers, x509 and asn1 APIs as stable. bugref:9246

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 93.9 KB
Line 
1/** @file
2 * IPRT - Abstract Syntax Notation One (ASN.1).
3 */
4
5/*
6 * Copyright (C) 2006-2017 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef ___iprt_asn1_h
27#define ___iprt_asn1_h
28
29#include <iprt/time.h>
30#include <iprt/stdarg.h>
31#include <iprt/err.h>
32#include <iprt/formats/asn1.h>
33
34
35RT_C_DECLS_BEGIN
36
37/** @defgroup grp_rt_asn1 RTAsn1 - Abstract Syntax Notation One
38 * @ingroup grp_rt
39 * @{
40 */
41
42
43/** Pointer to ASN.1 allocation information. */
44typedef struct RTASN1ALLOCATION *PRTASN1ALLOCATION;
45/** Pointer to ASN.1 array allocation information. */
46typedef struct RTASN1ARRAYALLOCATION *PRTASN1ARRAYALLOCATION;
47/** Pointer to a ASN.1 byte decoder cursor. */
48typedef struct RTASN1CURSOR *PRTASN1CURSOR;
49
50
51/**
52 * Sketch of a custom ASN.1 allocator virtual method table.
53 *
54 * Any information required by the allocator should be associated with this
55 * structure, i.e. use this as a kind of parent class. This saves storage in
56 * RTASN1ALLOCATORINFO and possibly reduces the number of parameters by one.
57 */
58typedef struct RTASN1ALLOCATORVTABLE
59{
60 /**
61 * Free a chunk of memory allocated by this allocator.
62 *
63 * @returns IPRT status code.
64 * @param pThis Pointer to the vtable structure.
65 * @param pAllocation Pointer to the allocation info structure.
66 * @param pv Pointer to the memory that shall be freed. Not NULL.
67 */
68 DECLCALLBACKMEMBER(void, pfnFree)(struct RTASN1ALLOCATORVTABLE const *pThis, PRTASN1ALLOCATION pAllocation,
69 void *pv);
70 /**
71 * Allocates a chunk of memory, all initialized to zero.
72 *
73 * @returns IPRT status code.
74 * @param pThis Pointer to the vtable structure.
75 * @param pAllocation Pointer to the allocation info structure.
76 * @param ppv Where to store the pointer on success.
77 * @param cb The minimum number of bytes to allocate. The actual
78 * number of bytes allocated shall be stored in
79 * pInfo->cbAllocated on success.
80 */
81 DECLCALLBACKMEMBER(int, pfnAlloc)(struct RTASN1ALLOCATORVTABLE const *pThis, PRTASN1ALLOCATION pAllocation,
82 void **ppv, size_t cb);
83 /**
84 * Reallocates a memory allocation.
85 *
86 * New memory does not need to be initialized, the caller takes care of that.
87 *
88 * This will not need to deal with free (@a cbNew == 0) or the initial
89 * allocation (@a pvOld == NULL), those calls will be directed to pfnFree and
90 * pfnAlloc respectively.
91 *
92 * @returns IPRT status code.
93 * @param pThis Pointer to the vtable structure.
94 * @param pAllocation Pointer to the allocation info structure.
95 * @param pvOld Pointer to the current allocation. Shall remain
96 * valid on failure, but may be invalid on success.
97 * @param ppvNew Where to store the pointer on success. Shall not be
98 * touched, except on successful returns.
99 * @param cbNew The new minimum allocation size. The actual number
100 * of bytes allocated shall be stored in
101 * pInfo->cbAllocated on success.
102 */
103 DECLCALLBACKMEMBER(int, pfnRealloc)(struct RTASN1ALLOCATORVTABLE const *pThis, PRTASN1ALLOCATION pAllocation,
104 void *pvOld, void **ppvNew, size_t cbNew);
105
106 /**
107 * Frees an array allocation (the array an all instances in it).
108 *
109 * @returns IPRT status code.
110 * @param pThis Pointer to the vtable structure.
111 * @param pAllocation Pointer to the allocation info structure.
112 * @param papvArray Pointer to the pointer array to be freed. Not NULL.
113 */
114 DECLCALLBACKMEMBER(void, pfnFreeArray)(struct RTASN1ALLOCATORVTABLE const *pThis, PRTASN1ARRAYALLOCATION pAllocation,
115 void **papvArray);
116 /**
117 * Grows the array to at least @a cMinEntries.
118 *
119 * The entries are initalized with ZEROs.
120 *
121 * @returns IPRT status code.
122 * @param pThis Pointer to the vtable structure.
123 * @param pAllocation Pointer to the allocation info structure.
124 * @param ppapvArray Pointer to the pointer to the array to be grown (or
125 * allocated).
126 * @param cMinEntries The minimum number of entries (array size and
127 * instantiated entries) that must be available
128 * on successful return.
129 */
130 DECLCALLBACKMEMBER(int, pfnGrowArray)(struct RTASN1ALLOCATORVTABLE const *pThis, PRTASN1ARRAYALLOCATION pAllocation,
131 void ***ppapvArray, uint32_t cMinEntries);
132 /**
133 * Shrinks the array (depends on allocator policy).
134 *
135 * If memory isn't freed, the implementation must fill the entries being
136 * shredded with ZEROs so the growth optimizations in RTAsn1MemResizeArray
137 * returns ZEROed entries.
138 *
139 * @returns IPRT status code.
140 * @param pThis Pointer to the vtable structure.
141 * @param pAllocation Pointer to the allocation info structure.
142 * @param ppapvArray Pointer to the pointer to the array to shrunk.
143 * @param cNew The new entry count.
144 * @param cCurrent The new entry count.
145 */
146 DECLCALLBACKMEMBER(void, pfnShrinkArray)(struct RTASN1ALLOCATORVTABLE const *pThis, PRTASN1ARRAYALLOCATION pAllocation,
147 void ***ppapvArray, uint32_t cNew, uint32_t cCurrent);
148} RTASN1ALLOCATORVTABLE;
149/** Pointer to an ASN.1 allocator vtable. */
150typedef RTASN1ALLOCATORVTABLE *PRTASN1ALLOCATORVTABLE;
151/** Pointer to a const ASN.1 allocator vtable. */
152typedef RTASN1ALLOCATORVTABLE const *PCRTASN1ALLOCATORVTABLE;
153
154/** The default ASN.1 allocator. */
155extern RTDATADECL(RTASN1ALLOCATORVTABLE const) g_RTAsn1DefaultAllocator;
156
157/** The Electric Fence ASN.1 allocator. */
158extern RTDATADECL(RTASN1ALLOCATORVTABLE const) g_RTAsn1EFenceAllocator;
159
160/** The safer ASN.1 allocator for sensitive data. */
161extern RTDATADECL(RTASN1ALLOCATORVTABLE const) g_RTAsn1SaferAllocator;
162
163
164/**
165 * Allocation information.
166 */
167typedef struct RTASN1ALLOCATION
168{
169 /** The number of bytes currently allocated. */
170 uint32_t cbAllocated;
171 /** Number of realloc calls. */
172 uint16_t cReallocs;
173 /** Reserved / padding. */
174 uint16_t uReserved0;
175 /** Allocator vtable, NULL for the default allocator. */
176 PCRTASN1ALLOCATORVTABLE pAllocator;
177} RTASN1ALLOCATION;
178
179
180/**
181 * Pointer array allocation information.
182 *
183 * Used by SET OF and SEQUENCE OF structures (typically automatically
184 * generated).
185 */
186typedef struct RTASN1ARRAYALLOCATION
187{
188 /** The size of the array entry. */
189 uint32_t cbEntry;
190 /** The size of the pointer array allocation. */
191 uint32_t cPointersAllocated;
192 /** Number of entry instances allocated. This can be greater than the
193 * official array size. */
194 uint32_t cEntriesAllocated;
195 /** Number of array resizing calls (for increasing growth rate).
196 * Maintained by RTAsn1MemResizeArray(). */
197 uint16_t cResizeCalls;
198 /** Reserved / padding. */
199 uint16_t uReserved0;
200 /** Allocator vtable, NULL for the default allocator. */
201 PCRTASN1ALLOCATORVTABLE pAllocator;
202} RTASN1ARRAYALLOCATION;
203
204
205/**
206 * Allocate a block of zero initialized memory.
207 *
208 * @returns IPRT status code.
209 * @param pAllocation The allocation record (initialized by
210 * RTAsn1CursorInitAllocation or similar).
211 * @param ppvMem Where to return the pointer to the block.
212 * @param cbMem The minimum number of bytes to allocate.
213 */
214RTDECL(int) RTAsn1MemAllocZ(PRTASN1ALLOCATION pAllocation, void **ppvMem, size_t cbMem);
215
216/**
217 * Allocates a block of memory initialized to the content of @a pvSrc.
218 *
219 * @returns IPRT status code.
220 * @param pAllocation The allocation record (initialized by
221 * RTAsn1CursorInitAllocation or similar).
222 * @param ppvMem Where to return the pointer to the block.
223 * @param pvSrc The source memory.
224 * @param cbMem The minimum number of bytes to allocate.
225 */
226RTDECL(int) RTAsn1MemDup(PRTASN1ALLOCATION pAllocation, void **ppvMem, void const *pvSrc, size_t cbMem);
227
228/**
229 * Free a memory block.
230 *
231 * @param pAllocation The allocation record (initialized by
232 * RTAsn1CursorInitAllocation or similar).
233 * @param pv The memory block to free. NULL will be ignored.
234 */
235RTDECL(void) RTAsn1MemFree(PRTASN1ALLOCATION pAllocation, void *pv);
236
237/**
238 * Initalize an allocation.
239 *
240 * @returns pAllocation
241 * @param pAllocation The allocation record (initialized by
242 * RTAsn1CursorInitAllocation or similar).
243 * @param pAllocator The allocator
244 */
245RTDECL(PRTASN1ALLOCATION) RTAsn1MemInitAllocation(PRTASN1ALLOCATION pAllocation, PCRTASN1ALLOCATORVTABLE pAllocator);
246
247/**
248 * Initalize an array allocation.
249 *
250 * @returns pAllocation
251 * @param pAllocation The allocation record (initialized by
252 * RTAsn1CursorInitAllocation or similar).
253 * @param pAllocator The allocator
254 * @param cbEntry The entry size.
255 */
256RTDECL(PRTASN1ARRAYALLOCATION) RTAsn1MemInitArrayAllocation(PRTASN1ARRAYALLOCATION pAllocation,
257 PCRTASN1ALLOCATORVTABLE pAllocator, size_t cbEntry);
258
259/**
260 * Resize an array with zero initialized memory.
261 *
262 * @returns IPRT status code.
263 * @param pAllocation The allocation record (initialized by
264 * RTAsn1CursorInitAllocation or similar).
265 * @param ppapvArray Pointer to the variable pointing to the array. This is
266 * both input and output. Remains valid on failure.
267 * @param cCurrent The current entry count. (Relevant for zero
268 * initialization of the new entries.)
269 * @param cNew The new entry count.
270 */
271RTDECL(int) RTAsn1MemResizeArray(PRTASN1ARRAYALLOCATION pAllocation, void ***ppapvArray, uint32_t cCurrent, uint32_t cNew);
272
273/**
274 * Frees an array and all its entries.
275 *
276 * @param pAllocation The array allocation record (initialized by
277 * RTAsn1CursorInitArrayAllocation or similar).
278 * @param papvArray The array to free. NULL is ignored.
279 */
280RTDECL(void) RTAsn1MemFreeArray(PRTASN1ARRAYALLOCATION pAllocation, void **papvArray);
281
282
283/** Pointer to a core ASN.1 encoding info structure. */
284typedef struct RTASN1CORE *PRTASN1CORE;
285/** Pointer to a const core ASN.1 encoding info structure. */
286typedef struct RTASN1CORE const *PCRTASN1CORE;
287
288RTDECL(int) RTAsn1ContentAllocZ(struct RTASN1CORE *pAsn1Core, size_t cb, PCRTASN1ALLOCATORVTABLE pAllocator);
289RTDECL(int) RTAsn1ContentDup(struct RTASN1CORE *pAsn1Core, void const *pvSrc, size_t cbSrc, PCRTASN1ALLOCATORVTABLE pAllocator);
290RTDECL(int) RTAsn1ContentReallocZ(struct RTASN1CORE *pAsn1Core, size_t cb, PCRTASN1ALLOCATORVTABLE pAllocator);
291RTDECL(void) RTAsn1ContentFree(struct RTASN1CORE *pAsn1Core);
292
293
294
295/**
296 * ASN.1 object enumeration callback.
297 *
298 * @returns IPRT status code. VINF_SUCCESS continues the enumberation, all
299 * others quit it and is returned to the caller's caller.
300 * @param pAsn1Core The ASN.1 object we're called back about.
301 * @param pszName The member name. Array member names ends with
302 * '[#]'.
303 * @param uDepth The current depth.
304 * @param pvUser Callback user parameter.
305 */
306typedef DECLCALLBACK(int) FNRTASN1ENUMCALLBACK(struct RTASN1CORE *pAsn1Core, const char *pszName, uint32_t uDepth, void *pvUser);
307/** Pointer to an ASN.1 object enumeration callback. */
308typedef FNRTASN1ENUMCALLBACK *PFNRTASN1ENUMCALLBACK;
309
310/**
311 * ASN.1 object encoding writer callback.
312 *
313 * @returns IPRT status code.
314 * @param pbBuf Pointer to the bytes to output.
315 * @param cbToWrite The number of bytes to write.
316 * @param pvUser Callback user parameter.
317 * @param pErrInfo Where to store extended error info. Optional.
318 */
319typedef DECLCALLBACK(int) FNRTASN1ENCODEWRITER(const void *pvBuf, size_t cbToWrite, void *pvUser, PRTERRINFO pErrInfo);
320/** Pointer to an ASN.1 encoding writer callback. */
321typedef FNRTASN1ENCODEWRITER *PFNRTASN1ENCODEWRITER;
322
323/** @name ASN.1 Vtable Method Types
324 * @{ */
325
326/**
327 * Destructor.
328 *
329 * RTAsn1Destroy will first destroy all children by recursive calls to pfnEnum,
330 * afterwards it will call this method to release any memory or other resources
331 * associated with this object. The memory backing the object structure shall
332 * not be freed by this method.
333 *
334 * @param pThisCore Pointer to the ASN.1 core to destroy.
335 */
336typedef DECLCALLBACK(void) FNRTASN1COREVTDTOR(PRTASN1CORE pThisCore);
337/** Pointer to a FNRTASN1COREVTDTOR method. */
338typedef FNRTASN1COREVTDTOR *PFNRTASN1COREVTDTOR;
339
340/**
341 * Enumerate members (not necessary for primitive objects).
342 *
343 * @returns IPRT status code, any non VINF_SUCCESS value stems from pfnCallback.
344 * @param pThisCore Pointer to the ASN.1 core to enumerate members of.
345 * @param pfnCallback The callback.
346 * @param uDepth The depth of this object. Children are at +1.
347 * @param pvUser Callback user argument.
348 */
349typedef DECLCALLBACK(int) FNRTASN1COREVTENUM(PRTASN1CORE pThisCore, PFNRTASN1ENUMCALLBACK pfnCallback,
350 uint32_t uDepth, void *pvUser);
351/** Pointer to a FNRTASN1COREVTENUM method. */
352typedef FNRTASN1COREVTENUM *PFNRTASN1COREVTENUM;
353
354/**
355 * Clone method.
356 *
357 * @param pThisCore Pointer to the ASN.1 core to initialize as a clone
358 * of pSrcClone. (The caller is responsible for making
359 * sure there is sufficent space and such.)
360 * @param pSrcCore The object to clone.
361 * @param pAllocator The allocator to use.
362 */
363typedef DECLCALLBACK(int) FNRTASN1COREVTCLONE(PRTASN1CORE pThisCore, PCRTASN1CORE pSrcCore, PCRTASN1ALLOCATORVTABLE pAllocator);
364/** Pointer to a FNRTASN1COREVTCLONE method. */
365typedef FNRTASN1COREVTCLONE *PFNRTASN1COREVTCLONE;
366
367/**
368 * Compare method.
369 *
370 * The caller makes sure both cores are present and have the same Vtable.
371 *
372 * @returns 0 if equal, -1 if @a pLeft is smaller, 1 if @a pLeft is larger.
373 * @param pLeftCore Pointer to the ASN.1 core of the left side object.
374 * @param pRightCore Pointer to the ASN.1 core of the right side object.
375 */
376typedef DECLCALLBACK(int) FNRTASN1COREVTCOMPARE(PCRTASN1CORE pLeftCore, PCRTASN1CORE pRightCore);
377/** Pointer to a FNRTASN1COREVTCOMPARE method. */
378typedef FNRTASN1COREVTCOMPARE *PFNRTASN1COREVTCOMPARE;
379
380/**
381 * Check sanity method.
382 *
383 * @returns IPRT status code.
384 * @param pThisCore Pointer to the ASN.1 core of the object to check out.
385 * @param fFlags See RTASN1_CHECK_SANITY_F_XXX.
386 * @param pErrInfo Where to return additional error details. Optional.
387 * @param pszErrorTag Tag for the additional error details.
388 */
389typedef DECLCALLBACK(int) FNRTASN1COREVTCHECKSANITY(PCRTASN1CORE pThisCore, uint32_t fFlags,
390 PRTERRINFO pErrInfo, const char *pszErrorTag);
391/** Pointer to a FNRTASN1COREVTCHECKSANITY method. */
392typedef FNRTASN1COREVTCHECKSANITY *PFNRTASN1COREVTCHECKSANITY;
393
394/**
395 * Optional encoding preparations.
396 *
397 * On successful return, the pThisCore->cb value shall be valid and up to date.
398 * Will be called for any present object, including ones with default values and
399 * similar.
400 *
401 * @returns IPRT status code
402 * @param pThisCore Pointer to the ASN.1 core to enumerate members of.
403 * @param fFlags Encoding flags, RTASN1ENCODE_F_XXX.
404 * @param pErrInfo Where to return extra error information. Optional.
405 */
406typedef DECLCALLBACK(int) FNRTASN1COREVTENCODEPREP(PRTASN1CORE pThisCore, uint32_t fFlags, PRTERRINFO pErrInfo);
407/** Pointer to a FNRTASN1COREVTENCODEWRITE method. */
408typedef FNRTASN1COREVTENCODEPREP *PFNRTASN1COREVTENCODEPREP;
409
410/**
411 * Optional encoder writer.
412 *
413 * This writes the header as well as all the content. Will be called for any
414 * present object, including ones with default values and similar.
415 *
416 * @returns IPRT status code.
417 * @param pThisCore Pointer to the ASN.1 core to enumerate members of.
418 * @param fFlags Encoding flags, RTASN1ENCODE_F_XXX.
419 * @param pfnWriter The output writer function.
420 * @param pvUser The user context for the writer function.
421 * @param pErrInfo Where to return extra error information. Optional.
422 */
423typedef DECLCALLBACK(int) FNRTASN1COREVTENCODEWRITE(PRTASN1CORE pThisCore, uint32_t fFlags, PFNRTASN1ENCODEWRITER pfnWriter,
424 void *pvUser, PRTERRINFO pErrInfo);
425/** Pointer to a FNRTASN1COREVTENCODEWRITE method. */
426typedef FNRTASN1COREVTENCODEWRITE *PFNRTASN1COREVTENCODEWRITE;
427/** @} */
428
429/** Mask of common flags. These will be propagated during sanity checking.
430 * Bits not in this mask are type specfic. */
431#define RTASN1_CHECK_SANITY_F_COMMON_MASK UINT32_C(0xffff0000)
432
433/**
434 * ASN.1 core vtable.
435 */
436typedef struct RTASN1COREVTABLE
437{
438 /** The name. */
439 const char *pszName;
440 /** Size of the structure. */
441 uint32_t cbStruct;
442 /** The default tag, UINT8_MAX if not applicable. */
443 uint8_t uDefaultTag;
444 /** The default class and flags. */
445 uint8_t fDefaultClass;
446 /** Reserved for later / alignment. */
447 uint16_t uReserved;
448 /** @copydoc FNRTASN1COREVTDTOR */
449 PFNRTASN1COREVTDTOR pfnDtor;
450 /** @copydoc FNRTASN1COREVTENUM */
451 PFNRTASN1COREVTENUM pfnEnum;
452 /** @copydoc FNRTASN1COREVTCLONE */
453 PFNRTASN1COREVTCLONE pfnClone;
454 /** @copydoc FNRTASN1COREVTCOMPARE */
455 PFNRTASN1COREVTCOMPARE pfnCompare;
456 /** @copydoc FNRTASN1COREVTCHECKSANITY */
457 PFNRTASN1COREVTCHECKSANITY pfnCheckSanity;
458 /** @copydoc FNRTASN1COREVTENCODEPREP */
459 PFNRTASN1COREVTENCODEPREP pfnEncodePrep;
460 /** @copydoc FNRTASN1COREVTENUM */
461 PFNRTASN1COREVTENCODEWRITE pfnEncodeWrite;
462} RTASN1COREVTABLE;
463/** Pointer to an ASN.1 allocator vtable. */
464typedef struct RTASN1COREVTABLE *PRTASN1COREVTABLE;
465/** Pointer to a const ASN.1 allocator vtable. */
466typedef RTASN1COREVTABLE const *PCRTASN1COREVTABLE;
467
468
469/** @name Helper macros for prototyping standard functions for an ASN.1 type.
470 * @{ */
471#define RTASN1TYPE_STANDARD_PROTOTYPES_NO_GET_CORE(a_TypeNm, a_DeclMacro, a_ImplExtNm) \
472 a_DeclMacro(int) RT_CONCAT(a_ImplExtNm,_Init)(RT_CONCAT(P,a_TypeNm) pThis, PCRTASN1ALLOCATORVTABLE pAllocator); \
473 a_DeclMacro(int) RT_CONCAT(a_ImplExtNm,_Clone)(RT_CONCAT(P,a_TypeNm) pThis, RT_CONCAT(PC,a_TypeNm) pSrc, \
474 PCRTASN1ALLOCATORVTABLE pAllocator); \
475 a_DeclMacro(void) RT_CONCAT(a_ImplExtNm,_Delete)(RT_CONCAT(P,a_TypeNm) pThis); \
476 a_DeclMacro(int) RT_CONCAT(a_ImplExtNm,_Enum)(RT_CONCAT(P,a_TypeNm) pThis, PFNRTASN1ENUMCALLBACK pfnCallback, \
477 uint32_t uDepth, void *pvUser); \
478 a_DeclMacro(int) RT_CONCAT(a_ImplExtNm,_Compare)(RT_CONCAT(PC,a_TypeNm) pLeft, RT_CONCAT(PC,a_TypeNm) pRight); \
479 a_DeclMacro(int) RT_CONCAT(a_ImplExtNm,_DecodeAsn1)(PRTASN1CURSOR pCursor, uint32_t fFlags, RT_CONCAT(P,a_TypeNm) pThis,\
480 const char *pszErrorTag); \
481 a_DeclMacro(int) RT_CONCAT(a_ImplExtNm,_CheckSanity)(RT_CONCAT(PC,a_TypeNm) pThis, uint32_t fFlags, \
482 PRTERRINFO pErrInfo, const char *pszErrorTag)
483
484
485/** @name Helper macros for prototyping standard functions for an ASN.1 type.
486 * @{ */
487#define RTASN1TYPE_STANDARD_PROTOTYPES(a_TypeNm, a_DeclMacro, a_ImplExtNm, a_Asn1CoreNm) \
488 DECL_FORCE_INLINE(PRTASN1CORE) RT_CONCAT(a_ImplExtNm,_GetAsn1Core)(RT_CONCAT(PC,a_TypeNm) pThis) \
489 { return (PRTASN1CORE)&pThis->a_Asn1CoreNm; } \
490 DECLINLINE(bool) RT_CONCAT(a_ImplExtNm,_IsPresent)(RT_CONCAT(PC,a_TypeNm) pThis) \
491 { return pThis && RTASN1CORE_IS_PRESENT(&pThis->a_Asn1CoreNm); } \
492 RTASN1TYPE_STANDARD_PROTOTYPES_NO_GET_CORE(a_TypeNm, a_DeclMacro, a_ImplExtNm)
493
494
495/** Aliases two ASN.1 types, no method aliases. */
496#define RTASN1TYPE_ALIAS_TYPE_ONLY(a_TypeNm, a_AliasType) \
497 typedef a_AliasType a_TypeNm; \
498 typedef a_TypeNm *RT_CONCAT(P,a_TypeNm); \
499 typedef a_TypeNm const *RT_CONCAT(PC,a_TypeNm)
500
501/** Aliases two ASN.1 types and methods. */
502#define RTASN1TYPE_ALIAS(a_TypeNm, a_AliasType, a_ImplExtNm, a_AliasExtNm) \
503 typedef a_AliasType a_TypeNm; \
504 typedef a_TypeNm *RT_CONCAT(P,a_TypeNm); \
505 \
506 DECLINLINE(PRTASN1CORE) RT_CONCAT(a_ImplExtNm,_GetAsn1Core)(a_TypeNm const *pThis) \
507 { return RT_CONCAT(a_AliasExtNm,_GetAsn1Core)(pThis); } \
508 DECLINLINE(bool) RT_CONCAT(a_ImplExtNm,_IsPresent)(a_TypeNm const *pThis) \
509 { return RT_CONCAT(a_AliasExtNm,_IsPresent)(pThis); } \
510 \
511 DECLINLINE(int) RT_CONCAT(a_ImplExtNm,_Init)(RT_CONCAT(P,a_TypeNm) pThis, PCRTASN1ALLOCATORVTABLE pAllocator) \
512 { return RT_CONCAT(a_AliasExtNm,_Init)(pThis, pAllocator); } \
513 DECLINLINE(int) RT_CONCAT(a_ImplExtNm,_Clone)(RT_CONCAT(P,a_TypeNm) pThis, a_TypeNm const *pSrc, \
514 PCRTASN1ALLOCATORVTABLE pAllocator) \
515 { return RT_CONCAT(a_AliasExtNm,_Clone)(pThis, pSrc, pAllocator); } \
516 DECLINLINE(void) RT_CONCAT(a_ImplExtNm,_Delete)(RT_CONCAT(P,a_TypeNm) pThis) \
517 { RT_CONCAT(a_AliasExtNm,_Delete)(pThis); } \
518 DECLINLINE(int) RT_CONCAT(a_ImplExtNm,_Enum)(a_TypeNm *pThis, PFNRTASN1ENUMCALLBACK pfnCallback, \
519 uint32_t uDepth, void *pvUser) \
520 { return RT_CONCAT(a_AliasExtNm,_Enum)(pThis, pfnCallback, uDepth, pvUser); } \
521 DECLINLINE(int) RT_CONCAT(a_ImplExtNm,_Compare)(a_TypeNm const *pLeft, a_TypeNm const *pRight) \
522 { return RT_CONCAT(a_AliasExtNm,_Compare)(pLeft, pRight); } \
523 DECLINLINE(int) RT_CONCAT(a_ImplExtNm,_DecodeAsn1)(PRTASN1CURSOR pCursor, uint32_t fFlags, RT_CONCAT(P,a_TypeNm) pThis,\
524 const char *pszErrorTag) \
525 { return RT_CONCAT(a_AliasExtNm,_DecodeAsn1)(pCursor, fFlags, pThis, pszErrorTag); } \
526 DECLINLINE(int) RT_CONCAT(a_ImplExtNm,_CheckSanity)(a_TypeNm const *pThis, uint32_t fFlags, \
527 PRTERRINFO pErrInfo, const char *pszErrorTag) \
528 { return RT_CONCAT(a_AliasExtNm,_CheckSanity)(pThis, fFlags, pErrInfo, pszErrorTag); } \
529 \
530 typedef a_TypeNm const *RT_CONCAT(PC,a_TypeNm)
531
532/** @} */
533
534
535/**
536 * Core ASN.1 structure for storing encoding details and data location.
537 *
538 * This is used as a 'parent' for all other decoded ASN.1 based structures.
539 */
540typedef struct RTASN1CORE
541{
542 /** The tag.
543 * @remarks 32-bit should be enough for everyone... We don't currently
544 * implement decoding tags larger than 30 anyway. :-) */
545 uint32_t uTag;
546 /** Tag class and flags (ASN1_TAGCLASS_XXX and ASN1_TAGFLAG_XXX). */
547 uint8_t fClass;
548 /** The real tag value for IMPLICT tag overrides. */
549 uint8_t uRealTag;
550 /** The real class value for IMPLICT tag overrides. */
551 uint8_t fRealClass;
552 /** The size of the tag and length ASN.1 header. */
553 uint8_t cbHdr;
554 /** Length. */
555 uint32_t cb;
556 /** IPRT flags (RTASN1CORE_F_XXX). */
557 uint32_t fFlags;
558 /** Pointer to the data.
559 * After decoding this generally points to the encoded data content. When
560 * preparting something for encoding or otherwise constructing things in memory,
561 * this generally points heap memory or read-only constants.
562 * @sa RTAsn1ContentAllocZ, RTAsn1ContentReallocZ, RTAsn1ContentDup,
563 * RTAsn1ContentFree. */
564 RTCPTRUNION uData;
565 /** Pointer to the virtual method table for this object. Optional. */
566 PCRTASN1COREVTABLE pOps;
567} RTASN1CORE;
568/** The Vtable for a RTASN1CORE structure when not in some way use used as a
569 * parent type/class. */
570extern RTDATADECL(RTASN1COREVTABLE const) g_RTAsn1Core_Vtable;
571
572RTASN1TYPE_STANDARD_PROTOTYPES_NO_GET_CORE(RTASN1CORE, RTDECL, RTAsn1Core);
573
574/** @name RTASN1CORE_F_XXX - Flags for RTASN1CORE::fFlags
575 * @{ */
576/** Present/valid. */
577#define RTASN1CORE_F_PRESENT RT_BIT_32(0)
578/** Not present in stream, using default value. */
579#define RTASN1CORE_F_DEFAULT RT_BIT_32(1)
580/** The tag was overriden by an implict context tag or some such thing,
581 * RTASN1CORE::uImplicitTag hold the universal tag value if one exists. */
582#define RTASN1CORE_F_TAG_IMPLICIT RT_BIT_32(2)
583/** Primitive tag with the corresponding RTASN1XXX struct. */
584#define RTASN1CORE_F_PRIMITE_TAG_STRUCT RT_BIT_32(3)
585/** Dummy node typically used with choices, has children, not encoded, must be
586 * ignored. */
587#define RTASN1CORE_F_DUMMY RT_BIT_32(4)
588/** Allocated content (pointed to by uData).
589 * The content should is still be considered 104% read-only by anyone other
590 * than then type methods (pOps and associates). */
591#define RTASN1CORE_F_ALLOCATED_CONTENT RT_BIT_32(5)
592/** Decoded content (pointed to by uData).
593 * Mutually exclusive with RTASN1CORE_F_ALLOCATED_CONTENT. If neither is
594 * set, uData might be NULL or point to some shared static memory for
595 * frequently used values. */
596#define RTASN1CORE_F_DECODED_CONTENT RT_BIT_32(6)
597/** @} */
598
599
600/** Checks whether an ASN.1 core object present in some way (default data,
601 * decoded data, ...). */
602#define RTASN1CORE_IS_PRESENT(a_pAsn1Core) ( RT_BOOL((a_pAsn1Core)->fFlags) )
603
604/** Checks whether an ASN.1 core object is a dummy object (and is present). */
605#define RTASN1CORE_IS_DUMMY(a_pAsn1Core) ( RT_BOOL((a_pAsn1Core)->fFlags & RTASN1CORE_F_DUMMY) )
606
607/**
608 * Calculates pointer to the raw ASN.1 record.
609 *
610 * ASSUMES that it's decoded content and that cbHdr and uData are both valid.
611 *
612 * @returns Byte pointer to the first tag byte.
613 * @param a_pAsn1Core The ASN.1 core.
614 */
615#define RTASN1CORE_GET_RAW_ASN1_PTR(a_pAsn1Core) ( (a_pAsn1Core)->uData.pu8 - (a_pAsn1Core)->cbHdr )
616
617/**
618 * Calculates the length of the raw ASN.1 record to go with the
619 * RTASN1CORE_GET_RAW_ASN1_PTR() result.
620 *
621 * ASSUMES that it's decoded content and that cbHdr and uData are both valid.
622 *
623 * @returns Size in bytes (uint32_t).
624 * @param a_pAsn1Core The ASN.1 core.
625 */
626#define RTASN1CORE_GET_RAW_ASN1_SIZE(a_pAsn1Core) ( (a_pAsn1Core)->cbHdr + (a_pAsn1Core)->cb )
627
628/**
629 * Retrievs the tag or implicit tag depending on the RTASN1CORE_F_TAG_IMPLICIT
630 * flag.
631 *
632 * @returns The ASN.1 tag of the object.
633 * @param a_pAsn1Core The ASN.1 core.
634 */
635#define RTASN1CORE_GET_TAG(a_pAsn1Core) ( !((a_pAsn1Core)->fFlags & RTASN1CORE_F_TAG_IMPLICIT) ? (a_pAsn1Core)->uTag : (a_pAsn1Core)->uRealTag )
636
637
638DECL_FORCE_INLINE(PRTASN1CORE) RTAsn1Core_GetAsn1Core(PCRTASN1CORE pThis)
639{
640 return (PRTASN1CORE)pThis;
641}
642
643
644DECL_FORCE_INLINE(bool) RTAsn1Core_IsPresent(PCRTASN1CORE pThis)
645{
646 return pThis && RTASN1CORE_IS_PRESENT(pThis);
647}
648
649
650RTDECL(int) RTAsn1Core_InitEx(PRTASN1CORE pAsn1Core, uint32_t uTag, uint8_t fClass, PCRTASN1COREVTABLE pOps, uint32_t fFlags);
651/**
652 * Initialize the ASN.1 core object representation to a default value.
653 *
654 * @returns VINF_SUCCESS
655 * @param pAsn1Core The ASN.1 core.
656 * @param uTag The tag number.
657 * @param fClass The tag class and flags.
658 */
659RTDECL(int) RTAsn1Core_InitDefault(PRTASN1CORE pAsn1Core, uint32_t uTag, uint8_t fClass);
660RTDECL(int) RTAsn1Core_CloneContent(PRTASN1CORE pThis, PCRTASN1CORE pSrc, PCRTASN1ALLOCATORVTABLE pAllocator);
661RTDECL(int) RTAsn1Core_CloneNoContent(PRTASN1CORE pThis, PCRTASN1CORE pSrc);
662RTDECL(int) RTAsn1Core_SetTagAndFlags(PRTASN1CORE pAsn1Core, uint32_t uTag, uint8_t fClass);
663RTDECL(int) RTAsn1Core_ChangeTag(PRTASN1CORE pAsn1Core, uint32_t uTag);
664RTDECL(void) RTAsn1Core_ResetImplict(PRTASN1CORE pThis);
665RTDECL(int) RTAsn1Core_CompareEx(PCRTASN1CORE pLeft, PCRTASN1CORE pRight, bool fIgnoreTagAndClass);
666
667
668/**
669 * Dummy ASN.1 object for use in choices and similar non-sequence structures.
670 *
671 * This allows hooking up destructors, enumerators and such, as well as not
672 * needing custom code for sequence-of / set-of collections.
673 */
674typedef struct RTASN1DUMMY
675{
676 /** Core ASN.1. */
677 RTASN1CORE Asn1Core;
678} RTASN1DUMMY;
679/** Pointer to a dummy record. */
680typedef RTASN1DUMMY *PRTASN1DUMMY;
681
682
683/**
684 * Initalizes a dummy ASN.1 object.
685 *
686 * @returns VINF_SUCCESS.
687 * @param pThis The dummy object.
688 */
689RTDECL(int) RTAsn1Dummy_InitEx(PRTASN1DUMMY pThis);
690
691/**
692 * Standard compliant initalizer.
693 *
694 * @returns VINF_SUCCESS.
695 * @param pThis The dummy object.
696 * @param pAllocator Ignored.
697 */
698DECLINLINE(int) RTAsn1Dummy_Init(PRTASN1DUMMY pThis, PCRTASN1ALLOCATORVTABLE pAllocator)
699{
700 NOREF(pAllocator);
701 return RTAsn1Dummy_InitEx(pThis);
702}
703
704
705/**
706 * ASN.1 sequence core (IPRT representation).
707 */
708typedef struct RTASN1SEQUENCECORE
709{
710 /** Core ASN.1 encoding details. */
711 RTASN1CORE Asn1Core;
712} RTASN1SEQUENCECORE;
713/** Pointer to an ASN.1 sequence core (IPRT representation). */
714typedef RTASN1SEQUENCECORE *PRTASN1SEQUENCECORE;
715/** Pointer to a const ASN.1 sequence core (IPRT representation). */
716typedef RTASN1SEQUENCECORE const *PCRTASN1SEQUENCECORE;
717
718RTDECL(int) RTAsn1SequenceCore_Init(PRTASN1SEQUENCECORE pSeqCore, PCRTASN1COREVTABLE pVtable);
719RTDECL(int) RTAsn1SequenceCore_Clone(PRTASN1SEQUENCECORE pSeqCore, PCRTASN1COREVTABLE pVtable, PCRTASN1SEQUENCECORE pSrc);
720
721/**
722 * ASN.1 sequence-of core (IPRT representation).
723 */
724#if 0
725typedef struct RTASN1SEQOFCORE
726{
727 /** Core ASN.1 encoding details. */
728 RTASN1CORE Asn1Core;
729} RTASN1SEQUENCECORE;
730/** Pointer to an ASN.1 sequence-of core (IPRT representation). */
731typedef RTASN1SEQUENCECORE *PRTASN1SEQUENCECORE;
732/** Pointer to a const ASN.1 sequence-of core (IPRT representation). */
733typedef RTASN1SEQUENCECORE const *PCRTASN1SEQUENCECORE;
734#else
735# define RTASN1SEQOFCORE RTASN1SEQUENCECORE
736# define PRTASN1SEQOFCORE PRTASN1SEQUENCECORE
737# define PCRTASN1SEQOFCORE PCRTASN1SEQUENCECORE
738#endif
739RTDECL(int) RTAsn1SeqOfCore_Init(PRTASN1SEQOFCORE pThis, PCRTASN1COREVTABLE pVtable);
740RTDECL(int) RTAsn1SeqOfCore_Clone(PRTASN1SEQOFCORE pThis, PCRTASN1COREVTABLE pVtable, PCRTASN1SEQOFCORE pSrc);
741
742
743/** Defines the typedefs and prototypes for a generic sequence-of/set-of type. */
744#define RTASN1_IMPL_GEN_SEQ_OR_SET_OF_TYPEDEFS_AND_PROTOS(a_CoreType, a_CoreMember, \
745 a_ThisType, a_ItemType, a_DeclMacro, a_ImplExtNm) \
746 typedef struct a_ThisType \
747 { \
748 /** Sequence/set core. */ \
749 a_CoreType a_CoreMember; \
750 /** The array allocation tracker. */ \
751 RTASN1ARRAYALLOCATION Allocation; \
752 /** Items in the array. */ \
753 uint32_t cItems; \
754 /** Array. */ \
755 RT_CONCAT(P,a_ItemType) *papItems; \
756 } a_ThisType; \
757 typedef a_ThisType *RT_CONCAT(P,a_ThisType); \
758 typedef a_ThisType const *RT_CONCAT(PC,a_ThisType); \
759 a_DeclMacro(int) RT_CONCAT(a_ImplExtNm,_Erase)(RT_CONCAT(P,a_ThisType) pThis, uint32_t iPosition); \
760 a_DeclMacro(int) RT_CONCAT(a_ImplExtNm,_InsertEx)(RT_CONCAT(P,a_ThisType) pThis, uint32_t iPosition, \
761 RT_CONCAT(PC,a_ItemType) pToClone, \
762 PCRTASN1ALLOCATORVTABLE pAllocator, uint32_t *piActualPos); \
763 /** Appends entry with default content, returns index or negative error code. */ \
764 DECLINLINE(int32_t) RT_CONCAT(a_ImplExtNm,_Append)(RT_CONCAT(P,a_ThisType) pThis) \
765 { \
766 uint32_t uPos = pThis->cItems; \
767 int rc = RT_CONCAT(a_ImplExtNm,_InsertEx)(pThis, uPos, NULL /*pToClone*/, pThis->Allocation.pAllocator, &uPos); \
768 if (RT_SUCCESS(rc)) \
769 return uPos; \
770 return rc; \
771 } \
772 RTASN1TYPE_STANDARD_PROTOTYPES(a_ThisType, a_DeclMacro, a_ImplExtNm, a_CoreMember.Asn1Core)
773
774/** Defines the typedefs and prototypes for a generic sequence-of type. */
775#define RTASN1_IMPL_GEN_SEQ_OF_TYPEDEFS_AND_PROTOS(a_SeqOfType, a_ItemType, a_DeclMacro, a_ImplExtNm) \
776 RTASN1_IMPL_GEN_SEQ_OR_SET_OF_TYPEDEFS_AND_PROTOS(RTASN1SEQUENCECORE, SeqCore, a_SeqOfType, a_ItemType, a_DeclMacro, a_ImplExtNm)
777
778
779/**
780 * ASN.1 set core (IPRT representation).
781 */
782typedef struct RTASN1SETCORE
783{
784 /** Core ASN.1 encoding details. */
785 RTASN1CORE Asn1Core;
786} RTASN1SETCORE;
787/** Pointer to an ASN.1 set core (IPRT representation). */
788typedef RTASN1SETCORE *PRTASN1SETCORE;
789/** Pointer to a const ASN.1 set core (IPRT representation). */
790typedef RTASN1SETCORE const *PCRTASN1SETCORE;
791
792RTDECL(int) RTAsn1SetCore_Init(PRTASN1SETCORE pThis, PCRTASN1COREVTABLE pVtable);
793RTDECL(int) RTAsn1SetCore_Clone(PRTASN1SETCORE pThis, PCRTASN1COREVTABLE pVtable, PCRTASN1SETCORE pSrc);
794
795/**
796 * ASN.1 set-of core (IPRT representation).
797 */
798#if 0
799typedef struct RTASN1SETOFCORE
800{
801 /** Core ASN.1 encoding details. */
802 RTASN1CORE Asn1Core;
803} RTASN1SETUENCECORE;
804/** Pointer to an ASN.1 set-of core (IPRT representation). */
805typedef RTASN1SETUENCECORE *PRTASN1SETUENCECORE;
806/** Pointer to a const ASN.1 set-of core (IPRT representation). */
807typedef RTASN1SETUENCECORE const *PCRTASN1SETUENCECORE;
808#else
809# define RTASN1SETOFCORE RTASN1SETCORE
810# define PRTASN1SETOFCORE PRTASN1SETCORE
811# define PCRTASN1SETOFCORE PCRTASN1SETCORE
812#endif
813RTDECL(int) RTAsn1SetOfCore_Init(PRTASN1SETOFCORE pThis, PCRTASN1COREVTABLE pVtable);
814RTDECL(int) RTAsn1SetOfCore_Clone(PRTASN1SETOFCORE pThis, PCRTASN1COREVTABLE pVtable, PCRTASN1SETOFCORE pSrc);
815
816
817/** Defines the typedefs and prototypes for a generic set-of type. */
818#define RTASN1_IMPL_GEN_SET_OF_TYPEDEFS_AND_PROTOS(a_SetOfType, a_ItemType, a_DeclMacro, a_ImplExtNm) \
819 RTASN1_IMPL_GEN_SEQ_OR_SET_OF_TYPEDEFS_AND_PROTOS(RTASN1SETCORE, SetCore, a_SetOfType, a_ItemType, a_DeclMacro, a_ImplExtNm)
820
821
822/*
823 * Declare sets and sequences of the core structure.
824 */
825RTASN1_IMPL_GEN_SEQ_OF_TYPEDEFS_AND_PROTOS(RTASN1SEQOFCORES, RTASN1CORE, RTDECL, RTAsn1SeqOfCores);
826RTASN1_IMPL_GEN_SET_OF_TYPEDEFS_AND_PROTOS(RTASN1SETOFCORES, RTASN1CORE, RTDECL, RTAsn1SetOfCores);
827
828
829/**
830 * ASN.1 null (IPRT representation).
831 */
832typedef struct RTASN1NULL
833{
834 /** Core ASN.1 encoding details. */
835 RTASN1CORE Asn1Core;
836} RTASN1NULL;
837/** Pointer to an ASN.1 null (IPRT representation). */
838typedef RTASN1NULL *PRTASN1NULL;
839/** Pointer to a const ASN.1 null (IPRT representation). */
840typedef RTASN1NULL const *PCRTASN1NULL;
841/** The Vtable for a RTASN1NULL structure. */
842extern RTDATADECL(RTASN1COREVTABLE const) g_RTAsn1Null_Vtable;
843
844RTASN1TYPE_STANDARD_PROTOTYPES(RTASN1NULL, RTDECL, RTAsn1Null, Asn1Core);
845
846
847/**
848 * ASN.1 integer (IPRT representation).
849 */
850typedef struct RTASN1INTEGER
851{
852 /** Core ASN.1 encoding details. */
853 RTASN1CORE Asn1Core;
854 /** The unsigned C representation of the 64 least significant bits.
855 * @note A ASN.1 integer doesn't define signed/unsigned and can have any
856 * length you like. Thus, the user needs to check the size and
857 * preferably use the access APIs for signed numbers. */
858 RTUINT64U uValue;
859} RTASN1INTEGER;
860/** Pointer to an ASN.1 integer (IPRT representation). */
861typedef RTASN1INTEGER *PRTASN1INTEGER;
862/** Pointer to a const ASN.1 integer (IPRT representation). */
863typedef RTASN1INTEGER const *PCRTASN1INTEGER;
864/** The Vtable for a RTASN1INTEGER structure. */
865extern RTDATADECL(RTASN1COREVTABLE const) g_RTAsn1Integer_Vtable;
866
867RTASN1TYPE_STANDARD_PROTOTYPES(RTASN1INTEGER, RTDECL, RTAsn1Integer, Asn1Core);
868
869/**
870 * Initializes an interger object to a default value.
871 * @returns VINF_SUCCESS.
872 * @param pInteger The integer object representation.
873 * @param uValue The default value (unsigned 64-bit).
874 * @param pAllocator The allocator (pro forma).
875 */
876RTDECL(int) RTAsn1Integer_InitDefault(PRTASN1INTEGER pInteger, uint64_t uValue, PCRTASN1ALLOCATORVTABLE pAllocator);
877
878RTDECL(int) RTAsn1Integer_InitU64(PRTASN1INTEGER pThis, uint64_t uValue, PCRTASN1ALLOCATORVTABLE pAllocator);
879
880/**
881 * Get the most significat bit that's set (1).
882 *
883 * @returns 0-base bit number, -1 if all clear.
884 * @param pInteger The integer to check.
885 */
886RTDECL(int32_t) RTAsn1Integer_UnsignedLastBit(PCRTASN1INTEGER pInteger);
887
888/**
889 * Compares two ASN.1 unsigned integers.
890 *
891 * @returns 0 if equal, -1 if @a pLeft is smaller, 1 if @a pLeft is larger.
892 * @param pLeft The first ASN.1 integer.
893 * @param pRight The second ASN.1 integer.
894 */
895RTDECL(int) RTAsn1Integer_UnsignedCompare(PCRTASN1INTEGER pLeft, PCRTASN1INTEGER pRight);
896
897/**
898 * Compares an ASN.1 unsigned integer with a uint64_t.
899 *
900 * @returns 0 if equal, -1 if @a pInteger is smaller, 1 if @a pInteger is
901 * larger.
902 * @param pInteger The ASN.1 integer to treat as unsigned.
903 * @param u64Const The uint64_t constant to compare with.
904 */
905RTDECL(int) RTAsn1Integer_UnsignedCompareWithU64(PCRTASN1INTEGER pInteger, uint64_t u64Const);
906
907/**
908 * Compares an ASN.1 unsigned integer with a uint32_t.
909 *
910 * @returns 0 if equal, -1 if @a pInteger is smaller, 1 if @a pInteger is
911 * larger.
912 * @param pInteger The ASN.1 integer to treat as unsigned.
913 * @param u32Const The uint32_t constant to compare with.
914 * @remarks We don't bother with U16 and U8 variants, just use this instead.
915 */
916RTDECL(int) RTAsn1Integer_UnsignedCompareWithU32(PCRTASN1INTEGER pInteger, uint32_t u32Const);
917
918
919/**
920 * Initializes a big integer number from an ASN.1 integer.
921 *
922 * @returns IPRT status code.
923 * @param pInteger The ASN.1 integer.
924 * @param pBigNum The big integer number structure to initialize.
925 * @param fBigNumInit Subset of RTBIGNUMINIT_F_XXX that concerns
926 * senitivity, signedness and endianness.
927 */
928RTDECL(int) RTAsn1Integer_ToBigNum(PCRTASN1INTEGER pInteger, PRTBIGNUM pBigNum, uint32_t fBigNumInit);
929RTDECL(int) RTAsn1Integer_FromBigNum(PRTASN1INTEGER pThis, PCRTBIGNUM pBigNum, PCRTASN1ALLOCATORVTABLE pAllocator);
930
931/**
932 * Converts the integer to a string.
933 *
934 * This will produce a hex represenation of the number. If it fits in 64-bit, a
935 * C style hex number will be produced. If larger than 64-bit, it will be
936 * printed as a space separated string of hex bytes.
937 *
938 * @returns IPRT status code.
939 * @param pThis The ASN.1 integer.
940 * @param pszBuf The output buffer.
941 * @param cbBuf The buffer size.
942 * @param fFlags Flags reserved for future exploits. MBZ.
943 * @param pcbActual Where to return the amount of buffer space used
944 * (i.e. including terminator). Optional.
945 *
946 * @remarks Currently assume unsigned number.
947 */
948RTDECL(int) RTAsn1Integer_ToString(PRTASN1INTEGER pThis, char *pszBuf, size_t cbBuf, uint32_t fFlags, size_t *pcbActual);
949
950RTASN1_IMPL_GEN_SEQ_OF_TYPEDEFS_AND_PROTOS(RTASN1SEQOFINTEGERS, RTASN1INTEGER, RTDECL, RTAsn1SeqOfIntegers);
951RTASN1_IMPL_GEN_SET_OF_TYPEDEFS_AND_PROTOS(RTASN1SETOFINTEGERS, RTASN1INTEGER, RTDECL, RTAsn1SetOfIntegers);
952
953
954
955/**
956 * ASN.1 boolean (IPRT representation).
957 */
958typedef struct RTASN1BOOLEAN
959{
960 /** Core ASN.1 encoding details. */
961 RTASN1CORE Asn1Core;
962 /** The boolean value. */
963 bool fValue;
964} RTASN1BOOLEAN;
965/** Pointer to the IPRT representation of an ASN.1 boolean. */
966typedef RTASN1BOOLEAN *PRTASN1BOOLEAN;
967/** Pointer to the const IPRT representation of an ASN.1 boolean. */
968typedef RTASN1BOOLEAN const *PCRTASN1BOOLEAN;
969/** The Vtable for a RTASN1BOOLEAN structure. */
970extern RTDATADECL(RTASN1COREVTABLE const) g_RTAsn1Boolean_Vtable;
971
972RTASN1TYPE_STANDARD_PROTOTYPES(RTASN1BOOLEAN, RTDECL, RTAsn1Boolean, Asn1Core);
973
974/**
975 * Initializes a boolean object to a default value.
976 * @returns VINF_SUCCESS
977 * @param pBoolean The boolean object representation.
978 * @param fValue The default value.
979 * @param pAllocator The allocator (pro forma).
980 */
981RTDECL(int) RTAsn1Boolean_InitDefault(PRTASN1BOOLEAN pBoolean, bool fValue, PCRTASN1ALLOCATORVTABLE pAllocator);
982RTDECL(int) RTAsn1Boolean_Set(PRTASN1BOOLEAN pThis, bool fValue);
983
984RTASN1_IMPL_GEN_SEQ_OF_TYPEDEFS_AND_PROTOS(RTASN1SEQOFBOOLEANS, RTASN1BOOLEAN, RTDECL, RTAsn1SeqOfBooleans);
985RTASN1_IMPL_GEN_SET_OF_TYPEDEFS_AND_PROTOS(RTASN1SETOFBOOLEANS, RTASN1BOOLEAN, RTDECL, RTAsn1SetOfBooleans);
986
987
988
989/**
990 * ASN.1 UTC and Generalized Time (IPRT representation).
991 *
992 * The two time types only differs in the precision the render (UTC time being
993 * the one for which you go "WTF were they thinking?!!" for in 2014).
994 */
995typedef struct RTASN1TIME
996{
997 /** The core structure, either ASN1_TAG_UTC_TIME or
998 * ASN1_TAG_GENERALIZED_TIME. */
999 RTASN1CORE Asn1Core;
1000 /** The exploded time. */
1001 RTTIME Time;
1002} RTASN1TIME;
1003/** Pointer to an IPRT representation of ASN.1 UTC/Generalized time. */
1004typedef RTASN1TIME *PRTASN1TIME;
1005/** Pointer to a const IPRT representation of ASN.1 UTC/Generalized time. */
1006typedef RTASN1TIME const *PCRTASN1TIME;
1007/** The Vtable for a RTASN1TIME structure. */
1008extern RTDATADECL(RTASN1COREVTABLE const) g_RTAsn1Time_Vtable;
1009
1010RTASN1TYPE_STANDARD_PROTOTYPES(RTASN1TIME, RTDECL, RTAsn1Time, Asn1Core);
1011
1012RTASN1TYPE_STANDARD_PROTOTYPES(RTASN1TIME, RTDECL, RTAsn1UtcTime, Asn1Core);
1013RTASN1TYPE_STANDARD_PROTOTYPES(RTASN1TIME, RTDECL, RTAsn1GeneralizedTime, Asn1Core);
1014
1015/**
1016 * Compares two ASN.1 time values.
1017 *
1018 * @returns 0 if equal, -1 if @a pLeft is smaller, 1 if @a pLeft is larger.
1019 * @param pLeft The first ASN.1 time object.
1020 * @param pTsRight The second time to compare.
1021 */
1022RTDECL(int) RTAsn1Time_CompareWithTimeSpec(PCRTASN1TIME pLeft, PCRTTIMESPEC pTsRight);
1023
1024RTDECL(int) RTAsn1Time_InitEx(PRTASN1TIME pThis, uint32_t uTag, PCRTASN1ALLOCATORVTABLE pAllocator);
1025
1026/** @name Predicate macros for determing the exact type of RTASN1TIME.
1027 * @{ */
1028/** True if UTC time. */
1029#define RTASN1TIME_IS_UTC_TIME(a_pAsn1Time) ((a_pAsn1Time)->Asn1Core.uTag == ASN1_TAG_UTC_TIME)
1030/** True if generalized time. */
1031#define RTASN1TIME_IS_GENERALIZED_TIME(a_pAsn1Time) ((a_pAsn1Time)->Asn1Core.uTag == ASN1_TAG_GENERALIZED_TIME)
1032/** @} */
1033
1034RTASN1_IMPL_GEN_SEQ_OF_TYPEDEFS_AND_PROTOS(RTASN1SEQOFTIMES, RTASN1TIME, RTDECL, RTAsn1SeqOfTimes);
1035RTASN1_IMPL_GEN_SET_OF_TYPEDEFS_AND_PROTOS(RTASN1SETOFTIMES, RTASN1TIME, RTDECL, RTAsn1SetOfTimes);
1036
1037
1038
1039/**
1040 * ASN.1 object identifier (IPRT representation).
1041 */
1042typedef struct RTASN1OBJID
1043{
1044 /** Core ASN.1 encoding details. */
1045 RTASN1CORE Asn1Core;
1046 /** Coverning the paComponents memory allocation if there isn't enough room in
1047 * szObjId for both the dottet string and the component values. */
1048 RTASN1ALLOCATION Allocation;
1049 /** Pointer to an array with the component values.
1050 * This may point within szObjId if there is enough space for both there. */
1051 uint32_t const *pauComponents;
1052 /** The number of components in the object identifier.
1053 * This ASSUMES that nobody will be ever needing more than 255 components. */
1054 uint8_t cComponents;
1055 /** The dotted string representation of the object identifier.
1056 * If there is sufficient space after the string, we will place the array that
1057 * paComponents points to here and/or the raw content bytes (Asn1Core.uData).
1058 *
1059 * An analysis of dumpasn1.cfg, hl7.org and our own _OID defines indicates
1060 * that we need space for at least 10 components and 30-something chars. We've
1061 * allocated 87 bytes, which we ASSUME should be enough for everyone. */
1062 char szObjId[87];
1063} RTASN1OBJID;
1064/** Pointer to an ASN.1 object identifier representation. */
1065typedef RTASN1OBJID *PRTASN1OBJID;
1066/** Pointer to a const ASN.1 object identifier representation. */
1067typedef RTASN1OBJID const *PCRTASN1OBJID;
1068/** The Vtable for a RTASN1OBJID structure. */
1069extern RTDATADECL(RTASN1COREVTABLE const) g_RTAsn1ObjId_Vtable;
1070
1071RTASN1TYPE_STANDARD_PROTOTYPES(RTASN1OBJID, RTDECL, RTAsn1ObjId, Asn1Core);
1072
1073RTDECL(int) RTAsn1ObjId_InitFromString(PRTASN1OBJID pThis, const char *pszObjId, PCRTASN1ALLOCATORVTABLE pAllocator);
1074
1075/**
1076 * Compares an ASN.1 object identifier with a dotted object identifier string.
1077 *
1078 * @returns 0 if equal, -1 if @a pLeft is smaller, 1 if @a pLeft is larger.
1079 * @param pThis The ASN.1 object identifier.
1080 * @param pszRight The dotted object identifier string.
1081 */
1082RTDECL(int) RTAsn1ObjId_CompareWithString(PCRTASN1OBJID pThis, const char *pszRight);
1083
1084/**
1085 * Checks if an ASN.1 object identifier starts with the given dotted object
1086 * identifier string.
1087 *
1088 * The matching is only successful if the given string matches matches the last
1089 * component completely.
1090 *
1091 * @returns true / false.
1092 * @param pThis The ASN.1 object identifier.
1093 * @param pszStartsWith The dotted object identifier string.
1094 */
1095RTDECL(bool) RTAsn1ObjId_StartsWith(PCRTASN1OBJID pThis, const char *pszStartsWith);
1096
1097RTDECL(uint8_t) RTAsn1ObjIdCountComponents(PCRTASN1OBJID pThis);
1098RTDECL(uint32_t) RTAsn1ObjIdGetComponentsAsUInt32(PCRTASN1OBJID pThis, uint8_t iComponent);
1099RTDECL(uint32_t) RTAsn1ObjIdGetLastComponentsAsUInt32(PCRTASN1OBJID pThis);
1100
1101RTASN1_IMPL_GEN_SEQ_OF_TYPEDEFS_AND_PROTOS(RTASN1SEQOFOBJIDS, RTASN1OBJID, RTDECL, RTAsn1SeqOfObjIds);
1102RTASN1_IMPL_GEN_SET_OF_TYPEDEFS_AND_PROTOS(RTASN1SETOFOBJIDS, RTASN1OBJID, RTDECL, RTAsn1SetOfObjIds);
1103RTASN1_IMPL_GEN_SET_OF_TYPEDEFS_AND_PROTOS(RTASN1SETOFOBJIDSEQS, RTASN1SEQOFOBJIDS, RTDECL, RTAsn1SetOfObjIdSeqs);
1104
1105
1106/**
1107 * ASN.1 bit string (IPRT representation).
1108 */
1109typedef struct RTASN1BITSTRING
1110{
1111 /** Core ASN.1 encoding details. */
1112 RTASN1CORE Asn1Core;
1113 /** The number of bits. */
1114 uint32_t cBits;
1115 /** The max number of bits (given at decoding / construction). */
1116 uint32_t cMaxBits;
1117 /** Pointer to the bits. */
1118 RTCPTRUNION uBits;
1119 /** Pointer to user structure encapsulated in this string, if dynamically
1120 * allocated the EncapsulatedAllocation member can be used to track it and
1121 * trigger automatic cleanup on object destruction. If EncapsulatedAllocation
1122 * is zero, any object pointed to will only be deleted. */
1123 PRTASN1CORE pEncapsulated;
1124 /** Allocation tracking structure for pEncapsulated. */
1125 RTASN1ALLOCATION EncapsulatedAllocation;
1126} RTASN1BITSTRING;
1127/** Pointer to the IPRT representation of an ASN.1 bit string. */
1128typedef RTASN1BITSTRING *PRTASN1BITSTRING;
1129/** Pointer to the const IPRT representation of an ASN.1 bit string. */
1130typedef RTASN1BITSTRING const *PCRTASN1BITSTRING;
1131/** The Vtable for a RTASN1BITSTRING structure. */
1132extern RTDATADECL(RTASN1COREVTABLE const) g_RTAsn1BitString_Vtable;
1133
1134RTASN1TYPE_STANDARD_PROTOTYPES(RTASN1BITSTRING, RTDECL, RTAsn1BitString, Asn1Core);
1135
1136/**
1137 * Calculates pointer to the first bit.
1138 *
1139 * @returns Byte pointer to the first bit.
1140 * @param a_pBitString The ASN.1 bit string.
1141 */
1142#define RTASN1BITSTRING_GET_BIT0_PTR(a_pBitString) ( &(a_pBitString)->Asn1Core.uData.pu8[1] )
1143
1144/**
1145 * Calculates the size in bytes.
1146 *
1147 * @returns Rounded up size in bytes.
1148 * @param a_pBitString The ASN.1 bit string.
1149 */
1150#define RTASN1BITSTRING_GET_BYTE_SIZE(a_pBitString) ( ((a_pBitString)->cBits + 7U) >> 3 )
1151
1152RTDECL(int) RTAsn1BitString_DecodeAsn1Ex(PRTASN1CURSOR pCursor, uint32_t fFlags, uint32_t cMaxBits, PRTASN1BITSTRING pThis,
1153 const char *pszErrorTag);
1154RTDECL(uint64_t) RTAsn1BitString_GetAsUInt64(PCRTASN1BITSTRING pThis);
1155RTDECL(int) RTAsn1BitString_RefreshContent(PRTASN1BITSTRING pThis, uint32_t fFlags,
1156 PCRTASN1ALLOCATORVTABLE pAllocator, PRTERRINFO pErrInfo);
1157RTDECL(bool) RTAsn1BitString_AreContentBitsValid(PCRTASN1BITSTRING pThis, uint32_t fFlags);
1158
1159RTASN1_IMPL_GEN_SEQ_OF_TYPEDEFS_AND_PROTOS(RTASN1SEQOFBITSTRINGS, RTASN1BITSTRING, RTDECL, RTAsn1SeqOfBitStrings);
1160RTASN1_IMPL_GEN_SET_OF_TYPEDEFS_AND_PROTOS(RTASN1SETOFBITSTRINGS, RTASN1BITSTRING, RTDECL, RTAsn1SetOfBitStrings);
1161
1162
1163/**
1164 * ASN.1 octet string (IPRT representation).
1165 */
1166typedef struct RTASN1OCTETSTRING
1167{
1168 /** Core ASN.1 encoding details. */
1169 RTASN1CORE Asn1Core;
1170 /** Pointer to user structure encapsulated in this string.
1171 *
1172 * If dynamically allocated the EncapsulatedAllocation member can be used to
1173 * track it and trigger automatic cleanup on object destruction. If
1174 * EncapsulatedAllocation is zero, any object pointed to will only be
1175 * deleted. */
1176 PRTASN1CORE pEncapsulated;
1177 /** Allocation tracking structure for pEncapsulated. */
1178 RTASN1ALLOCATION EncapsulatedAllocation;
1179} RTASN1OCTETSTRING;
1180/** Pointer to the IPRT representation of an ASN.1 octet string. */
1181typedef RTASN1OCTETSTRING *PRTASN1OCTETSTRING;
1182/** Pointer to the const IPRT representation of an ASN.1 octet string. */
1183typedef RTASN1OCTETSTRING const *PCRTASN1OCTETSTRING;
1184/** The Vtable for a RTASN1OCTETSTRING structure. */
1185extern RTDATADECL(RTASN1COREVTABLE const) g_RTAsn1OctetString_Vtable;
1186
1187RTASN1TYPE_STANDARD_PROTOTYPES(RTASN1OCTETSTRING, RTDECL, RTAsn1OctetString, Asn1Core);
1188
1189RTDECL(bool) RTAsn1OctetString_AreContentBytesValid(PCRTASN1OCTETSTRING pThis, uint32_t fFlags);
1190RTDECL(int) RTAsn1OctetString_RefreshContent(PRTASN1OCTETSTRING pThis, uint32_t fFlags,
1191 PCRTASN1ALLOCATORVTABLE pAllocator, PRTERRINFO pErrInfo);
1192
1193RTASN1_IMPL_GEN_SEQ_OF_TYPEDEFS_AND_PROTOS(RTASN1SEQOFOCTETSTRINGS, RTASN1OCTETSTRING, RTDECL, RTAsn1SeqOfOctetStrings);
1194RTASN1_IMPL_GEN_SET_OF_TYPEDEFS_AND_PROTOS(RTASN1SETOFOCTETSTRINGS, RTASN1OCTETSTRING, RTDECL, RTAsn1SetOfOctetStrings);
1195
1196
1197/**
1198 * ASN.1 string (IPRT representation).
1199 * All char string types except 'character string (29)'.
1200 */
1201typedef struct RTASN1STRING
1202{
1203 /** Core ASN.1 encoding details. */
1204 RTASN1CORE Asn1Core;
1205 /** Allocation tracking for pszUtf8. */
1206 RTASN1ALLOCATION Allocation;
1207 /** If conversion to UTF-8 was requested, we cache that here. */
1208 char const *pszUtf8;
1209 /** The length (chars, not code points) of the above UTF-8 string if
1210 * present. */
1211 uint32_t cchUtf8;
1212} RTASN1STRING;
1213/** Pointer to the IPRT representation of an ASN.1 string. */
1214typedef RTASN1STRING *PRTASN1STRING;
1215/** Pointer to the const IPRT representation of an ASN.1 string. */
1216typedef RTASN1STRING const *PCRTASN1STRING;
1217/** The Vtable for a RTASN1STRING structure. */
1218extern RTDATADECL(RTASN1COREVTABLE const) g_RTAsn1String_Vtable;
1219
1220RTASN1TYPE_STANDARD_PROTOTYPES(RTASN1STRING, RTDECL, RTAsn1String, Asn1Core);
1221
1222/** @name String type predicate macros.
1223 * @{ */
1224#define RTASN1STRING_IS_NUMERIC(a_pAsn1String) ( RTASN1CORE_GET_TAG(&(a_pAsn1String)->Asn1Core) == ASN1_TAG_NUMERIC_STRING )
1225#define RTASN1STRING_IS_PRINTABLE(a_pAsn1String) ( RTASN1CORE_GET_TAG(&(a_pAsn1String)->Asn1Core) == ASN1_TAG_PRINTABLE_STRING )
1226#define RTASN1STRING_IS_T61(a_pAsn1String) ( RTASN1CORE_GET_TAG(&(a_pAsn1String)->Asn1Core) == ASN1_TAG_T61_STRING )
1227#define RTASN1STRING_IS_VIDEOTEX(a_pAsn1String) ( RTASN1CORE_GET_TAG(&(a_pAsn1String)->Asn1Core) == ASN1_TAG_VIDEOTEX_STRING )
1228#define RTASN1STRING_IS_VISIBLE(a_pAsn1String) ( RTASN1CORE_GET_TAG(&(a_pAsn1String)->Asn1Core) == ASN1_TAG_VISIBLE_STRING )
1229#define RTASN1STRING_IS_IA5(a_pAsn1String) ( RTASN1CORE_GET_TAG(&(a_pAsn1String)->Asn1Core) == ASN1_TAG_IA5_STRING )
1230#define RTASN1STRING_IS_GRAPHIC(a_pAsn1String) ( RTASN1CORE_GET_TAG(&(a_pAsn1String)->Asn1Core) == ASN1_TAG_GRAPHIC_STRING )
1231#define RTASN1STRING_IS_GENERAL(a_pAsn1String) ( RTASN1CORE_GET_TAG(&(a_pAsn1String)->Asn1Core) == ASN1_TAG_GENERAL_STRING )
1232/** UTF-8. */
1233#define RTASN1STRING_IS_UTF8(a_pAsn1String) ( RTASN1CORE_GET_TAG(&(a_pAsn1String)->Asn1Core) == ASN1_TAG_UTF8_STRING )
1234/** UCS-2. */
1235#define RTASN1STRING_IS_BMP(a_pAsn1String) ( RTASN1CORE_GET_TAG(&(a_pAsn1String)->Asn1Core) == ASN1_TAG_BMP_STRING )
1236/** UCS-4. */
1237#define RTASN1STRING_IS_UNIVERSAL(a_pAsn1String) ( RTASN1CORE_GET_TAG(&(a_pAsn1String)->Asn1Core) == ASN1_TAG_UNIVERSAL_STRING )
1238/** @} */
1239
1240RTASN1TYPE_STANDARD_PROTOTYPES(RTASN1STRING, RTDECL, RTAsn1NumericString, Asn1Core);
1241RTASN1TYPE_STANDARD_PROTOTYPES(RTASN1STRING, RTDECL, RTAsn1PrintableString, Asn1Core);
1242RTASN1TYPE_STANDARD_PROTOTYPES(RTASN1STRING, RTDECL, RTAsn1T61String, Asn1Core);
1243RTASN1TYPE_STANDARD_PROTOTYPES(RTASN1STRING, RTDECL, RTAsn1VideoTexString, Asn1Core);
1244RTASN1TYPE_STANDARD_PROTOTYPES(RTASN1STRING, RTDECL, RTAsn1VisibleString, Asn1Core);
1245RTASN1TYPE_STANDARD_PROTOTYPES(RTASN1STRING, RTDECL, RTAsn1Ia5String, Asn1Core);
1246RTASN1TYPE_STANDARD_PROTOTYPES(RTASN1STRING, RTDECL, RTAsn1GraphicString, Asn1Core);
1247RTASN1TYPE_STANDARD_PROTOTYPES(RTASN1STRING, RTDECL, RTAsn1GeneralString, Asn1Core);
1248RTASN1TYPE_STANDARD_PROTOTYPES(RTASN1STRING, RTDECL, RTAsn1Utf8String, Asn1Core);
1249RTASN1TYPE_STANDARD_PROTOTYPES(RTASN1STRING, RTDECL, RTAsn1BmpString, Asn1Core);
1250RTASN1TYPE_STANDARD_PROTOTYPES(RTASN1STRING, RTDECL, RTAsn1UniversalString, Asn1Core);
1251
1252RTDECL(int) RTAsn1String_InitWithValue(PRTASN1STRING pThis, const char *pszUtf8Value, PCRTASN1ALLOCATORVTABLE pAllocator);
1253RTDECL(int) RTAsn1String_InitEx(PRTASN1STRING pThis, uint32_t uTag, void const *pvValue, size_t cbValue,
1254 PCRTASN1ALLOCATORVTABLE pAllocator);
1255
1256/**
1257 * Compares two strings values, extended version.
1258 *
1259 * @returns 0 if equal, -1 if @a pLeft is smaller, 1 if @a pLeft is larger.
1260 * @param pLeft The first string.
1261 * @param pRight The second string.
1262 * @param fTypeToo Set if the string types must match, false if
1263 * not.
1264 */
1265RTDECL(int) RTAsn1String_CompareEx(PCRTASN1STRING pLeft, PCRTASN1STRING pRight, bool fTypeToo);
1266RTDECL(int) RTAsn1String_CompareValues(PCRTASN1STRING pLeft, PCRTASN1STRING pRight);
1267
1268/**
1269 * Compares a ASN.1 string object with an UTF-8 string.
1270 *
1271 * @returns 0 if equal, -1 if @a pThis is smaller, 1 if @a pThis is larger.
1272 * @param pThis The ASN.1 string object.
1273 * @param pszString The UTF-8 string.
1274 * @param cchString The length of @a pszString, or RTSTR_MAX.
1275 */
1276RTDECL(int) RTAsn1String_CompareWithString(PCRTASN1STRING pThis, const char *pszString, size_t cchString);
1277
1278/**
1279 * Queries the UTF-8 length of an ASN.1 string object.
1280 *
1281 * This differs from RTAsn1String_QueryUtf8 in that it won't need to allocate
1282 * memory for the converted string, but just calculates the length.
1283 *
1284 * @returns IPRT status code.
1285 * @param pThis The ASN.1 string object.
1286 * @param pcch Where to return the string length.
1287 */
1288RTDECL(int) RTAsn1String_QueryUtf8Len(PCRTASN1STRING pThis, size_t *pcch);
1289
1290/**
1291 * Queries the UTF-8 string for an ASN.1 string object.
1292 *
1293 * This may fail as it may require memory to be allocated for storing the
1294 * string.
1295 *
1296 * @returns IPRT status code.
1297 * @param pString The ASN.1 string object. This is a const
1298 * parameter for making life easier on the caller,
1299 * however be aware that the object may be modified
1300 * by this call!
1301 * @param ppsz Where to return the pointer to the UTF-8 string.
1302 * Optional.
1303 * @param pcch Where to return the length (in 8-bit chars) to
1304 * of the UTF-8 string. Optional.
1305 */
1306RTDECL(int) RTAsn1String_QueryUtf8(PCRTASN1STRING pString, const char **ppsz, size_t *pcch);
1307RTDECL(int) RTAsn1String_RecodeAsUtf8(PRTASN1STRING pThis, PCRTASN1ALLOCATORVTABLE pAllocator);
1308
1309RTASN1_IMPL_GEN_SEQ_OF_TYPEDEFS_AND_PROTOS(RTASN1SEQOFSTRINGS, RTASN1STRING, RTDECL, RTAsn1SeqOfStrings);
1310RTASN1_IMPL_GEN_SET_OF_TYPEDEFS_AND_PROTOS(RTASN1SETOFSTRINGS, RTASN1STRING, RTDECL, RTAsn1SetOfStrings);
1311
1312
1313
1314/**
1315 * ASN.1 generic context specific tag (IPRT representation).
1316 *
1317 * Normally used to tag something that's optional, version specific or such.
1318 *
1319 * For the purpose of documenting the format with typedefs as well as possibly
1320 * making it a little more type safe, there's a set of typedefs for the most
1321 * commonly used tag values defined. These typedefs have are identical to
1322 * RTASN1CONTEXTTAG, except from the C++ type system point of view.
1323 */
1324typedef struct RTASN1CONTEXTTAG
1325{
1326 /** Core ASN.1 encoding details. */
1327 RTASN1CORE Asn1Core;
1328} RTASN1CONTEXTTAG;
1329/** Pointer to an ASN.1 context tag (IPRT thing). */
1330typedef RTASN1CONTEXTTAG *PRTASN1CONTEXTTAG;
1331/** Pointer to a const ASN.1 context tag (IPRT thing). */
1332typedef RTASN1CONTEXTTAG const *PCRTASN1CONTEXTTAG;
1333
1334RTDECL(int) RTAsn1ContextTagN_Init(PRTASN1CONTEXTTAG pThis, uint32_t uTag, PCRTASN1COREVTABLE pVtable);
1335RTDECL(int) RTAsn1ContextTagN_Clone(PRTASN1CONTEXTTAG pThis, PCRTASN1CONTEXTTAG pSrc, uint32_t uTag);
1336
1337
1338/** @internal */
1339#define RTASN1CONTEXTTAG_DO_TYPEDEF_AND_INLINE(a_uTag) \
1340 typedef struct RT_CONCAT(RTASN1CONTEXTTAG,a_uTag) { RTASN1CORE Asn1Core; } RT_CONCAT(RTASN1CONTEXTTAG,a_uTag); \
1341 typedef RT_CONCAT(RTASN1CONTEXTTAG,a_uTag) *RT_CONCAT(PRTASN1CONTEXTTAG,a_uTag); \
1342 DECLINLINE(int) RT_CONCAT3(RTAsn1ContextTag,a_uTag,_Init)(RT_CONCAT(PRTASN1CONTEXTTAG,a_uTag) pThis, \
1343 PCRTASN1COREVTABLE pVtable, PCRTASN1ALLOCATORVTABLE pAllocator) \
1344 { \
1345 NOREF(pAllocator); \
1346 return RTAsn1ContextTagN_Init((PRTASN1CONTEXTTAG)pThis, a_uTag, pVtable); \
1347 } \
1348 DECLINLINE(int) RT_CONCAT3(RTAsn1ContextTag,a_uTag,_Clone)(RT_CONCAT(PRTASN1CONTEXTTAG,a_uTag) pThis, \
1349 RT_CONCAT(RTASN1CONTEXTTAG,a_uTag) const *pSrc) \
1350 { return RTAsn1ContextTagN_Clone((PRTASN1CONTEXTTAG)pThis, (PCRTASN1CONTEXTTAG)pSrc, a_uTag); } \
1351 typedef RT_CONCAT(RTASN1CONTEXTTAG,a_uTag) const *RT_CONCAT(PCRTASN1CONTEXTTAG,a_uTag)
1352RTASN1CONTEXTTAG_DO_TYPEDEF_AND_INLINE(0);
1353RTASN1CONTEXTTAG_DO_TYPEDEF_AND_INLINE(1);
1354RTASN1CONTEXTTAG_DO_TYPEDEF_AND_INLINE(2);
1355RTASN1CONTEXTTAG_DO_TYPEDEF_AND_INLINE(3);
1356RTASN1CONTEXTTAG_DO_TYPEDEF_AND_INLINE(4);
1357RTASN1CONTEXTTAG_DO_TYPEDEF_AND_INLINE(5);
1358RTASN1CONTEXTTAG_DO_TYPEDEF_AND_INLINE(6);
1359RTASN1CONTEXTTAG_DO_TYPEDEF_AND_INLINE(7);
1360#undef RTASN1CONTEXTTAG_DO_TYPEDEF_AND_INLINE
1361
1362/** Helper for comparing optional context tags.
1363 * This will return if both are not present or if their precense differs.
1364 * @internal */
1365#define RTASN1CONTEXTTAG_COMPARE_PRESENT_RETURN_INTERNAL(a_iDiff, a_pLeft, a_pRight, a_uTag) \
1366 do { \
1367 /* type checks */ \
1368 RT_CONCAT(PCRTASN1CONTEXTTAG,a_uTag) const pMyLeftInternal = (a_pLeft); \
1369 RT_CONCAT(PCRTASN1CONTEXTTAG,a_uTag) const pMyRightInternal = (a_pRight); \
1370 (a_iDiff) = (int)RTASN1CORE_IS_PRESENT(&pMyLeftInternal->Asn1Core) \
1371 - (int)RTASN1CORE_IS_PRESENT(&pMyRightInternal->Asn1Core); \
1372 if ((a_iDiff) || !RTASN1CORE_IS_PRESENT(&pMyLeftInternal->Asn1Core)) return iDiff; \
1373 } while (0)
1374
1375/** Helpers for comparing optional context tags.
1376 * This will return if both are not present or if their precense differs.
1377 * @{ */
1378#define RTASN1CONTEXTTAG0_COMPARE_PRESENT_RETURN(a_iDiff, a_pLeft, a_pRight) RTASN1CONTEXTTAG_COMPARE_PRESENT_RETURN_INTERNAL(a_iDiff, a_pLeft, a_pRight, 0)
1379#define RTASN1CONTEXTTAG1_COMPARE_PRESENT_RETURN(a_iDiff, a_pLeft, a_pRight) RTASN1CONTEXTTAG_COMPARE_PRESENT_RETURN_INTERNAL(a_iDiff, a_pLeft, a_pRight, 1)
1380#define RTASN1CONTEXTTAG2_COMPARE_PRESENT_RETURN(a_iDiff, a_pLeft, a_pRight) RTASN1CONTEXTTAG_COMPARE_PRESENT_RETURN_INTERNAL(a_iDiff, a_pLeft, a_pRight, 2)
1381#define RTASN1CONTEXTTAG3_COMPARE_PRESENT_RETURN(a_iDiff, a_pLeft, a_pRight) RTASN1CONTEXTTAG_COMPARE_PRESENT_RETURN_INTERNAL(a_iDiff, a_pLeft, a_pRight, 3)
1382#define RTASN1CONTEXTTAG4_COMPARE_PRESENT_RETURN(a_iDiff, a_pLeft, a_pRight) RTASN1CONTEXTTAG_COMPARE_PRESENT_RETURN_INTERNAL(a_iDiff, a_pLeft, a_pRight, 4)
1383#define RTASN1CONTEXTTAG5_COMPARE_PRESENT_RETURN(a_iDiff, a_pLeft, a_pRight) RTASN1CONTEXTTAG_COMPARE_PRESENT_RETURN_INTERNAL(a_iDiff, a_pLeft, a_pRight, 5)
1384#define RTASN1CONTEXTTAG6_COMPARE_PRESENT_RETURN(a_iDiff, a_pLeft, a_pRight) RTASN1CONTEXTTAG_COMPARE_PRESENT_RETURN_INTERNAL(a_iDiff, a_pLeft, a_pRight, 6)
1385#define RTASN1CONTEXTTAG7_COMPARE_PRESENT_RETURN(a_iDiff, a_pLeft, a_pRight) RTASN1CONTEXTTAG_COMPARE_PRESENT_RETURN_INTERNAL(a_iDiff, a_pLeft, a_pRight, 7)
1386/** @} */
1387
1388
1389/**
1390 * Type information for dynamically bits (see RTASN1DYNTYPE).
1391 */
1392typedef enum RTASN1TYPE
1393{
1394 /** Not present. */
1395 RTASN1TYPE_NOT_PRESENT = 0,
1396 /** Generic ASN.1 for unknown tag/class. */
1397 RTASN1TYPE_CORE,
1398 /** ASN.1 NULL. */
1399 RTASN1TYPE_NULL,
1400 /** ASN.1 integer. */
1401 RTASN1TYPE_INTEGER,
1402 /** ASN.1 boolean. */
1403 RTASN1TYPE_BOOLEAN,
1404 /** ASN.1 character string. */
1405 RTASN1TYPE_STRING,
1406 /** ASN.1 octet string. */
1407 RTASN1TYPE_OCTET_STRING,
1408 /** ASN.1 bite string. */
1409 RTASN1TYPE_BIT_STRING,
1410 /** ASN.1 UTC or Generalize time. */
1411 RTASN1TYPE_TIME,
1412#if 0
1413 /** ASN.1 sequence core. */
1414 RTASN1TYPE_SEQUENCE_CORE,
1415 /** ASN.1 set core. */
1416 RTASN1TYPE_SET_CORE,
1417#endif
1418 /** ASN.1 object identifier. */
1419 RTASN1TYPE_OBJID,
1420 /** End of valid types. */
1421 RTASN1TYPE_END,
1422 /** Type size hack. */
1423 RTASN1TYPE_32BIT_HACK = 0x7fffffff
1424} RTASN1TYPE;
1425
1426
1427/**
1428 * ASN.1 dynamic type record.
1429 */
1430typedef struct RTASN1DYNTYPE
1431{
1432 /** Alternative interpretation provided by a user.
1433 * Before destroying this object, the user must explicitly free this and set
1434 * it to NULL, otherwise there will be memory leaks. */
1435 PRTASN1CORE pUser;
1436 /** The type of data we've got here. */
1437 RTASN1TYPE enmType;
1438 /** Union with data of the type dictated by enmType. */
1439 union
1440 {
1441 /** RTASN1TYPE_CORE. */
1442 RTASN1CORE Core;
1443 /** RTASN1TYPE_NULL. */
1444 RTASN1NULL Asn1Null;
1445 /** RTASN1TYPE_INTEGER. */
1446 RTASN1INTEGER Integer;
1447 /** RTASN1TYPE_BOOLEAN. */
1448 RTASN1BOOLEAN Boolean;
1449 /** RTASN1TYPE_STRING. */
1450 RTASN1STRING String;
1451 /** RTASN1TYPE_OCTET_STRING. */
1452 RTASN1OCTETSTRING OctetString;
1453 /** RTASN1TYPE_BIT_STRING. */
1454 RTASN1BITSTRING BitString;
1455 /** RTASN1TYPE_TIME. */
1456 RTASN1TIME Time;
1457#if 0
1458 /** RTASN1TYPE_SEQUENCE_CORE. */
1459 RTASN1SEQUENCECORE SeqCore;
1460 /** RTASN1TYPE_SET_CORE. */
1461 RTASN1SETCORE SetCore;
1462#endif
1463 /** RTASN1TYPE_OBJID. */
1464 RTASN1OBJID ObjId;
1465 } u;
1466} RTASN1DYNTYPE;
1467/** Pointer to an ASN.1 dynamic type record. */
1468typedef RTASN1DYNTYPE *PRTASN1DYNTYPE;
1469/** Pointer to a const ASN.1 dynamic type record. */
1470typedef RTASN1DYNTYPE const *PCRTASN1DYNTYPE;
1471RTASN1TYPE_STANDARD_PROTOTYPES(RTASN1DYNTYPE, RTDECL, RTAsn1DynType, u.Core);
1472
1473
1474/** @name Virtual Method Table Based API
1475 * @{ */
1476/**
1477 * Calls the destructor of the ASN.1 object.
1478 *
1479 * @param pThisCore The IPRT representation of an ASN.1 object.
1480 */
1481RTDECL(void) RTAsn1VtDelete(PRTASN1CORE pThisCore);
1482
1483/**
1484 * Deep enumeration of all descendants.
1485 *
1486 * @returns IPRT status code, any non VINF_SUCCESS value stems from pfnCallback.
1487 * @param pThisCore Pointer to the ASN.1 core to enumerate members of.
1488 * @param pfnCallback The callback.
1489 * @param uDepth The depth of this object. Children are at +1.
1490 * @param pvUser Callback user argument.
1491 * @param fDepthFirst When set, recurse into child objects before calling
1492 * pfnCallback on then. When clear, the child object
1493 * is first
1494 */
1495RTDECL(int) RTAsn1VtDeepEnum(PRTASN1CORE pThisCore, bool fDepthFirst, uint32_t uDepth,
1496 PFNRTASN1ENUMCALLBACK pfnCallback, void *pvUser);
1497
1498/**
1499 * Clones @a pSrcCore onto @a pThisCore.
1500 *
1501 * The caller must be sure that @a pSrcCore and @a pThisCore are of the same
1502 * types.
1503 *
1504 * @returns IPRT status code.
1505 * @param pThisCore Pointer to the ASN.1 core to clone onto. This shall
1506 * be uninitialized.
1507 * @param pSrcCore Pointer to the ASN.1 core to clone.
1508 * @param pAllocator The allocator to use.
1509 */
1510RTDECL(int) RTAsn1VtClone(PRTASN1CORE pThisCore, PRTASN1CORE pSrcCore, PCRTASN1ALLOCATORVTABLE pAllocator);
1511
1512/**
1513 * Compares two objects.
1514 *
1515 * @returns 0 if equal, -1 if @a pLeft is smaller, 1 if @a pLeft is larger.
1516 * @param pLeftCore Pointer to the ASN.1 core of the left side object.
1517 * @param pRightCore Pointer to the ASN.1 core of the right side object.
1518 */
1519RTDECL(int) RTAsn1VtCompare(PCRTASN1CORE pLeftCore, PCRTASN1CORE pRightCore);
1520
1521/**
1522 * Check sanity.
1523 *
1524 * A primary criteria is that the object is present and initialized.
1525 *
1526 * @returns IPRT status code.
1527 * @param pThisCore Pointer to the ASN.1 core of the object to check out.
1528 * @param fFlags See RTASN1_CHECK_SANITY_F_XXX.
1529 * @param pErrInfo Where to return additional error details. Optional.
1530 * @param pszErrorTag Tag for the additional error details.
1531 */
1532RTDECL(int) RTAsn1VtCheckSanity(PCRTASN1CORE pThisCore, uint32_t fFlags,
1533 PRTERRINFO pErrInfo, const char *pszErrorTag);
1534/** @} */
1535
1536
1537/** @defgroup rp_asn1_encode RTAsn1Encode - ASN.1 Encoding
1538 * @{ */
1539
1540/** @name RTASN1ENCODE_F_XXX
1541 * @{ */
1542/** Use distinguished encoding rules (DER) to encode the object. */
1543#define RTASN1ENCODE_F_DER UINT32_C(0x00000001)
1544/** Use base encoding rules (BER) to encode the object.
1545 * This is currently the same as DER for practical reasons. */
1546#define RTASN1ENCODE_F_BER RTASN1ENCODE_F_DER
1547/** Mask of valid encoding rules. */
1548#define RTASN1ENCODE_F_RULE_MASK UINT32_C(0x00000007)
1549/** @} */
1550
1551
1552/**
1553 * Recalculates cbHdr of and ASN.1 object.
1554 *
1555 * @returns IPRT status code.
1556 * @retval VINF_ASN1_NOT_ENCODED if the header size is zero (default value,
1557 * whatever).
1558 * @param pAsn1Core The object in question.
1559 * @param fFlags Valid combination of the RTASN1ENCODE_F_XXX
1560 * flags. Must include the encoding type.
1561 * @param pErrInfo Extended error info. Optional.
1562 */
1563RTDECL(int) RTAsn1EncodeRecalcHdrSize(PRTASN1CORE pAsn1Core, uint32_t fFlags, PRTERRINFO pErrInfo);
1564
1565/**
1566 * Prepares the ASN.1 structure for encoding.
1567 *
1568 * The preparations is mainly calculating accurate object size, but may also
1569 * involve operations like recoding internal UTF-8 strings to the actual ASN.1
1570 * format and other things that may require memory to allocated/reallocated.
1571 *
1572 * @returns IPRT status code
1573 * @param pRoot The root of the ASN.1 object tree to encode.
1574 * @param fFlags Valid combination of the RTASN1ENCODE_F_XXX
1575 * flags. Must include the encoding type.
1576 * @param pcbEncoded Where to return the encoded size. Optional.
1577 * @param pErrInfo Where to store extended error information.
1578 * Optional.
1579 */
1580RTDECL(int) RTAsn1EncodePrepare(PRTASN1CORE pRoot, uint32_t fFlags, uint32_t *pcbEncoded, PRTERRINFO pErrInfo);
1581
1582/**
1583 * Encodes and writes the header of an ASN.1 object.
1584 *
1585 * @returns IPRT status code.
1586 * @retval VINF_ASN1_NOT_ENCODED if nothing was written (default value,
1587 * whatever).
1588 * @param pAsn1Core The object in question.
1589 * @param fFlags Valid combination of the RTASN1ENCODE_F_XXX
1590 * flags. Must include the encoding type.
1591 * @param pfnWriter The output writer callback.
1592 * @param pvUser The user argument to pass to @a pfnWriter.
1593 * @param pErrInfo Where to store extended error information.
1594 * Optional.
1595 */
1596RTDECL(int) RTAsn1EncodeWriteHeader(PCRTASN1CORE pAsn1Core, uint32_t fFlags, FNRTASN1ENCODEWRITER pfnWriter, void *pvUser,
1597 PRTERRINFO pErrInfo);
1598
1599/**
1600 * Encodes and writes an ASN.1 object.
1601 *
1602 * @returns IPRT status code
1603 * @param pRoot The root of the ASN.1 object tree to encode.
1604 * @param fFlags Valid combination of the RTASN1ENCODE_F_XXX
1605 * flags. Must include the encoding type.
1606 * @param pfnWriter The output writer callback.
1607 * @param pvUser The user argument to pass to @a pfnWriter.
1608 * @param pErrInfo Where to store extended error information.
1609 * Optional.
1610 */
1611RTDECL(int) RTAsn1EncodeWrite(PCRTASN1CORE pRoot, uint32_t fFlags, FNRTASN1ENCODEWRITER pfnWriter, void *pvUser,
1612 PRTERRINFO pErrInfo);
1613
1614/**
1615 * Encodes and writes an ASN.1 object into a caller allocated memory buffer.
1616 *
1617 * @returns IPRT status code
1618 * @param pRoot The root of the ASN.1 object tree to encode.
1619 * @param fFlags Valid combination of the RTASN1ENCODE_F_XXX
1620 * flags. Must include the encoding type.
1621 * @param pvBuf The output buffer.
1622 * @param cbBuf The buffer size. This should have the size
1623 * returned by RTAsn1EncodePrepare().
1624 * @param pErrInfo Where to store extended error information.
1625 * Optional.
1626 */
1627RTDECL(int) RTAsn1EncodeToBuffer(PCRTASN1CORE pRoot, uint32_t fFlags, void *pvBuf, size_t cbBuf, PRTERRINFO pErrInfo);
1628
1629/** @} */
1630
1631
1632
1633/** @defgroup rp_asn1_cursor RTAsn1Cursor - BER, DER, and CER cursor
1634 * @{ */
1635
1636/**
1637 * ASN.1 decoder byte cursor.
1638 */
1639typedef struct RTASN1CURSOR
1640{
1641 /** Pointer to the current (next) byte. */
1642 uint8_t const *pbCur;
1643 /** Number of bytes left to decode. */
1644 uint32_t cbLeft;
1645 /** RTASN1CURSOR_FLAGS_XXX. */
1646 uint8_t fFlags;
1647 /** The cursor depth. */
1648 uint8_t cDepth;
1649 /** Two bytes reserved for future tricks. */
1650 uint8_t abReserved[2];
1651 /** Pointer to the primary cursor. */
1652 struct RTASN1CURSORPRIMARY *pPrimary;
1653 /** Pointer to the parent cursor. */
1654 struct RTASN1CURSOR *pUp;
1655 /** The error tag for this cursor level. */
1656 const char *pszErrorTag;
1657} RTASN1CURSOR;
1658
1659/** @name RTASN1CURSOR_FLAGS_XXX - Cursor flags.
1660 * @{ */
1661/** Enforce DER rules. */
1662#define RTASN1CURSOR_FLAGS_DER RT_BIT(1)
1663/** Enforce CER rules. */
1664#define RTASN1CURSOR_FLAGS_CER RT_BIT(2)
1665/** @} */
1666
1667
1668typedef struct RTASN1CURSORPRIMARY
1669{
1670 /** The normal cursor bits. */
1671 RTASN1CURSOR Cursor;
1672 /** For error reporting. */
1673 PRTERRINFO pErrInfo;
1674 /** The allocator virtual method table. */
1675 PCRTASN1ALLOCATORVTABLE pAllocator;
1676} RTASN1CURSORPRIMARY;
1677typedef RTASN1CURSORPRIMARY *PRTASN1CURSORPRIMARY;
1678
1679
1680/**
1681 * Initializes a primary cursor.
1682 *
1683 * The primary cursor is special in that it stores information shared with the
1684 * sub-cursors created by methods like RTAsn1CursorGetContextTagNCursor and
1685 * RTAsn1CursorGetSequenceCursor. Even if just sharing a few items at present,
1686 * it still important to save every possible byte since stack space is scarce in
1687 * some of the execution environments.
1688 *
1689 * @returns Pointer to pCursor->Cursor.
1690 * @param pPrimaryCursor The primary cursor structure to initialize.
1691 * @param pvFirst The first byte to decode.
1692 * @param cb The number of bytes to decode.
1693 * @param pErrInfo Where to store error information.
1694 * @param pAllocator The allocator to use.
1695 * @param fFlags RTASN1CURSOR_FLAGS_XXX.
1696 * @param pszErrorTag The primary error tag.
1697 */
1698RTDECL(PRTASN1CURSOR) RTAsn1CursorInitPrimary(PRTASN1CURSORPRIMARY pPrimaryCursor, void const *pvFirst, uint32_t cb,
1699 PRTERRINFO pErrInfo, PCRTASN1ALLOCATORVTABLE pAllocator, uint32_t fFlags,
1700 const char *pszErrorTag);
1701
1702RTDECL(int) RTAsn1CursorInitSub(PRTASN1CURSOR pParent, uint32_t cb, PRTASN1CURSOR pChild, const char *pszErrorTag);
1703
1704/**
1705 * Initialize a sub-cursor for traversing the content of an ASN.1 object.
1706 *
1707 * @returns IPRT status code.
1708 * @param pParent The parent cursor.
1709 * @param pAsn1Core The ASN.1 object which content we should
1710 * traverse with the sub-cursor.
1711 * @param pChild The sub-cursor to initialize.
1712 * @param pszErrorTag The error tag of the sub-cursor.
1713 */
1714RTDECL(int) RTAsn1CursorInitSubFromCore(PRTASN1CURSOR pParent, PRTASN1CORE pAsn1Core,
1715 PRTASN1CURSOR pChild, const char *pszErrorTag);
1716
1717/**
1718 * Initalizes the an allocation structure prior to making an allocation.
1719 *
1720 * To try unify and optimize memory managment for decoding and in-memory
1721 * construction of ASN.1 objects, each allocation has an allocation structure
1722 * associated with it. This stores the allocator and keep statistics for
1723 * optimizing resizable allocations.
1724 *
1725 * @returns Pointer to the allocator info (for call in alloc parameter).
1726 * @param pCursor The cursor.
1727 * @param pAllocation The allocation structure to initialize.
1728 */
1729RTDECL(PRTASN1ALLOCATION) RTAsn1CursorInitAllocation(PRTASN1CURSOR pCursor, PRTASN1ALLOCATION pAllocation);
1730
1731/**
1732 * Initalizes the an array allocation structure prior to making an allocation.
1733 *
1734 * This is a special case of RTAsn1CursorInitAllocation. We store a little bit
1735 * more detail here in order to optimize growing and shrinking of arrays.
1736 *
1737 * @returns Pointer to the allocator info (for call in alloc parameter).
1738 * @param pCursor The cursor.
1739 * @param pAllocation The allocation structure to initialize.
1740 * @param cbEntry The array entry size.
1741 */
1742RTDECL(PRTASN1ARRAYALLOCATION) RTAsn1CursorInitArrayAllocation(PRTASN1CURSOR pCursor, PRTASN1ARRAYALLOCATION pAllocation,
1743 size_t cbEntry);
1744
1745/**
1746 * Wrapper around RTErrInfoSetV.
1747 *
1748 * @returns @a rc
1749 * @param pCursor The cursor.
1750 * @param rc The return code to return.
1751 * @param pszMsg Message format string.
1752 * @param ... Format arguments.
1753 */
1754RTDECL(int) RTAsn1CursorSetInfo(PRTASN1CURSOR pCursor, int rc, const char *pszMsg, ...) RT_IPRT_FORMAT_ATTR(3, 4);
1755
1756/**
1757 * Wrapper around RTErrInfoSetV.
1758 *
1759 * @returns @a rc
1760 * @param pCursor The cursor.
1761 * @param rc The return code to return.
1762 * @param pszMsg Message format string.
1763 * @param va Format arguments.
1764 */
1765RTDECL(int) RTAsn1CursorSetInfoV(PRTASN1CURSOR pCursor, int rc, const char *pszMsg, va_list va) RT_IPRT_FORMAT_ATTR(3, 0);
1766
1767/**
1768 * Checks that we've reached the end of the data for the cursor.
1769 *
1770 * This differs from RTAsn1CursorCheckEnd in that it does not consider the end
1771 * an error and therefore leaves the error buffer alone.
1772 *
1773 * @returns True if end, otherwise false.
1774 * @param pCursor The cursor we're decoding from.
1775 */
1776RTDECL(bool) RTAsn1CursorIsEnd(PRTASN1CURSOR pCursor);
1777
1778/**
1779 * Checks that we've reached the end of the data for the cursor.
1780 *
1781 * @returns IPRT status code.
1782 * @param pCursor The cursor we're decoding from.
1783 */
1784RTDECL(int) RTAsn1CursorCheckEnd(PRTASN1CURSOR pCursor);
1785
1786
1787/**
1788 * Skips a given number of bytes.
1789 *
1790 * @returns @a pCursor
1791 * @param pCursor The cursor.
1792 * @param cb The number of bytes to skip.
1793 * @internal
1794 */
1795DECLINLINE(PRTASN1CURSOR) RTAsn1CursorSkip(PRTASN1CURSOR pCursor, uint32_t cb)
1796{
1797 if (cb <= pCursor->cbLeft)
1798 {
1799 pCursor->cbLeft -= cb;
1800 pCursor->pbCur += cb;
1801 }
1802 else
1803 {
1804 pCursor->pbCur += pCursor->cbLeft;
1805 pCursor->cbLeft = 0;
1806 }
1807
1808 return pCursor;
1809}
1810
1811/**
1812 * Low-level function for reading an ASN.1 header.
1813 *
1814 * @returns IPRT status code.
1815 * @param pCursor The cursor we're decoding from.
1816 * @param pAsn1Core The output object core.
1817 * @param pszErrorTag Error tag.
1818 * @internal
1819 */
1820RTDECL(int) RTAsn1CursorReadHdr(PRTASN1CURSOR pCursor, PRTASN1CORE pAsn1Core, const char *pszErrorTag);
1821
1822/**
1823 * Common helper for simple tag matching.
1824 *
1825 * @returns IPRT status code.
1826 * @param pCursor The cursor (for error reporting).
1827 * @param pAsn1Core The ASN.1 core structure.
1828 * @param uTag The expected tag.
1829 * @param fClass The expected class.
1830 * @param fString Set if it's a string type that shall follow
1831 * special CER and DER rules wrt to constructed and
1832 * primitive encoding.
1833 * @param fFlags The RTASN1CURSOR_GET_F_XXX flags.
1834 * @param pszErrorTag The error tag.
1835 * @param pszWhat The type/whatever name.
1836 */
1837RTDECL(int) RTAsn1CursorMatchTagClassFlagsEx(PRTASN1CURSOR pCursor, PRTASN1CORE pAsn1Core, uint32_t uTag, uint32_t fClass,
1838 bool fString, uint32_t fFlags, const char *pszErrorTag, const char *pszWhat);
1839
1840/**
1841 * Common helper for simple tag matching.
1842 *
1843 * @returns IPRT status code.
1844 * @param pCursor The cursor (for error reporting).
1845 * @param pAsn1Core The ASN.1 core structure.
1846 * @param uTag The expected tag.
1847 * @param fClass The expected class.
1848 * @param fFlags The RTASN1CURSOR_GET_F_XXX flags.
1849 * @param pszErrorTag The error tag.
1850 * @param pszWhat The type/whatever name.
1851 * @internal
1852 */
1853DECLINLINE(int) RTAsn1CursorMatchTagClassFlags(PRTASN1CURSOR pCursor, PRTASN1CORE pAsn1Core, uint32_t uTag, uint32_t fClass,
1854 uint32_t fFlags, const char *pszErrorTag, const char *pszWhat)
1855{
1856 if (pAsn1Core->uTag == uTag && pAsn1Core->fClass == fClass)
1857 return VINF_SUCCESS;
1858 return RTAsn1CursorMatchTagClassFlagsEx(pCursor, pAsn1Core, uTag, fClass, false /*fString*/, fFlags, pszErrorTag, pszWhat);
1859}
1860
1861
1862/**
1863 * Common helper for simple tag matching for strings.
1864 *
1865 * Check string encoding considerations.
1866 *
1867 * @returns IPRT status code.
1868 * @param pCursor The cursor (for error reporting).
1869 * @param pAsn1Core The ASN.1 core structure.
1870 * @param uTag The expected tag.
1871 * @param fClass The expected class.
1872 * @param fFlags The RTASN1CURSOR_GET_F_XXX flags.
1873 * @param pszErrorTag The error tag.
1874 * @param pszWhat The type/whatever name.
1875 * @internal
1876 */
1877DECLINLINE(int) RTAsn1CursorMatchTagClassFlagsString(PRTASN1CURSOR pCursor, PRTASN1CORE pAsn1Core, uint32_t uTag, uint32_t fClass,
1878 uint32_t fFlags, const char *pszErrorTag, const char *pszWhat)
1879{
1880 if (pAsn1Core->uTag == uTag && pAsn1Core->fClass == fClass)
1881 return VINF_SUCCESS;
1882 return RTAsn1CursorMatchTagClassFlagsEx(pCursor, pAsn1Core, uTag, fClass, true /*fString*/, fFlags, pszErrorTag, pszWhat);
1883}
1884
1885
1886
1887/** @name RTASN1CURSOR_GET_F_XXX - Common flags for all the getters.
1888 * @{ */
1889/** Used for decoding objects with implicit tags assigned to them. This only
1890 * works when calling getters with a unambigious types. */
1891#define RTASN1CURSOR_GET_F_IMPLICIT RT_BIT_32(0)
1892/** @} */
1893
1894/**
1895 * Read ANY object.
1896 *
1897 * @returns IPRT status code.
1898 * @param pCursor The cursor we're decoding from.
1899 * @param fFlags RTASN1CURSOR_GET_F_XXX.
1900 * @param pAsn1Core The output object core.
1901 * @param pszErrorTag Error tag.
1902 */
1903RTDECL(int) RTAsn1CursorGetCore(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1CORE pAsn1Core, const char *pszErrorTag);
1904
1905/**
1906 * Read a NULL object.
1907 *
1908 * @returns IPRT status code.
1909 * @param pCursor The cursor we're decoding from.
1910 * @param fFlags RTASN1CURSOR_GET_F_XXX.
1911 * @param pNull The output NULL object.
1912 * @param pszErrorTag Error tag.
1913 */
1914RTDECL(int) RTAsn1CursorGetNull(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1NULL pNull, const char *pszErrorTag);
1915
1916/**
1917 * Read an INTEGER object.
1918 *
1919 * @returns IPRT status code.
1920 * @param pCursor The cursor we're decoding from.
1921 * @param fFlags RTASN1CURSOR_GET_F_XXX.
1922 * @param pInteger The output integer object.
1923 * @param pszErrorTag Error tag.
1924 */
1925RTDECL(int) RTAsn1CursorGetInteger(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1INTEGER pInteger, const char *pszErrorTag);
1926
1927/**
1928 * Read an BOOLEAN object.
1929 *
1930 * @returns IPRT status code.
1931 * @param pCursor The cursor we're decoding from.
1932 * @param fFlags RTASN1CURSOR_GET_F_XXX.
1933 * @param pBoolean The output boolean object.
1934 * @param pszErrorTag Error tag.
1935 */
1936RTDECL(int) RTAsn1CursorGetBoolean(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1BOOLEAN pBoolean, const char *pszErrorTag);
1937
1938/**
1939 * Retrives an object identifier (aka ObjId or OID) item from the ASN.1 stream.
1940 *
1941 * @returns IPRT status code.
1942 * @param pCursor The cursor.
1943 * @param fFlags RTASN1CURSOR_GET_F_XXX.
1944 * @param pObjId The output ODI object.
1945 * @param pszErrorTag Error tag.
1946 */
1947RTDECL(int) RTAsn1CursorGetObjId(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1OBJID pObjId, const char *pszErrorTag);
1948
1949/**
1950 * Retrives and verifies an object identifier.
1951 *
1952 * @returns IPRT status code.
1953 * @param pCursor The cursor.
1954 * @param fFlags RTASN1CURSOR_GET_F_XXX.
1955 * @param pObjId Where to return the parsed object ID, optional.
1956 * @param pszExpectedObjId The expected object identifier (dotted).
1957 * @param pszErrorTag Error tag.
1958 */
1959RTDECL(int) RTAsn1CursorGetAndCheckObjId(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1OBJID pObjId,
1960 const char *pszExpectedObjId, const char *pszErrorTag);
1961
1962/**
1963 * Read an UTC TIME or GENERALIZED TIME object.
1964 *
1965 * @returns IPRT status code.
1966 * @param pCursor The cursor we're decoding from.
1967 * @param fFlags RTASN1CURSOR_GET_F_XXX.
1968 * @param pTime The output time object.
1969 * @param pszErrorTag Error tag.
1970 */
1971RTDECL(int) RTAsn1CursorGetTime(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1TIME pTime, const char *pszErrorTag);
1972
1973/**
1974 * Read an BIT STRING object (skips past the content).
1975 *
1976 * @returns IPRT status ocde.
1977 * @param pCursor The cursor.
1978 * @param fFlags RTASN1CURSOR_GET_F_XXX.
1979 * @param pBitString The output bit string object.
1980 * @param pszErrorTag Error tag.
1981 */
1982RTDECL(int) RTAsn1CursorGetBitString(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1BITSTRING pBitString,
1983 const char *pszErrorTag);
1984
1985/**
1986 * Read an BIT STRING object (skips past the content), extended version with
1987 * cMaxBits.
1988 *
1989 * @returns IPRT status ocde.
1990 * @param pCursor The cursor.
1991 * @param fFlags RTASN1CURSOR_GET_F_XXX.
1992 * @param cMaxBits The max length of the bit string in bits. Pass
1993 * UINT32_MAX if variable size.
1994 * @param pBitString The output bit string object.
1995 * @param pszErrorTag Error tag.
1996 */
1997RTDECL(int) RTAsn1CursorGetBitStringEx(PRTASN1CURSOR pCursor, uint32_t fFlags, uint32_t cMaxBits, PRTASN1BITSTRING pBitString,
1998 const char *pszErrorTag);
1999
2000/**
2001 * Read an OCTET STRING object (skips past the content).
2002 *
2003 * @returns IPRT status ocde.
2004 * @param pCursor The cursor.
2005 * @param fFlags RTASN1CURSOR_GET_F_XXX.
2006 * @param pOctetString The output octet string object.
2007 * @param pszErrorTag Error tag.
2008 */
2009RTDECL(int) RTAsn1CursorGetOctetString(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1OCTETSTRING pOctetString,
2010 const char *pszErrorTag);
2011
2012/**
2013 * Read any kind of string object, except 'character string (29)'.
2014 *
2015 * @returns IPRT status code.
2016 * @param pCursor The cursor we're decoding from.
2017 * @param fFlags RTASN1CURSOR_GET_F_XXX.
2018 * @param pString The output boolean object.
2019 * @param pszErrorTag Error tag.
2020 */
2021RTDECL(int) RTAsn1CursorGetString(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1STRING pString, const char *pszErrorTag);
2022
2023/**
2024 * Read a IA5 STRING object.
2025 *
2026 * @returns IPRT status code.
2027 * @param pCursor The cursor we're decoding from.
2028 * @param fFlags RTASN1CURSOR_GET_F_XXX.
2029 * @param pString The output boolean object.
2030 * @param pszErrorTag Error tag.
2031 */
2032RTDECL(int) RTAsn1CursorGetIa5String(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1STRING pString, const char *pszErrorTag);
2033
2034/**
2035 * Read a UTF8 STRING object.
2036 *
2037 * @returns IPRT status code.
2038 * @param pCursor The cursor we're decoding from.
2039 * @param fFlags RTASN1CURSOR_GET_F_XXX.
2040 * @param pString The output boolean object.
2041 * @param pszErrorTag Error tag.
2042 */
2043RTDECL(int) RTAsn1CursorGetUtf8String(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1STRING pString, const char *pszErrorTag);
2044
2045/**
2046 * Read a BMP STRING (UCS-2) object.
2047 *
2048 * @returns IPRT status code.
2049 * @param pCursor The cursor we're decoding from.
2050 * @param fFlags RTASN1CURSOR_GET_F_XXX.
2051 * @param pString The output boolean object.
2052 * @param pszErrorTag Error tag.
2053 */
2054RTDECL(int) RTAsn1CursorGetBmpString(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1STRING pString, const char *pszErrorTag);
2055
2056/**
2057 * Read a SEQUENCE object and create a cursor for its content.
2058 *
2059 * @returns IPRT status code.
2060 * @param pCursor The cursor we're decoding from.
2061 * @param fFlags RTASN1CURSOR_GET_F_XXX.
2062 * @param pSeqCore The output sequence core object.
2063 * @param pSeqCursor The output cursor for the sequence content.
2064 * @param pszErrorTag Error tag, this will be associated with the
2065 * returned cursor.
2066 */
2067RTDECL(int) RTAsn1CursorGetSequenceCursor(PRTASN1CURSOR pCursor, uint32_t fFlags,
2068 PRTASN1SEQUENCECORE pSeqCore, PRTASN1CURSOR pSeqCursor, const char *pszErrorTag);
2069
2070/**
2071 * Read a SET object and create a cursor for its content.
2072 *
2073 * @returns IPRT status code.
2074 * @param pCursor The cursor we're decoding from.
2075 * @param fFlags RTASN1CURSOR_GET_F_XXX.
2076 * @param pSetCore The output set core object.
2077 * @param pSetCursor The output cursor for the set content.
2078 * @param pszErrorTag Error tag, this will be associated with the
2079 * returned cursor.
2080 */
2081RTDECL(int) RTAsn1CursorGetSetCursor(PRTASN1CURSOR pCursor, uint32_t fFlags,
2082 PRTASN1SETCORE pSetCore, PRTASN1CURSOR pSetCursor, const char *pszErrorTag);
2083
2084/**
2085 * Read a given constructed context tag and create a cursor for its content.
2086 *
2087 * @returns IPRT status code.
2088 * @param pCursor The cursor we're decoding from.
2089 * @param fFlags RTASN1CURSOR_GET_F_XXX.
2090 * @param uExpectedTag The expected tag.
2091 * @param pVtable The vtable for the context tag node (see
2092 * RTASN1TMPL_PASS_XTAG).
2093 * @param pCtxTag The output context tag object.
2094 * @param pCtxTagCursor The output cursor for the context tag content.
2095 * @param pszErrorTag Error tag, this will be associated with the
2096 * returned cursor.
2097 *
2098 * @remarks There are specialized version of this function for each of the
2099 * numbered context tag structures, like for RTASN1CONTEXTTAG0 there is
2100 * RTAsn1CursorGetContextTag0Cursor.
2101 */
2102RTDECL(int) RTAsn1CursorGetContextTagNCursor(PRTASN1CURSOR pCursor, uint32_t fFlags, uint32_t uExpectedTag,
2103 PCRTASN1COREVTABLE pVtable, PRTASN1CONTEXTTAG pCtxTag, PRTASN1CURSOR pCtxTagCursor,
2104 const char *pszErrorTag);
2105
2106/**
2107 * Read a dynamic ASN.1 type.
2108 *
2109 * @returns IPRT status code.
2110 * @param pCursor The cursor we're decoding from.
2111 * @param fFlags RTASN1CURSOR_GET_F_XXX.
2112 * @param pDynType The output context tag object.
2113 * @param pszErrorTag Error tag.
2114 */
2115RTDECL(int) RTAsn1CursorGetDynType(PRTASN1CURSOR pCursor, uint32_t fFlags, PRTASN1DYNTYPE pDynType, const char *pszErrorTag);
2116
2117/**
2118 * Peeks at the next ASN.1 object.
2119 *
2120 * @returns IPRT status code.
2121 * @param pCursor The cursore we're decoding from.
2122 * @param pAsn1Core Where to store the output of the peek.
2123 */
2124RTDECL(int) RTAsn1CursorPeek(PRTASN1CURSOR pCursor, PRTASN1CORE pAsn1Core);
2125
2126/**
2127 * Checks if the next ASN.1 object matches the given tag and class/flags.
2128 *
2129 * @returns @c true on match, @c false on mismatch.
2130 * @param pCursor The cursore we're decoding from.
2131 * @param uTag The tag number to match against.
2132 * @param fClass The tag class and flags to match against.
2133 */
2134RTDECL(bool) RTAsn1CursorIsNextEx(PRTASN1CURSOR pCursor, uint32_t uTag, uint8_t fClass);
2135
2136
2137
2138/** @internal */
2139#define RTASN1CONTEXTTAG_IMPL_CURSOR_INLINES(a_uTag) \
2140 DECLINLINE(int) RT_CONCAT3(RTAsn1CursorGetContextTag,a_uTag,Cursor)(PRTASN1CURSOR pCursor, uint32_t fFlags, \
2141 PCRTASN1COREVTABLE pVtable, \
2142 RT_CONCAT(PRTASN1CONTEXTTAG,a_uTag) pCtxTag, \
2143 PRTASN1CURSOR pCtxTagCursor, const char *pszErrorTag) \
2144 { /* Constructed is automatically implied if you need a cursor to it. */ \
2145 return RTAsn1CursorGetContextTagNCursor(pCursor, fFlags, a_uTag, pVtable, (PRTASN1CONTEXTTAG)pCtxTag, pCtxTagCursor, pszErrorTag); \
2146 } \
2147 DECLINLINE(int) RT_CONCAT3(RTAsn1ContextTag,a_uTag,InitDefault)(RT_CONCAT(PRTASN1CONTEXTTAG,a_uTag) pCtxTag) \
2148 { /* Constructed is automatically implied if you need to init it with a default value. */ \
2149 return RTAsn1Core_InitDefault(&pCtxTag->Asn1Core, a_uTag, ASN1_TAGCLASS_CONTEXT | ASN1_TAGFLAG_CONSTRUCTED); \
2150 } \
2151 DECLINLINE(int) RT_CONCAT3(RTAsn1CursorIsConstructedContextTag,a_uTag,Next)(PRTASN1CURSOR pCursor) \
2152 { \
2153 return RTAsn1CursorIsNextEx(pCursor, a_uTag, ASN1_TAGCLASS_CONTEXT | ASN1_TAGFLAG_CONSTRUCTED); \
2154 } \
2155 DECLINLINE(int) RT_CONCAT3(RTAsn1CursorIsPrimitiveContextTag,a_uTag,Next)(PRTASN1CURSOR pCursor) \
2156 { \
2157 return RTAsn1CursorIsNextEx(pCursor, a_uTag, ASN1_TAGCLASS_CONTEXT | ASN1_TAGFLAG_PRIMITIVE); \
2158 } \
2159 DECLINLINE(int) RT_CONCAT3(RTAsn1CursorIsAnyContextTag,a_uTag,Next)(PRTASN1CURSOR pCursor) \
2160 { \
2161 return RTAsn1CursorIsNextEx(pCursor, a_uTag, ASN1_TAGCLASS_CONTEXT | ASN1_TAGFLAG_CONSTRUCTED) \
2162 || RTAsn1CursorIsNextEx(pCursor, a_uTag, ASN1_TAGCLASS_CONTEXT | ASN1_TAGFLAG_PRIMITIVE);\
2163 } \
2164
2165RTASN1CONTEXTTAG_IMPL_CURSOR_INLINES(0)
2166RTASN1CONTEXTTAG_IMPL_CURSOR_INLINES(1)
2167RTASN1CONTEXTTAG_IMPL_CURSOR_INLINES(2)
2168RTASN1CONTEXTTAG_IMPL_CURSOR_INLINES(3)
2169RTASN1CONTEXTTAG_IMPL_CURSOR_INLINES(4)
2170RTASN1CONTEXTTAG_IMPL_CURSOR_INLINES(5)
2171RTASN1CONTEXTTAG_IMPL_CURSOR_INLINES(6)
2172RTASN1CONTEXTTAG_IMPL_CURSOR_INLINES(7)
2173#undef RTASN1CONTEXTTAG_IMPL_CURSOR_INLINES
2174
2175
2176/**
2177 * Checks if the next object is a boolean.
2178 *
2179 * @returns true / false
2180 * @param pCursor The cursor we're decoding from.
2181 * @remarks May produce error info output on mismatch.
2182 */
2183DECLINLINE(bool) RTAsn1CursorIsBooleanNext(PRTASN1CURSOR pCursor)
2184{
2185 return RTAsn1CursorIsNextEx(pCursor, ASN1_TAG_BOOLEAN, ASN1_TAGFLAG_PRIMITIVE | ASN1_TAGCLASS_UNIVERSAL);
2186}
2187
2188
2189/**
2190 * Checks if the next object is a set.
2191 *
2192 * @returns true / false
2193 * @param pCursor The cursor we're decoding from.
2194 * @remarks May produce error info output on mismatch.
2195 */
2196DECLINLINE(bool) RTAsn1CursorIsSetNext(PRTASN1CURSOR pCursor)
2197{
2198 return RTAsn1CursorIsNextEx(pCursor, ASN1_TAG_SET, ASN1_TAGFLAG_CONSTRUCTED | ASN1_TAGCLASS_UNIVERSAL);
2199}
2200
2201
2202/** @} */
2203
2204
2205/** @name ASN.1 Utility APIs
2206 * @{ */
2207
2208/**
2209 * Dumps an IPRT representation of a ASN.1 object tree.
2210 *
2211 * @returns IPRT status code.
2212 * @param pAsn1Core The ASN.1 object which members should be dumped.
2213 * @param fFlags RTASN1DUMP_F_XXX.
2214 * @param uLevel The indentation level to start at.
2215 * @param pfnPrintfV The output function.
2216 * @param pvUser Argument to the output function.
2217 */
2218RTDECL(int) RTAsn1Dump(PCRTASN1CORE pAsn1Core, uint32_t fFlags, uint32_t uLevel, PFNRTDUMPPRINTFV pfnPrintfV, void *pvUser);
2219
2220/**
2221 * Queries the name for an object identifier.
2222 *
2223 * This API is very simple due to how we store the data.
2224 *
2225 * @returns IPRT status code.
2226 * @retval VINF_SUCCESS on success.
2227 * @retval VERR_NOT_FOUND if not found.
2228 * @retval VERR_BUFFER_OVERFLOW if more buffer space is required.
2229 *
2230 * @param pObjId The object ID to name.
2231 * @param pszDst Where to store the name if found.
2232 * @param cbDst The size of the destination buffer.
2233 */
2234RTDECL(int) RTAsn1QueryObjIdName(PCRTASN1OBJID pObjId, char *pszDst, size_t cbDst);
2235
2236/** @} */
2237
2238/** @} */
2239
2240RT_C_DECLS_END
2241
2242#endif
2243
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