Changeset 102292 in vbox
- Timestamp:
- Nov 24, 2023 1:01:41 PM (16 months ago)
- svn:sync-xref-src-repo-rev:
- 160426
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/crypto/shacrypt.h
r102289 r102292 52 52 RT_C_DECLS_BEGIN 53 53 54 RTDECL(int) RTShaCrypt256(const char *pszKey, const char *pszSalt, uint32_t cRounds, uint8_t pabHash[RTSHA256_HASH_SIZE]); 55 RTDECL(int) RTShaCrypt256ToString(uint8_t abHash[RTSHA256_HASH_SIZE], const char *pszSalt, uint32_t cRounds, char *pszString, size_t cbString); 56 RTDECL(int) RTShaCrypt512(const char *pszKey, const char *szSalt, uint32_t cRounds, uint8_t pabHash[RTSHA512_HASH_SIZE]); 57 RTDECL(int) RTShaCrypt512ToString(uint8_t abHash[RTSHA512_HASH_SIZE], const char *pszSalt, uint32_t cRounds, char *pszString, size_t cbString); 54 /** 55 * Calculates a SHAcrypt (SHA-256) digest. 56 * 57 * @returns VBox status code. 58 * @param pszKey Key (password) to use. 59 * @param pszSalt Salt to use. 60 * Must be >= RT_SHACRYPT_MIN_SALT_LEN and <= RT_SHACRYPT_MAX_SALT_LEN. 61 * @param cRounds Number of rounds to use. 62 * @param pabHash Where to return the hash on success. 63 * 64 * @note This implements SHA-crypt.txt Version: 0.6 2016-8-31. 65 */ 66 RTR3DECL(int) RTShaCrypt256(const char *pszKey, const char *pszSalt, uint32_t cRounds, uint8_t pabHash[RTSHA256_HASH_SIZE]); 67 68 /** 69 * Returns a SHAcrypt (SHA-256) digest as a printable scheme. 70 * 71 * @returns VBox status code. 72 * @param pabHash SHAcrypt (SHA-256) digest to return printable scheme for. 73 * @param pszSalt Salt to use. Must match the salt used when generating \a pabHash via RTSha256Crypt(). 74 * @param cRounds Number of rounds used for generating \a pabHash. 75 * @param pszString Where to store the printable string on success. 76 * @param cbString Size (in bytes) of \a pszString. 77 * 78 * @note This implements step 22 of SHA-crypt.txt Version: 0.6 2016-8-31. 79 */ 80 RTR3DECL(int) RTShaCrypt256ToString(uint8_t abHash[RTSHA256_HASH_SIZE], const char *pszSalt, uint32_t cRounds, char *pszString, size_t cbString); 81 82 83 /** 84 * Calculates a SHAcrypt (SHA-512) digest. 85 * 86 * @returns VBox status code. 87 * @param pszKey Key (password) to use. 88 * @param pszSalt Salt to use. 89 * Must be >= RT_SHACRYPT_MIN_SALT_LEN and <= RT_SHACRYPT_MAX_SALT_LEN. 90 * @param cRounds Number of rounds to use. 91 * @param pabHash Where to return the hash on success. 92 * 93 * @note This implements SHA-crypt.txt Version: 0.6 2016-8-31. 94 */ 95 RTR3DECL(int) RTShaCrypt512(const char *pszKey, const char *szSalt, uint32_t cRounds, uint8_t pabHash[RTSHA512_HASH_SIZE]); 96 97 98 /** 99 * Returns a SHAcrypt (SHA-512) digest as a printable scheme. 100 * 101 * @returns VBox status code. 102 * @param pabHash SHAcrypt (SHA-512) digest to return printable scheme for. 103 * @param pszSalt Salt to use. Must match the salt used when generating \a pabHash via RTSha512Crypt(). 104 * @param cRounds Number of rounds used for generating \a pabHash. 105 * @param pszString Where to store the printable string on success. 106 * @param cbString Size (in bytes) of \a pszString. 107 * 108 * @note This implements step 22 of SHA-crypt.txt Version: 0.6 2016-8-31. 109 */ 110 RTR3DECL(int) RTShaCrypt512ToString(uint8_t abHash[RTSHA512_HASH_SIZE], const char *pszSalt, uint32_t cRounds, char *pszString, size_t cbString); 58 111 59 112 RT_C_DECLS_END -
trunk/src/VBox/Runtime/common/crypto/shacrypt.cpp
r102289 r102292 47 47 48 48 49 /** 50 * Calculates a SHAcrypt (SHA-256) digest. 51 * 52 * @returns VBox status code. 53 * @param pszKey Key (password) to use. 54 * @param pszSalt Salt to use. 55 * Must be >= RT_SHACRYPT_MIN_SALT_LEN and <= RT_SHACRYPT_MAX_SALT_LEN. 56 * @param cRounds Number of rounds to use. 57 * @param pabHash Where to return the hash on success. 58 * 59 * @note This implements SHA-crypt.txt Version: 0.6 2016-8-31. 60 */ 61 int RTShaCrypt256(const char *pszKey, const char *pszSalt, uint32_t cRounds, uint8_t pabHash[RTSHA256_HASH_SIZE]) 49 50 RTR3DECL(int) RTShaCrypt256(const char *pszKey, const char *pszSalt, uint32_t cRounds, uint8_t pabHash[RTSHA256_HASH_SIZE]) 62 51 { 63 52 AssertPtrReturn(pszKey, VERR_INVALID_POINTER); … … 182 171 } 183 172 184 /** 185 * Returns a SHAcrypt (SHA-256) digest as a printable scheme. 186 * 187 * @returns VBox status code. 188 * @param pabHash SHAcrypt (SHA-256) digest to return printable scheme for. 189 * @param pszSalt Salt to use. Must match the salt used when generating \a pabHash via RTSha256Crypt(). 190 * @param cRounds Number of rounds used for generating \a pabHash. 191 * @param pszString Where to store the printable string on success. 192 * @param cbString Size (in bytes) of \a pszString. 193 * 194 * @note This implements step 22 of SHA-crypt.txt Version: 0.6 2016-8-31. 195 */ 196 int RTShaCrypt256ToString(uint8_t abHash[RTSHA256_HASH_SIZE], const char *pszSalt, uint32_t cRounds, 197 char *pszString, size_t cbString) 173 174 RTR3DECL(int) RTShaCrypt256ToString(uint8_t abHash[RTSHA256_HASH_SIZE], const char *pszSalt, uint32_t cRounds, 175 char *pszString, size_t cbString) 198 176 { 199 177 AssertPtrReturn(pszSalt, VERR_INVALID_POINTER); … … 243 221 } 244 222 245 /** 246 * Calculates a SHAcrypt (SHA-512) digest. 247 * 248 * @returns VBox status code. 249 * @param pszKey Key (password) to use. 250 * @param pszSalt Salt to use. 251 * Must be >= RT_SHACRYPT_MIN_SALT_LEN and <= RT_SHACRYPT_MAX_SALT_LEN. 252 * @param cRounds Number of rounds to use. 253 * @param pabHash Where to return the hash on success. 254 * 255 * @note This implements SHA-crypt.txt Version: 0.6 2016-8-31. 256 */ 257 int RTShaCrypt512(const char *pszKey, const char *pszSalt, uint32_t cRounds, uint8_t pabHash[RTSHA512_HASH_SIZE]) 223 224 RTR3DECL(int) RTShaCrypt512(const char *pszKey, const char *pszSalt, uint32_t cRounds, uint8_t pabHash[RTSHA512_HASH_SIZE]) 258 225 { 259 226 AssertPtrReturn(pszKey, VERR_INVALID_POINTER); … … 378 345 } 379 346 380 /** 381 * Returns a SHAcrypt (SHA-512) digest as a printable scheme. 382 * 383 * @returns VBox status code. 384 * @param pabHash SHAcrypt (SHA-512) digest to return printable scheme for. 385 * @param pszSalt Salt to use. Must match the salt used when generating \a pabHash via RTSha512Crypt(). 386 * @param cRounds Number of rounds used for generating \a pabHash. 387 * @param pszString Where to store the printable string on success. 388 * @param cbString Size (in bytes) of \a pszString. 389 * 390 * @note This implements step 22 of SHA-crypt.txt Version: 0.6 2016-8-31. 391 */ 392 int RTShaCrypt512ToString(uint8_t abHash[RTSHA512_HASH_SIZE], const char *pszSalt, uint32_t cRounds, 393 char *pszString, size_t cbString) 347 348 RTR3DECL(int) RTShaCrypt512ToString(uint8_t abHash[RTSHA512_HASH_SIZE], const char *pszSalt, uint32_t cRounds, 349 char *pszString, size_t cbString) 394 350 { 395 351 AssertPtrReturn(pszSalt, VERR_INVALID_POINTER);
Note:
See TracChangeset
for help on using the changeset viewer.