LibreOffice Module comphelper (master) 1
|
#include <hash.hxx>
Public Types | |
enum class | IterCount { NONE , PREPEND , APPEND } |
Public Member Functions | |
Hash (HashType eType) | |
~Hash () | |
void | update (const unsigned char *pInput, size_t length) |
std::vector< unsigned char > | finalize () |
size_t | getLength () const |
Static Public Member Functions | |
static std::vector< unsigned char > | calculateHash (const unsigned char *pInput, size_t length, HashType eType) |
static std::vector< unsigned char > | calculateHash (const unsigned char *pInput, size_t nLength, const unsigned char *pSalt, size_t nSaltLen, sal_uInt32 nSpinCount, IterCount eIterCount, HashType eType) |
Calculate hash value with salt (pSalt,nSaltLen) prepended to password (pInput,nLength) and repeated iterations run if nSpinCount>0. More... | |
static std::vector< unsigned char > | calculateHash (const rtl::OUString &rPassword, const std::vector< unsigned char > &rSaltValue, sal_uInt32 nSpinCount, IterCount eIterCount, HashType eType) |
Convenience function to calculate a salted hash with iterations. More... | |
Private Attributes | |
std::unique_ptr< HashImpl > | mpImpl |
|
strong |
|
static |
Convenience function to calculate a salted hash with iterations.
rPassword | UTF-16 encoded string, hashed byte-wise as unsigned char. |
rSaltValue | Salt that will be prepended to password data. |
References getLength().
|
static |
Definition at line 161 of file hash.cxx.
References eType, finalize(), length, and update().
Referenced by calculateHash(), comphelper::OStorageHelper::CreatePackageEncryptionData(), and comphelper::DocPasswordHelper::GetOoxHashAsVector().
|
static |
Calculate hash value with salt (pSalt,nSaltLen) prepended to password (pInput,nLength) and repeated iterations run if nSpinCount>0.
This implements the algorithms as specified in https://msdn.microsoft.com/en-us/library/dd920692 or https://msdn.microsoft.com/en-us/library/dd924776 and https://msdn.microsoft.com/en-us/library/dd925430
pSalt | may be nullptr thus no salt prepended |
nSpinCount | If >0, repeat nSpinCount iterations. For each iteration, the previous iteration's result plus a 4 byte value (0-based, little endian) containing the number of the iteration prepended or appended to the hash value is the input for the next iteration. |
eIterCount | If IterCount::APPEND, append iteration count as per https://msdn.microsoft.com/en-us/library/dd920692 If IterCount::PREPEND, prepend iteration count as per https://msdn.microsoft.com/en-us/library/dd924776 and https://msdn.microsoft.com/en-us/library/dd925430 If IterCount::NONE, do not add the iteration count to hash iterations. |
Definition at line 168 of file hash.cxx.
References APPEND, calculateHash(), eType, finalize(), i, nLength, NONE, p, PREPEND, and update().
std::vector< unsigned char > comphelper::Hash::finalize | ( | ) |
Definition at line 129 of file hash.cxx.
References getLength(), and mpImpl.
Referenced by calculateHash().
size_t comphelper::Hash::getLength | ( | ) | const |
Definition at line 144 of file hash.cxx.
References comphelper::MD5, comphelper::MD5_HASH_LENGTH, mpImpl, comphelper::SHA1, comphelper::SHA1_HASH_LENGTH, comphelper::SHA256, comphelper::SHA256_HASH_LENGTH, comphelper::SHA512, and comphelper::SHA512_HASH_LENGTH.
Referenced by finalize().
void comphelper::Hash::update | ( | const unsigned char * | pInput, |
size_t | length | ||
) |
Definition at line 117 of file hash.cxx.
References length, and mpImpl.
Referenced by calculateHash().
|
private |
Definition at line 43 of file hash.hxx.
Referenced by finalize(), getLength(), and update().