Package de.bsvrz.sys.funclib.srp6
Class SRP6CryptoParams
- java.lang.Object
-
- de.bsvrz.sys.funclib.srp6.SRP6CryptoParams
-
- All Implemented Interfaces:
java.io.Serializable
public class SRP6CryptoParams extends java.lang.Object implements java.io.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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description java.math.BigInteger
g
The corresponding generator 'g'.static java.math.BigInteger
g_common
static java.math.BigInteger
g_large
static java.math.BigInteger
g_x_large
Generator 'g' parameter forN_8192
as decimal.java.lang.String
H
The hash algorithm 'H'.java.math.BigInteger
N
The safe prime 'N'.static java.math.BigInteger
N_1024
Precomputed safe 1024-bit prime 'N', as decimal.static java.math.BigInteger
N_1536
Precomputed safe 1536-bit prime 'N', as decimal.static java.math.BigInteger
N_2048
Precomputed safe 2048-bit prime 'N', as decimal.static java.math.BigInteger
N_256
Precomputed safe 256-bit prime 'N', as decimal.static java.math.BigInteger
N_3072
Precomputed safe 3072-bit prime 'N', as decimal.static java.math.BigInteger
N_4096
Precomputed safe 4096-bit prime 'N', as decimal.static java.math.BigInteger
N_512
Precomputed safe 512-bit prime 'N', as decimal.static java.math.BigInteger
N_6144
Precomputed safe 6144-bit prime 'N', as decimal.static java.math.BigInteger
N_768
Precomputed safe 768-bit prime 'N', as decimal.static java.math.BigInteger
N_8192
Precomputed safe 8192-bit prime 'N', as decimal.
-
Constructor Summary
Constructors Constructor Description SRP6CryptoParams(java.math.BigInteger N, java.math.BigInteger g, java.lang.String H)
Creates a new SRP-6a crypto parameters instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SRP6CryptoParams
getInstance()
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, java.lang.String H)
Returns an SRP-6a crypto parameters instance with precomputed 'N' and 'g' values and the specified hash algorithm 'H'.java.security.MessageDigest
getMessageDigestInstance()
Returns a new message digest instance for the hash algorithm 'H'.static boolean
isSupportedHashAlgorithm(java.lang.String H)
Checks if the specified hash algorithm 'H' is supported by the default security provider of the underlying Java runtime.
-
-
-
Field Detail
-
N_256
public static final java.math.BigInteger N_256
Precomputed safe 256-bit prime 'N', as decimal. Origin SRP-6a demo at http://srp.stanford.edu/demo/demo.html.
-
N_512
public static final java.math.BigInteger N_512
Precomputed safe 512-bit prime 'N', as decimal. Origin SRP-6a demo at http://srp.stanford.edu/demo/demo.html.
-
N_768
public static final java.math.BigInteger N_768
Precomputed safe 768-bit prime 'N', as decimal. Origin SRP-6a demo at http://srp.stanford.edu/demo/demo.html.
-
N_1024
public static final java.math.BigInteger N_1024
Precomputed safe 1024-bit prime 'N', as decimal. Origin RFC 5054, appendix A.
-
N_1536
public static final java.math.BigInteger N_1536
Precomputed safe 1536-bit prime 'N', as decimal. Origin RFC 5054, appendix A.
-
N_2048
public static final java.math.BigInteger N_2048
Precomputed safe 2048-bit prime 'N', as decimal. Origin RFC 5054, appendix A.
-
N_3072
public static final java.math.BigInteger N_3072
Precomputed safe 3072-bit prime 'N', as decimal. Origin RFC 5054, appendix A.
-
N_4096
public static final java.math.BigInteger N_4096
Precomputed safe 4096-bit prime 'N', as decimal. Origin RFC 5054, appendix A.
-
N_6144
public static final java.math.BigInteger N_6144
Precomputed safe 6144-bit prime 'N', as decimal. Origin RFC 5054, appendix A.
-
N_8192
public static final java.math.BigInteger N_8192
Precomputed safe 8192-bit prime 'N', as decimal. Origin RFC 5054, appendix A.
-
g_common
public static final java.math.BigInteger g_common
-
g_large
public static final java.math.BigInteger g_large
-
g_x_large
public static final java.math.BigInteger g_x_large
Generator 'g' parameter forN_8192
as decimal.
-
N
public final java.math.BigInteger N
The safe prime 'N'.
-
g
public final java.math.BigInteger g
The corresponding generator 'g'.
-
H
public final java.lang.String H
The hash algorithm 'H'.
-
-
Constructor Detail
-
SRP6CryptoParams
public SRP6CryptoParams(java.math.BigInteger N, java.math.BigInteger g, java.lang.String H)
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 Detail
-
getInstance
public static SRP6CryptoParams getInstance(int bitsize, java.lang.String H)
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
public static SRP6CryptoParams 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
public static boolean isSupportedHashAlgorithm(java.lang.String H)
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
public java.security.MessageDigest 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.
-
-