Interface SecureMemory.Native

    • Method Detail

      • sodiumMemZero

        boolean sodiumMemZero​(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.
        Returns:
        True if zeroed
      • sodiumMLock

        boolean sodiumMLock​(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.
        Returns:
        True if locked, false otherwise.
      • sodiumMUnlock

        boolean sodiumMUnlock​(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.
        Returns:
        True if unlocked, false otherwise.
      • sodiumMalloc

        com.sun.jna.Pointer sodiumMalloc​(int size)
        Returns a pointer from which exactly size contiguous bytes of memory can be accessed.
        Parameters:
        size - The size of the byte array to allocate.
        Returns:
        A Pointer to the byte array.
      • sodiumAllocArray

        com.sun.jna.Pointer sodiumAllocArray​(int count,
                                             int size)
        Returns a pointer from which count objects that are size bytes of memory each can be accessed. It provides the same guarantees as sodiumMalloc(int) but also protects against arithmetic overflows when count * size exceeds SIZE_MAX.
        Parameters:
        count - Number of objects
        size - Size of those objects
        Returns:
        A Pointer to the resulting array.
      • sodiumFree

        void sodiumFree​(com.sun.jna.Pointer p)
        Unlocks and deallocates memory allocated using sodiumMalloc(int) or sodiumAllocArray(int, int)}.
        Parameters:
        p - The pointer to which an array shall be freed.
      • sodiumMProtectNoAccess

        boolean sodiumMProtectNoAccess​(com.sun.jna.Pointer ptr)
        Makes a region allocated using sodiumMalloc(int) or sodiumAllocArray(int, int)} inaccessible. It cannot be read or written, but the data is preserved.
        Parameters:
        ptr - The pointer to a region to decline access to.
        Returns:
        True if operation completed successfully.
      • sodiumMProtectReadOnly

        boolean sodiumMProtectReadOnly​(com.sun.jna.Pointer ptr)
        Marks a region allocated using sodiumMalloc(int) or sodiumAllocArray(int, int)} as read-only. Attempting to modify the data will cause the process to terminate.
        Parameters:
        ptr - Pointer to the region.
        Returns:
        True if operation completed successfully.