ObjFW
Loading...
Searching...
No Matches
<OFCryptographicHash> Protocol Reference

A protocol for classes providing cryptographic hash functions. More...

#include <ObjFW/ObjFW.h>

Inheritance diagram for <OFCryptographicHash>:
<OFObject> <OFCopying> OFMD5Hash OFRIPEMD160Hash OFSHA1Hash OFSHA224Or256Hash OFSHA384Or512Hash OFSHA224Hash OFSHA256Hash OFSHA384Hash OFSHA512Hash

Instance Methods

(instancetype) - initWithAllowsSwappableMemory:
 Initializes an already allocated cryptographic hash.
 
(void) - updateWithBuffer:length:
 Adds a buffer to the cryptographic hash to be calculated.
 
(void) - calculate
 Performs the final calculation of the cryptographic hash.
 
(void) - reset
 Resets all state so that a new hash can be calculated.
 
- Instance Methods inherited from <OFObject>
(Class) - class
 Returns the class of the object.
 
(nullable Class) - superclass
 Returns the superclass of the object.
 
(unsigned long) - hash
 Returns a hash for the object.
 
(unsigned int) - retainCount
 Returns the retain count.
 
(bool) - isProxy
 Returns whether the object is a proxy object.
 
(bool) - isKindOfClass:
 Returns a boolean whether the object is of the specified kind.
 
(bool) - isMemberOfClass:
 Returns a boolean whether the object is a member of the specified class.
 
(bool) - respondsToSelector:
 Returns a boolean whether the object responds to the specified selector.
 
(bool) - conformsToProtocol:
 Checks whether the object conforms to the specified protocol.
 
(nullable IMP- methodForSelector:
 Returns the implementation for the specified selector.
 
(nullable id) - performSelector:
 Performs the specified selector.
 
(nullable id) - performSelector:withObject:
 Performs the specified selector with the specified object.
 
(nullable id) - performSelector:withObject:withObject:
 Performs the specified selector with the specified objects.
 
(nullable id) - performSelector:withObject:withObject:withObject:
 Performs the specified selector with the specified objects.
 
(nullable id) - performSelector:withObject:withObject:withObject:withObject:
 Performs the specified selector with the specified objects.
 
(bool) - isEqual:
 Checks two objects for equality.
 
(instancetype) - retain
 Increases the retain count.
 
(void) - release
 Decreases the retain count.
 
(instancetype) - autorelease
 Adds the object to the topmost autorelease pool of the thread's autorelease pool stack.
 
(instancetype) - self
 Returns the receiver.
 
(bool) - allowsWeakReference
 Returns whether the object allows a weak reference.
 
(bool) - retainWeakReference
 Retain a weak reference to this object.
 
- Instance Methods inherited from <OFCopying>
(id) - copy
 Copies the object.
 

Class Methods

(instancetype) + hashWithAllowsSwappableMemory:
 Creates a new cryptographic hash.
 
(size_t) + digestSize
 Returns the digest size of the cryptographic hash, in bytes.
 
(size_t) + blockSize
 Returns the block size of the cryptographic hash, in bytes.
 

Properties

size_t digestSize
 The digest size of the cryptographic hash, in bytes.
 
size_t blockSize
 The block size of the cryptographic hash, in bytes.
 
bool allowsSwappableMemory
 Whether data may be stored in swappable memory.
 
bool calculated
 A boolean whether the hash has already been calculated.
 
const unsigned char * digest
 A buffer containing the cryptographic hash.
 

Detailed Description

A protocol for classes providing cryptographic hash functions.

A cryptographic hash implementing this protocol can be copied. The entire state is copied, allowing to calculate a new hash from there. This is especially useful for generating many hashes with a common prefix.

Method Documentation

◆ blockSize

+ (size_t) blockSize

Returns the block size of the cryptographic hash, in bytes.

Returns
The block size of the cryptographic hash, in bytes

◆ calculate

- (void) calculate

Performs the final calculation of the cryptographic hash.

Exceptions
OFHashAlreadyCalculatedExceptionThe hash has already been calculated

◆ digestSize

+ (size_t) digestSize

Returns the digest size of the cryptographic hash, in bytes.

Returns
The digest size of the cryptographic hash, in bytes

◆ hashWithAllowsSwappableMemory:

+ (instancetype) hashWithAllowsSwappableMemory: (bool) allowsSwappableMemory

Creates a new cryptographic hash.

Returns
A new autoreleased cryptographic hash

◆ initWithAllowsSwappableMemory:

- (instancetype) initWithAllowsSwappableMemory: (bool) allowsSwappableMemory

Initializes an already allocated cryptographic hash.

Returns
An initialized cryptographic hash

◆ reset

- (void) reset

Resets all state so that a new hash can be calculated.

Warning
This invalidates any pointer previously returned by digest. If you are still interested in the previous digest, you need to memcpy it yourself before calling reset!

◆ updateWithBuffer:length:

- (void) updateWithBuffer: (const void *) buffer
length: (size_t) length 

Adds a buffer to the cryptographic hash to be calculated.

Parameters
bufferThe buffer which should be included into the calculation
lengthThe length of the buffer
Exceptions
OFHashAlreadyCalculatedExceptionThe hash has already been calculated

Property Documentation

◆ digest

- (const unsigned char*) digest
readnonatomicassign

A buffer containing the cryptographic hash.

The size of the buffer depends on the hash used. The buffer is part of the receiver's memory pool.

Exceptions
OFHashNotCalculatedExceptionThe hash hasn't been calculated yet

The documentation for this protocol was generated from the following file: