Search in sources :

Example 6 with Buffer

use of com.jn.agileway.ssh.client.utils.Buffer in project agileway by fangjinuo.

the class Eddsa25519PublicKeyCodec method decode.

@Override
public PublicKey decode(byte[] bytes) {
    try {
        Buffer buf = new Buffer.PlainBuffer(bytes);
        final int keyLen = buf.readUInt32AsInt();
        final byte[] p = new byte[keyLen];
        buf.readRawBytes(p);
        if (logger.isDebugEnabled()) {
            logger.debug("Key algo: {}, Key curve: 25519, Key Len: {}\np: {}", getName(), keyLen, Arrays.toString(p));
        }
        EdDSANamedCurveSpec ed25519 = EdDSANamedCurveTable.getByName("Ed25519");
        EdDSAPublicKeySpec publicSpec = new EdDSAPublicKeySpec(p, ed25519);
        return new Ed25519PublicKey(publicSpec);
    } catch (Buffer.BufferException be) {
        throw new SshException(be);
    }
}
Also used : Buffer(com.jn.agileway.ssh.client.utils.Buffer) EdDSAPublicKeySpec(net.i2p.crypto.eddsa.spec.EdDSAPublicKeySpec) SshException(com.jn.agileway.ssh.client.SshException) EdDSANamedCurveSpec(net.i2p.crypto.eddsa.spec.EdDSANamedCurveSpec)

Example 7 with Buffer

use of com.jn.agileway.ssh.client.utils.Buffer in project agileway by fangjinuo.

the class EcdsaXPublicKeyCodec method encode.

@Override
public byte[] encode(PublicKey publicKey) {
    Buffer buf = new Buffer.PlainBuffer();
    EcdsaXs.writePubKeyContentsIntoBuffer(publicKey, buf);
    return buf.array();
}
Also used : Buffer(com.jn.agileway.ssh.client.utils.Buffer)

Aggregations

Buffer (com.jn.agileway.ssh.client.utils.Buffer)7 IllegalKeyException (com.jn.langx.security.crypto.IllegalKeyException)2 BigInteger (java.math.BigInteger)2 InvalidKeySpecException (java.security.spec.InvalidKeySpecException)2 SshException (com.jn.agileway.ssh.client.SshException)1 IllegalSshKeyException (com.jn.agileway.ssh.client.transport.hostkey.IllegalSshKeyException)1 UnsupportedHostsKeyTypeException (com.jn.agileway.ssh.client.transport.hostkey.UnsupportedHostsKeyTypeException)1 DSAPublicKey (java.security.interfaces.DSAPublicKey)1 DSAPublicKeySpec (java.security.spec.DSAPublicKeySpec)1 RSAPublicKeySpec (java.security.spec.RSAPublicKeySpec)1 EdDSAPublicKey (net.i2p.crypto.eddsa.EdDSAPublicKey)1 EdDSANamedCurveSpec (net.i2p.crypto.eddsa.spec.EdDSANamedCurveSpec)1 EdDSAPublicKeySpec (net.i2p.crypto.eddsa.spec.EdDSAPublicKeySpec)1