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);
}
}
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();
}
Aggregations