Interface Argon2Library

  • All Superinterfaces:
    com.sun.jna.Library

    public interface Argon2Library
    extends com.sun.jna.Library
    JNA bindings for Argon2.
    • Field Detail

      • INSTANCE

        static final Argon2Library INSTANCE
        Singleton instance.
      • ARGON2_OK

        static final int ARGON2_OK
        Return code if everything is okay.
        See Also:
        Constant Field Values
    • Method Detail

      • argon2i_hash_encoded

        int argon2i_hash_encoded​(JnaUint32 t_cost,
                                 JnaUint32 m_cost,
                                 JnaUint32 parallelism,
                                 byte[] pwd,
                                 Size_t pwdlen,
                                 byte[] salt,
                                 Size_t saltlen,
                                 Size_t hashlen,
                                 byte[] encoded,
                                 Size_t encodedlen)
        Hashes a password with Argon2i, producing an encoded hash.
        Parameters:
        t_cost - Number of iterations
        m_cost - Sets memory usage to m_cost kibibytes
        parallelism - Number of threads and compute lanes
        pwd - Pointer to password
        pwdlen - Password size in bytes
        salt - Pointer to salt
        saltlen - Salt size in bytes
        hashlen - Desired length of the hash in bytes
        encoded - Buffer where to write the encoded hash
        encodedlen - Size of the buffer (thus max size of the encoded hash)
        Returns:
        ARGON2_OK if successful
      • argon2id_hash_encoded

        int argon2id_hash_encoded​(JnaUint32 t_cost,
                                  JnaUint32 m_cost,
                                  JnaUint32 parallelism,
                                  byte[] pwd,
                                  Size_t pwdlen,
                                  byte[] salt,
                                  Size_t saltlen,
                                  Size_t hashlen,
                                  byte[] encoded,
                                  Size_t encodedlen)
        Hashes a password with Argon2id, producing an encoded hash.
        Parameters:
        t_cost - Number of iterations
        m_cost - Sets memory usage to m_cost kibibytes
        parallelism - Number of threads and compute lanes
        pwd - Pointer to password
        pwdlen - Password size in bytes
        salt - Pointer to salt
        saltlen - Salt size in bytes
        hashlen - Desired length of the hash in bytes
        encoded - Buffer where to write the encoded hash
        encodedlen - Size of the buffer (thus max size of the encoded hash)
        Returns:
        ARGON2_OK if successful
      • argon2d_hash_encoded

        int argon2d_hash_encoded​(JnaUint32 t_cost,
                                 JnaUint32 m_cost,
                                 JnaUint32 parallelism,
                                 byte[] pwd,
                                 Size_t pwdlen,
                                 byte[] salt,
                                 Size_t saltlen,
                                 Size_t hashlen,
                                 byte[] encoded,
                                 Size_t encodedlen)
        Hashes a password with Argon2d, producing an encoded hash.
        Parameters:
        t_cost - Number of iterations
        m_cost - Sets memory usage to m_cost kibibytes
        parallelism - Number of threads and compute lanes
        pwd - Pointer to password
        pwdlen - Password size in bytes
        salt - Pointer to salt
        saltlen - Salt size in bytes
        hashlen - Desired length of the hash in bytes
        encoded - Buffer where to write the encoded hash
        encodedlen - Size of the buffer (thus max size of the encoded hash)
        Returns:
        ARGON2_OK if successful
      • argon2i_hash_raw

        int argon2i_hash_raw​(JnaUint32 t_cost,
                             JnaUint32 m_cost,
                             JnaUint32 parallelism,
                             byte[] pwd,
                             Size_t pwdlen,
                             byte[] salt,
                             Size_t saltlen,
                             byte[] hash,
                             Size_t hashlen)
        Hashes a password with Argon2i, producing an encoded hash.
        Parameters:
        t_cost - Number of iterations
        m_cost - Sets memory usage to m_cost kibibytes
        parallelism - Number of threads and compute lanes
        pwd - Pointer to password
        pwdlen - Password size in bytes
        salt - Pointer to salt
        saltlen - Salt size in bytes
        hash - Buffer where to write the raw hash
        hashlen - Desired length of the hash in bytes
        Returns:
        ARGON2_OK if successful
      • argon2id_hash_raw

        int argon2id_hash_raw​(JnaUint32 t_cost,
                              JnaUint32 m_cost,
                              JnaUint32 parallelism,
                              byte[] pwd,
                              Size_t pwdlen,
                              byte[] salt,
                              Size_t saltlen,
                              byte[] hash,
                              Size_t hashlen)
        Hashes a password with Argon2id, producing an encoded hash.
        Parameters:
        t_cost - Number of iterations
        m_cost - Sets memory usage to m_cost kibibytes
        parallelism - Number of threads and compute lanes
        pwd - Pointer to password
        pwdlen - Password size in bytes
        salt - Pointer to salt
        saltlen - Salt size in bytes
        hash - Buffer where to write the raw hash
        hashlen - Desired length of the hash in bytes
        Returns:
        ARGON2_OK if successful
      • argon2d_hash_raw

        int argon2d_hash_raw​(JnaUint32 t_cost,
                             JnaUint32 m_cost,
                             JnaUint32 parallelism,
                             byte[] pwd,
                             Size_t pwdlen,
                             byte[] salt,
                             Size_t saltlen,
                             byte[] hash,
                             Size_t hashlen)
        Hashes a password with Argon2d, producing an encoded hash.
        Parameters:
        t_cost - Number of iterations
        m_cost - Sets memory usage to m_cost kibibytes
        parallelism - Number of threads and compute lanes
        pwd - Pointer to password
        pwdlen - Password size in bytes
        salt - Pointer to salt
        saltlen - Salt size in bytes
        hash - Buffer where to write the raw hash
        hashlen - Desired length of the hash in bytes
        Returns:
        ARGON2_OK if successful
      • argon2i_verify

        int argon2i_verify​(byte[] encoded,
                           byte[] pwd,
                           Size_t pwdlen)
        Verifies a password against an Argon2i encoded string.
        Parameters:
        encoded - String encoding parameters, salt, hash
        pwd - Pointer to password
        pwdlen - Password size in bytes
        Returns:
        ARGON2_OK if successful
      • argon2d_verify

        int argon2d_verify​(byte[] encoded,
                           byte[] pwd,
                           Size_t pwdlen)
        Verifies a password against an Argon2d encoded string.
        Parameters:
        encoded - String encoding parameters, salt, hash
        pwd - Pointer to password
        pwdlen - Password size in bytes
        Returns:
        ARGON2_OK if successful
      • argon2id_verify

        int argon2id_verify​(byte[] encoded,
                            byte[] pwd,
                            Size_t pwdlen)
        Verifies a password against an Argon2id encoded string.
        Parameters:
        encoded - String encoding parameters, salt, hash
        pwd - Pointer to password
        pwdlen - Password size in bytes
        Returns:
        ARGON2_OK if successful
      • argon2_verify

        int argon2_verify​(byte[] encoded,
                          byte[] pwd,
                          Size_t pwdlen,
                          Argon2_type type)
      • argon2i_ctx

        int argon2i_ctx​(Argon2_context.ByReference context)
        Argon2i: Version of Argon2 that picks memory blocks independent on the password and salt. Good for side-channels, but worse w.r.t. tradeoff attacks if only one pass is used.
        Parameters:
        context - Pointer to current Argon2 context
        Returns:
        Zero if successful, a non zero error code otherwise
      • argon2d_ctx

        int argon2d_ctx​(Argon2_context.ByReference contexts)
        Argon2d: Version of Argon2 that picks memory blocks depending on the password and salt. Only for side-channel-free environment!!
        Parameters:
        contexts - Pointer to current Argon2 context
        Returns:
        Zero if successful, a non zero error code otherwise
      • argon2id_ctx

        int argon2id_ctx​(Argon2_context.ByReference contexts)
        Argon2id: Version of Argon2 where the first half-pass over memory is password-independent, the rest are password-dependent (on the password and salt). OK against side channels (they reduce to 1/2-pass Argon2i), and better with w.r.t. tradeoff attacks (similar to Argon2d).
        Parameters:
        contexts - Pointer to current Argon2 context
        Returns:
        Zero if successful, a non zero error code otherwise
      • argon2i_verify_ctx

        int argon2i_verify_ctx​(Argon2_context.ByReference context,
                               byte[] hash)
        Verify if a given password is correct for Argon2d hashing
        Parameters:
        context - Pointer to current Argon2 context
        hash - The password hash to verify. The length of the hash is specified by the context outlen member
        Returns:
        Zero if successful, a non zero error code otherwise
      • argon2d_verify_ctx

        int argon2d_verify_ctx​(Argon2_context.ByReference context,
                               byte[] hash)
        Verify if a given password is correct for Argon2i hashing
        Parameters:
        context - Pointer to current Argon2 context
        hash - The password hash to verify. The length of the hash is specified by the context outlen member
        Returns:
        Zero if successful, a non zero error code otherwise
      • argon2id_verify_ctx

        int argon2id_verify_ctx​(Argon2_context.ByReference context,
                                byte[] hash)
        Verify if a given password is correct for Argon2id hashing
        Parameters:
        context - Pointer to current Argon2 context
        hash - The password hash to verify. The length of the hash is specified by the context outlen member
        Returns:
        Zero if successful, a non zero error code otherwise
      • argon2_encodedlen

        Size_t argon2_encodedlen​(JnaUint32 t_cost,
                                 JnaUint32 m_cost,
                                 JnaUint32 parallelism,
                                 JnaUint32 saltlen,
                                 JnaUint32 hashlen,
                                 Argon2_type type)
        Returns the encoded hash length for the given input parameters.
        Parameters:
        t_cost - Number of iterations.
        m_cost - Memory usage in kibibytes.
        parallelism - Number of threads; used to compute lanes.
        saltlen - Salt size in bytes.
        hashlen - Hash size in bytes.
        type - The argon2 type.
        Returns:
        The encoded hash length in bytes.
      • argon2_error_message

        java.lang.String argon2_error_message​(int error_code)
        Get the associated error message for given error code.
        Parameters:
        error_code - Numeric error code.
        Returns:
        The error message associated with the given error code.