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_N1024_SHA256. BigInteger values are communicated
010 * as 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 SRP6JavascriptServerSessionSHA256 extends SRP6JavascriptServerSession implements Serializable {
019
020        /**
021         * Serializable class version number
022         */
023        private static final long serialVersionUID = 8311147633496438232L;
024
025        public static final String SHA_256 = "SHA-256";
026
027        /**
028         * This must match the expected character length of the specified algorithm
029         * i.e. SHA-256 is 64
030         */
031        public static final int HASH_HEX_LENGTH = 64;
032
033        public static final int HASH_BYTE_LENGTH = HASH_HEX_LENGTH / 2;
034
035
036        /**
037         * Create a SHA-256 server session compatible with a JavaScript client
038         * session.
039         * 
040         * You can generate your own with openssl see {@link OpenSSLCryptoConfigConverter}
041         * 
042         * @param N
043         *            The large safe prime in radix10
044         * @param g
045         *            The safe prime generator in radix10
046         */
047        public SRP6JavascriptServerSessionSHA256(String N, String g) {
048                super(new SRP6CryptoParams(fromDecimal(N), fromDecimal(g), SHA_256));
049        }
050}