Class SecureArray
Base class of all SecureArray<T> classes.
Inherited Members
Namespace: Isopoh.Cryptography.SecureArray
Assembly: Isopoh.Cryptography.SecureArray.dll
Syntax
public class SecureArray
Constructors
| Improve this Doc View SourceSecureArray(SecureArrayCall)
Initializes a new instance of the SecureArray class.
Declaration
protected SecureArray(SecureArrayCall call)
Parameters
Type | Name | Description |
---|---|---|
SecureArrayCall | call | The methods that get called to secure the array. A null value defaults to SecureArray.DefaultCall. |
Remarks
You cannot create a SecureArray directly, you must derive from this class like SecureArray<T> does.
Properties
| Improve this Doc View SourceCall
Gets or sets the methods that get called to secure the array.
Declaration
public SecureArrayCall Call { get; set; }
Property Value
Type | Description |
---|---|
SecureArrayCall |
DefaultCall
Gets the default methods that get called to secure the array.
Declaration
public static SecureArrayCall DefaultCall { get; }
Property Value
Type | Description |
---|---|
SecureArrayCall |
ProtectionType
Gets the SecureArrayType of protection this SecureArray has.
Declaration
public SecureArrayType ProtectionType { get; }
Property Value
Type | Description |
---|---|
SecureArrayType |
ReportMaxLockableOnLockFail
Gets or sets a value indicating whether the maximum lockable memory will be reported in the exception message upon lock failure.
Declaration
public static bool ReportMaxLockableOnLockFail { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
Only turn this on if you need this information because this calculation can take a lot of time (over 90% of the time for something like typical Argon2 hashing).
Methods
| Improve this Doc View SourceBuiltInTypeElementSize<T>(T[])
Gets the size of the buffer element. Will throw a System.NotSupportedException if the element type is not a built in type.
Declaration
public static int BuiltInTypeElementSize<T>(T[] buffer)
Parameters
Type | Name | Description |
---|---|---|
T[] | buffer | The array. |
Returns
Type | Description |
---|---|
System.Int32 | The lengths in bytes of the size of the element in |
Type Parameters
Name | Description |
---|---|
T | The array element type to return the size of. |
Cleanup<T>(T[])
Zero buf
and release resources.
Declaration
protected void Cleanup<T>(T[] buf)
Parameters
Type | Name | Description |
---|---|---|
T[] | buf | The buffer to zero and whose resources to release. Should be the same as passed into Init<T>(T[], SecureArrayType). |
Type Parameters
Name | Description |
---|---|
T | The type of the array elements in |
Init<T>(T[], SecureArrayType)
Call this with the array to secure and the number of bytes in that array. The buffer will be zeroed and the handle freed when the instance is disposed.
Declaration
protected void Init<T>(T[] buffer, SecureArrayType type)
Parameters
Type | Name | Description |
---|---|---|
T[] | buffer | The array to secure. |
SecureArrayType | type | The type of secure array to initialize. |
Type Parameters
Name | Description |
---|---|
T | The type of the array elements in |
Exceptions
Type | Condition |
---|---|
LockFailException | Operating system did not allow the memory to be locked. |
Zero<T>(T[], SecureArrayCall)
Zero the given buffer in a way that will not be optimized away.
Declaration
public static void Zero<T>(T[] buffer, SecureArrayCall call = null)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
T[] | buffer | The buffer to zero. |
SecureArrayCall | call | The methods to call to secure the array. Defaults to SecureArray.DefaultCall. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the buffer. |