LibreOffice Module comphelper (master) 1
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
comphelper::Hash Class Reference

#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< HashImplmpImpl
 

Detailed Description

Definition at line 40 of file hash.hxx.

Member Enumeration Documentation

◆ IterCount

enum class comphelper::Hash::IterCount
strong
Enumerator
NONE 
PREPEND 

Iteration count not added to hash iterations.

APPEND 

Iteration count prepended to hash iterations.

Iteration count appended to hash iterations.

Definition at line 47 of file hash.hxx.

Constructor & Destructor Documentation

◆ Hash()

comphelper::Hash::Hash ( HashType  eType)

Definition at line 108 of file hash.cxx.

References eType.

◆ ~Hash()

comphelper::Hash::~Hash ( )

Definition at line 113 of file hash.cxx.

Member Function Documentation

◆ calculateHash() [1/3]

static std::vector< unsigned char > comphelper::Hash::calculateHash ( const rtl::OUString &  rPassword,
const std::vector< unsigned char > &  rSaltValue,
sal_uInt32  nSpinCount,
IterCount  eIterCount,
HashType  eType 
)
static

Convenience function to calculate a salted hash with iterations.

Parameters
rPasswordUTF-16 encoded string, hashed byte-wise as unsigned char.
rSaltValueSalt that will be prepended to password data.

References getLength().

◆ calculateHash() [2/3]

std::vector< unsigned char > comphelper::Hash::calculateHash ( const unsigned char *  pInput,
size_t  length,
HashType  eType 
)
static

◆ calculateHash() [3/3]

std::vector< unsigned char > comphelper::Hash::calculateHash ( const unsigned char *  pInput,
size_t  nLength,
const unsigned char *  pSalt,
size_t  nSaltLen,
sal_uInt32  nSpinCount,
IterCount  eIterCount,
HashType  eType 
)
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

Parameters
pSaltmay be nullptr thus no salt prepended
nSpinCountIf >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.
eIterCountIf 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.
Returns
the raw hash value

Definition at line 168 of file hash.cxx.

References APPEND, calculateHash(), eType, finalize(), i, nLength, NONE, p, PREPEND, and update().

◆ finalize()

std::vector< unsigned char > comphelper::Hash::finalize ( )

Definition at line 129 of file hash.cxx.

References getLength(), and mpImpl.

Referenced by calculateHash().

◆ getLength()

size_t comphelper::Hash::getLength ( ) const

◆ update()

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().

Member Data Documentation

◆ mpImpl

std::unique_ptr<HashImpl> comphelper::Hash::mpImpl
private

Definition at line 43 of file hash.hxx.

Referenced by finalize(), getLength(), and update().


The documentation for this class was generated from the following files: