VirtualBox

Changeset 64883 in vbox for trunk/src/VBox/Runtime/common


Ignore:
Timestamp:
Dec 15, 2016 3:26:20 PM (8 years ago)
Author:
vboxsync
Message:

IPRT/ASN.1: Refactored array handling (SET OF, SEQUENCE OF) to use a pointer array instead of an object instance array. The old approach would move objects around in memory after they'd be initialized/decoded, making certain core optimziations involving pointers to object members impossible, as well as causing potentially causing trouble when modifying structures that takes down pointers after decoding. Fixed validation bug in rtCrX509Name_CheckSanityExtra where it didn't check that the RDNs had subitems but instead checked the parent twice (slight risk).

Location:
trunk/src/VBox/Runtime/common
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/asn1/asn1-basics.cpp

    r62564 r64883  
    7575
    7676
    77 
    78 RTDECL(int) RTAsn1MemGrowArray(PRTASN1ALLOCATION pAllocation, void **ppvArray, size_t cbEntry,
    79                                uint32_t cCurrent, uint32_t cNew)
     77RTDECL(int) RTAsn1MemResizeArray(PRTASN1ARRAYALLOCATION pAllocation, void ***ppapvArray, uint32_t cCurrent, uint32_t cNew)
    8078{
    8179    AssertReturn(pAllocation->pAllocator != NULL, VERR_WRONG_ORDER);
    82     AssertReturn(cbEntry > 0, VERR_INVALID_PARAMETER);
    83     AssertReturn(cNew > cCurrent, VERR_INVALID_PARAMETER);
     80    AssertReturn(pAllocation->cbEntry > 0, VERR_WRONG_ORDER);
     81    AssertReturn(cCurrent <= pAllocation->cEntriesAllocated, VERR_INVALID_PARAMETER);
     82    AssertReturn(cCurrent <= pAllocation->cPointersAllocated, VERR_INVALID_PARAMETER);
    8483    AssertReturn(cNew < _1M, VERR_OUT_OF_RANGE);
    85 
    86     pAllocation->cReallocs++;
    87 
    88     void *pvOld = *ppvArray;
    89 
    90     /* Initial allocation? */
    91     if (cCurrent == 0)
    92     {
    93         AssertReturn(pvOld == NULL, VERR_INVALID_PARAMETER);
    94         AssertReturn(cNew != 0, VERR_INVALID_PARAMETER);
    95         return pAllocation->pAllocator->pfnAlloc(pAllocation->pAllocator, pAllocation, ppvArray, cNew * cbEntry);
    96     }
    97 
    98     /* Do we need to grow the allocation or did we already allocate sufficient memory in a previous call? */
    99     size_t cbNew = cNew * cbEntry;
    100     if (pAllocation->cbAllocated < cbNew)
    101     {
    102         /* Need to grow.  Adjust the new size according to how many times we've been called. */
    103         if (pAllocation->cReallocs > 2)
    104         {
    105             if (pAllocation->cReallocs > 8)
    106                 cNew += 8;
    107             else if (pAllocation->cReallocs < 4)
    108                 cNew += 2;
    109             else
    110                 cNew += 4;
    111             cbNew += cNew * cbEntry;
    112         }
    113 
    114         int rc = pAllocation->pAllocator->pfnRealloc(pAllocation->pAllocator, pAllocation, pvOld, ppvArray, cbNew);
    115         if (RT_FAILURE(rc))
    116             return rc;
    117         Assert(pAllocation->cbAllocated >= cbNew);
    118 
    119         /* Clear the memory. */
    120         size_t cbOld = cCurrent * cbEntry;
    121         RT_BZERO((uint8_t *)*ppvArray + cbOld, pAllocation->cbAllocated - cbOld);
    122     }
    123 
    124     return VINF_SUCCESS;
     84    Assert(pAllocation->cEntriesAllocated <= pAllocation->cPointersAllocated);
     85
     86    /*
     87     * Is there sufficent space allocated already?
     88     *
     89     * We keep unused entires ZEROed, therefore we must always call the allocator
     90     * when shrinking (this also helps with the electric fence allocator).
     91     */
     92    if (cNew <= pAllocation->cEntriesAllocated)
     93    {
     94        if (cCurrent <= cNew)
     95            return VINF_SUCCESS;
     96        pAllocation->pAllocator->pfnShrinkArray(pAllocation->pAllocator, pAllocation, ppapvArray, cCurrent, cNew);
     97        return VINF_SUCCESS;
     98    }
     99
     100    /*
     101     * Must grow (or do initial alloc).
     102     */
     103    pAllocation->cResizeCalls++;
     104    return pAllocation->pAllocator->pfnGrowArray(pAllocation->pAllocator, pAllocation, ppapvArray, cNew);
     105}
     106
     107
     108RTDECL(void) RTAsn1MemFreeArray(PRTASN1ARRAYALLOCATION pAllocation, void **papvArray)
     109{
     110    Assert(pAllocation->pAllocator != NULL);
     111    if (papvArray)
     112    {
     113        pAllocation->pAllocator->pfnFreeArray(pAllocation->pAllocator, pAllocation, papvArray);
     114        Assert(pAllocation->cPointersAllocated == 0);
     115        Assert(pAllocation->cEntriesAllocated == 0);
     116    }
    125117}
    126118
     
    171163    pAllocation->uReserved0  = 0;
    172164    pAllocation->pAllocator  = pAllocator;
     165    return pAllocation;
     166}
     167
     168
     169RTDECL(PRTASN1ARRAYALLOCATION) RTAsn1MemInitArrayAllocation(PRTASN1ARRAYALLOCATION pAllocation,
     170                                                            PCRTASN1ALLOCATORVTABLE pAllocator, size_t cbEntry)
     171{
     172    Assert(cbEntry >= sizeof(RTASN1CORE));
     173    Assert(cbEntry < _1M);
     174    Assert(RT_ALIGN_Z(cbEntry, sizeof(void *)) == cbEntry);
     175    pAllocation->cbEntry            = (uint32_t)cbEntry;
     176    pAllocation->cPointersAllocated = 0;
     177    pAllocation->cEntriesAllocated  = 0;
     178    pAllocation->cResizeCalls       = 0;
     179    pAllocation->uReserved0         = 0;
     180    pAllocation->pAllocator         = pAllocator;
    173181    return pAllocation;
    174182}
  • trunk/src/VBox/Runtime/common/asn1/asn1-cursor.cpp

    r63451 r64883  
    202202    pAllocation->uReserved0  = 0;
    203203    pAllocation->pAllocator  = pCursor->pPrimary->pAllocator;
     204    return pAllocation;
     205}
     206
     207
     208RTDECL(PRTASN1ARRAYALLOCATION) RTAsn1CursorInitArrayAllocation(PRTASN1CURSOR pCursor, PRTASN1ARRAYALLOCATION pAllocation,
     209                                                               size_t cbEntry)
     210{
     211    Assert(cbEntry >= sizeof(RTASN1CORE));
     212    Assert(cbEntry < _1M);
     213    Assert(RT_ALIGN_Z(cbEntry, sizeof(void *)) == cbEntry);
     214    pAllocation->cbEntry            = (uint32_t)cbEntry;
     215    pAllocation->cPointersAllocated = 0;
     216    pAllocation->cEntriesAllocated  = 0;
     217    pAllocation->cResizeCalls       = 0;
     218    pAllocation->uReserved0         = 0;
     219    pAllocation->pAllocator         = pCursor->pPrimary->pAllocator;
    204220    return pAllocation;
    205221}
  • trunk/src/VBox/Runtime/common/asn1/asn1-default-allocator.cpp

    r62564 r64883  
    100100
    101101
     102/** @interface_method_impl{RTASN1ALLOCATORVTABLE, pfnFreeArray} */
     103static DECLCALLBACK(void) rtAsn1DefaultAllocator_FreeArray(PCRTASN1ALLOCATORVTABLE pThis, PRTASN1ARRAYALLOCATION pAllocation,
     104                                                           void **papvArray)
     105{
     106    RT_NOREF_PV(pThis);
     107    Assert(papvArray);
     108    Assert(pAllocation->cbEntry);
     109
     110    uint32_t i = pAllocation->cEntriesAllocated;
     111    while (i-- > 0)
     112        RTMemFree(papvArray[i]);
     113    RTMemFree(papvArray);
     114
     115    pAllocation->cEntriesAllocated  = 0;
     116    pAllocation->cPointersAllocated = 0;
     117}
     118
     119
     120/** @interface_method_impl{RTASN1ALLOCATORVTABLE, pfnGrowArray} */
     121static DECLCALLBACK(int) rtAsn1DefaultAllocator_GrowArray(PCRTASN1ALLOCATORVTABLE pThis, PRTASN1ARRAYALLOCATION pAllocation,
     122                                                          void ***ppapvArray, uint32_t cMinEntries)
     123{
     124    RT_NOREF_PV(pThis);
     125
     126    /*
     127     * Resize the pointer array.  We do chunks of 64 bytes for now.
     128     */
     129    void **papvArray = *ppapvArray;
     130    uint32_t cPointers = RT_ALIGN_32(cMinEntries, 64 / sizeof(void *));
     131    if (cPointers > pAllocation->cPointersAllocated)
     132    {
     133        void *pvPointers = RTMemRealloc(papvArray, cPointers * sizeof(void *));
     134        if (pvPointers)
     135        { /* likely */ }
     136        else if (cMinEntries > pAllocation->cPointersAllocated)
     137        {
     138            cPointers  = cMinEntries;
     139            pvPointers = RTMemRealloc(*ppapvArray, cPointers * sizeof(void *));
     140            if (!pvPointers)
     141                return VERR_NO_MEMORY;
     142        }
     143        else
     144        {
     145            cPointers  = pAllocation->cPointersAllocated;
     146            pvPointers = papvArray;
     147        }
     148
     149        *ppapvArray = papvArray = (void **)pvPointers;
     150        RT_BZERO(&papvArray[pAllocation->cPointersAllocated], (cPointers - pAllocation->cPointersAllocated) * sizeof(void *));
     151        pAllocation->cPointersAllocated = cPointers;
     152    }
     153
     154    /*
     155     * Add more entries.  Do multiple as the array grows.
     156     *
     157     * Note! We could possibly optimize this by allocating slabs of entries and
     158     *       slice them up.  However, keep things as simple as possible for now.
     159     */
     160    uint32_t cEntries = cMinEntries;
     161    if (cEntries > 2)
     162    {
     163        if (cEntries > 8)
     164            cEntries = RT_ALIGN_32(cEntries, 4);
     165        else
     166            cEntries = RT_ALIGN_32(cEntries, 2);
     167        cEntries = RT_MIN(cEntries, cPointers);
     168        Assert(cEntries >= cMinEntries);
     169    }
     170    Assert(cEntries <= pAllocation->cPointersAllocated);
     171
     172    while (pAllocation->cEntriesAllocated < cEntries)
     173    {
     174        void *pv;
     175        papvArray[pAllocation->cEntriesAllocated] = pv = RTMemAllocZ(pAllocation->cbEntry);
     176        if (pv)
     177            pAllocation->cEntriesAllocated++;
     178        else if (pAllocation->cEntriesAllocated >= cMinEntries)
     179            break;
     180        else
     181            return VERR_NO_MEMORY;
     182    }
     183
     184    return VINF_SUCCESS;
     185}
     186
     187
     188/** @interface_method_impl{RTASN1ALLOCATORVTABLE, pfnShrinkArray} */
     189static DECLCALLBACK(void) rtAsn1DefaultAllocator_ShrinkArray(PCRTASN1ALLOCATORVTABLE pThis, PRTASN1ARRAYALLOCATION pAllocation,
     190                                                             void ***ppapvArray, uint32_t cNew, uint32_t cCurrent)
     191{
     192    RT_NOREF_PV(pThis);
     193
     194    /*
     195     * For now we only zero the entries being removed.
     196     */
     197    void **papvArray = *ppapvArray;
     198    while (cNew < cCurrent)
     199    {
     200        RT_BZERO(papvArray[cNew], pAllocation->cbEntry);
     201        cNew++;
     202    }
     203}
     204
     205
     206
    102207/** The default ASN.1 allocator. */
     208#if 1 || !defined(IN_RING3) || defined(DOXYGEN_RUNNING)
    103209RT_DECL_DATA_CONST(RTASN1ALLOCATORVTABLE const) g_RTAsn1DefaultAllocator =
     210#else
     211RT_DECL_DATA_CONST(RTASN1ALLOCATORVTABLE const) g_RTAsn1DefaultAllocatorDisabled =
     212#endif
    104213{
    105214    rtAsn1DefaultAllocator_Free,
    106215    rtAsn1DefaultAllocator_Alloc,
    107     rtAsn1DefaultAllocator_Realloc
     216    rtAsn1DefaultAllocator_Realloc,
     217    rtAsn1DefaultAllocator_FreeArray,
     218    rtAsn1DefaultAllocator_GrowArray,
     219    rtAsn1DefaultAllocator_ShrinkArray
    108220};
    109221
  • trunk/src/VBox/Runtime/common/asn1/asn1-efence-allocator.cpp

    r62564 r64883  
    8080
    8181
     82/** @interface_method_impl{RTASN1ALLOCATORVTABLE, pfnFreeArray} */
     83static DECLCALLBACK(void) rtAsn1EFenceAllocator_FreeArray(PCRTASN1ALLOCATORVTABLE pThis, PRTASN1ARRAYALLOCATION pAllocation,
     84                                                          void **papvArray)
     85{
     86    RT_NOREF_PV(pThis);
     87    Assert(papvArray);
     88    Assert(pAllocation->cbEntry);
     89    Assert(pAllocation->cEntriesAllocated <= pAllocation->cPointersAllocated);
     90
     91    uint32_t i = pAllocation->cEntriesAllocated;
     92    while (i-- > 0)
     93    {
     94        RTMemEfFreeNP(papvArray[i]);
     95        papvArray[i] = NULL;
     96    }
     97    RTMemEfFreeNP(papvArray);
     98
     99    pAllocation->cEntriesAllocated  = 0;
     100    pAllocation->cPointersAllocated = 0;
     101}
     102
     103
     104/** @interface_method_impl{RTASN1ALLOCATORVTABLE, pfnGrowArray} */
     105static DECLCALLBACK(int) rtAsn1EFenceAllocator_GrowArray(PCRTASN1ALLOCATORVTABLE pThis, PRTASN1ARRAYALLOCATION pAllocation,
     106                                                         void ***ppapvArray, uint32_t cMinEntries)
     107{
     108    RT_NOREF_PV(pThis);
     109    Assert(pAllocation->cbEntry);
     110    Assert(pAllocation->cEntriesAllocated <= pAllocation->cPointersAllocated);
     111
     112    /*
     113     * Resize the pointer array.
     114     */
     115    void **papvArray = *ppapvArray;
     116    void *pvPointers = RTMemEfReallocNP(papvArray, cMinEntries * sizeof(void *), RTMEM_TAG);
     117    if (pvPointers)
     118    {
     119        *ppapvArray = papvArray = (void **)pvPointers;
     120        if (cMinEntries > pAllocation->cPointersAllocated) /* possible on multiple shrink failures */
     121            RT_BZERO(&papvArray[pAllocation->cPointersAllocated],
     122                     (cMinEntries - pAllocation->cPointersAllocated) * sizeof(void *));
     123        else
     124            AssertFailed();
     125        pAllocation->cPointersAllocated = cMinEntries;
     126    }
     127    else if (cMinEntries > pAllocation->cPointersAllocated)
     128        return VERR_NO_MEMORY;
     129    /* else: possible but unlikely */
     130
     131    /*
     132     * Add more entries.
     133     */
     134    while (pAllocation->cEntriesAllocated < cMinEntries)
     135    {
     136        void *pv;
     137        papvArray[pAllocation->cEntriesAllocated] = pv = RTMemEfAllocZNP(pAllocation->cbEntry, RTMEM_TAG);
     138        if (pv)
     139            pAllocation->cEntriesAllocated++;
     140        else
     141            return VERR_NO_MEMORY;
     142    }
     143
     144    return VINF_SUCCESS;
     145}
     146
     147
     148/** @interface_method_impl{RTASN1ALLOCATORVTABLE, pfnShrinkArray} */
     149static DECLCALLBACK(void) rtAsn1EFenceAllocator_ShrinkArray(PCRTASN1ALLOCATORVTABLE pThis, PRTASN1ARRAYALLOCATION pAllocation,
     150                                                            void ***ppapvArray, uint32_t cNew, uint32_t cCurrent)
     151{
     152    RT_NOREF_PV(pThis);
     153    Assert(pAllocation->cbEntry);
     154    Assert(pAllocation->cEntriesAllocated <= pAllocation->cPointersAllocated);
     155
     156    /*
     157     * We always free and resize.
     158     */
     159    Assert(pAllocation->cEntriesAllocated == cCurrent);
     160    Assert(cNew < cCurrent);
     161
     162    /* Free entries. */
     163    void **papvArray = *ppapvArray;
     164    while (cCurrent-- > cNew)
     165    {
     166        RTMemEfFreeNP(papvArray[cCurrent]);
     167        papvArray[cCurrent] = NULL;
     168    }
     169    pAllocation->cEntriesAllocated = cNew;
     170
     171    /* Try resize pointer array.  Failure here is a genuine possibility since the
     172       efence code will try allocate a new block.  This causes extra fun in the
     173       grow method above. */
     174    void *pvPointers = RTMemEfReallocNP(papvArray, cNew * sizeof(void *), RTMEM_TAG);
     175    if (pvPointers)
     176    {
     177        *ppapvArray = (void **)pvPointers;
     178        pAllocation->cPointersAllocated = cNew;
     179    }
     180}
     181
     182
    82183/** The Electric Fence ASN.1 allocator. */
    83184RT_DECL_DATA_CONST(RTASN1ALLOCATORVTABLE const) g_RTAsn1EFenceAllocator =
     
    85186    rtAsn1EFenceAllocator_Free,
    86187    rtAsn1EFenceAllocator_Alloc,
    87     rtAsn1EFenceAllocator_Realloc
     188    rtAsn1EFenceAllocator_Realloc,
     189    rtAsn1EFenceAllocator_FreeArray,
     190    rtAsn1EFenceAllocator_GrowArray,
     191    rtAsn1EFenceAllocator_ShrinkArray
    88192};
    89193
     194#if 0 && defined(IN_RING3) /* for efence testing */
     195RT_DECL_DATA_CONST(RTASN1ALLOCATORVTABLE const) g_RTAsn1DefaultAllocator =
     196{
     197    rtAsn1EFenceAllocator_Free,
     198    rtAsn1EFenceAllocator_Alloc,
     199    rtAsn1EFenceAllocator_Realloc,
     200    rtAsn1EFenceAllocator_FreeArray,
     201    rtAsn1EFenceAllocator_GrowArray,
     202    rtAsn1EFenceAllocator_ShrinkArray
     203};
     204#endif
     205
  • trunk/src/VBox/Runtime/common/crypto/pkcs7-core.cpp

    r62477 r64883  
    4949     * Note! We ASSUME a single signing time attribute, which simplifies the interface.
    5050     */
    51     uint32_t                cAttrsLeft;
    52     PCRTCRPKCS7ATTRIBUTE    pAttr;
     51    uint32_t                    cAttrsLeft;
     52    PRTCRPKCS7ATTRIBUTE const  *ppAttr;
    5353    if (!ppSignerInfo || *ppSignerInfo == NULL)
    5454    {
    5555        cAttrsLeft = pThis->AuthenticatedAttributes.cItems;
    56         pAttr      = pThis->AuthenticatedAttributes.paItems;
     56        ppAttr     = pThis->AuthenticatedAttributes.papItems;
    5757        while (cAttrsLeft-- > 0)
    5858        {
     59            PCRTCRPKCS7ATTRIBUTE pAttr = *ppAttr;
    5960            if (   pAttr->enmType == RTCRPKCS7ATTRIBUTETYPE_SIGNING_TIME
    6061                && pAttr->uValues.pSigningTime->cItems > 0)
     
    6263                if (ppSignerInfo)
    6364                    *ppSignerInfo = pThis;
    64                 return &pAttr->uValues.pSigningTime->paItems[0];
     65                return pAttr->uValues.pSigningTime->papItems[0];
    6566            }
    66             pAttr++;
     67            ppAttr++;
    6768        }
    6869    }
     
    7475     */
    7576    cAttrsLeft = pThis->UnauthenticatedAttributes.cItems;
    76     pAttr      = pThis->UnauthenticatedAttributes.paItems;
     77    ppAttr     = pThis->UnauthenticatedAttributes.papItems;
    7778    while (cAttrsLeft-- > 0)
    7879    {
     80        PCRTCRPKCS7ATTRIBUTE pAttr = *ppAttr;
    7981        if (pAttr->enmType == RTCRPKCS7ATTRIBUTETYPE_COUNTER_SIGNATURES)
    8082        {
    81             uint32_t              cSignatures = pAttr->uValues.pCounterSignatures->cItems;
    82             PCRTCRPKCS7SIGNERINFO pSignature  = pAttr->uValues.pCounterSignatures->paItems;
     83            uint32_t               cSignatures = pAttr->uValues.pCounterSignatures->cItems;
     84            PRTCRPKCS7SIGNERINFO  *ppSignature = pAttr->uValues.pCounterSignatures->papItems;
    8385
    8486            /* Skip past the previous counter signature. */
     
    8789                {
    8890                    cSignatures--;
    89                     if (pSignature == *ppSignerInfo)
     91                    if (*ppSignature == *ppSignerInfo)
    9092                    {
    9193                        *ppSignerInfo = NULL;
    92                         pSignature++;
     94                        ppSignature++;
    9395                        break;
    9496                    }
    95                     pSignature++;
     97                    ppSignature++;
    9698                }
    9799
     
    99101            while (cSignatures-- > 0)
    100102            {
    101                 uint32_t                cCounterAttrsLeft = pSignature->AuthenticatedAttributes.cItems;
    102                 PCRTCRPKCS7ATTRIBUTE    pCounterAttr      = pSignature->AuthenticatedAttributes.paItems;
     103                PCRTCRPKCS7SIGNERINFO       pSignature        = *ppSignature;
     104                uint32_t                    cCounterAttrsLeft = pSignature->AuthenticatedAttributes.cItems;
     105                PRTCRPKCS7ATTRIBUTE const  *ppCounterAttr     = pSignature->AuthenticatedAttributes.papItems;
    103106                while (cCounterAttrsLeft-- > 0)
    104107                {
     108                    PCRTCRPKCS7ATTRIBUTE pCounterAttr = *ppCounterAttr;
    105109                    if (   pCounterAttr->enmType == RTCRPKCS7ATTRIBUTETYPE_SIGNING_TIME
    106110                        && pCounterAttr->uValues.pSigningTime->cItems > 0)
     
    108112                        if (ppSignerInfo)
    109113                            *ppSignerInfo = pSignature;
    110                         return &pCounterAttr->uValues.pSigningTime->paItems[0];
     114                        return pCounterAttr->uValues.pSigningTime->papItems[0];
    111115                    }
    112                     pCounterAttr++;
     116                    ppCounterAttr++;
    113117                }
    114                 pSignature++;
     118                ppSignature++;
    115119            }
    116120        }
    117         pAttr++;
     121        ppAttr++;
    118122    }
    119123
     
    128132
    129133
    130 RTDECL(PCRTASN1TIME) RTCrPkcs7SignerInfo_GetMsTimestamp(PCRTCRPKCS7SIGNERINFO pThis, PCRTCRPKCS7CONTENTINFO *ppContentInfo)
     134RTDECL(PCRTASN1TIME) RTCrPkcs7SignerInfo_GetMsTimestamp(PCRTCRPKCS7SIGNERINFO pThis, PCRTCRPKCS7CONTENTINFO *ppContentInfoRet)
    131135{
    132136    /*
    133137     * Assume there is only one, so no need to enumerate anything here.
    134138     */
    135     uint32_t             cAttrsLeft = pThis->UnauthenticatedAttributes.cItems;
    136     PCRTCRPKCS7ATTRIBUTE pAttr      = pThis->UnauthenticatedAttributes.paItems;
     139    uint32_t                    cAttrsLeft = pThis->UnauthenticatedAttributes.cItems;
     140    PRTCRPKCS7ATTRIBUTE const  *ppAttr      = pThis->UnauthenticatedAttributes.papItems;
    137141    while (cAttrsLeft-- > 0)
    138142    {
     143        PCRTCRPKCS7ATTRIBUTE pAttr = *ppAttr;
    139144        if (pAttr->enmType == RTCRPKCS7ATTRIBUTETYPE_MS_TIMESTAMP)
    140145        {
    141             uint32_t                cLeft        = pAttr->uValues.pContentInfos->cItems;
    142             PCRTCRPKCS7CONTENTINFO  pContentInfo = &pAttr->uValues.pContentInfos->paItems[0];
     146            uint32_t                     cLeft         = pAttr->uValues.pContentInfos->cItems;
     147            PRTCRPKCS7CONTENTINFO const *ppContentInfo = pAttr->uValues.pContentInfos->papItems;
    143148            while (cLeft-- > 0)
    144149            {
     150                PCRTCRPKCS7CONTENTINFO pContentInfo = *ppContentInfo;
    145151                if (RTAsn1ObjId_CompareWithString(&pContentInfo->ContentType, RTCRPKCS7SIGNEDDATA_OID) == 0)
    146152                {
     
    148154                                                      RTCRTSPTSTINFO_OID) == 0)
    149155                    {
    150                         if (ppContentInfo)
    151                             *ppContentInfo = pContentInfo;
     156                        if (ppContentInfoRet)
     157                            *ppContentInfoRet = pContentInfo;
    152158                        return &pContentInfo->u.pSignedData->ContentInfo.u.pTstInfo->GenTime;
    153159                    }
     
    157163            }
    158164        }
    159         pAttr++;
     165        ppAttr++;
    160166    }
    161167
     
    163169     * No signature was found.
    164170     */
    165     if (ppContentInfo)
    166         *ppContentInfo = NULL;
     171    if (ppContentInfoRet)
     172        *ppContentInfoRet = NULL;
    167173
    168174    return NULL;
     
    189195{
    190196    for (uint32_t i = 0; i < pCertificates->cItems; i++)
    191         if (   pCertificates->paItems[i].enmChoice == RTCRPKCS7CERTCHOICE_X509
    192             && RTCrX509Certificate_MatchIssuerAndSerialNumber(pCertificates->paItems[i].u.pX509Cert, pIssuer, pSerialNumber))
    193             return pCertificates->paItems[i].u.pX509Cert;
     197    {
     198        PCRTCRPKCS7CERT pCert = pCertificates->papItems[i];
     199        if (   pCert->enmChoice == RTCRPKCS7CERTCHOICE_X509
     200            && RTCrX509Certificate_MatchIssuerAndSerialNumber(pCert->u.pX509Cert, pIssuer, pSerialNumber))
     201            return pCert->u.pX509Cert;
     202    }
    194203    return NULL;
    195204}
  • trunk/src/VBox/Runtime/common/crypto/pkcs7-sanity.cpp

    r62564 r64883  
    6868        for (uint32_t i = 0; i < pSignedData->DigestAlgorithms.cItems; i++)
    6969        {
    70             if (RTCrX509AlgorithmIdentifier_QueryDigestType(&pSignedData->DigestAlgorithms.paItems[i]) == RTDIGESTTYPE_INVALID)
     70            if (RTCrX509AlgorithmIdentifier_QueryDigestType(pSignedData->DigestAlgorithms.papItems[i]) == RTDIGESTTYPE_INVALID)
    7171                return RTErrInfoSetF(pErrInfo, VERR_CR_PKCS7_UNKNOWN_DIGEST_ALGORITHM,
    7272                                     "%s: SignedData.DigestAlgorithms[%i] is not known: %s",
    73                                      pszErrorTag, i, pSignedData->DigestAlgorithms.paItems[i].Algorithm.szObjId);
    74             if (pSignedData->DigestAlgorithms.paItems[i].Parameters.enmType != RTASN1TYPE_NULL)
     73                                     pszErrorTag, i, pSignedData->DigestAlgorithms.papItems[i]->Algorithm.szObjId);
     74            if (pSignedData->DigestAlgorithms.papItems[i]->Parameters.enmType != RTASN1TYPE_NULL)
    7575                return RTErrInfoSetF(pErrInfo, VERR_CR_PKCS7_DIGEST_PARAMS_NOT_IMPL,
    7676                                     "%s: SignedData.DigestAlgorithms[%i] has parameters: tag=%u",
    77                                      pszErrorTag, i, pSignedData->DigestAlgorithms.paItems[i].Parameters.u.Core.uTag);
     77                                     pszErrorTag, i, pSignedData->DigestAlgorithms.papItems[i]->Parameters.u.Core.uTag);
    7878        }
    7979
     
    106106    for (uint32_t i = 0; i < pSignedData->SignerInfos.cItems; i++)
    107107    {
    108         PCRTCRPKCS7SIGNERINFO pSignerInfo = &pSignedData->SignerInfos.paItems[i];
     108        PCRTCRPKCS7SIGNERINFO pSignerInfo = pSignedData->SignerInfos.papItems[i];
    109109
    110110        if (RTAsn1Integer_UnsignedCompareWithU32(&pSignerInfo->Version, RTCRPKCS7SIGNERINFO_V1) != 0)
     
    136136        uint32_t j = 0;
    137137        while (   j < pSignedData->DigestAlgorithms.cItems
    138                && RTCrX509AlgorithmIdentifier_Compare(&pSignedData->DigestAlgorithms.paItems[j],
     138               && RTCrX509AlgorithmIdentifier_Compare(pSignedData->DigestAlgorithms.papItems[j],
    139139                                                      &pSignerInfo->DigestAlgorithm) != 0)
    140140            j++;
     
    162162            for (j = 0; j < pSignerInfo->AuthenticatedAttributes.cItems; j++)
    163163            {
    164                 PCRTCRPKCS7ATTRIBUTE pAttrib = &pSignerInfo->AuthenticatedAttributes.paItems[j];
     164                PCRTCRPKCS7ATTRIBUTE pAttrib = pSignerInfo->AuthenticatedAttributes.papItems[j];
    165165                if (RTAsn1ObjId_CompareWithString(&pAttrib->Type, RTCR_PKCS9_ID_CONTENT_TYPE_OID) == 0)
    166166                {
  • trunk/src/VBox/Runtime/common/crypto/pkcs7-verify.cpp

    r64531 r64883  
    7575            PCRTCRPKCS7SETOFCERTS pCerts = &pContentInfo->u.pSignedData->Certificates;
    7676            for (uint32_t i = 0; i < pCerts->cItems; i++)
    77                 if (pCerts->paItems[i].enmChoice == RTCRPKCS7CERTCHOICE_X509)
    78                     rtCrOpenSslAddX509CertToStack(pAddCerts, pCerts->paItems[i].u.pX509Cert);
     77                if (pCerts->papItems[i]->enmChoice == RTCRPKCS7CERTCHOICE_X509)
     78                    rtCrOpenSslAddX509CertToStack(pAddCerts, pCerts->papItems[i]->u.pX509Cert);
    7979
    8080
     
    238238    while (i-- > 0)
    239239    {
    240         PCRTCRPKCS7ATTRIBUTE pAttrib = &pSignerInfo->AuthenticatedAttributes.paItems[i];
     240        PCRTCRPKCS7ATTRIBUTE pAttrib = pSignerInfo->AuthenticatedAttributes.papItems[i];
    241241
    242242        if (RTAsn1ObjId_CompareWithString(&pAttrib->Type, RTCR_PKCS9_ID_CONTENT_TYPE_OID) == 0)
     
    247247
    248248            if (   !(fFlags & RTCRPKCS7VERIFY_SD_F_COUNTER_SIGNATURE) /* See note about microsoft below. */
    249                 && RTAsn1ObjId_Compare(&pAttrib->uValues.pObjIds->paItems[0], &pSignedData->ContentInfo.ContentType) != 0)
     249                && RTAsn1ObjId_Compare(pAttrib->uValues.pObjIds->papItems[0], &pSignedData->ContentInfo.ContentType) != 0)
    250250                   return RTErrInfoSetF(pErrInfo, VERR_CR_PKCS7_CONTENT_TYPE_ATTRIB_MISMATCH,
    251                                         "Expected content-type %s, found %s",
    252                                         &pAttrib->uValues.pObjIds->paItems[0], pSignedData->ContentInfo.ContentType.szObjId);
     251                                        "Expected content-type %s, found %s", pAttrib->uValues.pObjIds->papItems[0]->szObjId,
     252                                        pSignedData->ContentInfo.ContentType.szObjId);
    253253            cContentTypes++;
    254254        }
     
    260260
    261261            if (!RTCrDigestMatch(*phDigest,
    262                                  pAttrib->uValues.pOctetStrings->paItems[0].Asn1Core.uData.pv,
    263                                  pAttrib->uValues.pOctetStrings->paItems[0].Asn1Core.cb))
     262                                 pAttrib->uValues.pOctetStrings->papItems[0]->Asn1Core.uData.pv,
     263                                 pAttrib->uValues.pOctetStrings->papItems[0]->Asn1Core.cb))
    264264            {
    265265                size_t cbHash = RTCrDigestGetHashSize(*phDigest);
    266                 if (cbHash != pAttrib->uValues.pOctetStrings->paItems[0].Asn1Core.cb)
     266                if (cbHash != pAttrib->uValues.pOctetStrings->papItems[0]->Asn1Core.cb)
    267267                    return RTErrInfoSetF(pErrInfo, VERR_CR_PKCS7_MESSAGE_DIGEST_ATTRIB_MISMATCH,
    268268                                         "Authenticated message-digest attribute mismatch: cbHash=%#zx cbValue=%#x",
    269                                          cbHash, pAttrib->uValues.pOctetStrings->paItems[0].Asn1Core.cb);
     269                                         cbHash, pAttrib->uValues.pOctetStrings->papItems[0]->Asn1Core.cb);
    270270                return RTErrInfoSetF(pErrInfo, VERR_CR_PKCS7_MESSAGE_DIGEST_ATTRIB_MISMATCH,
    271271                                     "Authenticated message-digest attribute mismatch (cbHash=%#zx):\n"
     
    273273                                     "our:    %.*Rhxs\n",
    274274                                     cbHash,
    275                                      cbHash, pAttrib->uValues.pOctetStrings->paItems[0].Asn1Core.uData.pv,
     275                                     cbHash, pAttrib->uValues.pOctetStrings->papItems[0]->Asn1Core.uData.pv,
    276276                                     cbHash, RTCrDigestGetHash(*phDigest));
    277277            }
     
    342342    uint32_t iDigest = pSignedData->DigestAlgorithms.cItems;
    343343    while (iDigest-- > 0)
    344         if (RTCrX509AlgorithmIdentifier_Compare(&pSignedData->DigestAlgorithms.paItems[iDigest],
     344        if (RTCrX509AlgorithmIdentifier_Compare(pSignedData->DigestAlgorithms.papItems[iDigest],
    345345                                                &pSignerInfo->DigestAlgorithm) == 0)
    346346        {
     
    620620    for (i = 0; i < cDigests; i++)
    621621    {
    622         rc = RTCrDigestCreateByObjId(&ahDigests[i], &pSignedData->DigestAlgorithms.paItems[i].Algorithm);
     622        rc = RTCrDigestCreateByObjId(&ahDigests[i], &pSignedData->DigestAlgorithms.papItems[i]->Algorithm);
    623623        if (RT_FAILURE(rc))
    624624        {
    625625            rc = RTErrInfoSetF(pErrInfo, VERR_CR_PKCS7_DIGEST_CREATE_ERROR, "Error creating digest for '%s': %Rrc",
    626                                pSignedData->DigestAlgorithms.paItems[i].Algorithm.szObjId, rc);
     626                               pSignedData->DigestAlgorithms.papItems[i]->Algorithm.szObjId, rc);
    627627            break;
    628628        }
     
    647647            for (i = 0; i < pSignedData->SignerInfos.cItems; i++)
    648648            {
    649                 PCRTCRPKCS7SIGNERINFO   pSignerInfo = &pSignedData->SignerInfos.paItems[i];
     649                PCRTCRPKCS7SIGNERINFO   pSignerInfo = pSignedData->SignerInfos.papItems[i];
    650650                RTCRDIGEST              hThisDigest = NIL_RTCRDIGEST; /* (gcc maybe incredible stupid.) */
    651651                rc = rtCrPkcs7VerifyFindDigest(&hThisDigest, pSignedData, pSignerInfo, ahDigests, pErrInfo);
  • trunk/src/VBox/Runtime/common/crypto/spc-core.cpp

    r62477 r64883  
    6969                if (pData)
    7070                    for (uint32_t i = 0; i < pData->cItems; i++)
    71                         if (pData->paItems[i].enmType == enmType)
    72                             return &pData->paItems[i];
     71                        if (pData->papItems[i]->enmType == enmType)
     72                            return pData->papItems[i];
    7373            }
    7474        }
  • trunk/src/VBox/Runtime/common/crypto/spc-sanity.cpp

    r62477 r64883  
    5757
    5858    if (RTCrX509AlgorithmIdentifier_Compare(&pIndData->DigestInfo.DigestAlgorithm, /** @todo not entirely sure about this check... */
    59                                             &pSignedData->SignerInfos.paItems[0].DigestAlgorithm) != 0)
     59                                            &pSignedData->SignerInfos.papItems[0]->DigestAlgorithm) != 0)
    6060        return RTErrInfoSetF(pErrInfo, VERR_CR_SPC_SIGNED_IND_DATA_DIGEST_ALGO_MISMATCH,
    6161                             "SpcIndirectDataContent DigestInfo and SignerInfos algorithms mismatch: %s vs %s",
    6262                             pIndData->DigestInfo.DigestAlgorithm.Algorithm.szObjId,
    63                              pSignedData->SignerInfos.paItems[0].DigestAlgorithm.Algorithm.szObjId);
     63                             pSignedData->SignerInfos.papItems[0]->DigestAlgorithm.Algorithm.szObjId);
    6464
    6565    if (RTCrX509AlgorithmIdentifier_Compare(&pIndData->DigestInfo.DigestAlgorithm,
    66                                             &pSignedData->DigestAlgorithms.paItems[0]) != 0)
     66                                            pSignedData->DigestAlgorithms.papItems[0]) != 0)
    6767        return RTErrInfoSetF(pErrInfo, VERR_CR_SPC_IND_DATA_DIGEST_ALGO_NOT_IN_DIGEST_ALGOS,
    6868                             "SpcIndirectDataContent DigestInfo and SignedData.DigestAlgorithms[0] mismatch: %s vs %s",
    6969                             pIndData->DigestInfo.DigestAlgorithm.Algorithm.szObjId,
    70                              pSignedData->DigestAlgorithms.paItems[0].Algorithm.szObjId);
     70                             pSignedData->DigestAlgorithms.papItems[0]->Algorithm.szObjId);
    7171
    7272    if (fFlags & RTCRSPCINDIRECTDATACONTENT_SANITY_F_ONLY_KNOWN_HASH)
     
    126126            for (uint32_t i = 0; i < pObj->u.pData->cItems; i++)
    127127            {
    128                 PCRTCRSPCSERIALIZEDOBJECTATTRIBUTE pAttr = &pObj->u.pData->paItems[i];
     128                PCRTCRSPCSERIALIZEDOBJECTATTRIBUTE pAttr = pObj->u.pData->papItems[i];
    129129                if (   RTAsn1ObjId_CompareWithString(&pAttr->Type, RTCRSPC_PE_IMAGE_HASHES_V1_OID) == 0
    130130                    || RTAsn1ObjId_CompareWithString(&pAttr->Type, RTCRSPC_PE_IMAGE_HASHES_V2_OID) == 0 )
  • trunk/src/VBox/Runtime/common/crypto/x509-certpaths.cpp

    r64531 r64883  
    723723    if (pThis->pUntrustedCertsSet)
    724724    {
    725         uint32_t const  cCerts  = pThis->pUntrustedCertsSet->cItems;
    726         PCRTCRPKCS7CERT paCerts = pThis->pUntrustedCertsSet->paItems;
     725        uint32_t const        cCerts   = pThis->pUntrustedCertsSet->cItems;
     726        PRTCRPKCS7CERT const *papCerts = pThis->pUntrustedCertsSet->papItems;
    727727        for (uint32_t i = 0; i < cCerts; i++)
    728             if (   paCerts[i].enmChoice == RTCRPKCS7CERTCHOICE_X509
    729                 && RTCrX509Certificate_MatchSubjectOrAltSubjectByRfc5280(paCerts[i].u.pX509Cert, pIssuer))
    730                 rtCrX509CertPathsAddIssuer(pThis, pNode, paCerts[i].u.pX509Cert, NULL, RTCRX509CERTPATHNODE_SRC_UNTRUSTED_SET);
     728        {
     729            PCRTCRPKCS7CERT pCert = papCerts[i];
     730            if (   pCert->enmChoice == RTCRPKCS7CERTCHOICE_X509
     731                && RTCrX509Certificate_MatchSubjectOrAltSubjectByRfc5280(pCert->u.pX509Cert, pIssuer))
     732                rtCrX509CertPathsAddIssuer(pThis, pNode, pCert->u.pX509Cert, NULL, RTCRX509CERTPATHNODE_SRC_UNTRUSTED_SET);
     733        }
    731734    }
    732735}
     
    10571060{
    10581061    for (uint32_t i = 0; i < pName->cItems; i++)
    1059         for (uint32_t j = 0; j < pName->paItems[i].cItems; j++)
    1060         {
    1061             PRTCRX509ATTRIBUTETYPEANDVALUE pAttrib = &pName->paItems[i].paItems[j];
     1062    {
     1063        PCRTCRX509RELATIVEDISTINGUISHEDNAME const pRdn = pName->papItems[i];
     1064        for (uint32_t j = 0; j < pRdn->cItems; j++)
     1065        {
     1066            PRTCRX509ATTRIBUTETYPEANDVALUE pAttrib = pRdn->papItems[j];
    10621067
    10631068            const char *pszType = pAttrib->Type.szObjId;
     
    11181123                rtDumpPrintf(pfnPrintfV, pvUser, "<not-string: uTag=%#x>", pAttrib->Value.u.Core.uTag);
    11191124        }
     1125    }
    11201126}
    11211127
     
    13501356 * @param   pThis               The validator instance.
    13511357 * @param   cSubtrees           The number of sub-trees to add.
    1352  * @param   paSubtrees          Array of sub-trees to add.
    1353  */
    1354 static bool rtCrX509CpvAddPermittedSubtrees(PRTCRX509CERTPATHSINT pThis, uint32_t cSubtrees, PCRTCRX509GENERALSUBTREE paSubtrees)
     1358 * @param   papSubtrees         Array of sub-trees to add.
     1359 */
     1360static bool rtCrX509CpvAddPermittedSubtrees(PRTCRX509CERTPATHSINT pThis, uint32_t cSubtrees,
     1361                                            PRTCRX509GENERALSUBTREE const *papSubtrees)
    13551362{
    13561363    /*
     
    13751382    for (uint32_t iSrc = 0; iSrc < cSubtrees; iSrc++)
    13761383    {
    1377         if (!rtCrX509CpvCheckSubtreeValidity(pThis, &paSubtrees[iSrc]))
     1384        if (!rtCrX509CpvCheckSubtreeValidity(pThis, papSubtrees[iSrc]))
    13781385            return false;
    1379         pThis->v.papPermittedSubtrees[iDst] = &paSubtrees[iSrc];
     1386        pThis->v.papPermittedSubtrees[iDst] = papSubtrees[iSrc];
    13801387        iDst++;
    13811388    }
     
    13831390
    13841391    return true;
     1392}
     1393
     1394
     1395/**
     1396 * Adds a one permitted sub-tree.
     1397 *
     1398 * We store reference to each individual sub-tree because we must support
     1399 * intersection calculation.
     1400 *
     1401 * @returns success indiciator.
     1402 * @param   pThis               The validator instance.
     1403 * @param   pSubtree            Array of sub-trees to add.
     1404 */
     1405static bool rtCrX509CpvAddPermittedSubtree(PRTCRX509CERTPATHSINT pThis, PCRTCRX509GENERALSUBTREE pSubtree)
     1406{
     1407    return rtCrX509CpvAddPermittedSubtrees(pThis, 1, (PRTCRX509GENERALSUBTREE const *)&pSubtree);
    13851408}
    13861409
     
    14051428    }
    14061429
    1407     uint32_t                    cRight  = pSubtrees->cItems;
    1408     PCRTCRX509GENERALSUBTREE    paRight = pSubtrees->paItems;
     1430    uint32_t                       cRight   = pSubtrees->cItems;
     1431    PRTCRX509GENERALSUBTREE const *papRight = pSubtrees->papItems;
    14091432    if (cRight == 0)
    14101433    {
     
    14171440    PCRTCRX509GENERALSUBTREE   *papLeft = pThis->v.papPermittedSubtrees;
    14181441    if (!cLeft) /* first name constraint, no initial constraint */
    1419         return rtCrX509CpvAddPermittedSubtrees(pThis, cRight, paRight);
     1442        return rtCrX509CpvAddPermittedSubtrees(pThis, cRight, papRight);
    14201443
    14211444    /*
     
    14311454    for (uint32_t iRight = 0; iRight < cRight; iRight++)
    14321455    {
    1433         if (!rtCrX509CpvCheckSubtreeValidity(pThis, &paRight[iRight]))
     1456        if (!rtCrX509CpvCheckSubtreeValidity(pThis, papRight[iRight]))
    14341457            return false;
    14351458
    1436         RTCRX509GENERALNAMECHOICE const enmRightChoice = paRight[iRight].Base.enmChoice;
     1459        RTCRX509GENERALNAMECHOICE const enmRightChoice = papRight[iRight]->Base.enmChoice;
    14371460        afRightTags[enmRightChoice] = true;
    14381461
     
    14411464            if (papLeft[iLeft]->Base.enmChoice == enmRightChoice)
    14421465            {
    1443                 if (RTCrX509GeneralSubtree_Compare(papLeft[iLeft], &paRight[iRight]) == 0)
     1466                if (RTCrX509GeneralSubtree_Compare(papLeft[iLeft], papRight[iRight]) == 0)
    14441467                {
    14451468                    if (!fHaveRight)
    14461469                    {
    14471470                        fHaveRight = true;
    1448                         rtCrX509CpvAddPermittedSubtrees(pThis, 1, papLeft[iLeft]);
     1471                        rtCrX509CpvAddPermittedSubtree(pThis, papLeft[iLeft]);
    14491472                    }
    14501473                }
    1451                 else if (RTCrX509GeneralSubtree_ConstraintMatch(papLeft[iLeft], &paRight[iRight]))
     1474                else if (RTCrX509GeneralSubtree_ConstraintMatch(papLeft[iLeft], papRight[iRight]))
    14521475                {
    14531476                    if (!fHaveRight)
    14541477                    {
    14551478                        fHaveRight = true;
    1456                         rtCrX509CpvAddPermittedSubtrees(pThis, 1, &paRight[iRight]);
     1479                        rtCrX509CpvAddPermittedSubtree(pThis, papRight[iRight]);
    14571480                    }
    14581481                }
    1459                 else if (RTCrX509GeneralSubtree_ConstraintMatch(&paRight[iRight], papLeft[iLeft]))
    1460                     rtCrX509CpvAddPermittedSubtrees(pThis, 1, papLeft[iLeft]);
     1482                else if (RTCrX509GeneralSubtree_ConstraintMatch(papRight[iRight], papLeft[iLeft]))
     1483                    rtCrX509CpvAddPermittedSubtree(pThis, papLeft[iLeft]);
    14611484            }
    14621485    }
     
    14671490    for (uint32_t iLeft = 0; iLeft < cLeft; iLeft++)
    14681491        if (!afRightTags[papLeft[iLeft]->Base.enmChoice])
    1469             rtCrX509CpvAddPermittedSubtrees(pThis, 1, papLeft[iLeft]);
     1492            rtCrX509CpvAddPermittedSubtree(pThis, papLeft[iLeft]);
    14701493
    14711494    /*
     
    15411564        uint32_t j = pSubTrees->cItems;
    15421565        while (j-- > 0)
    1543             if (   RTCRX509GENERALNAME_IS_DIRECTORY_NAME(&pSubTrees->paItems[j].Base)
    1544                 && RTCrX509Name_ConstraintMatch(&pSubTrees->paItems[j].Base.u.pT4->DirectoryName, pName))
     1566        {
     1567            PCRTCRX509GENERALSUBTREE const pSubTree = pSubTrees->papItems[j];
     1568            if (   RTCRX509GENERALNAME_IS_DIRECTORY_NAME(&pSubTree->Base)
     1569                && RTCrX509Name_ConstraintMatch(&pSubTree->Base.u.pT4->DirectoryName, pName))
    15451570                return true;
     1571        }
    15461572    }
    15471573    return false;
     
    15661592        uint32_t j = pSubTrees->cItems;
    15671593        while (j-- > 0)
    1568             if (RTCrX509GeneralName_ConstraintMatch(&pSubTrees->paItems[j].Base, pGeneralName))
     1594            if (RTCrX509GeneralName_ConstraintMatch(&pSubTrees->papItems[j]->Base, pGeneralName))
    15691595                return true;
    15701596    }
     
    19511977    if (pThis->pInitialPermittedSubtrees)
    19521978        rtCrX509CpvAddPermittedSubtrees(pThis, pThis->pInitialPermittedSubtrees->cItems,
    1953                                         pThis->pInitialPermittedSubtrees->paItems);
     1979                                        pThis->pInitialPermittedSubtrees->papItems);
    19541980    if (pThis->pInitialExcludedSubtrees)
    19551981        rtCrX509CpvAddExcludedSubtrees(pThis, pThis->pInitialExcludedSubtrees);
     
    20532079        uint32_t i = pAltSubjectName->cItems;
    20542080        while (i-- > 0)
    2055             if (   !rtCrX509CpvIsGeneralNamePermitted(pThis, &pAltSubjectName->paItems[i])
    2056                 || rtCrX509CpvIsGeneralNameExcluded(pThis, &pAltSubjectName->paItems[i]))
     2081            if (   !rtCrX509CpvIsGeneralNamePermitted(pThis, pAltSubjectName->papItems[i])
     2082                || rtCrX509CpvIsGeneralNameExcluded(pThis, pAltSubjectName->papItems[i]))
    20572083                return rtCrX509CpvFailed(pThis, VERR_CR_X509_CPV_ALT_NAME_NOT_PERMITTED,
    20582084                                         "Alternative name #%u is is not permitted by current name constraints", i);
     
    20812107        while (i-- > 0)
    20822108        {
    2083             PCRTCRX509POLICYQUALIFIERINFOS const    pQualifiers = &pPolicies->paItems[i].PolicyQualifiers;
    2084             PCRTASN1OBJID const                     pIdP        = &pPolicies->paItems[i].PolicyIdentifier;
     2109            PCRTCRX509POLICYQUALIFIERINFOS const    pQualifiers = &pPolicies->papItems[i]->PolicyQualifiers;
     2110            PCRTASN1OBJID const                     pIdP        = &pPolicies->papItems[i]->PolicyIdentifier;
    20852111            if (RTAsn1ObjId_CompareWithString(pIdP, RTCRX509_ID_CE_CP_ANY_POLICY_OID) == 0)
    20862112            {
     
    21322158                || (pNode->pParent && fSelfIssued) ) )
    21332159        {
    2134             PCRTCRX509POLICYQUALIFIERINFOS pApQ = &pPolicies->paItems[iAnyPolicy].PolicyQualifiers;
     2160            PCRTCRX509POLICYQUALIFIERINFOS pApQ = &pPolicies->papItems[iAnyPolicy]->PolicyQualifiers;
    21352161            RTListForEach(pListAbove, pCur, RTCRX509CERTPATHSPOLICYNODE, DepthEntry)
    21362162            {
     
    21832209    while (i-- > 0)
    21842210    {
    2185         if (RTAsn1ObjId_CompareWithString(&pPolicyMappings->paItems[i].IssuerDomainPolicy, RTCRX509_ID_CE_CP_ANY_POLICY_OID) == 0)
     2211        PCRTCRX509POLICYMAPPING const pOne = pPolicyMappings->papItems[i];
     2212        if (RTAsn1ObjId_CompareWithString(&pOne->IssuerDomainPolicy, RTCRX509_ID_CE_CP_ANY_POLICY_OID) == 0)
    21862213            return rtCrX509CpvFailed(pThis, VERR_CR_X509_CPV_INVALID_POLICY_MAPPING,
    21872214                                     "Invalid policy mapping %#u: IssuerDomainPolicy is anyPolicy.", i);
    21882215
    2189         if (RTAsn1ObjId_CompareWithString(&pPolicyMappings->paItems[i].SubjectDomainPolicy, RTCRX509_ID_CE_CP_ANY_POLICY_OID) == 0)
     2216        if (RTAsn1ObjId_CompareWithString(&pOne->SubjectDomainPolicy, RTCRX509_ID_CE_CP_ANY_POLICY_OID) == 0)
    21902217            return rtCrX509CpvFailed(pThis, VERR_CR_X509_CPV_INVALID_POLICY_MAPPING,
    21912218                                     "Invalid policy mapping %#u: SubjectDomainPolicy is anyPolicy.", i);
     
    22012228        while (i-- > 0)
    22022229        {
     2230            PCRTCRX509POLICYMAPPING const pOne = pPolicyMappings->papItems[i];
     2231
    22032232            uint32_t cFound = 0;
    22042233            RTListForEach(&pThis->v.paValidPolicyDepthLists[iDepth], pCur, RTCRX509CERTPATHSPOLICYNODE, DepthEntry)
    22052234            {
    2206                 if (RTAsn1ObjId_Compare(pCur->pValidPolicy, &pPolicyMappings->paItems[i].IssuerDomainPolicy))
     2235                if (RTAsn1ObjId_Compare(pCur->pValidPolicy, &pOne->IssuerDomainPolicy))
    22072236                {
    22082237                    if (!pCur->fAlreadyMapped)
    22092238                    {
    22102239                        pCur->fAlreadyMapped = true;
    2211                         pCur->pExpectedPolicyFirst = &pPolicyMappings->paItems[i].SubjectDomainPolicy;
     2240                        pCur->pExpectedPolicyFirst = &pOne->SubjectDomainPolicy;
    22122241                    }
    22132242                    else
     
    22212250                                                     pCur->cMoreExpectedPolicySet, iDepth);
    22222251                        pCur->papMoreExpectedPolicySet = (PCRTASN1OBJID *)pvNew;
    2223                         pCur->papMoreExpectedPolicySet[iExpected] = &pPolicyMappings->paItems[i].SubjectDomainPolicy;
     2252                        pCur->papMoreExpectedPolicySet[iExpected] = &pOne->SubjectDomainPolicy;
    22242253                        pCur->cMoreExpectedPolicySet = iExpected  + 1;
    22252254                    }
     
    22382267                    {
    22392268                        if (!rtCrX509CpvPolicyTreeInsertNew(pThis, pCur->pParent, iDepth,
    2240                                                             &pPolicyMappings->paItems[i].IssuerDomainPolicy,
     2269                                                            &pOne->IssuerDomainPolicy,
    22412270                                                            pCur->pPolicyQualifiers,
    2242                                                             &pPolicyMappings->paItems[i].SubjectDomainPolicy))
     2271                                                            &pOne->SubjectDomainPolicy))
    22432272                            return false;
    22442273                        break;
     
    22582287        while (i-- > 0)
    22592288        {
     2289            PCRTCRX509POLICYMAPPING const pOne = pPolicyMappings->papItems[i];
    22602290            RTListForEachSafe(&pThis->v.paValidPolicyDepthLists[iDepth], pCur, pNext, RTCRX509CERTPATHSPOLICYNODE, DepthEntry)
    22612291            {
    2262                 if (RTAsn1ObjId_Compare(pCur->pValidPolicy, &pPolicyMappings->paItems[i].IssuerDomainPolicy))
     2292                if (RTAsn1ObjId_Compare(pCur->pValidPolicy, &pOne->IssuerDomainPolicy))
    22632293                {
    22642294                    rtCrX509CpvPolicyTreeDestroyNode(pThis, pCur);
     
    24102440static bool rtCrX509CpvCheckCriticalExtensions(PRTCRX509CERTPATHSINT pThis, PRTCRX509CERTPATHNODE pNode)
    24112441{
    2412     uint32_t                cLeft = pNode->pCert->TbsCertificate.T3.Extensions.cItems;
    2413     PCRTCRX509EXTENSION     pCur  = pNode->pCert->TbsCertificate.T3.Extensions.paItems;
     2442    uint32_t                  cLeft = pNode->pCert->TbsCertificate.T3.Extensions.cItems;
     2443    PRTCRX509EXTENSION const *ppCur = pNode->pCert->TbsCertificate.T3.Extensions.papItems;
    24142444    while (cLeft-- > 0)
    24152445    {
     2446        PCRTCRX509EXTENSION const pCur = *ppCur;
    24162447        if (pCur->Critical.fValue)
    24172448        {
     
    24312462        }
    24322463
    2433         pCur++;
     2464        ppCur++;
    24342465    }
    24352466
  • trunk/src/VBox/Runtime/common/crypto/x509-core.cpp

    r62477 r64883  
    608608        for (uint32_t iLeft = 0; iLeft < cItems; iLeft++)
    609609        {
    610             PCRTCRX509ATTRIBUTETYPEANDVALUE pLeftAttr = &pLeft->paItems[iLeft];
     610            PCRTCRX509ATTRIBUTETYPEANDVALUE pLeftAttr = pLeft->papItems[iLeft];
    611611            bool fFound = false;
    612612            for (uint32_t iRight = 0; iRight < cItems; iRight++)
    613                 if (RTCrX509AttributeTypeAndValue_MatchAsRdnByRfc5280(pLeftAttr, &pRight->paItems[iRight]))
     613                if (RTCrX509AttributeTypeAndValue_MatchAsRdnByRfc5280(pLeftAttr, pRight->papItems[iRight]))
    614614                {
    615615                    fFound = true;
     
    637637        /* Require exact order. */
    638638        for (uint32_t iRdn = 0; iRdn < cItems; iRdn++)
    639             if (!RTCrX509RelativeDistinguishedName_MatchByRfc5280(&pLeft->paItems[iRdn], &pRight->paItems[iRdn]))
     639            if (!RTCrX509RelativeDistinguishedName_MatchByRfc5280(pLeft->papItems[iRdn], pRight->papItems[iRdn]))
    640640                return false;
    641641        return true;
     
    658658        for (uint32_t i = 0; pConstraint->cItems; i++)
    659659        {
    660             PCRTCRX509RELATIVEDISTINGUISHEDNAME pConstrRdns = &pConstraint->paItems[i];
    661             PCRTCRX509RELATIVEDISTINGUISHEDNAME pNameRdns   = &pName->paItems[i];
     660            PCRTCRX509RELATIVEDISTINGUISHEDNAME pConstrRdns = pConstraint->papItems[i];
     661            PCRTCRX509RELATIVEDISTINGUISHEDNAME pNameRdns   = pName->papItems[i];
    662662
    663663            /*
     
    666666            for (uint32_t iConstrAttrib = 0; iConstrAttrib < pConstrRdns->cItems; iConstrAttrib++)
    667667            {
    668                 PCRTCRX509ATTRIBUTETYPEANDVALUE pConstrAttrib = &pConstrRdns->paItems[iConstrAttrib];
     668                PCRTCRX509ATTRIBUTETYPEANDVALUE pConstrAttrib = pConstrRdns->papItems[iConstrAttrib];
    669669
    670670                /*
     
    673673                bool fFound = false;
    674674                for (uint32_t iNameAttrib = 0; iNameAttrib < pNameRdns->cItems; iNameAttrib++)
    675                     if (RTCrX509AttributeTypeAndValue_MatchAsRdnByRfc5280(pConstrAttrib, &pNameRdns->paItems[iNameAttrib]))
     675                    if (RTCrX509AttributeTypeAndValue_MatchAsRdnByRfc5280(pConstrAttrib, pNameRdns->papItems[iNameAttrib]))
    676676                    {
    677677                        fFound = true;
     
    737737    for (uint32_t i = 0; i < pThis->cItems; i++)
    738738    {
    739         PCRTCRX509RELATIVEDISTINGUISHEDNAME pRdn = &pThis->paItems[i];
     739        PCRTCRX509RELATIVEDISTINGUISHEDNAME pRdn = pThis->papItems[i];
    740740        for (uint32_t j = 0; j < pRdn->cItems; j++)
    741741        {
    742             PCRTCRX509ATTRIBUTETYPEANDVALUE pComponent = &pRdn->paItems[j];
     742            PCRTCRX509ATTRIBUTETYPEANDVALUE pComponent = pRdn->papItems[j];
    743743
    744744            /*
     
    816816    for (uint32_t i = 0; i < pThis->cItems; i++)
    817817    {
    818         PCRTCRX509RELATIVEDISTINGUISHEDNAME pRdn = &pThis->paItems[i];
     818        PCRTCRX509RELATIVEDISTINGUISHEDNAME pRdn = pThis->papItems[i];
    819819        for (uint32_t j = 0; j < pRdn->cItems; j++)
    820820        {
    821             PCRTCRX509ATTRIBUTETYPEANDVALUE pComponent = &pRdn->paItems[j];
     821            PCRTCRX509ATTRIBUTETYPEANDVALUE pComponent = pRdn->papItems[j];
    822822
    823823            /*
     
    13321332    {
    13331333
    1334         if (RTAsn1ObjId_CompareWithString(&pObjIds->paItems[i], RTCRX509_ANY_EXTENDED_KEY_USAGE_OID) == 0)
     1334        if (RTAsn1ObjId_CompareWithString(pObjIds->papItems[i], RTCRX509_ANY_EXTENDED_KEY_USAGE_OID) == 0)
    13351335            pThis->T3.fExtKeyUsage |= RTCRX509CERT_EKU_F_ANY;
    1336         else if (RTAsn1ObjId_StartsWith(&pObjIds->paItems[i], RTCRX509_ID_KP_OID))
    1337         {
    1338             if (RTAsn1ObjIdCountComponents(&pObjIds->paItems[i]) == 9)
    1339                 switch (RTAsn1ObjIdGetLastComponentsAsUInt32(&pObjIds->paItems[i]))
     1336        else if (RTAsn1ObjId_StartsWith(pObjIds->papItems[i], RTCRX509_ID_KP_OID))
     1337        {
     1338            if (RTAsn1ObjIdCountComponents(pObjIds->papItems[i]) == 9)
     1339                switch (RTAsn1ObjIdGetLastComponentsAsUInt32(pObjIds->papItems[i]))
    13401340                {
    13411341                    case  1: pThis->T3.fExtKeyUsage |= RTCRX509CERT_EKU_F_SERVER_AUTH; break;
     
    13571357                pThis->T3.fExtKeyUsage |= RTCRX509CERT_EKU_F_OTHER;
    13581358        }
    1359         else if (RTAsn1ObjId_StartsWith(&pObjIds->paItems[i], RTCRX509_APPLE_EKU_APPLE_EXTENDED_KEY_USAGE_OID))
    1360         {
    1361             if (RTAsn1ObjId_CompareWithString(&pObjIds->paItems[i], RTCRX509_APPLE_EKU_CODE_SIGNING_OID) == 0)
     1359        else if (RTAsn1ObjId_StartsWith(pObjIds->papItems[i], RTCRX509_APPLE_EKU_APPLE_EXTENDED_KEY_USAGE_OID))
     1360        {
     1361            if (RTAsn1ObjId_CompareWithString(pObjIds->papItems[i], RTCRX509_APPLE_EKU_CODE_SIGNING_OID) == 0)
    13621362                pThis->T3.fExtKeyUsage |= RTCRX509CERT_EKU_F_APPLE_CODE_SIGNING;
    1363             else if (RTAsn1ObjId_CompareWithString(&pObjIds->paItems[i], RTCRX509_APPLE_EKU_CODE_SIGNING_DEVELOPMENT_OID) == 0)
     1363            else if (RTAsn1ObjId_CompareWithString(pObjIds->papItems[i], RTCRX509_APPLE_EKU_CODE_SIGNING_DEVELOPMENT_OID) == 0)
    13641364                pThis->T3.fExtKeyUsage |= RTCRX509CERT_EKU_F_APPLE_CODE_SIGNING_DEVELOPMENT;
    1365             else if (RTAsn1ObjId_CompareWithString(&pObjIds->paItems[i], RTCRX509_APPLE_EKU_SOFTWARE_UPDATE_SIGNING_OID) == 0)
     1365            else if (RTAsn1ObjId_CompareWithString(pObjIds->papItems[i], RTCRX509_APPLE_EKU_SOFTWARE_UPDATE_SIGNING_OID) == 0)
    13661366                pThis->T3.fExtKeyUsage |= RTCRX509CERT_EKU_F_APPLE_SOFTWARE_UPDATE_SIGNING;
    1367             else if (RTAsn1ObjId_CompareWithString(&pObjIds->paItems[i], RTCRX509_APPLE_EKU_CODE_SIGNING_THRID_PARTY_OID) == 0)
     1367            else if (RTAsn1ObjId_CompareWithString(pObjIds->papItems[i], RTCRX509_APPLE_EKU_CODE_SIGNING_THRID_PARTY_OID) == 0)
    13681368                pThis->T3.fExtKeyUsage |= RTCRX509CERT_EKU_F_APPLE_CODE_SIGNING_THIRD_PARTY;
    1369             else if (RTAsn1ObjId_CompareWithString(&pObjIds->paItems[i], RTCRX509_APPLE_EKU_RESOURCE_SIGNING_OID) == 0)
     1369            else if (RTAsn1ObjId_CompareWithString(pObjIds->papItems[i], RTCRX509_APPLE_EKU_RESOURCE_SIGNING_OID) == 0)
    13701370                pThis->T3.fExtKeyUsage |= RTCRX509CERT_EKU_F_APPLE_RESOURCE_SIGNING;
    1371             else if (RTAsn1ObjId_CompareWithString(&pObjIds->paItems[i], RTCRX509_APPLE_EKU_SYSTEM_IDENTITY_OID) == 0)
     1371            else if (RTAsn1ObjId_CompareWithString(pObjIds->papItems[i], RTCRX509_APPLE_EKU_SYSTEM_IDENTITY_OID) == 0)
    13721372                pThis->T3.fExtKeyUsage |= RTCRX509CERT_EKU_F_APPLE_SYSTEM_IDENTITY;
    13731373            else
    13741374                pThis->T3.fExtKeyUsage |= RTCRX509CERT_EKU_F_OTHER;
    13751375        }
    1376         else if (RTAsn1ObjId_StartsWith(&pObjIds->paItems[i], "1.3.6.1.4.1.311"))
    1377         {
    1378             if (RTAsn1ObjId_CompareWithString(&pObjIds->paItems[i], RTCRX509_MS_EKU_TIMESTAMP_SIGNING_OID) == 0)
     1376        else if (RTAsn1ObjId_StartsWith(pObjIds->papItems[i], "1.3.6.1.4.1.311"))
     1377        {
     1378            if (RTAsn1ObjId_CompareWithString(pObjIds->papItems[i], RTCRX509_MS_EKU_TIMESTAMP_SIGNING_OID) == 0)
    13791379                pThis->T3.fExtKeyUsage |= RTCRX509CERT_EKU_F_MS_TIMESTAMP_SIGNING;
    1380             else if (RTAsn1ObjId_CompareWithString(&pObjIds->paItems[i], RTCRX509_MS_EKU_NT5_CRYPTO_OID) == 0)
     1380            else if (RTAsn1ObjId_CompareWithString(pObjIds->papItems[i], RTCRX509_MS_EKU_NT5_CRYPTO_OID) == 0)
    13811381                pThis->T3.fExtKeyUsage |= RTCRX509CERT_EKU_F_MS_NT5_CRYPTO;
    1382             else if (RTAsn1ObjId_CompareWithString(&pObjIds->paItems[i], RTCRX509_MS_EKU_OEM_WHQL_CRYPTO_OID) == 0)
     1382            else if (RTAsn1ObjId_CompareWithString(pObjIds->papItems[i], RTCRX509_MS_EKU_OEM_WHQL_CRYPTO_OID) == 0)
    13831383                pThis->T3.fExtKeyUsage |= RTCRX509CERT_EKU_F_MS_OEM_WHQL_CRYPTO;
    1384             else if (RTAsn1ObjId_CompareWithString(&pObjIds->paItems[i], RTCRX509_MS_EKU_EMBEDDED_NT_CRYPTO_OID) == 0)
     1384            else if (RTAsn1ObjId_CompareWithString(pObjIds->papItems[i], RTCRX509_MS_EKU_EMBEDDED_NT_CRYPTO_OID) == 0)
    13851385                pThis->T3.fExtKeyUsage |= RTCRX509CERT_EKU_F_MS_EMBEDDED_NT_CRYPTO;
    1386             else if (RTAsn1ObjId_CompareWithString(&pObjIds->paItems[i], RTCRX509_MS_EKU_KERNEL_MODE_CODE_SIGNING_OID) == 0)
     1386            else if (RTAsn1ObjId_CompareWithString(pObjIds->papItems[i], RTCRX509_MS_EKU_KERNEL_MODE_CODE_SIGNING_OID) == 0)
    13871387                pThis->T3.fExtKeyUsage |= RTCRX509CERT_EKU_F_MS_KERNEL_MODE_CODE_SIGNING;
    1388             else if (RTAsn1ObjId_CompareWithString(&pObjIds->paItems[i], RTCRX509_MS_EKU_LIFETIME_SIGNING_OID) == 0)
     1388            else if (RTAsn1ObjId_CompareWithString(pObjIds->papItems[i], RTCRX509_MS_EKU_LIFETIME_SIGNING_OID) == 0)
    13891389                pThis->T3.fExtKeyUsage |= RTCRX509CERT_EKU_F_MS_LIFETIME_SIGNING;
    1390             else if (RTAsn1ObjId_CompareWithString(&pObjIds->paItems[i], RTCRX509_MS_EKU_DRM_OID) == 0)
     1390            else if (RTAsn1ObjId_CompareWithString(pObjIds->papItems[i], RTCRX509_MS_EKU_DRM_OID) == 0)
    13911391                pThis->T3.fExtKeyUsage |= RTCRX509CERT_EKU_F_MS_DRM;
    1392             else if (RTAsn1ObjId_CompareWithString(&pObjIds->paItems[i], RTCRX509_MS_EKU_DRM_INDIVIDUALIZATION_OID) == 0)
     1392            else if (RTAsn1ObjId_CompareWithString(pObjIds->papItems[i], RTCRX509_MS_EKU_DRM_INDIVIDUALIZATION_OID) == 0)
    13931393                pThis->T3.fExtKeyUsage |= RTCRX509CERT_EKU_F_MS_DRM_INDIVIDUALIZATION;
    13941394            else
     
    14431443    for (uint32_t i = 0; i < pThis->T3.Extensions.cItems; i++)
    14441444    {
    1445         PCRTASN1OBJID       pExtnId   = &pThis->T3.Extensions.paItems[i].ExtnId;
    1446         PCRTASN1OCTETSTRING pExtValue = &pThis->T3.Extensions.paItems[i].ExtnValue;
     1445        PCRTASN1OBJID       pExtnId   = &pThis->T3.Extensions.papItems[i]->ExtnId;
     1446        PCRTASN1OCTETSTRING pExtValue = &pThis->T3.Extensions.papItems[i]->ExtnValue;
    14471447        if (RTAsn1ObjId_CompareWithString(pExtnId, RTCRX509_ID_CE_KEY_USAGE_OID) == 0)
    14481448        {
    14491449            CHECK_SET_PRESENT_RET_ON_DUP(pThis, pErrInfo, RTCRX509TBSCERTIFICATE_F_PRESENT_KEY_USAGE);
    1450             rtCrx509TbsCertificate_AddKeyUsageFlags(pThis, &pThis->T3.Extensions.paItems[i]);
    1451             Assert(pThis->T3.Extensions.paItems[i].enmValue == RTCRX509EXTENSIONVALUE_BIT_STRING);
     1450            rtCrx509TbsCertificate_AddKeyUsageFlags(pThis, pThis->T3.Extensions.papItems[i]);
     1451            Assert(pThis->T3.Extensions.papItems[i]->enmValue == RTCRX509EXTENSIONVALUE_BIT_STRING);
    14521452        }
    14531453        else if (RTAsn1ObjId_CompareWithString(pExtnId, RTCRX509_ID_CE_EXT_KEY_USAGE_OID) == 0)
    14541454        {
    14551455            CHECK_SET_PRESENT_RET_ON_DUP(pThis, pErrInfo, RTCRX509TBSCERTIFICATE_F_PRESENT_EXT_KEY_USAGE);
    1456             rtCrx509TbsCertificate_AddExtKeyUsageFlags(pThis, &pThis->T3.Extensions.paItems[i]);
    1457             Assert(pThis->T3.Extensions.paItems[i].enmValue == RTCRX509EXTENSIONVALUE_SEQ_OF_OBJ_IDS);
     1456            rtCrx509TbsCertificate_AddExtKeyUsageFlags(pThis, pThis->T3.Extensions.papItems[i]);
     1457            Assert(pThis->T3.Extensions.papItems[i]->enmValue == RTCRX509EXTENSIONVALUE_SEQ_OF_OBJ_IDS);
    14581458        }
    14591459        else if (RTAsn1ObjId_CompareWithString(pExtnId, RTCRX509_ID_CE_AUTHORITY_KEY_IDENTIFIER_OID) == 0)
     
    14611461            CHECK_SET_PRESENT_RET_ON_DUP(pThis, pErrInfo, RTCRX509TBSCERTIFICATE_F_PRESENT_AUTHORITY_KEY_IDENTIFIER);
    14621462            pThis->T3.pAuthorityKeyIdentifier = (PCRTCRX509AUTHORITYKEYIDENTIFIER)pExtValue->pEncapsulated;
    1463             Assert(pThis->T3.Extensions.paItems[i].enmValue == RTCRX509EXTENSIONVALUE_AUTHORITY_KEY_IDENTIFIER);
     1463            Assert(pThis->T3.Extensions.papItems[i]->enmValue == RTCRX509EXTENSIONVALUE_AUTHORITY_KEY_IDENTIFIER);
    14641464        }
    14651465        else if (RTAsn1ObjId_CompareWithString(pExtnId, RTCRX509_ID_CE_OLD_AUTHORITY_KEY_IDENTIFIER_OID) == 0)
     
    14671467            CHECK_SET_PRESENT_RET_ON_DUP(pThis, pErrInfo, RTCRX509TBSCERTIFICATE_F_PRESENT_OLD_AUTHORITY_KEY_IDENTIFIER);
    14681468            pThis->T3.pOldAuthorityKeyIdentifier = (PCRTCRX509OLDAUTHORITYKEYIDENTIFIER)pExtValue->pEncapsulated;
    1469             Assert(pThis->T3.Extensions.paItems[i].enmValue == RTCRX509EXTENSIONVALUE_OLD_AUTHORITY_KEY_IDENTIFIER);
     1469            Assert(pThis->T3.Extensions.papItems[i]->enmValue == RTCRX509EXTENSIONVALUE_OLD_AUTHORITY_KEY_IDENTIFIER);
    14701470        }
    14711471        else if (RTAsn1ObjId_CompareWithString(pExtnId, RTCRX509_ID_CE_SUBJECT_KEY_IDENTIFIER_OID) == 0)
     
    14731473            CHECK_SET_PRESENT_RET_ON_DUP(pThis, pErrInfo, RTCRX509TBSCERTIFICATE_F_PRESENT_SUBJECT_KEY_IDENTIFIER);
    14741474            pThis->T3.pSubjectKeyIdentifier = (PCRTASN1OCTETSTRING)pExtValue->pEncapsulated;
    1475             Assert(pThis->T3.Extensions.paItems[i].enmValue == RTCRX509EXTENSIONVALUE_OCTET_STRING);
     1475            Assert(pThis->T3.Extensions.papItems[i]->enmValue == RTCRX509EXTENSIONVALUE_OCTET_STRING);
    14761476        }
    14771477        else if (RTAsn1ObjId_CompareWithString(pExtnId, RTCRX509_ID_CE_SUBJECT_ALT_NAME_OID) == 0)
     
    14791479            CHECK_SET_PRESENT_RET_ON_DUP(pThis, pErrInfo, RTCRX509TBSCERTIFICATE_F_PRESENT_SUBJECT_ALT_NAME);
    14801480            pThis->T3.pAltSubjectName = (PCRTCRX509GENERALNAMES)pExtValue->pEncapsulated;
    1481             Assert(pThis->T3.Extensions.paItems[i].enmValue == RTCRX509EXTENSIONVALUE_GENERAL_NAMES);
     1481            Assert(pThis->T3.Extensions.papItems[i]->enmValue == RTCRX509EXTENSIONVALUE_GENERAL_NAMES);
    14821482        }
    14831483        else if (RTAsn1ObjId_CompareWithString(pExtnId, RTCRX509_ID_CE_ISSUER_ALT_NAME_OID) == 0)
     
    14851485            CHECK_SET_PRESENT_RET_ON_DUP(pThis, pErrInfo, RTCRX509TBSCERTIFICATE_F_PRESENT_ISSUER_ALT_NAME);
    14861486            pThis->T3.pAltIssuerName = (PCRTCRX509GENERALNAMES)pExtValue->pEncapsulated;
    1487             Assert(pThis->T3.Extensions.paItems[i].enmValue == RTCRX509EXTENSIONVALUE_GENERAL_NAMES);
     1487            Assert(pThis->T3.Extensions.papItems[i]->enmValue == RTCRX509EXTENSIONVALUE_GENERAL_NAMES);
    14881488        }
    14891489        else if (RTAsn1ObjId_CompareWithString(pExtnId, RTCRX509_ID_CE_CERTIFICATE_POLICIES_OID) == 0)
     
    14911491            CHECK_SET_PRESENT_RET_ON_DUP(pThis, pErrInfo, RTCRX509TBSCERTIFICATE_F_PRESENT_CERTIFICATE_POLICIES);
    14921492            pThis->T3.pCertificatePolicies = (PCRTCRX509CERTIFICATEPOLICIES)pExtValue->pEncapsulated;
    1493             Assert(pThis->T3.Extensions.paItems[i].enmValue == RTCRX509EXTENSIONVALUE_CERTIFICATE_POLICIES);
     1493            Assert(pThis->T3.Extensions.papItems[i]->enmValue == RTCRX509EXTENSIONVALUE_CERTIFICATE_POLICIES);
    14941494        }
    14951495        else if (RTAsn1ObjId_CompareWithString(pExtnId, RTCRX509_ID_CE_POLICY_MAPPINGS_OID) == 0)
     
    14971497            CHECK_SET_PRESENT_RET_ON_DUP(pThis, pErrInfo, RTCRX509TBSCERTIFICATE_F_PRESENT_POLICY_MAPPINGS);
    14981498            pThis->T3.pPolicyMappings = (PCRTCRX509POLICYMAPPINGS)pExtValue->pEncapsulated;
    1499             Assert(pThis->T3.Extensions.paItems[i].enmValue == RTCRX509EXTENSIONVALUE_POLICY_MAPPINGS);
     1499            Assert(pThis->T3.Extensions.papItems[i]->enmValue == RTCRX509EXTENSIONVALUE_POLICY_MAPPINGS);
    15001500        }
    15011501        else if (RTAsn1ObjId_CompareWithString(pExtnId, RTCRX509_ID_CE_BASIC_CONSTRAINTS_OID) == 0)
     
    15031503            CHECK_SET_PRESENT_RET_ON_DUP(pThis, pErrInfo, RTCRX509TBSCERTIFICATE_F_PRESENT_BASIC_CONSTRAINTS);
    15041504            pThis->T3.pBasicConstraints = (PCRTCRX509BASICCONSTRAINTS)pExtValue->pEncapsulated;
    1505             Assert(pThis->T3.Extensions.paItems[i].enmValue == RTCRX509EXTENSIONVALUE_BASIC_CONSTRAINTS);
     1505            Assert(pThis->T3.Extensions.papItems[i]->enmValue == RTCRX509EXTENSIONVALUE_BASIC_CONSTRAINTS);
    15061506        }
    15071507        else if (RTAsn1ObjId_CompareWithString(pExtnId, RTCRX509_ID_CE_NAME_CONSTRAINTS_OID) == 0)
     
    15091509            CHECK_SET_PRESENT_RET_ON_DUP(pThis, pErrInfo, RTCRX509TBSCERTIFICATE_F_PRESENT_NAME_CONSTRAINTS);
    15101510            pThis->T3.pNameConstraints = (PCRTCRX509NAMECONSTRAINTS)pExtValue->pEncapsulated;
    1511             Assert(pThis->T3.Extensions.paItems[i].enmValue == RTCRX509EXTENSIONVALUE_NAME_CONSTRAINTS);
     1511            Assert(pThis->T3.Extensions.papItems[i]->enmValue == RTCRX509EXTENSIONVALUE_NAME_CONSTRAINTS);
    15121512        }
    15131513        else if (RTAsn1ObjId_CompareWithString(pExtnId, RTCRX509_ID_CE_POLICY_CONSTRAINTS_OID) == 0)
     
    15151515            CHECK_SET_PRESENT_RET_ON_DUP(pThis, pErrInfo, RTCRX509TBSCERTIFICATE_F_PRESENT_POLICY_CONSTRAINTS);
    15161516            pThis->T3.pPolicyConstraints = (PCRTCRX509POLICYCONSTRAINTS)pExtValue->pEncapsulated;
    1517             Assert(pThis->T3.Extensions.paItems[i].enmValue == RTCRX509EXTENSIONVALUE_POLICY_CONSTRAINTS);
     1517            Assert(pThis->T3.Extensions.papItems[i]->enmValue == RTCRX509EXTENSIONVALUE_POLICY_CONSTRAINTS);
    15181518        }
    15191519        else if (RTAsn1ObjId_CompareWithString(pExtnId, RTCRX509_ID_CE_INHIBIT_ANY_POLICY_OID) == 0)
     
    15211521            CHECK_SET_PRESENT_RET_ON_DUP(pThis, pErrInfo, RTCRX509TBSCERTIFICATE_F_PRESENT_INHIBIT_ANY_POLICY);
    15221522            pThis->T3.pInhibitAnyPolicy = (PCRTASN1INTEGER)pExtValue->pEncapsulated;
    1523             Assert(pThis->T3.Extensions.paItems[i].enmValue == RTCRX509EXTENSIONVALUE_INTEGER);
     1523            Assert(pThis->T3.Extensions.papItems[i]->enmValue == RTCRX509EXTENSIONVALUE_INTEGER);
    15241524        }
    15251525        else if (RTAsn1ObjId_CompareWithString(pExtnId, RTCRX509_ID_CE_ACCEPTABLE_CERT_POLICIES_OID) == 0)
     
    15601560        for (uint32_t i = 0; i < pThis->TbsCertificate.T3.Extensions.cItems; i++)
    15611561        {
    1562             PCRTCRX509EXTENSION pExt = &pThis->TbsCertificate.T3.Extensions.paItems[i];
     1562            PCRTCRX509EXTENSION pExt = pThis->TbsCertificate.T3.Extensions.papItems[i];
    15631563            if (   pExt->enmValue == RTCRX509EXTENSIONVALUE_GENERAL_NAMES
    15641564                && RTAsn1ObjId_CompareWithString(&pExt->ExtnId, RTCRX509_ID_CE_SUBJECT_ALT_NAME_OID))
     
    15661566                PCRTCRX509GENERALNAMES pGeneralNames = (PCRTCRX509GENERALNAMES)pExt->ExtnValue.pEncapsulated;
    15671567                for (uint32_t j = 0; j < pGeneralNames->cItems; j++)
    1568                     if (   RTCRX509GENERALNAME_IS_DIRECTORY_NAME(&pGeneralNames->paItems[j])
    1569                         && RTCrX509Name_MatchByRfc5280(&pGeneralNames->paItems[j].u.pT4->DirectoryName, pName))
     1568                    if (   RTCRX509GENERALNAME_IS_DIRECTORY_NAME(pGeneralNames->papItems[j])
     1569                        && RTCrX509Name_MatchByRfc5280(&pGeneralNames->papItems[j]->u.pT4->DirectoryName, pName))
    15701570                        return true;
    15711571            }
     
    15951595{
    15961596    for (uint32_t i = 0; i < pCertificates->cItems; i++)
    1597         if (RTCrX509Certificate_MatchIssuerAndSerialNumber(&pCertificates->paItems[i], pIssuer, pSerialNumber))
    1598             return &pCertificates->paItems[i];
     1597        if (RTCrX509Certificate_MatchIssuerAndSerialNumber(pCertificates->papItems[i], pIssuer, pSerialNumber))
     1598            return pCertificates->papItems[i];
    15991599    return NULL;
    16001600}
  • trunk/src/VBox/Runtime/common/crypto/x509-init.cpp

    r62477 r64883  
    4949{
    5050    uint32_t                            cRdns = pThis->cItems;
    51     PRTCRX509RELATIVEDISTINGUISHEDNAME  pRdn   = &pThis->paItems[0];
     51    PRTCRX509RELATIVEDISTINGUISHEDNAME *ppRdn = pThis->papItems;
    5252    while (cRdns-- > 0)
    5353    {
    54         uint32_t                        cAttribs = pRdn->cItems;
    55         PRTCRX509ATTRIBUTETYPEANDVALUE  pAttrib  = &pRdn->paItems[0];
     54        PRTCRX509RELATIVEDISTINGUISHEDNAME const pRdn     = *ppRdn;
     55        uint32_t                                 cAttribs = pRdn->cItems;
     56        PRTCRX509ATTRIBUTETYPEANDVALUE          *ppAttrib = pRdn->papItems;
    5657        while (cAttribs-- > 0)
    5758        {
     59            PRTCRX509ATTRIBUTETYPEANDVALUE const pAttrib = *ppAttrib;
    5860            if (pAttrib->Value.enmType == RTASN1TYPE_STRING)
    5961            {
     
    6264                    return rc;
    6365            }
    64             pAttrib++;
     66            ppAttrib++;
    6567        }
    66         pRdn++;
     68        ppRdn++;
    6769    }
    6870    return VINF_SUCCESS;
  • trunk/src/VBox/Runtime/common/crypto/x509-sanity.cpp

    r62564 r64883  
    5959    for (uint32_t i = 0; i < pThis->cItems; i++)
    6060    {
    61         if (pThis->cItems == 0)
     61        PCRTCRX509RELATIVEDISTINGUISHEDNAME const pRdn = pThis->papItems[i];
     62        if (pRdn->cItems == 0)
    6263            return RTErrInfoSetF(pErrInfo, VERR_CR_X509_NAME_EMPTY_SUB_SET,
    6364                                 "%s: Items[%u] has no sub components.", pszErrorTag, i);
    6465
    65         for (uint32_t j = 0; j < pThis->paItems[i].cItems; j++)
     66        for (uint32_t j = 0; j < pRdn->cItems; j++)
    6667        {
    67             if (pThis->paItems[i].paItems[j].Value.enmType != RTASN1TYPE_STRING)
     68            PCRTCRX509ATTRIBUTETYPEANDVALUE const pAttr = pRdn->papItems[j];
     69
     70            if (pAttr->Value.enmType != RTASN1TYPE_STRING)
    6871                return RTErrInfoSetF(pErrInfo, VERR_CR_X509_NAME_NOT_STRING,
    6972                                     "%s: Items[%u].paItems[%u].enmType is %d instead of string (%d).",
    70                                      pszErrorTag, i, j, pThis->paItems[i].paItems[j].Value.enmType, RTASN1TYPE_STRING);
    71             if (pThis->paItems[i].paItems[j].Value.u.String.Asn1Core.cb == 0)
     73                                     pszErrorTag, i, j, pAttr->Value.enmType, RTASN1TYPE_STRING);
     74            if (pAttr->Value.u.String.Asn1Core.cb == 0)
    7275                return RTErrInfoSetF(pErrInfo, VERR_CR_X509_NAME_EMPTY_STRING,
    7376                                     "%s: Items[%u].paItems[%u] is an empty string", pszErrorTag, i, j);
    74             switch (pThis->paItems[i].paItems[j].Value.u.String.Asn1Core.uTag)
     77            switch (pAttr->Value.u.String.Asn1Core.uTag)
    7578            {
    7679                case ASN1_TAG_PRINTABLE_STRING:
     
    8689                    return RTErrInfoSetF(pErrInfo, VERR_CR_X509_INVALID_NAME_STRING_TAG,
    8790                                         "%s: Items[%u].paItems[%u] invalid string type: %u",  pszErrorTag, i, j,
    88                                          pThis->paItems[i].paItems[j].Value.u.String.Asn1Core.uTag);
     91                                         pAttr->Value.u.String.Asn1Core.uTag);
    8992            }
    9093        }
Note: See TracChangeset for help on using the changeset viewer.

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