Class SCrypt

    • Constructor Summary

      Constructors 
      Constructor Description
      SCrypt()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void blockmix_salsa8​(byte[] BY, int Bi, int Yi, int r)  
      static void blockxor​(byte[] S, int Si, byte[] D, int Di, int len)  
      static int integerify​(byte[] B, int Bi, int r)  
      static int R​(int a, int b)  
      static void salsa20_8​(byte[] B)  
      static byte[] scrypt​(byte[] passwd, byte[] salt, int N, int r, int p, int dkLen)
      Implementation of the scrypt KDF.
      static byte[] scryptJ​(byte[] passwd, byte[] salt, int N, int r, int p, int dkLen)
      Pure Java implementation of the scrypt KDF.
      static byte[] scryptN​(byte[] passwd, byte[] salt, int N, int r, int p, int dkLen)
      Native C implementation of the scrypt KDF using the code from http://www.tarsnap.com/scrypt.html.
      static void smix​(byte[] B, int Bi, int r, int N, byte[] V, byte[] XY)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • native_library_loaded

        private static final boolean native_library_loaded
    • Constructor Detail

      • SCrypt

        public SCrypt()
    • Method Detail

      • scrypt

        public static byte[] scrypt​(byte[] passwd,
                                    byte[] salt,
                                    int N,
                                    int r,
                                    int p,
                                    int dkLen)
                             throws java.security.GeneralSecurityException
        Implementation of the scrypt KDF. Calls the native implementation scryptN(byte[], byte[], int, int, int, int) when the native library was successfully loaded, otherwise calls scryptJ(byte[], byte[], int, int, int, int).
        Parameters:
        passwd - Password.
        salt - Salt.
        N - CPU cost parameter.
        r - Memory cost parameter.
        p - Parallelization parameter.
        dkLen - Intended length of the derived key.
        Returns:
        The derived key.
        Throws:
        java.security.GeneralSecurityException - when HMAC_SHA256 is not available.
      • scryptJ

        public static byte[] scryptJ​(byte[] passwd,
                                     byte[] salt,
                                     int N,
                                     int r,
                                     int p,
                                     int dkLen)
                              throws java.security.GeneralSecurityException
        Pure Java implementation of the scrypt KDF.
        Parameters:
        passwd - Password.
        salt - Salt.
        N - CPU cost parameter.
        r - Memory cost parameter.
        p - Parallelization parameter.
        dkLen - Intended length of the derived key.
        Returns:
        The derived key.
        Throws:
        java.security.GeneralSecurityException - when HMAC_SHA256 is not available.
      • smix

        public static void smix​(byte[] B,
                                int Bi,
                                int r,
                                int N,
                                byte[] V,
                                byte[] XY)
      • blockmix_salsa8

        public static void blockmix_salsa8​(byte[] BY,
                                           int Bi,
                                           int Yi,
                                           int r)
      • R

        public static int R​(int a,
                            int b)
      • salsa20_8

        public static void salsa20_8​(byte[] B)
      • blockxor

        public static void blockxor​(byte[] S,
                                    int Si,
                                    byte[] D,
                                    int Di,
                                    int len)
      • integerify

        public static int integerify​(byte[] B,
                                     int Bi,
                                     int r)