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 final int HASH_HEX_LENGTH = 40;
032
033        public static final int HASH_BYTE_LENGTH = HASH_HEX_LENGTH / 2;
034
035        /**
036         * Create a SHA1 server session compatible with a JavaScript client session.
037         * 
038         * You can generate your own with openssl see {@link OpenSSLCryptoConfigConverter}
039         * 
040         * @param N
041         *            The large safe prime in radix10
042         * @param g
043         *            The safe prime generator in radix10
044         */
045        public SRP6JavascriptServerSessionSHA1(String N, String g) {
046                super(new SRP6CryptoParams(fromDecimal(N), fromDecimal(g), SHA_1));
047        }
048
049}