VirtualBox

Ignore:
Timestamp:
Aug 6, 2020 12:56:34 AM (4 years ago)
Author:
vboxsync
Message:

IPRT: More SHA-3 work. bugref:9734

Location:
trunk/src/VBox/Runtime/common/crypto
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/crypto/pkix-signature-rsa.cpp

    r84251 r85629  
    112112    0x30,0x2d, 0x30,0x0d, 0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x04,   0x05,0x00,  0x04,0x1c
    113113};
    114 static const uint8_t g_abSha512T224[] =
     114static const uint8_t g_abSha512t224[] =
    115115{/* {          {          2.16.840.1.101.3.4.2.5 (SHA-512T224),                     NULL },     hash octet-string } */
    116116    0x30,0x2d, 0x30,0x0d, 0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x05,   0x05,0x00,  0x04,0x1c
    117117};
    118 static const uint8_t g_abSha512T256[] =
     118static const uint8_t g_abSha512t256[] =
    119119{/* {          {          2.16.840.1.101.3.4.2.6 (SHA-512T256),                     NULL },     hash octet-string } */
    120120    0x30,0x31, 0x30,0x0d, 0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x06,   0x05,0x00,  0x04,0x20
     121};
     122static const uint8_t g_abSha3t224[] =
     123{/* {          {          2.16.840.1.101.3.4.2.7 (SHA3-224),                        NULL },     hash octet-string } */
     124    0x30,0x31, 0x30,0x0d, 0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x07,   0x05,0x00,  0x04,0x1c
     125};
     126static const uint8_t g_abSha3t256[] =
     127{/* {          {          2.16.840.1.101.3.4.2.8 (SHA3-256),                        NULL },     hash octet-string } */
     128    0x30,0x31, 0x30,0x0d, 0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x08,   0x05,0x00,  0x04,0x20
     129};
     130static const uint8_t g_abSha3t384[] =
     131{/* {          {          2.16.840.1.101.3.4.2.9 (SHA3-384),                        NULL },     hash octet-string } */
     132    0x30,0x31, 0x30,0x0d, 0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x09,   0x05,0x00,  0x04,0x30
     133};
     134static const uint8_t g_abSha3t512[] =
     135{/* {          {          2.16.840.1.101.3.4.2.10 (SHA3-512),                       NULL },     hash octet-string } */
     136    0x30,0x31, 0x30,0x0d, 0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x0a,   0x05,0x00,  0x04,0x40
    121137};
    122138/** @} */
     
    138154    { RTDIGESTTYPE_SHA384,      g_abSha384,     sizeof(g_abSha384) },
    139155    { RTDIGESTTYPE_SHA224,      g_abSha224,     sizeof(g_abSha224) },
    140     { RTDIGESTTYPE_SHA512T224,  g_abSha512T224, sizeof(g_abSha512T224)},
    141     { RTDIGESTTYPE_SHA512T256,  g_abSha512T256, sizeof(g_abSha512T256)},
     156    { RTDIGESTTYPE_SHA512T224,  g_abSha512t224, sizeof(g_abSha512t224)},
     157    { RTDIGESTTYPE_SHA512T256,  g_abSha512t256, sizeof(g_abSha512t256)},
     158    { RTDIGESTTYPE_SHA3_224,    g_abSha3t224,   sizeof(g_abSha3t224) },
     159    { RTDIGESTTYPE_SHA3_256,    g_abSha3t256,   sizeof(g_abSha3t256) },
     160    { RTDIGESTTYPE_SHA3_384,    g_abSha3t384,   sizeof(g_abSha3t384) },
     161    { RTDIGESTTYPE_SHA3_512,    g_abSha3t512,   sizeof(g_abSha3t512) },
    142162};
    143163
  • trunk/src/VBox/Runtime/common/crypto/x509-core.cpp

    r84248 r85629  
    8383    if (!strcmp(pThis->Algorithm.szObjId, RTCRX509ALGORITHMIDENTIFIERID_SHA512T256))
    8484        return RTDIGESTTYPE_SHA512T256;
     85
     86    if (!strcmp(pThis->Algorithm.szObjId, RTCRX509ALGORITHMIDENTIFIERID_SHA3_224))
     87        return RTDIGESTTYPE_SHA3_224;
     88    if (!strcmp(pThis->Algorithm.szObjId, RTCRX509ALGORITHMIDENTIFIERID_SHA3_256))
     89        return RTDIGESTTYPE_SHA3_256;
     90    if (!strcmp(pThis->Algorithm.szObjId, RTCRX509ALGORITHMIDENTIFIERID_SHA3_384))
     91        return RTDIGESTTYPE_SHA3_384;
     92    if (!strcmp(pThis->Algorithm.szObjId, RTCRX509ALGORITHMIDENTIFIERID_SHA3_512))
     93        return RTDIGESTTYPE_SHA3_512;
    8594    return RTDIGESTTYPE_INVALID;
    8695}
     
    114123    if (!strcmp(pThis->Algorithm.szObjId, RTCRX509ALGORITHMIDENTIFIERID_SHA512T256))
    115124        return 256 / 8;
     125    if (!strcmp(pThis->Algorithm.szObjId, RTCRX509ALGORITHMIDENTIFIERID_SHA3_224))
     126        return 224 / 8;
     127    if (!strcmp(pThis->Algorithm.szObjId, RTCRX509ALGORITHMIDENTIFIERID_SHA3_256))
     128        return 256 / 8;
     129    if (!strcmp(pThis->Algorithm.szObjId, RTCRX509ALGORITHMIDENTIFIERID_SHA3_384))
     130        return 384 / 8;
     131    if (!strcmp(pThis->Algorithm.szObjId, RTCRX509ALGORITHMIDENTIFIERID_SHA3_512))
     132        return 512 / 8;
    116133    if (!strcmp(pThis->Algorithm.szObjId, RTCRX509ALGORITHMIDENTIFIERID_WHIRLPOOL))
    117134        return 512 / 8;
     
    180197    {
    181198        if (!strcmp(pszEncryptedDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA512T256_WITH_RSA))
     199            return 0;
     200    }
     201    else if (!strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA3_224))
     202    {
     203        if (!strcmp(pszEncryptedDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA3_224_WITH_RSA))
     204            return 0;
     205    }
     206    else if (!strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA3_256))
     207    {
     208        if (!strcmp(pszEncryptedDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA3_256_WITH_RSA))
     209            return 0;
     210    }
     211    else if (!strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA3_384))
     212    {
     213        if (!strcmp(pszEncryptedDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA3_384_WITH_RSA))
     214            return 0;
     215    }
     216    else if (!strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA3_512))
     217    {
     218        if (!strcmp(pszEncryptedDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA3_512_WITH_RSA))
    182219            return 0;
    183220    }
     
    235272            || !strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA512T256_WITH_RSA))
    236273            return RTCRX509ALGORITHMIDENTIFIERID_SHA512T256_WITH_RSA;
     274        if (   !strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA3_224)
     275            || !strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA3_224_WITH_RSA))
     276            return RTCRX509ALGORITHMIDENTIFIERID_SHA3_224_WITH_RSA;
     277        if (   !strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA3_256)
     278            || !strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA3_256_WITH_RSA))
     279            return RTCRX509ALGORITHMIDENTIFIERID_SHA3_256_WITH_RSA;
     280        if (   !strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA3_384)
     281            || !strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA3_384_WITH_RSA))
     282            return RTCRX509ALGORITHMIDENTIFIERID_SHA3_384_WITH_RSA;
     283        if (   !strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA3_512)
     284            || !strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_SHA3_512_WITH_RSA))
     285            return RTCRX509ALGORITHMIDENTIFIERID_SHA3_512_WITH_RSA;
    237286
    238287        /* if (!strcmp(pszDigestOid, RTCRX509ALGORITHMIDENTIFIERID_WHIRLPOOL))
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