/** * Writes Java byte-array as an SSH byte-array * * @param b Java byte-array * @param off offset * @param len length * * @return this */ public T putBytes(byte[] b, int off, int len) { return putUInt32(len).putRawBytes(b, off, len); }
public T putMPInt(BigInteger bi) { final byte[] asBytes = bi.toByteArray(); putUInt32(asBytes.length); return putRawBytes(asBytes); }
/** * Writes a char-array as an SSH string and then blanks it out. * <p/> * This is useful when a plaintext password needs to be sent. If {@code str} is {@code null}, an empty string is * written. * * @param str (null-ok) the string as a character array * * @return this */ @SuppressWarnings("unchecked") public T putSensitiveString(char[] str) { if (str == null) return putString(""); putUInt32(str.length); ensureCapacity(str.length); for (char c : str) data[wpos++] = (byte) c; Arrays.fill(str, ' '); return (T) this; }
static void writePubKeyContentsIntoBuffer(PublicKey publicKey, KeyType innerKeyType, Buffer<?> buf) { Certificate<PublicKey> certificate = toCertificate(publicKey); buf.putBytes(certificate.getNonce()); innerKeyType.writePubKeyContentsIntoBuffer(certificate.getKey(), buf); buf.putUInt64(certificate.getSerial()) .putUInt32(certificate.getType()) .putString(certificate.getId()) .putBytes(packList(certificate.getValidPrincipals())) .putUInt64(epochFromDate(certificate.getValidAfter())) .putUInt64(epochFromDate(certificate.getValidBefore())) .putBytes(packMap(certificate.getCritOptions())) .putBytes(packMap(certificate.getExtensions())) .putString("") // reserved .putBytes(certificate.getSignatureKey()) .putBytes(certificate.getSignature()); }
public T putMPInt(BigInteger bi) { final byte[] asBytes = bi.toByteArray(); putUInt32(asBytes.length); return putRawBytes(asBytes); }
/** * Writes Java byte-array as an SSH byte-array * * @param b Java byte-array * @param off offset * @param len length * * @return this */ public T putBytes(byte[] b, int off, int len) { return putUInt32(len - off).putRawBytes(b, off, len); }
public T putMPInt(BigInteger bi) { final byte[] asBytes = bi.toByteArray(); putUInt32(asBytes.length); return putRawBytes(asBytes); }
/** * Writes Java byte-array as an SSH byte-array * * @param b Java byte-array * @param off offset * @param len length * * @return this */ public T putBytes(byte[] b, int off, int len) { return putUInt32(len).putRawBytes(b, off, len); }
/** * Writes a char-array as an SSH string and then blanks it out. * <p/> * This is useful when a plaintext password needs to be sent. If {@code str} is {@code null}, an empty string is * written. * * @param str (null-ok) the string as a character array * * @return this */ @SuppressWarnings("unchecked") public T putSensitiveString(char[] str) { if (str == null) return putString(""); putUInt32(str.length); ensureCapacity(str.length); for (char c : str) data[wpos++] = (byte) c; Arrays.fill(str, ' '); return (T) this; }
/** * Writes a char-array as an SSH string and then blanks it out. * <p/> * This is useful when a plaintext password needs to be sent. If {@code str} is {@code null}, an empty string is * written. * * @param str (null-ok) the string as a character array * * @return this */ @SuppressWarnings("unchecked") public T putSensitiveString(char[] str) { if (str == null) return putString(""); putUInt32(str.length); ensureCapacity(str.length); for (char c : str) data[wpos++] = (byte) c; Arrays.fill(str, ' '); return (T) this; }
@Override public void putPubKeyIntoBuffer(PublicKey pk, Buffer<?> buf) { final ECPublicKey ecdsa = (ECPublicKey) pk; final java.security.spec.ECPoint point = ecdsa.getW(); final byte[] x = trimStartingZeros(point.getAffineX().toByteArray()); final byte[] y = trimStartingZeros(point.getAffineY().toByteArray()); buf.putString(sType) .putString(NISTP_CURVE) .putUInt32(1 + x.length + y.length) .putRawBytes(new byte[] { (byte) 0x04 }) .putRawBytes(x) .putRawBytes(y) ; }
static void writePubKeyContentsIntoBuffer(PublicKey publicKey, KeyType innerKeyType, Buffer<?> buf) { Certificate<PublicKey> certificate = toCertificate(publicKey); buf.putBytes(certificate.getNonce()); innerKeyType.writePubKeyContentsIntoBuffer(certificate.getKey(), buf); buf.putUInt64(certificate.getSerial()) .putUInt32(certificate.getType()) .putString(certificate.getId()) .putBytes(packList(certificate.getValidPrincipals())) .putUInt64(epochFromDate(certificate.getValidAfter())) .putUInt64(epochFromDate(certificate.getValidBefore())) .putBytes(packMap(certificate.getCritOptions())) .putBytes(packMap(certificate.getExtensions())) .putString("") // reserved .putBytes(certificate.getSignatureKey()) .putBytes(certificate.getSignature()); }