diff options
author | Roberto Tyley <roberto.tyley@gmail.com> | 2014-07-15 01:38:01 +0400 |
---|---|---|
committer | Roberto Tyley <roberto.tyley@gmail.com> | 2014-07-26 11:23:17 +0400 |
commit | 7cb752aaf746dc0b473afeb9e892b7fbc12666c5 (patch) | |
tree | cc4f91ddc18332b5adbe82e3fcb040d976c90105 /core/src/main/java/org/spongycastle/crypto/agreement/srp/SRP6VerifierGenerator.java | |
parent | 551830f8ea5177042af2c7dd1fc90888bc67387d (diff) |
Execute become-spongy.sh
https://github.com/rtyley/spongycastle/blob/3040af/become-spongy.sh
Diffstat (limited to 'core/src/main/java/org/spongycastle/crypto/agreement/srp/SRP6VerifierGenerator.java')
-rw-r--r-- | core/src/main/java/org/spongycastle/crypto/agreement/srp/SRP6VerifierGenerator.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/core/src/main/java/org/spongycastle/crypto/agreement/srp/SRP6VerifierGenerator.java b/core/src/main/java/org/spongycastle/crypto/agreement/srp/SRP6VerifierGenerator.java new file mode 100644 index 00000000..0324af18 --- /dev/null +++ b/core/src/main/java/org/spongycastle/crypto/agreement/srp/SRP6VerifierGenerator.java @@ -0,0 +1,47 @@ +package org.spongycastle.crypto.agreement.srp; + +import java.math.BigInteger; + +import org.spongycastle.crypto.Digest; + +/** + * Generates new SRP verifier for user + */ +public class SRP6VerifierGenerator +{ + protected BigInteger N; + protected BigInteger g; + protected Digest digest; + + public SRP6VerifierGenerator() + { + } + + /** + * Initialises generator to create new verifiers + * @param N The safe prime to use (see DHParametersGenerator) + * @param g The group parameter to use (see DHParametersGenerator) + * @param digest The digest to use. The same digest type will need to be used later for the actual authentication + * attempt. Also note that the final session key size is dependent on the chosen digest. + */ + public void init(BigInteger N, BigInteger g, Digest digest) + { + this.N = N; + this.g = g; + this.digest = digest; + } + + /** + * Creates a new SRP verifier + * @param salt The salt to use, generally should be large and random + * @param identity The user's identifying information (eg. username) + * @param password The user's password + * @return A new verifier for use in future SRP authentication + */ + public BigInteger generateVerifier(byte[] salt, byte[] identity, byte[] password) + { + BigInteger x = SRP6Util.calculateX(digest, N, salt, identity, password); + + return g.modPow(x, N); + } +} |