VirtualBox

Changeset 102372 in vbox for trunk


Ignore:
Timestamp:
Nov 29, 2023 9:47:41 AM (15 months ago)
Author:
vboxsync
Message:

IPRT/crypto: Renaming. bugref:10551

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/crypto/shacrypt.cpp

    r102361 r102372  
    6969    AssertReturn   (cRounds, VERR_INVALID_PARAMETER);
    7070
    71     size_t const cbKey     = strlen(pszKey);
    72     AssertReturn(cbKey, VERR_INVALID_PARAMETER);
    73     size_t const cbSalt    = strlen(pszSalt);
    74     AssertMsgReturn(cbSalt >= RT_SHACRYPT_MIN_SALT_LEN && cbSalt <= RT_SHACRYPT_MAX_SALT_LEN, ("len=%zu\n", cbSalt),
     71    size_t const cchKey     = strlen(pszKey);
     72    AssertReturn(cchKey, VERR_INVALID_PARAMETER);
     73    size_t const cchSalt    = strlen(pszSalt);
     74    AssertMsgReturn(cchSalt >= RT_SHACRYPT_MIN_SALT_LEN && cchSalt <= RT_SHACRYPT_MAX_SALT_LEN, ("len=%zu\n", cchSalt),
    7575                    VERR_INVALID_PARAMETER);
    7676
     
    8080    RTSHA256CONTEXT Ctx;
    8181    RTSha256Init(&Ctx);                                                         /* Step 1. */
    82     RTSha256Update(&Ctx, pszKey, cbKey);                                        /* Step 2. */
    83     RTSha256Update(&Ctx, pszSalt, cbSalt);                                      /* Step 3. */
     82    RTSha256Update(&Ctx, pszKey, cchKey);                                       /* Step 2. */
     83    RTSha256Update(&Ctx, pszSalt, cchSalt);                                     /* Step 3. */
    8484
    8585    RTSHA256CONTEXT CtxAlt;
    8686    RTSha256Init(&CtxAlt);                                                      /* Step 4. */
    87     RTSha256Update(&CtxAlt, pszKey, cbKey);                                     /* Step 5. */
    88     RTSha256Update(&CtxAlt, pszSalt, cbSalt);                                   /* Step 6. */
    89     RTSha256Update(&CtxAlt, pszKey, cbKey);                                     /* Step 7. */
     87    RTSha256Update(&CtxAlt, pszKey, cchKey);                                    /* Step 5. */
     88    RTSha256Update(&CtxAlt, pszSalt, cchSalt);                                  /* Step 6. */
     89    RTSha256Update(&CtxAlt, pszKey, cchKey);                                    /* Step 7. */
    9090    RTSha256Final(&CtxAlt, abDigest);                                           /* Step 8. */
    9191
    92     size_t i = cbKey;
     92    size_t i = cchKey;
    9393    for (; i > RTSHA256_HASH_SIZE; i -= RTSHA256_HASH_SIZE)                     /* Step 9. */
    9494        RTSha256Update(&Ctx, abDigest, sizeof(abDigest));
    9595    RTSha256Update(&Ctx, abDigest, i);                                          /* Step 10. */
    9696
    97     size_t keyBits = cbKey;
     97    size_t keyBits = cchKey;
    9898    while (keyBits)                                                             /* Step 11. */
    9999    {
     
    101101            RTSha256Update(&Ctx, abDigest, sizeof(abDigest));                   /* a) */
    102102        else
    103             RTSha256Update(&Ctx, pszKey, cbKey);                                /* b) */
     103            RTSha256Update(&Ctx, pszKey, cchKey);                               /* b) */
    104104        keyBits >>= 1;
    105105    }
     
    108108
    109109    RTSha256Init(&CtxAlt);                                                      /* Step 13. */
    110     for (i = 0; i < cbKey; i++)                                                 /* Step 14. */
    111         RTSha256Update(&CtxAlt, pszKey, cbKey);
     110    for (i = 0; i < cchKey; i++)                                                /* Step 14. */
     111        RTSha256Update(&CtxAlt, pszKey, cchKey);
    112112    RTSha256Final(&CtxAlt, abDigestTemp);                                       /* Step 15. */
    113113
     
    115115     * Byte sequence P (= password).
    116116     */
    117     size_t const cbSeqP  = cbKey;
     117    size_t const cbSeqP  = cchKey;
    118118    uint8_t     *pabSeqP = (uint8_t *)RTMemDup(pszKey, cbSeqP);
    119119    uint8_t     *p       = pabSeqP;
     
    130130
    131131    for (i = 0; i < 16 + (unsigned)abDigest[0]; i++)                            /* Step 18. */
    132         RTSha256Update(&CtxAlt, pszSalt, cbSalt);
     132        RTSha256Update(&CtxAlt, pszSalt, cchSalt);
    133133
    134134    RTSha256Final(&CtxAlt, abDigestTemp);                                       /* Step 19. */
     
    137137     * Byte sequence S (= salt).
    138138     */
    139     size_t   const cbSeqS  = cbSalt;
     139    size_t   const cbSeqS  = cchSalt;
    140140    uint8_t       *pabSeqS = (uint8_t *)RTMemDup(pszSalt, cbSeqS);
    141141                   p       = pabSeqS;
     
    255255    AssertReturn   (cRounds, VERR_INVALID_PARAMETER);
    256256
    257     size_t const cbKey     = strlen(pszKey);
    258     AssertReturn(cbKey, VERR_INVALID_PARAMETER);
    259     size_t const cbSalt    = strlen(pszSalt);
    260     AssertMsgReturn(cbSalt >= RT_SHACRYPT_MIN_SALT_LEN && cbSalt <= RT_SHACRYPT_MAX_SALT_LEN, ("len=%zu\n", cbSalt),
     257    size_t const cchKey     = strlen(pszKey);
     258    AssertReturn(cchKey, VERR_INVALID_PARAMETER);
     259    size_t const cchSalt    = strlen(pszSalt);
     260    AssertMsgReturn(cchSalt >= RT_SHACRYPT_MIN_SALT_LEN && cchSalt <= RT_SHACRYPT_MAX_SALT_LEN, ("len=%zu\n", cchSalt),
    261261                    VERR_INVALID_PARAMETER);
    262262
     
    266266    RTSHA512CONTEXT Ctx;
    267267    RTSha512Init(&Ctx);                                                         /* Step 1. */
    268     RTSha512Update(&Ctx, pszKey, cbKey);                                        /* Step 2. */
    269     RTSha512Update(&Ctx, pszSalt, cbSalt);                                      /* Step 3. */
     268    RTSha512Update(&Ctx, pszKey, cchKey);                                       /* Step 2. */
     269    RTSha512Update(&Ctx, pszSalt, cchSalt);                                     /* Step 3. */
    270270
    271271    RTSHA512CONTEXT CtxAlt;
    272272    RTSha512Init(&CtxAlt);                                                      /* Step 4. */
    273     RTSha512Update(&CtxAlt, pszKey, cbKey);                                     /* Step 5. */
    274     RTSha512Update(&CtxAlt, pszSalt, cbSalt);                                   /* Step 6. */
    275     RTSha512Update(&CtxAlt, pszKey, cbKey);                                     /* Step 7. */
     273    RTSha512Update(&CtxAlt, pszKey, cchKey);                                    /* Step 5. */
     274    RTSha512Update(&CtxAlt, pszSalt, cchSalt);                                  /* Step 6. */
     275    RTSha512Update(&CtxAlt, pszKey, cchKey);                                    /* Step 7. */
    276276    RTSha512Final(&CtxAlt, abDigest);                                           /* Step 8. */
    277277
    278     size_t i = cbKey;
     278    size_t i = cchKey;
    279279    for (; i > RTSHA512_HASH_SIZE; i -= RTSHA512_HASH_SIZE)                     /* Step 9. */
    280280        RTSha512Update(&Ctx, abDigest, sizeof(abDigest));
    281281    RTSha512Update(&Ctx, abDigest, i);                                          /* Step 10. */
    282282
    283     size_t keyBits = cbKey;
     283    size_t keyBits = cchKey;
    284284    while (keyBits)                                                             /* Step 11. */
    285285    {
     
    287287            RTSha512Update(&Ctx, abDigest, sizeof(abDigest));                   /* a) */
    288288        else
    289             RTSha512Update(&Ctx, pszKey, cbKey);                                /* b) */
     289            RTSha512Update(&Ctx, pszKey, cchKey);                               /* b) */
    290290        keyBits >>= 1;
    291291    }
     
    294294
    295295    RTSha512Init(&CtxAlt);                                                      /* Step 13. */
    296     for (i = 0; i < cbKey; i++)                                                 /* Step 14. */
    297         RTSha512Update(&CtxAlt, pszKey, cbKey);
     296    for (i = 0; i < cchKey; i++)                                                /* Step 14. */
     297        RTSha512Update(&CtxAlt, pszKey, cchKey);
    298298    RTSha512Final(&CtxAlt, abDigestTemp);                                       /* Step 15. */
    299299
     
    301301     * Byte sequence P (= password).
    302302     */
    303     size_t const cbSeqP  = cbKey;
     303    size_t const cbSeqP  = cchKey;
    304304    uint8_t     *pabSeqP = (uint8_t *)RTMemDup(pszKey, cbSeqP);
    305305    uint8_t     *p       = pabSeqP;
     
    316316
    317317    for (i = 0; i < 16 + (unsigned)abDigest[0]; i++)                            /* Step 18. */
    318         RTSha512Update(&CtxAlt, pszSalt, cbSalt);
     318        RTSha512Update(&CtxAlt, pszSalt, cchSalt);
    319319
    320320    RTSha512Final(&CtxAlt, abDigestTemp);                                       /* Step 19. */
     
    323323     * Byte sequence S (= salt).
    324324     */
    325     size_t   const cbSeqS  = cbSalt;
     325    size_t   const cbSeqS  = cchSalt;
    326326    uint8_t       *pabSeqS = (uint8_t *)RTMemDup(pszSalt, cbSeqS);
    327327                   p       = pabSeqS;
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