Search in sources :

Example 6 with OtrInputStream

use of net.java.otr4j.io.OtrInputStream in project Zom-Android by zom.

the class SM method unserialize.

public static BigInteger[] unserialize(byte[] bytes) throws SMException {
    try {
        ByteArrayInputStream in = new ByteArrayInputStream(bytes);
        OtrInputStream ois = new OtrInputStream(in);
        int len = ois.readInt();
        if (len > 100) {
            ois.close();
            throw new SMException("Too many ints");
        }
        BigInteger[] ints = new BigInteger[len];
        for (int i = 0; i < len; i++) {
            ints[i] = ois.readBigInt();
        }
        ois.close();
        return ints;
    } catch (IOException ex) {
        throw new SMException("cannot unserialize bigints");
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) OtrInputStream(net.java.otr4j.io.OtrInputStream) BigInteger(java.math.BigInteger) IOException(java.io.IOException)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)6 OtrInputStream (net.java.otr4j.io.OtrInputStream)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 OtrOutputStream (net.java.otr4j.io.OtrOutputStream)4 OtrCryptoEngineImpl (net.java.otr4j.crypto.OtrCryptoEngineImpl)3 IOException (java.io.IOException)2 BigInteger (java.math.BigInteger)2 KeyPair (java.security.KeyPair)2 DHPublicKey (javax.crypto.interfaces.DHPublicKey)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 OtrException (net.java.otr4j.OtrException)1 OtrCryptoEngine (net.java.otr4j.crypto.OtrCryptoEngine)1 OtrTlvHandler (net.java.otr4j.crypto.OtrTlvHandler)1