ObjFW
Instance Methods | Class Methods | Properties | List of all members
<OFCryptoHash> Protocol Reference

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

#import <ObjFW/OFCryptoHash.h>

Inheritance diagram for <OFCryptoHash>:
Inheritance graph
[legend]
Collaboration diagram for <OFCryptoHash>:
Collaboration graph
[legend]

Instance Methods

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

Class Methods

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

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. More...
 

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

◆ cryptoHashWithAllowsSwappableMemory:

+ (instancetype) cryptoHashWithAllowsSwappableMemory: (bool)  allowsSwappableMemory

Creates a new cryptographic hash.

Returns
A new autoreleased cryptographic hash

◆ digestSize

+ (size_t) digestSize

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

Returns
The digest size of the cryptographic hash, in bytes

◆ 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

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.


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