VirtualBox

Changeset 102294 in vbox


Ignore:
Timestamp:
Nov 24, 2023 1:40:35 PM (12 months ago)
Author:
vboxsync
Message:

IPRT: Implemented SHA-crypt 256 / 512 variants, along with testcases. Needed for password hashing in cloud-init-based Linux installers [docs fixes]. bugref:10551

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/crypto/shacrypt.h

    r102292 r102294  
    6060 *                              Must be >= RT_SHACRYPT_MIN_SALT_LEN and <= RT_SHACRYPT_MAX_SALT_LEN.
    6161 * @param   cRounds             Number of rounds to use.
    62  * @param   pabHash             Where to return the hash on success.
     62 * @param   abHash              Where to return the hash on success.
    6363 *
    6464 * @note    This implements SHA-crypt.txt Version: 0.6 2016-8-31.
    6565 */
    66 RTR3DECL(int) RTShaCrypt256(const char *pszKey, const char *pszSalt, uint32_t cRounds, uint8_t pabHash[RTSHA256_HASH_SIZE]);
     66RTR3DECL(int) RTShaCrypt256(const char *pszKey, const char *pszSalt, uint32_t cRounds, uint8_t abHash[RTSHA256_HASH_SIZE]);
    6767
    6868/**
     
    7070 *
    7171 * @returns VBox status code.
    72  * @param   pabHash             SHAcrypt (SHA-256) digest to return printable scheme for.
     72 * @param   abHash              SHAcrypt (SHA-256) digest to return printable scheme for.
    7373 * @param   pszSalt             Salt to use. Must match the salt used when generating \a pabHash via RTSha256Crypt().
    7474 * @param   cRounds             Number of rounds used for generating \a pabHash.
     
    8989 *                              Must be >= RT_SHACRYPT_MIN_SALT_LEN and <= RT_SHACRYPT_MAX_SALT_LEN.
    9090 * @param   cRounds             Number of rounds to use.
    91  * @param   pabHash             Where to return the hash on success.
     91 * @param   abHash              Where to return the hash on success.
    9292 *
    9393 * @note    This implements SHA-crypt.txt Version: 0.6 2016-8-31.
    9494 */
    95 RTR3DECL(int) RTShaCrypt512(const char *pszKey, const char *szSalt, uint32_t cRounds, uint8_t pabHash[RTSHA512_HASH_SIZE]);
     95RTR3DECL(int) RTShaCrypt512(const char *pszKey, const char *pszSalt, uint32_t cRounds, uint8_t abHash[RTSHA512_HASH_SIZE]);
    9696
    9797
     
    100100 *
    101101 * @returns VBox status code.
    102  * @param   pabHash             SHAcrypt (SHA-512) digest to return printable scheme for.
     102 * @param   abHash              SHAcrypt (SHA-512) digest to return printable scheme for.
    103103 * @param   pszSalt             Salt to use. Must match the salt used when generating \a pabHash via RTSha512Crypt().
    104104 * @param   cRounds             Number of rounds used for generating \a pabHash.
  • trunk/src/VBox/Runtime/common/crypto/shacrypt.cpp

    r102292 r102294  
    4848
    4949
    50 RTR3DECL(int) RTShaCrypt256(const char *pszKey, const char *pszSalt, uint32_t cRounds, uint8_t pabHash[RTSHA256_HASH_SIZE])
     50RTR3DECL(int) RTShaCrypt256(const char *pszKey, const char *pszSalt, uint32_t cRounds, uint8_t abHash[RTSHA256_HASH_SIZE])
    5151{
    5252    AssertPtrReturn(pszKey,   VERR_INVALID_POINTER);
     
    159159    }
    160160
    161     memcpy(pabHash, abDigest, RTSHA256_HASH_SIZE);
     161    memcpy(abHash, abDigest, RTSHA256_HASH_SIZE);
    162162
    163163    RTMemWipeThoroughly(abDigestTemp, RTSHA256_HASH_SIZE, 3);
     
    222222
    223223
    224 RTR3DECL(int) RTShaCrypt512(const char *pszKey, const char *pszSalt, uint32_t cRounds, uint8_t pabHash[RTSHA512_HASH_SIZE])
     224RTR3DECL(int) RTShaCrypt512(const char *pszKey, const char *pszSalt, uint32_t cRounds, uint8_t abHash[RTSHA512_HASH_SIZE])
    225225{
    226226    AssertPtrReturn(pszKey,   VERR_INVALID_POINTER);
     
    333333    }
    334334
    335     memcpy(pabHash, abDigest, RTSHA512_HASH_SIZE);
     335    memcpy(abHash, abDigest, RTSHA512_HASH_SIZE);
    336336
    337337    RTMemWipeThoroughly(abDigestTemp, RTSHA512_HASH_SIZE, 3);
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