VirtualBox

Changeset 99668 in vbox


Ignore:
Timestamp:
May 8, 2023 1:03:08 PM (19 months ago)
Author:
vboxsync
Message:

IPRT/ldrPE: Added support for SHA384 image signatures. bugref:10439

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/ldr/ldrPE.cpp

    r98103 r99668  
    191191{
    192192    RTSHA512CONTEXT Sha512;
     193    RTSHA384CONTEXT Sha384;
    193194    RTSHA256CONTEXT Sha256;
    194195    RTSHA1CONTEXT   Sha1;
     
    205206{
    206207    uint8_t abSha512[RTSHA512_HASH_SIZE];
     208    uint8_t abSha384[RTSHA384_HASH_SIZE];
    207209    uint8_t abSha256[RTSHA256_HASH_SIZE];
    208210    uint8_t abSha1[RTSHA1_HASH_SIZE];
     
    21812183    {
    21822184        case RTDIGESTTYPE_SHA512:  RTSha512Init(&pHashCtx->Sha512); break;
     2185        case RTDIGESTTYPE_SHA384:  RTSha384Init(&pHashCtx->Sha384); break;
    21832186        case RTDIGESTTYPE_SHA256:  RTSha256Init(&pHashCtx->Sha256); break;
    21842187        case RTDIGESTTYPE_SHA1:    RTSha1Init(&pHashCtx->Sha1); break;
     
    22032206    {
    22042207        case RTDIGESTTYPE_SHA512:  RTSha512Update(&pHashCtx->Sha512, pvBuf, cbBuf); break;
     2208        case RTDIGESTTYPE_SHA384:  RTSha384Update(&pHashCtx->Sha384, pvBuf, cbBuf); break;
    22052209        case RTDIGESTTYPE_SHA256:  RTSha256Update(&pHashCtx->Sha256, pvBuf, cbBuf); break;
    22062210        case RTDIGESTTYPE_SHA1:    RTSha1Update(&pHashCtx->Sha1, pvBuf, cbBuf); break;
     
    22232227    {
    22242228        case RTDIGESTTYPE_SHA512:  RTSha512Final(&pHashCtx->Sha512, pHashRes->abSha512); break;
     2229        case RTDIGESTTYPE_SHA384:  RTSha384Final(&pHashCtx->Sha384, pHashRes->abSha384); break;
    22252230        case RTDIGESTTYPE_SHA256:  RTSha256Final(&pHashCtx->Sha256, pHashRes->abSha256); break;
    22262231        case RTDIGESTTYPE_SHA1:    RTSha1Final(&pHashCtx->Sha1, pHashRes->abSha1); break;
     
    22422247    {
    22432248        case RTDIGESTTYPE_SHA512:  return RTSHA512_HASH_SIZE;
     2249        case RTDIGESTTYPE_SHA384:  return RTSHA384_HASH_SIZE;
    22442250        case RTDIGESTTYPE_SHA256:  return RTSHA256_HASH_SIZE;
    22452251        case RTDIGESTTYPE_SHA1:    return RTSHA1_HASH_SIZE;
    22462252        case RTDIGESTTYPE_MD5:     return RTMD5_HASH_SIZE;
    22472253        default:                   AssertReleaseFailedReturn(0);
     2254    }
     2255}
     2256
     2257
     2258/**
     2259 * Checks if the hash type is supported.
     2260 *
     2261 * @returns true/false.
     2262 * @param   enmDigest           The hash type in question.
     2263 */
     2264static bool rtLdrPE_HashIsSupported(RTDIGESTTYPE enmDigest)
     2265{
     2266    switch (enmDigest)
     2267    {
     2268        case RTDIGESTTYPE_SHA512:
     2269        case RTDIGESTTYPE_SHA384:
     2270        case RTDIGESTTYPE_SHA256:
     2271        case RTDIGESTTYPE_SHA1:
     2272        case RTDIGESTTYPE_MD5:
     2273            return true;
     2274        default:
     2275            return false;
    22482276    }
    22492277}
     
    32473275    AssertReturn(RTASN1CORE_IS_PRESENT(&pInfo->pIndData->DigestInfo.Digest.Asn1Core), VERR_INTERNAL_ERROR_5);
    32483276    AssertPtrReturn(pInfo->pIndData->DigestInfo.Digest.Asn1Core.uData.pv, VERR_INTERNAL_ERROR_5);
     3277
     3278    /* Check that the hash is supported by the code here before continuing. */
     3279    AssertReturn(rtLdrPE_HashIsSupported(pInfo->enmDigest),
     3280                 RTErrInfoSetF(pErrInfo, VERR_CR_DIGEST_NOT_SUPPORTED, "Unsupported digest type: %d", pInfo->enmDigest));
    32493281
    32503282    /*
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