KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > security > srp > SRPConf


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.security.srp;
23
24 import java.math.BigInteger JavaDoc;
25
26 import org.jboss.security.Util;
27
28 /** A port of the libsrp/t_conf.c predefined constants for the N & g parameters
29 of the SRP algorithm. It contains a collection of "good" primes for N and the
30 corresponding the corresponding generator g.
31
32 This product includes software developed by Tom Wu and Eugene
33 Jhong for the SRP Distribution (http://srp.stanford.edu/srp/).
34
35 @author Scott.Stark@jboss.org
36 @version $Revision: 40096 $
37 */

38 public class SRPConf
39 {
40     /* Master builtin parameter storage object */
41     public static class SRPParams
42     {
43         String JavaDoc modb64;
44         String JavaDoc genb64;
45         String JavaDoc comment;
46         BigInteger JavaDoc N;
47         BigInteger JavaDoc g;
48         SRPParams(String JavaDoc modb64, String JavaDoc genb64, String JavaDoc comment)
49         {
50             this.modb64 = modb64;
51             this.genb64 = genb64;
52             this.comment = comment;
53         }
54         public byte[] Nbytes()
55         {
56             return Util.fromb64(modb64);
57         }
58         public byte[] gbytes()
59         {
60             return Util.fromb64(genb64);
61         }
62         public BigInteger JavaDoc N()
63         {
64             if( N == null )
65                 N = new BigInteger JavaDoc(1, Util.fromb64(modb64));
66             return N;
67         }
68         public BigInteger JavaDoc g()
69         {
70             if( g == null )
71                 g = new BigInteger JavaDoc(1, Util.fromb64(genb64));
72             return g;
73         }
74         public String JavaDoc getComment()
75         {
76             return comment;
77         }
78     }
79
80     static SRPParams[] pre_params = {
81         new SRPParams("3Kn/YYiomHkFkfM1x4kayR125MGkzpLUDy3y14FlTMwYnhZkjrMXnoC2TcFAecNlU5kFzgcpKYUbBOPZFRtyf3",
82             "2", null),
83         new SRPParams("CbDP.jR6YD6wAj2ByQWxQxQZ7.9J9xkn2.Uqb3zVm16vQyizprhBw9hi80psatZ8k54vwZfiIeEHZVsDnyqeWSSIpWso.wh5GD4OFgdhVI3",
84             "2", null),
85         new SRPParams("iqJ7nFZ4bGCRjE1F.FXEwL085Zb0kLM2TdHDaVVCdq0cKxvnH/0FLskJTKlDtt6sDl89dc//aEULTVFGtcbA/tDzc.bnFE.DWthQOu2n2JwKjgKfgCR2lZFWXdnWmoOh",
86             "2", null),
87         new SRPParams("///////////93zgY8MZ2DCJ6Oek0t1pHAG9E28fdp7G22xwcEnER8b5A27cED0JTxvKPiyqwGnimAmfjybyKDq/XDMrjKS95v8MrTc9UViRqJ4BffZes8F//////////",
88             "7", "oakley prime 1"),
89         new SRPParams("Ewl2hcjiutMd3Fu2lgFnUXWSc67TVyy2vwYCKoS9MLsrdJVT9RgWTCuEqWJrfB6uE3LsE9GkOlaZabS7M29sj5TnzUqOLJMjiwEzArfiLr9WbMRANlF68N5AVLcPWvNx6Zjl3m5Scp0BzJBz9TkgfhzKJZ.WtP3Mv/67I/0wmRZ",
90             "2", null),
91         new SRPParams("F//////////oG/QeY5emZJ4ncABWDmSqIa2JWYAPynq0Wk.fZiJco9HIWXvZZG4tU.L6RFDEaCRC2iARV9V53TFuJLjRL72HUI5jNPYNdx6z4n2wQOtxMiB/rosz0QtxUuuQ/jQYP.bhfya4NnB7.P9A6PHxEPJWV//////////",
92             "5", "oakley prime 2"),
93         new SRPParams("3NUKQ2Re4P5BEK0TLg2dX3gETNNNECPoe92h4OVMaDn3Xo/0QdjgG/EvM.hiVV1BdIGklSI14HA38Mpe5k04juR5/EXMU0r1WtsLhNXwKBlf2zEfoOh0zVmDvqInpU695f29Iy7sNW3U5RIogcs740oUp2Kdv5wuITwnIx84cnO.e467/IV1lPnvMCr0pd1dgS0a.RV5eBJr03Q65Xy61R",
94             "2", null),
95         new SRPParams("dUyyhxav9tgnyIg65wHxkzkb7VIPh4o0lkwfOKiPp4rVJrzLRYVBtb76gKlaO7ef5LYGEw3G.4E0jbMxcYBetDy2YdpiP/3GWJInoBbvYHIRO9uBuxgsFKTKWu7RnR7yTau/IrFTdQ4LY/q.AvoCzMxV0PKvD9Odso/LFIItn8PbTov3VMn/ZEH2SqhtpBUkWtmcIkEflhX/YY/fkBKfBbe27/zUaKUUZEUYZ2H2nlCL60.JIPeZJSzsu/xHDVcx",
96             "2", null),
97         new SRPParams("2iQzj1CagQc/5ctbuJYLWlhtAsPHc7xWVyCPAKFRLWKADpASkqe9djWPFWTNTdeJtL8nAhImCn3Sr/IAdQ1FrGw0WvQUstPx3FO9KNcXOwisOQ1VlL.gheAHYfbYyBaxXL.NcJx9TUwgWDT0hRzFzqSrdGGTN3FgSTA1v4QnHtEygNj3eZ.u0MThqWUaDiP87nqha7XnT66bkTCkQ8.7T8L4KZjIImrNrUftedTTBi.WCi.zlrBxDuOM0da0JbUkQlXqvp0yvJAPpC11nxmmZOAbQOywZGmu9nhZNuwTlxjfIro0FOdthaDTuZRL9VL7MRPUDo/DQEyW.d4H.UIlzp",
98             "2", null),
99     };
100
101     public int getPredefinedCount()
102     {
103         return pre_params.length;
104     }
105     public static SRPParams getPredefinedParams(int n)
106     {
107         return pre_params[n];
108     }
109     public static SRPParams getDefaultParams()
110     {
111         return pre_params[6];
112     }
113 }
114
Popular Tags