@@ -24,13 +24,18 @@ * * @brief A class which provides methods to calculate an HMAC. */ @interface OFHMAC: OFObject { + Class _hashClass; id _outerHash, _innerHash; - bool _keySet, _calculated; + id _outerHashCopy, _innerHashCopy; + bool _calculated; } + +/*! The class for the cryptographic hash used by the HMAC. */ +@property (assign, readonly) Class hashClass; /*! * @brief Returns a new OFHMAC with the specified hashing algorithm. * * @param class The class of the hashing algorithm @@ -48,10 +53,16 @@ - initWithHashClass: (Class )class; /*! * @brief Sets the key for the HMAC. * + * @note This resets the HMAC! + * + * @warning This invalidates any pointer previously returned by @ref digest. If + * you are still interested in the previous digest, you need to memcpy + * it yourself before calling @ref setKey:length:! + * * @param key The key for the HMAC * @param length The length of the key for the HMAC */ - (void)setKey: (const void*)key length: (size_t)length; @@ -81,15 +92,19 @@ * @return The size of the digest. */ - (size_t)digestSize; /*! - * @brief Resets all state so that a new HMAC can be calculated. + * @brief Resets the HMAC so that it can be calculated for a new message. + * + * @note This does not reset the key so that a new HMAC with the same key can + * be calculated efficiently. If you want to reset both, use + * @ref setKey:length:. * * @warning This invalidates any pointer previously returned by @ref digest. If * you are still interested in the previous digest, you need to memcpy * it yourself before calling @ref reset! */ - (void)reset; @end OF_ASSUME_NONNULL_END