001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.security.srp;
023:
024: import java.math.BigInteger;
025:
026: import org.jboss.security.Util;
027:
028: /** A port of the libsrp/t_conf.c predefined constants for the N & g parameters
029: of the SRP algorithm. It contains a collection of "good" primes for N and the
030: corresponding the corresponding generator g.
031:
032: This product includes software developed by Tom Wu and Eugene
033: Jhong for the SRP Distribution (http://srp.stanford.edu/srp/).
034:
035: @author Scott.Stark@jboss.org
036: @version $Revision: 57210 $
037: */
038: public class SRPConf {
039: /* Master builtin parameter storage object */
040: public static class SRPParams {
041: String modb64;
042: String genb64;
043: String comment;
044: BigInteger N;
045: BigInteger g;
046:
047: SRPParams(String modb64, String genb64, String comment) {
048: this .modb64 = modb64;
049: this .genb64 = genb64;
050: this .comment = comment;
051: }
052:
053: public byte[] Nbytes() {
054: return Util.fromb64(modb64);
055: }
056:
057: public byte[] gbytes() {
058: return Util.fromb64(genb64);
059: }
060:
061: public BigInteger N() {
062: if (N == null)
063: N = new BigInteger(1, Util.fromb64(modb64));
064: return N;
065: }
066:
067: public BigInteger g() {
068: if (g == null)
069: g = new BigInteger(1, Util.fromb64(genb64));
070: return g;
071: }
072:
073: public String getComment() {
074: return comment;
075: }
076: }
077:
078: static SRPParams[] pre_params = {
079: new SRPParams(
080: "3Kn/YYiomHkFkfM1x4kayR125MGkzpLUDy3y14FlTMwYnhZkjrMXnoC2TcFAecNlU5kFzgcpKYUbBOPZFRtyf3",
081: "2", null),
082: new SRPParams(
083: "CbDP.jR6YD6wAj2ByQWxQxQZ7.9J9xkn2.Uqb3zVm16vQyizprhBw9hi80psatZ8k54vwZfiIeEHZVsDnyqeWSSIpWso.wh5GD4OFgdhVI3",
084: "2", null),
085: new SRPParams(
086: "iqJ7nFZ4bGCRjE1F.FXEwL085Zb0kLM2TdHDaVVCdq0cKxvnH/0FLskJTKlDtt6sDl89dc//aEULTVFGtcbA/tDzc.bnFE.DWthQOu2n2JwKjgKfgCR2lZFWXdnWmoOh",
087: "2", null),
088: new SRPParams(
089: "///////////93zgY8MZ2DCJ6Oek0t1pHAG9E28fdp7G22xwcEnER8b5A27cED0JTxvKPiyqwGnimAmfjybyKDq/XDMrjKS95v8MrTc9UViRqJ4BffZes8F//////////",
090: "7", "oakley prime 1"),
091: new SRPParams(
092: "Ewl2hcjiutMd3Fu2lgFnUXWSc67TVyy2vwYCKoS9MLsrdJVT9RgWTCuEqWJrfB6uE3LsE9GkOlaZabS7M29sj5TnzUqOLJMjiwEzArfiLr9WbMRANlF68N5AVLcPWvNx6Zjl3m5Scp0BzJBz9TkgfhzKJZ.WtP3Mv/67I/0wmRZ",
093: "2", null),
094: new SRPParams(
095: "F//////////oG/QeY5emZJ4ncABWDmSqIa2JWYAPynq0Wk.fZiJco9HIWXvZZG4tU.L6RFDEaCRC2iARV9V53TFuJLjRL72HUI5jNPYNdx6z4n2wQOtxMiB/rosz0QtxUuuQ/jQYP.bhfya4NnB7.P9A6PHxEPJWV//////////",
096: "5", "oakley prime 2"),
097: new SRPParams(
098: "3NUKQ2Re4P5BEK0TLg2dX3gETNNNECPoe92h4OVMaDn3Xo/0QdjgG/EvM.hiVV1BdIGklSI14HA38Mpe5k04juR5/EXMU0r1WtsLhNXwKBlf2zEfoOh0zVmDvqInpU695f29Iy7sNW3U5RIogcs740oUp2Kdv5wuITwnIx84cnO.e467/IV1lPnvMCr0pd1dgS0a.RV5eBJr03Q65Xy61R",
099: "2", null),
100: new SRPParams(
101: "dUyyhxav9tgnyIg65wHxkzkb7VIPh4o0lkwfOKiPp4rVJrzLRYVBtb76gKlaO7ef5LYGEw3G.4E0jbMxcYBetDy2YdpiP/3GWJInoBbvYHIRO9uBuxgsFKTKWu7RnR7yTau/IrFTdQ4LY/q.AvoCzMxV0PKvD9Odso/LFIItn8PbTov3VMn/ZEH2SqhtpBUkWtmcIkEflhX/YY/fkBKfBbe27/zUaKUUZEUYZ2H2nlCL60.JIPeZJSzsu/xHDVcx",
102: "2", null),
103: new SRPParams(
104: "2iQzj1CagQc/5ctbuJYLWlhtAsPHc7xWVyCPAKFRLWKADpASkqe9djWPFWTNTdeJtL8nAhImCn3Sr/IAdQ1FrGw0WvQUstPx3FO9KNcXOwisOQ1VlL.gheAHYfbYyBaxXL.NcJx9TUwgWDT0hRzFzqSrdGGTN3FgSTA1v4QnHtEygNj3eZ.u0MThqWUaDiP87nqha7XnT66bkTCkQ8.7T8L4KZjIImrNrUftedTTBi.WCi.zlrBxDuOM0da0JbUkQlXqvp0yvJAPpC11nxmmZOAbQOywZGmu9nhZNuwTlxjfIro0FOdthaDTuZRL9VL7MRPUDo/DQEyW.d4H.UIlzp",
105: "2", null), };
106:
107: public int getPredefinedCount() {
108: return pre_params.length;
109: }
110:
111: public static SRPParams getPredefinedParams(int n) {
112: return pre_params[n];
113: }
114:
115: public static SRPParams getDefaultParams() {
116: return pre_params[6];
117: }
118: }
|