001package com.bitbucket.thinbus.srp6.js;
002
003import java.io.Serializable;
004
005import com.nimbusds.srp6.SRP6CryptoParams;
006
007/**
008 * Wrapper of a server session matching the Javascript client session
009 * SRP6JavascriptClientSession_N256_SHA1. BigInteger values are communicated as
010 * hex strings. Hashing is done as string concat of hex numbers. Does not
011 * include any session timeout logic on the assumption that can be handled by
012 * web server session logic.
013 * <p>
014 * Specification RFC 2945.
015 * 
016 * @author Simon Massey
017 */
018public class SRP6JavascriptServerSessionSHA1 extends SRP6JavascriptServerSession implements Serializable {
019
020        /**
021         * Serializable class version number
022         */
023        private static final long serialVersionUID = -8615033464877868308L;
024
025        public static final String SHA_1 = "SHA-1";
026
027        /**
028         * This must match the expected character length of the specified algorithm
029         * i.e. SHA-1 is 40
030         */
031        public static int HASH_HEX_LENGTH = 40;
032
033        /**
034         * Create a SHA1 server session compatible with a JavaScript client session.
035         * 
036         * You can generate your own with openssl see {@link OpenSSLCryptoConfig}
037         * 
038         * @param N
039         *            The large safe prime in radix10
040         * @param g
041         *            The safe prime generator in radix10
042         */
043        public SRP6JavascriptServerSessionSHA1(String N, String g) {
044                super(new SRP6CryptoParams(fromDecimal(N), fromDecimal(g), SHA_1));
045        }
046
047}