-
public interface SecureMemory.Native
-
-
Method Summary
Modifier and Type Method Description abstract voidsodiumMemZero(Array<byte> pnt, int len)The sodium_memzero() function tries to effectively zero len bytes starting at pnt,even if optimizations are being applied to the code. abstract booleansodiumMLock(Array<byte> array, int len)Locks at least len bytes of memory from the array.This can help avoid swapping sensitive data to disk. abstract booleansodiumMUnlock(Array<byte> array, int len)Unlocks at least len bytes of memory from the array. abstract PointersodiumMalloc(int size)Returns a pointer from which exactlysize contiguous bytes of memory can be accessed. abstract PointersodiumAllocArray(int count, int size)Returns a pointer from whichcount objects that are size bytes of memory each can be accessed. abstract voidsodiumFree(Pointer p)Unlocks and deallocates memory allocated using sodiumMalloc or sodiumAllocArray}. abstract booleansodiumMProtectNoAccess(Pointer ptr)Makes a region allocated using sodiumMalloc or sodiumAllocArray}inaccessible. abstract booleansodiumMProtectReadOnly(Pointer ptr)Marks a region allocated using sodiumMalloc or sodiumAllocArray}as read-only.Attempting to modify the data will cause the process to terminate. abstract booleansodiumMProtectReadWrite(Pointer ptr)Marks a region allocated using sodiumMalloc or sodiumAllocArray}as readable and writable, after having been protected using sodiumMProtectReadOnly or sodiumMProtectNoAccess}/ -
-
Method Detail
-
sodiumMemZero
abstract void sodiumMemZero(Array<byte> pnt, int len)
The sodium_memzero() function tries to effectively zero len bytes starting at pnt,even if optimizations are being applied to the code.
- Parameters:
pnt- The byte array to zero out.len- How many bytes to zero out.
-
sodiumMLock
abstract boolean sodiumMLock(Array<byte> array, int len)
Locks at least len bytes of memory from the array.This can help avoid swapping sensitive data to disk.
- Parameters:
array- Array to lock.len- Number of bytes to lock.
-
sodiumMUnlock
abstract boolean sodiumMUnlock(Array<byte> array, int len)
Unlocks at least len bytes of memory from the array.
- Parameters:
array- Array to unlock.len- Number of bytes to unlock.
-
sodiumMalloc
abstract Pointer sodiumMalloc(int size)
Returns a pointer from which exactlysize contiguous bytes of memory can be accessed.
- Parameters:
size- The size of the byte array to allocate.
-
sodiumAllocArray
abstract Pointer sodiumAllocArray(int count, int size)
Returns a pointer from whichcount objects that are size bytes of memory each can be accessed.It provides the same guarantees as sodiumMalloc butalso protects against arithmetic overflows when count * size exceeds SIZE_MAX.
- Parameters:
count- Number of objectssize- Size of those objects
-
sodiumFree
abstract void sodiumFree(Pointer p)
Unlocks and deallocates memory allocated using sodiumMalloc or sodiumAllocArray}.
- Parameters:
p- The pointer to which an array shall be freed.
-
sodiumMProtectNoAccess
abstract boolean sodiumMProtectNoAccess(Pointer ptr)
Makes a region allocated using sodiumMalloc or sodiumAllocArray}inaccessible. It cannot be read or written, but the data is preserved.
- Parameters:
ptr- The pointer to a region to decline access to.
-
sodiumMProtectReadOnly
abstract boolean sodiumMProtectReadOnly(Pointer ptr)
Marks a region allocated using sodiumMalloc or sodiumAllocArray}as read-only.Attempting to modify the data will cause the process to terminate.
- Parameters:
ptr- Pointer to the region.
-
sodiumMProtectReadWrite
abstract boolean sodiumMProtectReadWrite(Pointer ptr)
Marks a region allocated using sodiumMalloc or sodiumAllocArray}as readable and writable, after having been protected using sodiumMProtectReadOnly or sodiumMProtectNoAccess}/
- Parameters:
ptr- Pointer to the region.
-
-
-
-