68 if (salt && saltLen) {
71 hash->
finalizeHMAC(salt, saltLen, buf + hashSize, hashSize);
75 memset(buf, 0, hashSize);
78 hash->
finalizeHMAC(buf, hashSize, buf + hashSize, hashSize);
99 uint8_t *outPtr = (uint8_t *)out;
102 if (posn >= hashSize) {
103 hash->
resetHMAC(buf + hashSize, hashSize);
105 hash->
update(buf, hashSize);
107 hash->
update(info, infoLen);
108 hash->
update(&counter, 1);
109 hash->
finalizeHMAC(buf + hashSize, hashSize, buf, hashSize);
115 size_t len = hashSize - posn;
118 memcpy(outPtr, buf + posn, len);
132 clean(buf, hashSize * 2);
void setKey(const void *key, size_t keyLen, const void *salt=0, size_t saltLen=0)
Sets the key and salt for a HKDF session.
void clear()
Clears sensitive information from this HKDF instance.
HKDFCommon()
Constructs a new HKDF instance.
void extract(void *out, size_t outLen, const void *info=0, size_t infoLen=0)
Extracts data from a HKDF session.
virtual ~HKDFCommon()
Destroys this HKDF instance.
virtual void clear()=0
Clears the hash state, removing all sensitive data, and then resets the hash ready for a new hashing ...
virtual void finalizeHMAC(const void *key, size_t keyLen, void *hash, size_t hashLen)=0
Finalizes the HMAC hashing process and returns the hash.
virtual size_t hashSize() const =0
Size of the hash result from finalize().
virtual void resetHMAC(const void *key, size_t keyLen)=0
Resets the hash ready for a new HMAC hashing process.
virtual void update(const void *data, size_t len)=0
Updates the hash with more data.