ObjFW
|
A class for storing arbitrary data in secure (non-swappable) memory, securely wiping it when it gets deallocated. More...
#import <ObjFW/OFSecureData.h>
Instance Methods | |
(instancetype) | - initWithCount:allowsSwappableMemory: |
Initializes an already allocated OFSecureData with count items of item size 1, all set to zero. More... | |
(instancetype) | - initWithCount:itemSize:allowsSwappableMemory: |
Initializes an already allocated OFSecureData with count items of the specified item size, all set to zero. More... | |
(instancetype) | - initWithItems:count: |
Initialized an already allocated OFData with the specified count items of size 1. More... | |
(instancetype) | - initWithItems:count:itemSize: |
Initialized an already allocated OFData with the specified count items of the specified size. More... | |
(instancetype) | - initWithItemsNoCopy:count:freeWhenDone: |
Initializes an already allocated OFData with the specified count items of size 1 by taking over ownership of the specified items pointer. More... | |
(instancetype) | - initWithItemsNoCopy:count:itemSize:freeWhenDone: |
Initializes an already allocated OFData with the specified count items of the specified size by taking ownership of the specified items pointer. More... | |
(instancetype) | - initWithContentsOfFile: |
Initializes an already allocated OFData with an item size of 1, containing the data of the specified file. More... | |
(instancetype) | - initWithContentsOfURL: |
Initializes an already allocated OFData with an item size of 1, containing the data of the specified URL. More... | |
(instancetype) | - initWithStringRepresentation: |
Initializes an already allocated OFData with an item size of 1, containing the data of the string representation. More... | |
(instancetype) | - initWithBase64EncodedString: |
Initializes an already allocated OFData with an item size of 1, containing the data of the Base64-encoded string. More... | |
(instancetype) | - initWithSerialization: |
Initializes the object with the specified XML element serialization. More... | |
(void *) | - mutableItemAtIndex: |
Returns a specific item of the OFSecureData. More... | |
(bool) | - isEqual: |
Checks the OFSecureData for equality to another object. More... | |
(void) | - zero |
Zeroes the data. | |
(void) | - writeToFile: |
Writes the OFData into the specified file. More... | |
(void) | - writeToURL: |
Writes the OFData to the specified URL. More... | |
![]() | |
(const void *) | - itemAtIndex: |
Returns a specific item of the OFData. More... | |
(OFData *) | - subdataWithRange: |
Returns the data in the specified range as a new OFData. More... | |
(of_range_t) | - rangeOfData:options:range: |
Returns the range of the data. More... | |
(id) | - objectByParsingASN1DERWithDepthLimit: |
Parses the ASN.1 DER representation and returns it as an object. More... | |
(id) | - objectByParsingMessagePackWithDepthLimit: |
Parses the MessagePack representation and returns it as an object. More... | |
![]() | |
(instancetype) | - init |
Initializes an already allocated object. More... | |
(nullable OFMethodSignature *) | - methodSignatureForSelector: |
Returns the method signature for the specified selector. More... | |
(void) | - dealloc |
Deallocates the object. More... | |
(void) | - performSelector:afterDelay: |
Performs the specified selector after the specified delay. More... | |
(void) | - performSelector:withObject:afterDelay: |
Performs the specified selector with the specified object after the specified delay. More... | |
(void) | - performSelector:withObject:withObject:afterDelay: |
Performs the specified selector with the specified objects after the specified delay. More... | |
(void) | - performSelector:withObject:withObject:withObject:afterDelay: |
Performs the specified selector with the specified objects after the specified delay. More... | |
(void) | - performSelector:withObject:withObject:withObject:withObject:afterDelay: |
Performs the specified selector with the specified objects after the specified delay. More... | |
(void) | - performSelector:onThread:waitUntilDone: |
Performs the specified selector on the specified thread. More... | |
(void) | - performSelector:onThread:withObject:waitUntilDone: |
Performs the specified selector on the specified thread with the specified object. More... | |
(void) | - performSelector:onThread:withObject:withObject:waitUntilDone: |
Performs the specified selector on the specified thread with the specified objects. More... | |
(void) | - performSelector:onThread:withObject:withObject:withObject:waitUntilDone: |
Performs the specified selector on the specified thread with the specified objects. More... | |
(void) | - performSelector:onThread:withObject:withObject:withObject:withObject:waitUntilDone: |
Performs the specified selector on the specified thread with the specified objects. More... | |
(void) | - performSelectorOnMainThread:waitUntilDone: |
Performs the specified selector on the main thread. More... | |
(void) | - performSelectorOnMainThread:withObject:waitUntilDone: |
Performs the specified selector on the main thread with the specified object. More... | |
(void) | - performSelectorOnMainThread:withObject:withObject:waitUntilDone: |
Performs the specified selector on the main thread with the specified objects. More... | |
(void) | - performSelectorOnMainThread:withObject:withObject:withObject:waitUntilDone: |
Performs the specified selector on the main thread with the specified objects. More... | |
(void) | - performSelectorOnMainThread:withObject:withObject:withObject:withObject:waitUntilDone: |
Performs the specified selector on the main thread with the specified objects. More... | |
(void) | - performSelector:onThread:afterDelay: |
Performs the specified selector on the specified thread after the specified delay. More... | |
(void) | - performSelector:onThread:withObject:afterDelay: |
Performs the specified selector on the specified thread with the specified object after the specified delay. More... | |
(void) | - performSelector:onThread:withObject:withObject:afterDelay: |
Performs the specified selector on the specified thread with the specified objects after the specified delay. More... | |
(void) | - performSelector:onThread:withObject:withObject:withObject:afterDelay: |
Performs the specified selector on the specified thread with the specified objects after the specified delay. More... | |
(void) | - performSelector:onThread:withObject:withObject:withObject:withObject:afterDelay: |
Performs the specified selector on the specified thread with the specified objects after the specified delay. More... | |
(nullable id) | - forwardingTargetForSelector: |
This method is called when resolveClassMethod: or resolveInstanceMethod: returned false. It should return a target to which the message should be forwarded. More... | |
(void) | - doesNotRecognizeSelector: |
Handles messages which are not understood by the receiver. 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... | |
(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... | |
(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... | |
![]() | |
(id) | - copy |
Copies the object. More... | |
![]() | |
(id) | - mutableCopy |
Creates a mutable copy of the object. More... | |
![]() | |
(of_comparison_result_t) | - compare: |
Compares the object with another object. More... | |
Class Methods | |
(void) | + preallocateUnswappableMemoryWithSize: |
Preallocates the specified number of bytes for unswappable memory. More... | |
(instancetype) | + dataWithCount:allowsSwappableMemory: |
Creates a new, autoreleased OFSecureData with count items of item size 1, all set to zero. More... | |
(instancetype) | + dataWithCount:itemSize:allowsSwappableMemory: |
Creates a new, autoreleased OFSecureData with count items of the specified item size, all set to zero. More... | |
(instancetype) | + dataWithItems:count: |
Creates a new OFData with the specified count items of size 1. More... | |
(instancetype) | + dataWithItems:count:itemSize: |
Creates a new OFData with the specified count items of the specified size. More... | |
(instancetype) | + dataWithItemsNoCopy:count:freeWhenDone: |
Creates a new OFData with the specified count items of size 1 by taking over ownership of the specified items pointer. More... | |
(instancetype) | + dataWithItemsNoCopy:count:itemSize:freeWhenDone: |
Creates a new OFData with the specified count items of the specified size by taking ownership of the specified items pointer. More... | |
(instancetype) | + dataWithContentsOfFile: |
Creates a new OFData with an item size of 1, containing the data of the specified file. More... | |
(instancetype) | + dataWithContentsOfURL: |
Creates a new OFData with an item size of 1, containing the data of the specified URL. More... | |
(instancetype) | + dataWithStringRepresentation: |
Creates a new OFData with an item size of 1, containing the data of the string representation. More... | |
(instancetype) | + dataWithBase64EncodedString: |
Creates a new OFData with an item size of 1, containing the data of the Base64-encoded string. More... | |
![]() | |
(void) | + load |
A method which is called once when the class is loaded into the runtime. More... | |
(void) | + unload |
A method which is called when the class is unloaded from the runtime. More... | |
(void) | + initialize |
A method which is called the moment before the first call to the class is being made. More... | |
(instancetype) | + alloc |
Allocates memory for an instance of the class and sets up the memory pool for the object. More... | |
(instancetype) | + new |
Calls alloc on self and then init on the returned object. More... | |
(Class) | + class |
Returns the class. More... | |
(OFString *) | + className |
Returns the name of the class as a string. More... | |
(bool) | + isSubclassOfClass: |
Returns a boolean whether the class is a subclass of the specified class. More... | |
(nullable Class) | + superclass |
Returns the superclass of the class. More... | |
(bool) | + instancesRespondToSelector: |
Checks whether instances of the class respond to a given selector. More... | |
(bool) | + conformsToProtocol: |
Checks whether the class conforms to a given protocol. More... | |
(nullable IMP) | + instanceMethodForSelector: |
Returns the implementation of the instance method for the specified selector. More... | |
(nullable OFMethodSignature *) | + instanceMethodSignatureForSelector: |
Returns the method signature of the instance method for the specified selector. More... | |
(OFString *) | + description |
Returns a description for the class, which is usually the class name. More... | |
(nullable IMP) | + replaceClassMethod:withMethodFromClass: |
Replaces a class method with a class method from another class. More... | |
(nullable IMP) | + replaceInstanceMethod:withMethodFromClass: |
Replaces an instance method with an instance method from another class. More... | |
(void) | + inheritMethodsFromClass: |
Adds all methods from the specified class to the class that is the receiver. More... | |
(bool) | + resolveClassMethod: |
Try to resolve the specified class method. More... | |
(bool) | + resolveInstanceMethod: |
Try to resolve the specified instance method. More... | |
(id) | + copy |
Returns the class. More... | |
Properties | |
bool | allowsSwappableMemory |
Whether the data may be stored in swappable memory. | |
void * | mutableItems |
All items of the OFSecureData as a C array. More... | |
![]() | |
size_t | itemSize |
The size of a single item in the OFData in bytes. | |
size_t | count |
The number of items in the OFData. | |
const void * | items |
All elements of the OFData as a C array. More... | |
const void * | firstItem |
The first item of the OFData or NULL . | |
const void * | lastItem |
The last item of the OFData or NULL . | |
OFString * | stringRepresentation |
The string representation of the data. More... | |
OFString * | stringByBase64Encoding |
A string containing the data in Base64 encoding. | |
id | objectByParsingASN1DER |
The data interpreted as ASN.1 in DER representation and parsed as an object. More... | |
OFString * | MD5Hash |
The MD5 hash of the data as a string. | |
OFString * | RIPEMD160Hash |
The RIPEMD-160 hash of the data as a string. | |
OFString * | SHA1Hash |
The SHA-1 hash of the data as a string. | |
OFString * | SHA224Hash |
The SHA-224 hash of the data as a string. | |
OFString * | SHA256Hash |
The SHA-256 hash of the data as a string. | |
OFString * | SHA384Hash |
The SHA-384 hash of the data as a string. | |
OFString * | SHA512Hash |
The SHA-512 hash of the data as a string. | |
id | objectByParsingMessagePack |
The data interpreted as MessagePack representation and parsed as an object. | |
![]() | |
OFString * | className |
The name of the object's class. | |
OFString * | description |
A description for the object. More... | |
OFString * | stringBySerializing |
The object serialized as a string. | |
![]() | |
OFXMLElement * | XMLElementBySerializing |
The object serialized into an XML element. | |
![]() | |
OFData * | messagePackRepresentation |
The MessagePack representation of the object as OFData. | |
A class for storing arbitrary data in secure (non-swappable) memory, securely wiping it when it gets deallocated.
+ (instancetype) dataWithBase64EncodedString: | (OFString *) | string |
+ (instancetype) dataWithContentsOfFile: | (OFString *) | path |
+ (instancetype) dataWithContentsOfURL: | (OFURL *) | URL |
+ (instancetype) dataWithCount: | (size_t) | count | |
allowsSwappableMemory: | (bool) | allowsSwappableMemory | |
Creates a new, autoreleased OFSecureData with count items of item size 1, all set to zero.
count | The number of zero items the OFSecureData should contain |
allowsSwappableMemory | Whether the data may be stored in swappable memory |
+ (instancetype) dataWithCount: | (size_t) | count | |
itemSize: | (size_t) | itemSize | |
allowsSwappableMemory: | (bool) | allowsSwappableMemory | |
Creates a new, autoreleased OFSecureData with count items of the specified item size, all set to zero.
count | The number of zero items the OFSecureData should contain |
itemSize | The size of a single item in the OFSecureData in bytes |
allowsSwappableMemory | Whether the data may be stored in swappable memory |
+ (instancetype) dataWithItems: | (const void *) | items | |
count: | (size_t) | count | |
+ (instancetype) dataWithItems: | (const void *) | items | |
count: | (size_t) | count | |
itemSize: | (size_t) | itemSize | |
+ (instancetype) dataWithItemsNoCopy: | (void *) | items | |
count: | (size_t) | count | |
freeWhenDone: | (bool) | freeWhenDone | |
Creates a new OFData with the specified count
items of size 1 by taking over ownership of the specified items pointer.
items | The items to store in the OFData |
count | The number of items |
freeWhenDone | Whether to free the pointer when it is no longer needed by the OFData |
Reimplemented from OFData.
+ (instancetype) dataWithItemsNoCopy: | (void *) | items | |
count: | (size_t) | count | |
itemSize: | (size_t) | itemSize | |
freeWhenDone: | (bool) | freeWhenDone | |
Creates a new OFData with the specified count
items of the specified size by taking ownership of the specified items pointer.
items | The items to store in the OFData |
count | The number of items |
itemSize | The item size of a single item in bytes |
freeWhenDone | Whether to free the pointer when it is no longer needed by the OFData |
Reimplemented from OFData.
+ (instancetype) dataWithStringRepresentation: | (OFString *) | string |
- (instancetype) initWithBase64EncodedString: | (OFString *) | string |
- (instancetype) initWithContentsOfFile: | (OFString *) | path |
- (instancetype) initWithContentsOfURL: | (OFURL *) | URL |
- (instancetype) initWithCount: | (size_t) | count | |
allowsSwappableMemory: | (bool) | allowsSwappableMemory | |
Initializes an already allocated OFSecureData with count items of item size 1, all set to zero.
count | The number of zero items the OFSecureData should contain |
allowsSwappableMemory | Whether the data may be stored in swappable memory |
- (instancetype) initWithCount: | (size_t) | count | |
itemSize: | (size_t) | itemSize | |
allowsSwappableMemory: | (bool) | allowsSwappableMemory | |
Initializes an already allocated OFSecureData with count items of the specified item size, all set to zero.
itemSize | The size of a single item in the OFSecureData in bytes |
count | The number of zero items the OFSecureData should contain |
allowsSwappableMemory | Whether the data may be stored in swappable memory |
- (instancetype) initWithItems: | (const void *) | items | |
count: | (size_t) | count | |
- (instancetype) initWithItems: | (const void *) | items | |
count: | (size_t) | count | |
itemSize: | (size_t) | itemSize | |
- (instancetype) initWithItemsNoCopy: | (void *) | items | |
count: | (size_t) | count | |
freeWhenDone: | (bool) | freeWhenDone | |
Initializes an already allocated OFData with the specified count
items of size 1 by taking over ownership of the specified items pointer.
items | The items to store in the OFData |
count | The number of items |
freeWhenDone | Whether to free the pointer when it is no longer needed by the OFData |
Reimplemented from OFData.
- (instancetype) initWithItemsNoCopy: | (void *) | items | |
count: | (size_t) | count | |
itemSize: | (size_t) | itemSize | |
freeWhenDone: | (bool) | freeWhenDone | |
Initializes an already allocated OFData with the specified count
items of the specified size by taking ownership of the specified items pointer.
items | The items to store in the OFData |
count | The number of items |
itemSize | The item size of a single item in bytes |
freeWhenDone | Whether to free the pointer when it is no longer needed by the OFData |
Reimplemented from OFData.
- (instancetype) initWithSerialization: | (OFXMLElement *) | element |
Initializes the object with the specified XML element serialization.
element | An OFXMLElement with the serialized object |
Reimplemented from <OFSerialization>.
- (instancetype) initWithStringRepresentation: | (OFString *) | string |
- (bool) isEqual: | (nullable id) | object |
Checks the OFSecureData for equality to another object.
If the specified object is a subclass of OFData, the comparison is performed in constant time.
object | The object which should be tested for equality |
Reimplemented from <OFObject>.
- (void *) mutableItemAtIndex: | (size_t) | index |
Returns a specific item of the OFSecureData.
Modifying the returned item directly is allowed and will change the contents of the data array.
index | The number of the item to return |
+ (void) preallocateUnswappableMemoryWithSize: | (size_t) | size |
Preallocates the specified number of bytes for unswappable memory.
This is useful to allocate unswappable memory before enabling a sandbox that does not allow it anymore.
size | The number of bytes of unswappable memory to preallocate |
- (void) writeToFile: | (OFString *) | path |
- (void) writeToURL: | (OFURL *) | URL |
|
readnonatomicassign |
All items of the OFSecureData as a C array.
Modifying the returned array directly is allowed and will change the contents of the data.