/** * Reads an SSH string using {@code UTF8} * * @return the string as a Java {@code String} */ public String readString() throws BufferException { return readString(IOUtils.UTF8); }
private static Map<String, String> unpackMap(byte[] packedString) throws BufferException { Map<String, String> map = new LinkedHashMap<String, String>(); Buffer<?> buf = new Buffer.PlainBuffer(packedString); while (buf.available() > 0) { String name = buf.readString(); String data = unpackString(buf.readStringAsBytes()); map.put(name, data); } return map; }
private static List<String> unpackList(byte[] packedString) throws BufferException { List<String> list = new ArrayList<String>(); Buffer<?> buf = new Buffer.PlainBuffer(packedString); while (buf.available() > 0) { list.add(buf.readString()); } return list; }
private static Map<String, String> unpackMap(byte[] packedString) throws BufferException { Map<String, String> map = new LinkedHashMap<String, String>(); Buffer<?> buf = new Buffer.PlainBuffer(packedString); while (buf.available() > 0) { String name = buf.readString(); String data = unpackString(buf.readStringAsBytes()); map.put(name, data); } return map; }
final String curveName = buf.readString(); final int keyLen = buf.readUInt32AsInt(); final byte x04 = buf.readByte(); // it must be 0x04, but don't think
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); } }
@SuppressWarnings("unchecked") static <T extends PublicKey> Certificate<T> readPubKey(Buffer<?> buf, KeyType innerKeyType) throws GeneralSecurityException { Certificate.Builder<T> builder = Certificate.getBuilder(); try { builder.nonce(buf.readBytes()); builder.publicKey((T) innerKeyType.readPubKeyFromBuffer(buf)); builder.serial(buf.readUInt64AsBigInteger()); builder.type(buf.readUInt32()); builder.id(buf.readString()); builder.validPrincipals(unpackList(buf.readBytes())); builder.validAfter(dateFromEpoch(buf.readUInt64())); builder.validBefore(dateFromEpoch(buf.readUInt64())); builder.critOptions(unpackMap(buf.readBytes())); builder.extensions(unpackMap(buf.readBytes())); buf.readString(); // reserved builder.signatureKey(buf.readBytes()); builder.signature(buf.readBytes()); } catch (Buffer.BufferException be) { throw new GeneralSecurityException(be); } return builder.build(); }
/** * Reads an SSH string using {@code UTF8} * * @return the string as a Java {@code String} */ public String readString() throws BufferException { return readString(IOUtils.UTF8); }
private static List<String> unpackList(byte[] packedString) throws BufferException { List<String> list = new ArrayList<String>(); Buffer<?> buf = new Buffer.PlainBuffer(packedString); while (buf.available() > 0) { list.add(buf.readString()); } return list; }
public PublicKey readPublicKey() throws BufferException { try { final String type = readString(); return KeyType.fromString(type).readPubKeyFromBuffer(type, this); } catch (GeneralSecurityException e) { throw new SSHRuntimeException(e); } }
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); } }
final String curveName = buf.readString(); final int keyLen = buf.readUInt32AsInt(); final byte x04 = buf.readByte(); // it must be 0x04, but don't think
try { final String curveName = buf.readString(); final int keyLen = buf.readUInt32AsInt(); final byte x04 = buf.readByte(); // it must be 0x04, but don't think we need that check
@SuppressWarnings("unchecked") static <T extends PublicKey> Certificate<T> readPubKey(Buffer<?> buf, KeyType innerKeyType) throws GeneralSecurityException { Certificate.Builder<T> builder = Certificate.getBuilder(); try { builder.nonce(buf.readBytes()); builder.publicKey((T) innerKeyType.readPubKeyFromBuffer(buf)); builder.serial(buf.readUInt64AsBigInteger()); builder.type(buf.readUInt32()); builder.id(buf.readString()); builder.validPrincipals(unpackList(buf.readBytes())); builder.validAfter(dateFromEpoch(buf.readUInt64())); builder.validBefore(dateFromEpoch(buf.readUInt64())); builder.critOptions(unpackMap(buf.readBytes())); builder.extensions(unpackMap(buf.readBytes())); buf.readString(); // reserved builder.signatureKey(buf.readBytes()); builder.signature(buf.readBytes()); } catch (Buffer.BufferException be) { throw new GeneralSecurityException(be); } return builder.build(); }