Package de.bsvrz.sys.funclib.srp6
Class SRP6CryptoParams
java.lang.Object
de.bsvrz.sys.funclib.srp6.SRP6CryptoParams
- All Implemented Interfaces:
Serializable
The crypto parameters for the SRP-6a protocol. These must be agreed between
client and server before authentication and consist of a large safe prime
'N', a corresponding generator 'g' and a hash function algorithm 'H'.
The practical approach is to have the server manage these and make them available to clients on request. This way, the client does not need to anticipate or otherwise keep track of which parameters are used for which users or servers; it only needs to verify their validity, which can be done mathematically or by simple table lookup.
For convenience this class includes a set of precomputed parameters.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal BigInteger
The corresponding generator 'g'.static final BigInteger
static final BigInteger
static final BigInteger
Generator 'g' parameter forN_8192
as decimal.final String
The hash algorithm 'H'.final BigInteger
The safe prime 'N'.static final BigInteger
Precomputed safe 1024-bit prime 'N', as decimal.static final BigInteger
Precomputed safe 1536-bit prime 'N', as decimal.static final BigInteger
Precomputed safe 2048-bit prime 'N', as decimal.static final BigInteger
Precomputed safe 256-bit prime 'N', as decimal.static final BigInteger
Precomputed safe 3072-bit prime 'N', as decimal.static final BigInteger
Precomputed safe 4096-bit prime 'N', as decimal.static final BigInteger
Precomputed safe 512-bit prime 'N', as decimal.static final BigInteger
Precomputed safe 6144-bit prime 'N', as decimal.static final BigInteger
Precomputed safe 768-bit prime 'N', as decimal.static final BigInteger
Precomputed safe 8192-bit prime 'N', as decimal. -
Constructor Summary
ConstructorsConstructorDescriptionSRP6CryptoParams
(BigInteger N, BigInteger g, String H) Creates a new SRP-6a crypto parameters instance. -
Method Summary
Modifier and TypeMethodDescriptionstatic SRP6CryptoParams
Returns an SRP-6a crypto parameters instance with precomputed 512-bit prime 'N', matching 'g' value and "SHA-1" hash algorithm.static SRP6CryptoParams
getInstance
(int bitsize, String H) Returns an SRP-6a crypto parameters instance with precomputed 'N' and 'g' values and the specified hash algorithm 'H'.Returns a new message digest instance for the hash algorithm 'H'.static boolean
Checks if the specified hash algorithm 'H' is supported by the default security provider of the underlying Java runtime.
-
Field Details
-
N_256
Precomputed safe 256-bit prime 'N', as decimal. Origin SRP-6a demo at http://srp.stanford.edu/demo/demo.html. -
N_512
Precomputed safe 512-bit prime 'N', as decimal. Origin SRP-6a demo at http://srp.stanford.edu/demo/demo.html. -
N_768
Precomputed safe 768-bit prime 'N', as decimal. Origin SRP-6a demo at http://srp.stanford.edu/demo/demo.html. -
N_1024
Precomputed safe 1024-bit prime 'N', as decimal. Origin RFC 5054, appendix A. -
N_1536
Precomputed safe 1536-bit prime 'N', as decimal. Origin RFC 5054, appendix A. -
N_2048
Precomputed safe 2048-bit prime 'N', as decimal. Origin RFC 5054, appendix A. -
N_3072
Precomputed safe 3072-bit prime 'N', as decimal. Origin RFC 5054, appendix A. -
N_4096
Precomputed safe 4096-bit prime 'N', as decimal. Origin RFC 5054, appendix A. -
N_6144
Precomputed safe 6144-bit prime 'N', as decimal. Origin RFC 5054, appendix A. -
N_8192
Precomputed safe 8192-bit prime 'N', as decimal. Origin RFC 5054, appendix A. -
g_common
-
g_large
-
g_x_large
Generator 'g' parameter forN_8192
as decimal. -
N
The safe prime 'N'. -
g
The corresponding generator 'g'. -
H
The hash algorithm 'H'.
-
-
Constructor Details
-
SRP6CryptoParams
Creates a new SRP-6a crypto parameters instance. Note that the 'N' and 'g' values are not validated, nor is the 'H' support by the default security provider of the underlying Java runtime.- Parameters:
N
- A large safe prime for the 'N' parameter. Must not benull
.g
- A corresponding generator for the 'g' parameter. Must not benull
.H
- A hash algorithm. Must by supported by the default security provider of the underlying Java runtime. Must not benull
.
-
-
Method Details
-
getInstance
Returns an SRP-6a crypto parameters instance with precomputed 'N' and 'g' values and the specified hash algorithm 'H'.- Parameters:
bitsize
- The preferred prime number bitsize. Must exist as a precomputed constant.H
- The preferred hash algorithm. Must be supported by the default security provider of the underlying Java runtime.- Returns:
- The matching SRP-6a crypto parameters instance, or
null
if no matching constants or hash algorithm provider could be found.
-
getInstance
Returns an SRP-6a crypto parameters instance with precomputed 512-bit prime 'N', matching 'g' value and "SHA-1" hash algorithm.- Returns:
- SRP-6a crypto parameters instance with 512-bit prime 'N', matching 'g' value and "SHA-1" hash algorithm.
-
isSupportedHashAlgorithm
Checks if the specified hash algorithm 'H' is supported by the default security provider of the underlying Java runtime.- Parameters:
H
- The hash algorithm to check, e.g. "SHA-1".- Returns:
true
if the hash algorightm is supported, elsefalse
.
-
getMessageDigestInstance
Returns a new message digest instance for the hash algorithm 'H'.- Returns:
- A new message digest instance or
null
if not supported by the default security provider of the underlying Java runtime.
-