summaryrefslogtreecommitdiff
path: root/bcprov/src/main/java/org/bouncycastle/crypto/tls/ServerSRPParams.java
diff options
context:
space:
mode:
authorSergio Giro <sgiro@google.com>2016-02-01 10:41:58 +0000
committerSergio Giro <sgiro@google.com>2016-02-01 10:41:58 +0000
commit53b61f9fe9d58034fcc7021137e92460f91b70ce (patch)
tree90632062175928181977c1ab3ab59951bc1146c3 /bcprov/src/main/java/org/bouncycastle/crypto/tls/ServerSRPParams.java
parent3eebc2629986481f9fc77ab101c0c9b8ff2f2660 (diff)
downloadbouncycastle-53b61f9fe9d58034fcc7021137e92460f91b70ce.tar.gz
bouncycastle: Android tree with upstream code for version 1.52
Android tree as of 1af9aad12fedf1d93333e19f5ed0ab86f1cc4e2a Change-Id: I714fa0954a5d000cd88d1fb78b0b7fe28246d404
Diffstat (limited to 'bcprov/src/main/java/org/bouncycastle/crypto/tls/ServerSRPParams.java')
-rw-r--r--bcprov/src/main/java/org/bouncycastle/crypto/tls/ServerSRPParams.java75
1 files changed, 75 insertions, 0 deletions
diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/tls/ServerSRPParams.java b/bcprov/src/main/java/org/bouncycastle/crypto/tls/ServerSRPParams.java
new file mode 100644
index 00000000..21ca7d0f
--- /dev/null
+++ b/bcprov/src/main/java/org/bouncycastle/crypto/tls/ServerSRPParams.java
@@ -0,0 +1,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);
+ }
+}