Search in sources :

Example 16 with TypesReader

use of com.trilead.ssh2.packets.TypesReader in project intellij-community by JetBrains.

the class RSASHA1Verify method decodeSSHRSAPublicKey.

public static RSAPublicKey decodeSSHRSAPublicKey(byte[] key) throws IOException {
    TypesReader tr = new TypesReader(key);
    String key_format = tr.readString();
    if (key_format.equals("ssh-rsa") == false)
        throw new IllegalArgumentException("This is not a ssh-rsa public key");
    BigInteger e = tr.readMPINT();
    BigInteger n = tr.readMPINT();
    if (tr.remain() != 0)
        throw new IOException("Padding in RSA public key!");
    return new RSAPublicKey(e, n);
}
Also used : TypesReader(com.trilead.ssh2.packets.TypesReader) BigInteger(java.math.BigInteger) IOException(java.io.IOException)

Aggregations

TypesReader (com.trilead.ssh2.packets.TypesReader)16 TypesWriter (com.trilead.ssh2.packets.TypesWriter)10 IOException (java.io.IOException)5 BigInteger (java.math.BigInteger)4 Vector (java.util.Vector)1