Search in sources :

Example 21 with TypesWriter

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

the class DSASHA1Verify method encodeSSHDSAPublicKey.

public static byte[] encodeSSHDSAPublicKey(DSAPublicKey pk) throws IOException {
    TypesWriter tw = new TypesWriter();
    tw.writeString("ssh-dss");
    tw.writeMPInt(pk.getP());
    tw.writeMPInt(pk.getQ());
    tw.writeMPInt(pk.getG());
    tw.writeMPInt(pk.getY());
    return tw.getBytes();
}
Also used : TypesWriter(com.trilead.ssh2.packets.TypesWriter)

Example 22 with TypesWriter

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

the class RSASHA1Verify method encodeSSHRSASignature.

public static byte[] encodeSSHRSASignature(RSASignature sig) throws IOException {
    TypesWriter tw = new TypesWriter();
    tw.writeString("ssh-rsa");
    /* S is NOT an MPINT. "The value for 'rsa_signature_blob' is encoded as a string
		 * containing s (which is an integer, without lengths or padding, unsigned and in
		 * network byte order)."
		 */
    byte[] s = sig.getS().toByteArray();
    if ((s.length > 1) && (s[0] == 0x00))
        tw.writeString(s, 1, s.length - 1);
    else
        tw.writeString(s, 0, s.length);
    return tw.getBytes();
}
Also used : TypesWriter(com.trilead.ssh2.packets.TypesWriter)

Example 23 with TypesWriter

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

the class RSASHA1Verify method encodeSSHRSAPublicKey.

public static byte[] encodeSSHRSAPublicKey(RSAPublicKey pk) throws IOException {
    TypesWriter tw = new TypesWriter();
    tw.writeString("ssh-rsa");
    tw.writeMPInt(pk.getE());
    tw.writeMPInt(pk.getN());
    return tw.getBytes();
}
Also used : TypesWriter(com.trilead.ssh2.packets.TypesWriter)

Aggregations

TypesWriter (com.trilead.ssh2.packets.TypesWriter)23 TypesReader (com.trilead.ssh2.packets.TypesReader)10 Vector (java.util.Vector)1