use of net.java.otr4j.io.OtrOutputStream in project Zom-Android by zom.
the class IOTest method testIOBigInt.
public void testIOBigInt() throws Exception {
KeyPair pair = new OtrCryptoEngineImpl().generateDHKeyPair();
BigInteger source = ((DHPublicKey) pair.getPublic()).getY();
ByteArrayOutputStream out = new ByteArrayOutputStream();
OtrOutputStream oos = new OtrOutputStream(out);
oos.writeBigInt(source);
oos.close();
byte[] converted = out.toByteArray();
ByteArrayInputStream bin = new ByteArrayInputStream(converted);
OtrInputStream ois = new OtrInputStream(bin);
BigInteger result = ois.readBigInt();
ois.close();
assertTrue(source.compareTo(result) == 0);
}
use of net.java.otr4j.io.OtrOutputStream in project Zom-Android by zom.
the class SM method serialize.
public static byte[] serialize(BigInteger[] ints) throws SMException {
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
OtrOutputStream oos = new OtrOutputStream(out);
oos.writeInt(ints.length);
for (BigInteger i : ints) {
oos.writeBigInt(i);
}
byte[] b = out.toByteArray();
oos.close();
return b;
} catch (IOException ex) {
throw new SMException("cannot serialize bigints");
}
}
Aggregations