Top Description Constructors Methods
org.bouncycastle.crypto.general

pack-priv Class SCryptImpl

extends Object
Class Inheritance
Imports
org.bouncycastle.crypto.fips.FipsSHS, org.bouncycastle.crypto.internal.PBEParametersGenerator, org.bouncycastle.crypto.internal.params.KeyParameter, org.bouncycastle.util.Arrays, .Pack

Implementation of the scrypt a password-based key derivation function.

Scrypt was created by Colin Percival and is specified in RFC 7914 - The scrypt Password-Based Key Derivation Function

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static void
BlockMix(int[] B, int[] X1, int[] X2, int[] Y, int r)

private static void
Clear(byte[] array)

private static void
Clear(int[] array)

private static void
ClearAll(int[][] arrays)

public static byte[]

Returns:

the generated key.
generate
(byte[]
the bytes of the pass phrase.
P
,
byte[]
the salt to use for this invocation.
S
,
int
CPU/Memory cost parameter. Must be larger than 1, a power of 2 and less than 2^(128 * r / 8).
N
,
int
the block size, must be >= 1.
r
,
int
Parallelization parameter. Must be a positive integer less than or equal to Integer.MAX_VALUE / (128 * r * 8).
p
,
int
the length of the key to generate.
dkLen
)

Generate a key using the scrypt key derivation function.

private static boolean
isPowerOf2(int x)

private static byte[]
MFcrypt(byte[] P, byte[] S, int N, int r, int p, int dkLen)

private static byte[]
SingleIterationPBKDF2(byte[] P, byte[] S, int dkLen)

private static void
SMix(int[] B, int BOff, int N, int r)

private static void
Xor(int[] a, int[] b, int bOff, int[] output)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

SCryptImplback to summary
private SCryptImpl()

Method Detail

BlockMixback to summary
private static void BlockMix(int[] B, int[] X1, int[] X2, int[] Y, int r)
Clearback to summary
private static void Clear(byte[] array)
Clearback to summary
private static void Clear(int[] array)
ClearAllback to summary
private static void ClearAll(int[][] arrays)
generateback to summary
public static byte[] generate(byte[] P, byte[] S, int N, int r, int p, int dkLen)

Generate a key using the scrypt key derivation function.

Parameters
P:byte[]

the bytes of the pass phrase.

S:byte[]

the salt to use for this invocation.

N:int

CPU/Memory cost parameter. Must be larger than 1, a power of 2 and less than 2^(128 * r / 8).

r:int

the block size, must be >= 1.

p:int

Parallelization parameter. Must be a positive integer less than or equal to Integer.MAX_VALUE / (128 * r * 8).

dkLen:int

the length of the key to generate.

Returns:byte[]

the generated key.

isPowerOf2back to summary
private static boolean isPowerOf2(int x)
MFcryptback to summary
private static byte[] MFcrypt(byte[] P, byte[] S, int N, int r, int p, int dkLen)
SingleIterationPBKDF2back to summary
private static byte[] SingleIterationPBKDF2(byte[] P, byte[] S, int dkLen)
SMixback to summary
private static void SMix(int[] B, int BOff, int N, int r)
Xorback to summary
private static void Xor(int[] a, int[] b, int bOff, int[] output)