VirtualBox

Changeset 51861 in vbox for trunk/src


Ignore:
Timestamp:
Jul 3, 2014 10:56:18 PM (11 years ago)
Author:
vboxsync
Message:

clear the context after use, converted SHA-1 to use an array of H values.

Location:
trunk/src/VBox/Runtime/common/checksum
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/checksum/alt-md2.cpp

    r51851 r51861  
    256256    memcpy(pabDigest, pCtx->AltPrivate.abStateX, RTMD2_HASH_SIZE);
    257257
     258    RT_ZERO(pCtx->AltPrivate);
    258259    pCtx->AltPrivate.cbBuffer = UINT8_MAX;
    259260}
  • trunk/src/VBox/Runtime/common/checksum/alt-sha1.cpp

    r51851 r51861  
    5353    /** The message length (in bytes). */
    5454    uint64_t    cbMessage;
    55     /** @name The 5 hash values.
    56      * @{ */
    57     uint32_t    uH0;
    58     uint32_t    uH1;
    59     uint32_t    uH2;
    60     uint32_t    uH3;
    61     uint32_t    uH4;
    62     /** @} */
     55
     56    /** The 5 hash values. */
     57    uint32_t    auH[5];
    6358} RTSHA1ALTPRIVATECTX;
    6459
     
    6863
    6964AssertCompile(RT_SIZEOFMEMB(RTSHA1CONTEXT, abPadding) >= RT_SIZEOFMEMB(RTSHA1CONTEXT, AltPrivate));
    70 AssertCompileMemberSize(RTSHA1ALTPRIVATECTX, uH0, sizeof(uint32_t)); AssertCompileAdjacentMembers(RTSHA1ALTPRIVATECTX, uH0, uH1);
    71 AssertCompileMemberSize(RTSHA1ALTPRIVATECTX, uH1, sizeof(uint32_t)); AssertCompileAdjacentMembers(RTSHA1ALTPRIVATECTX, uH1, uH2);
    72 AssertCompileMemberSize(RTSHA1ALTPRIVATECTX, uH2, sizeof(uint32_t)); AssertCompileAdjacentMembers(RTSHA1ALTPRIVATECTX, uH2, uH3);
    73 AssertCompileMemberSize(RTSHA1ALTPRIVATECTX, uH3, sizeof(uint32_t)); AssertCompileAdjacentMembers(RTSHA1ALTPRIVATECTX, uH3, uH4);
    74 AssertCompileMemberSize(RTSHA1ALTPRIVATECTX, uH4, sizeof(uint32_t)); AssertCompile(sizeof(uint32_t) * 5 == RTSHA1_HASH_SIZE);
     65AssertCompileMemberSize(RTSHA1ALTPRIVATECTX, auH, RTSHA1_HASH_SIZE);
    7566
    7667
     
    8071{
    8172    pCtx->AltPrivate.cbMessage = 0;
    82     pCtx->AltPrivate.uH0 = UINT32_C(0x67452301);
    83     pCtx->AltPrivate.uH1 = UINT32_C(0xefcdab89);
    84     pCtx->AltPrivate.uH2 = UINT32_C(0x98badcfe);
    85     pCtx->AltPrivate.uH3 = UINT32_C(0x10325476);
    86     pCtx->AltPrivate.uH4 = UINT32_C(0xc3d2e1f0);
     73    pCtx->AltPrivate.auH[0] = UINT32_C(0x67452301);
     74    pCtx->AltPrivate.auH[1] = UINT32_C(0xefcdab89);
     75    pCtx->AltPrivate.auH[2] = UINT32_C(0x98badcfe);
     76    pCtx->AltPrivate.auH[3] = UINT32_C(0x10325476);
     77    pCtx->AltPrivate.auH[4] = UINT32_C(0xc3d2e1f0);
    8778}
    8879RT_EXPORT_SYMBOL(RTSha1Init);
     
    146137static void rtSha1BlockProcess(PRTSHA1CONTEXT pCtx)
    147138{
    148     uint32_t uA = pCtx->AltPrivate.uH0;
    149     uint32_t uB = pCtx->AltPrivate.uH1;
    150     uint32_t uC = pCtx->AltPrivate.uH2;
    151     uint32_t uD = pCtx->AltPrivate.uH3;
    152     uint32_t uE = pCtx->AltPrivate.uH4;
     139    uint32_t uA = pCtx->AltPrivate.auH[0];
     140    uint32_t uB = pCtx->AltPrivate.auH[1];
     141    uint32_t uC = pCtx->AltPrivate.auH[2];
     142    uint32_t uD = pCtx->AltPrivate.auH[3];
     143    uint32_t uE = pCtx->AltPrivate.auH[4];
    153144
    154145#if 1
     
    208199#endif
    209200
    210     pCtx->AltPrivate.uH0 += uA;
    211     pCtx->AltPrivate.uH1 += uB;
    212     pCtx->AltPrivate.uH2 += uC;
    213     pCtx->AltPrivate.uH3 += uD;
    214     pCtx->AltPrivate.uH4 += uE;
     201    pCtx->AltPrivate.auH[0] += uA;
     202    pCtx->AltPrivate.auH[1] += uB;
     203    pCtx->AltPrivate.auH[2] += uC;
     204    pCtx->AltPrivate.auH[3] += uD;
     205    pCtx->AltPrivate.auH[4] += uE;
    215206}
    216207
     
    324315     * Convert the byte order of the hash words and we're done.
    325316     */
    326     pCtx->AltPrivate.uH0 = RT_H2BE_U32(pCtx->AltPrivate.uH0);
    327     pCtx->AltPrivate.uH1 = RT_H2BE_U32(pCtx->AltPrivate.uH1);
    328     pCtx->AltPrivate.uH2 = RT_H2BE_U32(pCtx->AltPrivate.uH2);
    329     pCtx->AltPrivate.uH3 = RT_H2BE_U32(pCtx->AltPrivate.uH3);
    330     pCtx->AltPrivate.uH4 = RT_H2BE_U32(pCtx->AltPrivate.uH4);
    331 
    332     memcpy(pabDigest, &pCtx->AltPrivate.uH0, RTSHA1_HASH_SIZE);
    333 
     317    pCtx->AltPrivate.auH[0] = RT_H2BE_U32(pCtx->AltPrivate.auH[0]);
     318    pCtx->AltPrivate.auH[1] = RT_H2BE_U32(pCtx->AltPrivate.auH[1]);
     319    pCtx->AltPrivate.auH[2] = RT_H2BE_U32(pCtx->AltPrivate.auH[2]);
     320    pCtx->AltPrivate.auH[3] = RT_H2BE_U32(pCtx->AltPrivate.auH[3]);
     321    pCtx->AltPrivate.auH[4] = RT_H2BE_U32(pCtx->AltPrivate.auH[4]);
     322
     323    memcpy(pabDigest, &pCtx->AltPrivate.auH[0], RTSHA1_HASH_SIZE);
     324
     325    RT_ZERO(pCtx->AltPrivate);
    334326    pCtx->AltPrivate.cbMessage = UINT64_MAX;
    335327}
  • trunk/src/VBox/Runtime/common/checksum/alt-sha256.cpp

    r51851 r51861  
    394394    pCtx->AltPrivate.auH[7] = RT_H2BE_U32(pCtx->AltPrivate.auH[7]);
    395395
     396    RT_ZERO(pCtx->AltPrivate.auW);
    396397    pCtx->AltPrivate.cbMessage = UINT64_MAX;
    397398}
     
    403404    rtSha256FinalInternal(pCtx);
    404405    memcpy(pabDigest, &pCtx->AltPrivate.auH[0], RTSHA256_HASH_SIZE);
     406    RT_ZERO(pCtx->AltPrivate.auH);
    405407}
    406408RT_EXPORT_SYMBOL(RTSha256Final);
     
    448450    rtSha256FinalInternal(pCtx);
    449451    memcpy(pabDigest, &pCtx->AltPrivate.auH[0], RTSHA224_HASH_SIZE);
     452    RT_ZERO(pCtx->AltPrivate.auH);
    450453}
    451454RT_EXPORT_SYMBOL(RTSha224Final);
  • trunk/src/VBox/Runtime/common/checksum/alt-sha512.cpp

    r51851 r51861  
    412412    pCtx->AltPrivate.auH[7] = RT_H2BE_U64(pCtx->AltPrivate.auH[7]);
    413413
     414    RT_ZERO(pCtx->AltPrivate.auW);
    414415    pCtx->AltPrivate.cbMessage.s.Lo = UINT64_MAX;
    415416    pCtx->AltPrivate.cbMessage.s.Hi = UINT64_MAX;
     
    422423    rtSha512FinalInternal(pCtx);
    423424    memcpy(pabDigest, &pCtx->AltPrivate.auH[0], RTSHA512_HASH_SIZE);
     425    RT_ZERO(pCtx->AltPrivate.auH);
    424426}
    425427RT_EXPORT_SYMBOL(RTSha512Final);
     
    468470    rtSha512FinalInternal(pCtx);
    469471    memcpy(pabDigest, &pCtx->AltPrivate.auH[0], RTSHA384_HASH_SIZE);
     472    RT_ZERO(pCtx->AltPrivate.auH);
    470473}
    471474RT_EXPORT_SYMBOL(RTSha384Final);
     
    513516    rtSha512FinalInternal(pCtx);
    514517    memcpy(pabDigest, &pCtx->AltPrivate.auH[0], RTSHA512T224_HASH_SIZE);
     518    RT_ZERO(pCtx->AltPrivate.auH);
    515519}
    516520RT_EXPORT_SYMBOL(RTSha512t224Final);
     
    558562    rtSha512FinalInternal(pCtx);
    559563    memcpy(pabDigest, &pCtx->AltPrivate.auH[0], RTSHA512T256_HASH_SIZE);
     564    RT_ZERO(pCtx->AltPrivate.auH);
    560565}
    561566RT_EXPORT_SYMBOL(RTSha512t256Final);
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