VirtualBox

Ignore:
Timestamp:
Sep 4, 2014 10:59:00 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
95876
Message:

IPRT: Added support for microsoft timestamp counter signatures. This required making the PKCS #7 code accept some of the CMS (RFC-5652) stuff.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/crypto/pkcs7-core.cpp

    r52537 r52600  
    3434#include <iprt/err.h>
    3535#include <iprt/string.h>
     36#include <iprt/crypto/tsp.h>
    3637
    3738#include "pkcs7-internal.h"
     
    127128
    128129
     130RTDECL(PCRTASN1TIME) RTCrPkcs7SignerInfo_GetMsTimestamp(PCRTCRPKCS7SIGNERINFO pThis, PCRTCRPKCS7CONTENTINFO *ppContentInfo)
     131{
     132    /*
     133     * Assume there is only one, so no need to enumerate anything here.
     134     */
     135    uint32_t             cAttrsLeft = pThis->UnauthenticatedAttributes.cItems;
     136    PCRTCRPKCS7ATTRIBUTE pAttr      = pThis->UnauthenticatedAttributes.paItems;
     137    while (cAttrsLeft-- > 0)
     138    {
     139        if (pAttr->enmType == RTCRPKCS7ATTRIBUTETYPE_MS_TIMESTAMP)
     140        {
     141            uint32_t                cLeft        = pAttr->uValues.pContentInfos->cItems;
     142            PCRTCRPKCS7CONTENTINFO  pContentInfo = &pAttr->uValues.pContentInfos->paItems[0];
     143            while (cLeft-- > 0)
     144            {
     145                if (RTAsn1ObjId_CompareWithString(&pContentInfo->ContentType, RTCRPKCS7SIGNEDDATA_OID) == 0)
     146                {
     147                    if (RTAsn1ObjId_CompareWithString(&pContentInfo->u.pSignedData->ContentInfo.ContentType,
     148                                                      RTCRTSPTSTINFO_OID) == 0)
     149                    {
     150                        if (ppContentInfo)
     151                            *ppContentInfo = pContentInfo;
     152                        return &pContentInfo->u.pSignedData->ContentInfo.u.pTstInfo->GenTime;
     153                    }
     154                }
     155
     156                pContentInfo++;
     157            }
     158        }
     159        pAttr++;
     160    }
     161
     162    /*
     163     * No signature was found.
     164     */
     165    if (ppContentInfo)
     166        *ppContentInfo = NULL;
     167
     168    return NULL;
     169}
     170
     171
    129172/*
    130173 * PCKS #7 ContentInfo.
     
    138181
    139182/*
     183 * Set of some kind of certificate supported by PKCS #7 or CMS.
     184 */
     185
     186RTDECL(PCRTCRX509CERTIFICATE)
     187RTCrPkcs7SetOfCerts_FindX509ByIssuerAndSerialNumber(PCRTCRPKCS7SETOFCERTS pCertificates,
     188                                                    PCRTCRX509NAME pIssuer, PCRTASN1INTEGER pSerialNumber)
     189{
     190    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;
     194    return NULL;
     195}
     196
     197
     198/*
    140199 * Generate the standard core code.
    141200 */
Note: See TracChangeset for help on using the changeset viewer.

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