public PublicKey readPublicKey() throws BufferException { KeyType keyType = KeyType.fromString(readString()); try { return keyType.readPubKeyFromBuffer(this); } catch (GeneralSecurityException e) { throw new SSHRuntimeException(e); } catch (UnsupportedOperationException uoe) { throw new BufferException("Could not decode keytype " + keyType); } }
public T putSignature(String sigFormat, byte[] sigData) { final byte[] sig = new PlainBuffer().putString(sigFormat).putBytes(sigData).getCompactData(); return putString(sig); }
private String getKeyString(PublicKey pk) { final Buffer.PlainBuffer buf = new Buffer.PlainBuffer().putPublicKey(pk); return Base64.encodeBytes(buf.array(), buf.rpos(), buf.available()); }
private static byte[] packList(Iterable<String> strings) { Buffer<?> buf = new Buffer.PlainBuffer(); for (String string : strings) { buf.putString(string); } return buf.getCompactData(); }
protected Buffer.PlainBuffer initializedBuffer() { return new Buffer.PlainBuffer() .putString(V_C) .putString(V_S) .putString(I_C) .putString(I_S); }
public DHBase(String generator, String agreement) { try { this.generator = SecurityUtils.getKeyPairGenerator(generator); this.agreement = SecurityUtils.getKeyAgreement(agreement); } catch (GeneralSecurityException e) { throw new SSHRuntimeException(e); } }
@Override public void init() { try { md = SecurityUtils.getMessageDigest(algorithm); } catch (GeneralSecurityException e) { throw new SSHRuntimeException(e); } }
protected AbstractSignature(String algorithm) { try { this.signature = SecurityUtils.getSignature(algorithm); } catch (GeneralSecurityException e) { throw new SSHRuntimeException(e); } }
public long readUInt64() throws BufferException { long uint64 = (readUInt32() << 32) + (readUInt32() & 0xffffffffL); if (uint64 < 0) throw new BufferException("Cannot handle values > Long.MAX_VALUE"); return uint64; }
protected void ensureAvailable(int a) throws BufferException { if (available() < a) { throw new BufferException("Underflow"); } }
/** * Decodes data from Base64 notation, automatically * detecting gzip-compressed data and decompressing it. * * @param s the string to decode * @return the decoded data * @throws java.io.IOException If there is a problem * @since 1.4 */ public static byte[] decode( String s ) throws java.io.IOException { return decode( s, NO_OPTIONS ); }
/** * Get the hexadecimal representation of a byte array. * * @param array * * @return hex string */ public static String toHex(byte[] array) { return toHex(array, 0, array.length); }
/** * Writes Java byte-array as an SSH byte-array * * @param b Java byte-array * * @return this */ public T putBytes(byte[] b) { return putBytes(b, 0, b.length); }
public SSHException(DisconnectReason code, String message, Throwable cause) { super(message); this.reason = code; if (cause != null) initCause(cause); }
/** * Puts an SSH boolean value * * @param b the value * * @return this */ public T putBoolean(boolean b) { return putByte(b ? (byte) 1 : (byte) 0); }
@Override protected boolean isMyType(Key key) { return ECDSAVariationsAdapter.isECKeyWithFieldSize(key, 256); } },
@Override protected boolean isMyType(Key key) { return ECDSAVariationsAdapter.isECKeyWithFieldSize(key, 384); } },