本文整理了Java中org.apache.sshd.common.util.buffer.Buffer.putMPInt()
方法的一些代码示例,展示了Buffer.putMPInt()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Buffer.putMPInt()
方法的具体详情如下:
包路径:org.apache.sshd.common.util.buffer.Buffer
类名称:Buffer
方法名:putMPInt
暂无
代码示例来源:origin: org.apache.sshd/sshd-osgi
public void putMPInt(BigInteger bi) {
putMPInt(bi.toByteArray());
}
代码示例来源:origin: org.apache.sshd/sshd-common
public void putMPInt(BigInteger bi) {
putMPInt(bi.toByteArray());
}
代码示例来源:origin: org.apache.sshd/sshd-osgi
putMPInt(rsaPub.getPublicExponent());
putMPInt(rsaPub.getModulus());
putMPInt(rsaPrv.getPrivateExponent());
putMPInt(rsaPrv.getCrtCoefficient());
putMPInt(rsaPrv.getPrimeQ());
putMPInt(rsaPrv.getPrimeP());
} else if (pubKey instanceof DSAPublicKey) {
DSAPublicKey dsaPub = (DSAPublicKey) pubKey;
putMPInt(dsaParams.getP());
putMPInt(dsaParams.getQ());
putMPInt(dsaParams.getG());
putMPInt(dsaPub.getY());
putMPInt(dsaPrv.getX());
} else if (pubKey instanceof ECPublicKey) {
ECPublicKey ecPub = (ECPublicKey) pubKey;
putString(curve.getName());
putBytes(ecPoint);
putMPInt(ecPriv.getS());
} else if (SecurityUtils.EDDSA.equals(pubKey.getAlgorithm())) {
SecurityUtils.putEDDSAKeyPair(this, pubKey, prvKey);
代码示例来源:origin: org.apache.sshd/sshd-common
putMPInt(rsaPub.getPublicExponent());
putMPInt(rsaPub.getModulus());
putMPInt(rsaPrv.getPrivateExponent());
putMPInt(rsaPrv.getCrtCoefficient());
putMPInt(rsaPrv.getPrimeQ());
putMPInt(rsaPrv.getPrimeP());
} else if (pubKey instanceof DSAPublicKey) {
DSAPublicKey dsaPub = (DSAPublicKey) pubKey;
putMPInt(dsaParams.getP());
putMPInt(dsaParams.getQ());
putMPInt(dsaParams.getG());
putMPInt(dsaPub.getY());
putMPInt(dsaPrv.getX());
} else if (pubKey instanceof ECPublicKey) {
ECPublicKey ecPub = (ECPublicKey) pubKey;
putString(curve.getName());
putBytes(ECCurves.encodeECPoint(ecPub.getW(), ecParams));
putMPInt(ecPriv.getS());
} else if (SecurityUtils.EDDSA.equals(pubKey.getAlgorithm())) {
SecurityUtils.putEDDSAKeyPair(this, pubKey, prvKey);
代码示例来源:origin: org.apache.sshd/sshd-osgi
putMPInt(rsaPub.getPublicExponent());
putMPInt(rsaPub.getModulus());
} else if (key instanceof DSAPublicKey) {
DSAPublicKey dsaPub = (DSAPublicKey) key;
putMPInt(dsaParams.getP());
putMPInt(dsaParams.getQ());
putMPInt(dsaParams.getG());
putMPInt(dsaPub.getY());
} else if (key instanceof ECPublicKey) {
ECPublicKey ecKey = (ECPublicKey) key;
代码示例来源:origin: org.apache.sshd/sshd-common
putMPInt(rsaPub.getPublicExponent());
putMPInt(rsaPub.getModulus());
} else if (key instanceof DSAPublicKey) {
DSAPublicKey dsaPub = (DSAPublicKey) key;
putMPInt(dsaParams.getP());
putMPInt(dsaParams.getQ());
putMPInt(dsaParams.getG());
putMPInt(dsaPub.getY());
} else if (key instanceof ECPublicKey) {
ECPublicKey ecKey = (ECPublicKey) key;
代码示例来源:origin: org.apache.sshd/sshd-common
@Override
public byte[] sign() throws Exception {
byte[] sig = super.sign();
try (DERParser parser = new DERParser(sig)) {
int type = parser.read();
if (type != 0x30) {
throw new StreamCorruptedException("Invalid signature format - not a DER SEQUENCE: 0x" + Integer.toHexString(type));
}
// length of remaining encoding of the 2 integers
int remainLen = parser.readLength();
/*
* There are supposed to be 2 INTEGERs, each encoded with:
*
* - one byte representing the fact that it is an INTEGER
* - one byte of the integer encoding length
* - at least one byte of integer data (zero length is not an option)
*/
if (remainLen < (2 * 3)) {
throw new StreamCorruptedException("Invalid signature format - not enough encoded data length: " + remainLen);
}
BigInteger r = parser.readBigInteger();
BigInteger s = parser.readBigInteger();
// Write the <r,s> to its own types writer.
Buffer rsBuf = new ByteArrayBuffer();
rsBuf.putMPInt(r);
rsBuf.putMPInt(s);
return rsBuf.getCompactData();
}
}
代码示例来源:origin: org.apache.sshd/sshd-osgi
@Override
public void init(Session s, byte[] v_s, byte[] v_c, byte[] i_s, byte[] i_c) throws Exception {
super.init(s, v_s, v_c, i_s, i_c);
dh = getDH();
hash = dh.getHash();
hash.init();
e = dh.getE();
if (log.isDebugEnabled()) {
log.debug("init({})[{}] Send SSH_MSG_KEXDH_INIT", this, s);
}
Buffer buffer = s.createBuffer(SshConstants.SSH_MSG_KEXDH_INIT, e.length + Integer.SIZE);
buffer.putMPInt(e);
s.writePacket(buffer);
}
代码示例来源:origin: org.apache.sshd/sshd-osgi
@Override
public byte[] sign() throws Exception {
byte[] sig = super.sign();
try (DERParser parser = new DERParser(sig)) {
int type = parser.read();
if (type != 0x30) {
throw new StreamCorruptedException("Invalid signature format - not a DER SEQUENCE: 0x" + Integer.toHexString(type));
}
// length of remaining encoding of the 2 integers
int remainLen = parser.readLength();
/*
* There are supposed to be 2 INTEGERs, each encoded with:
*
* - one byte representing the fact that it is an INTEGER
* - one byte of the integer encoding length
* - at least one byte of integer data (zero length is not an option)
*/
if (remainLen < (2 * 3)) {
throw new StreamCorruptedException("Invalid signature format - not enough encoded data length: " + remainLen);
}
BigInteger r = parser.readBigInteger();
BigInteger s = parser.readBigInteger();
// Write the <r,s> to its own types writer.
Buffer rsBuf = new ByteArrayBuffer();
rsBuf.putMPInt(r);
rsBuf.putMPInt(s);
return rsBuf.getCompactData();
}
}
代码示例来源:origin: org.apache.sshd/sshd-core
@Override
public void init(Session s, byte[] v_s, byte[] v_c, byte[] i_s, byte[] i_c) throws Exception {
super.init(s, v_s, v_c, i_s, i_c);
dh = getDH();
hash = dh.getHash();
hash.init();
e = dh.getE();
if (log.isDebugEnabled()) {
log.debug("init({})[{}] Send SSH_MSG_KEXDH_INIT", this, s);
}
Buffer buffer = s.createBuffer(SshConstants.SSH_MSG_KEXDH_INIT, e.length + Integer.SIZE);
buffer.putMPInt(e);
s.writePacket(buffer);
}
代码示例来源:origin: org.apache.sshd/sshd-osgi
/**
* Method used while putting new keys into use that will resize the key used to
* initialize the cipher to the needed length.
*
* @param e the key to resize
* @param kdfSize the cipher key-derivation-factor (in bytes)
* @param hash the hash algorithm
* @param k the key exchange k parameter
* @param h the key exchange h parameter
* @return the resized key
* @throws Exception if a problem occur while resizing the key
*/
protected byte[] resizeKey(byte[] e, int kdfSize, Digest hash, byte[] k, byte[] h) throws Exception {
for (Buffer buffer = null; kdfSize > e.length; buffer = BufferUtils.clear(buffer)) {
if (buffer == null) {
buffer = new ByteArrayBuffer();
}
buffer.putMPInt(k);
buffer.putRawBytes(h);
buffer.putRawBytes(e);
hash.update(buffer.array(), 0, buffer.available());
byte[] foo = hash.digest();
byte[] bar = new byte[e.length + foo.length];
System.arraycopy(e, 0, bar, 0, e.length);
System.arraycopy(foo, 0, bar, e.length, foo.length);
e = bar;
}
return e;
}
代码示例来源:origin: org.apache.sshd/sshd-core
/**
* Method used while putting new keys into use that will resize the key used to
* initialize the cipher to the needed length.
*
* @param e the key to resize
* @param blockSize the cipher block size (in bytes)
* @param hash the hash algorithm
* @param k the key exchange k parameter
* @param h the key exchange h parameter
* @return the resized key
* @throws Exception if a problem occur while resizing the key
*/
protected byte[] resizeKey(byte[] e, int blockSize, Digest hash, byte[] k, byte[] h) throws Exception {
for (Buffer buffer = null; blockSize > e.length; buffer = BufferUtils.clear(buffer)) {
if (buffer == null) {
buffer = new ByteArrayBuffer();
}
buffer.putMPInt(k);
buffer.putRawBytes(h);
buffer.putRawBytes(e);
hash.update(buffer.array(), 0, buffer.available());
byte[] foo = hash.digest();
byte[] bar = new byte[e.length + foo.length];
System.arraycopy(e, 0, bar, 0, e.length);
System.arraycopy(foo, 0, bar, e.length, foo.length);
e = bar;
}
return e;
}
代码示例来源:origin: org.apache.sshd/sshd-osgi
buffer.putBytes(i_s);
buffer.putBytes(k_s);
buffer.putMPInt(e);
buffer.putMPInt(f);
buffer.putMPInt(k);
hash.update(buffer.array(), 0, buffer.available());
h = hash.digest();
代码示例来源:origin: org.apache.sshd/sshd-core
buffer.putBytes(i_s);
buffer.putBytes(k_s);
buffer.putMPInt(e);
buffer.putMPInt(f);
buffer.putMPInt(k);
hash.update(buffer.array(), 0, buffer.available());
h = hash.digest();
代码示例来源:origin: org.apache.sshd/sshd-core
buffer.putMPInt(e);
session.writePacket(buffer);
expected = SshConstants.SSH_MSG_KEX_DH_GEX_REPLY;
buffer.putInt(prf);
buffer.putInt(max);
buffer.putMPInt(p);
buffer.putMPInt(g);
buffer.putMPInt(e);
buffer.putMPInt(f);
buffer.putMPInt(k);
hash.update(buffer.array(), 0, buffer.available());
h = hash.digest();
代码示例来源:origin: org.apache.sshd/sshd-osgi
buffer.putMPInt(e);
session.writePacket(buffer);
expected = SshConstants.SSH_MSG_KEX_DH_GEX_REPLY;
buffer.putInt(prf);
buffer.putInt(max);
buffer.putMPInt(p);
buffer.putMPInt(g);
buffer.putMPInt(e);
buffer.putMPInt(f);
buffer.putMPInt(k);
hash.update(buffer.array(), 0, buffer.available());
h = hash.digest();
代码示例来源:origin: org.apache.sshd/sshd-core
buffer.putMPInt(dh.getP());
buffer.putMPInt(dh.getG());
session.writePacket(buffer);
buffer.putMPInt(dh.getP());
buffer.putMPInt(dh.getG());
session.writePacket(buffer);
buffer.putInt(max);
buffer.putMPInt(dh.getP());
buffer.putMPInt(dh.getG());
buffer.putMPInt(e);
buffer.putMPInt(f);
buffer.putMPInt(k);
hash.update(buffer.array(), 0, buffer.available());
h = hash.digest();
代码示例来源:origin: org.apache.sshd/sshd-core
buffer.putBytes(i_s);
buffer.putBytes(k_s);
buffer.putMPInt(e);
buffer.putMPInt(f);
buffer.putMPInt(k);
hash.update(buffer.array(), 0, buffer.available());
h = hash.digest();
代码示例来源:origin: org.apache.sshd/sshd-osgi
buffer.putBytes(i_s);
buffer.putBytes(k_s);
buffer.putMPInt(e);
buffer.putMPInt(f);
buffer.putMPInt(k);
hash.update(buffer.array(), 0, buffer.available());
h = hash.digest();
代码示例来源:origin: org.apache.sshd/sshd-core
buffer.putMPInt(k);
buffer.putRawBytes(h);
buffer.putByte((byte) 0x41);
内容来源于网络,如有侵权,请联系作者删除!