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