Show / Hide Table of Contents

Class SecureArray

Base class of all SecureArray<T> classes.

Inheritance
System.Object
SecureArray
SecureArray<T>
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Isopoh.Cryptography.SecureArray
Assembly: Isopoh.Cryptography.SecureArray.dll
Syntax
public class SecureArray

Constructors

| Improve this Doc View Source

SecureArray(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 Source

Call

Gets or sets the methods that get called to secure the array.

Declaration
public SecureArrayCall Call { get; set; }
Property Value
Type Description
SecureArrayCall
| Improve this Doc View Source

DefaultCall

Gets the default methods that get called to secure the array.

Declaration
public static SecureArrayCall DefaultCall { get; }
Property Value
Type Description
SecureArrayCall
| Improve this Doc View Source

ProtectionType

Gets the SecureArrayType of protection this SecureArray has.

Declaration
public SecureArrayType ProtectionType { get; }
Property Value
Type Description
SecureArrayType
| Improve this Doc View Source

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 Source

BuiltInTypeElementSize<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 buffer.

Type Parameters
Name Description
T

The array element type to return the size of.

| Improve this Doc View Source

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

| Improve this Doc View Source

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

Exceptions
Type Condition
LockFailException

Operating system did not allow the memory to be locked.

| Improve this Doc View Source

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.

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX