blob: 21ca7d0f433240b6b4247c3c4718b4f93c7a4130 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
package org.bouncycastle.crypto.tls;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigInteger;
import org.bouncycastle.util.Arrays;
public class ServerSRPParams
{
protected BigInteger N, g, B;
protected byte[] s;
public ServerSRPParams(BigInteger N, BigInteger g, byte[] s, BigInteger B)
{
this.N = N;
this.g = g;
this.s = Arrays.clone(s);
this.B = B;
}
public BigInteger getB()
{
return B;
}
public BigInteger getG()
{
return g;
}
public BigInteger getN()
{
return N;
}
public byte[] getS()
{
return s;
}
/**
* Encode this {@link ServerSRPParams} to an {@link OutputStream}.
*
* @param output
* the {@link OutputStream} to encode to.
* @throws IOException
*/
public void encode(OutputStream output) throws IOException
{
TlsSRPUtils.writeSRPParameter(N, output);
TlsSRPUtils.writeSRPParameter(g, output);
TlsUtils.writeOpaque8(s, output);
TlsSRPUtils.writeSRPParameter(B, output);
}
/**
* Parse a {@link ServerSRPParams} from an {@link InputStream}.
*
* @param input
* the {@link InputStream} to parse from.
* @return a {@link ServerSRPParams} object.
* @throws IOException
*/
public static ServerSRPParams parse(InputStream input) throws IOException
{
BigInteger N = TlsSRPUtils.readSRPParameter(input);
BigInteger g = TlsSRPUtils.readSRPParameter(input);
byte[] s = TlsUtils.readOpaque8(input);
BigInteger B = TlsSRPUtils.readSRPParameter(input);
return new ServerSRPParams(N, g, s, B);
}
}
|