1 | /******************************************************************************
|
---|
2 | *
|
---|
3 | * Copyright (c) 1998,99 by Mindbright Technology AB, Stockholm, Sweden.
|
---|
4 | * www.mindbright.se, [email protected]
|
---|
5 | *
|
---|
6 | * This program is free software; you can redistribute it and/or modify
|
---|
7 | * it under the terms of the GNU General Public License as published by
|
---|
8 | * the Free Software Foundation; either version 2 of the License, or
|
---|
9 | * (at your option) any later version.
|
---|
10 | *
|
---|
11 | * This program is distributed in the hope that it will be useful,
|
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | * GNU General Public License for more details.
|
---|
15 | *
|
---|
16 | *****************************************************************************
|
---|
17 | * $Author: mats $
|
---|
18 | * $Date: 1999/10/21 07:21:40 $
|
---|
19 | * $Name: rel1-2-1 $
|
---|
20 | *****************************************************************************/
|
---|
21 | package mindbright.ssh;
|
---|
22 |
|
---|
23 | import java.io.*;
|
---|
24 | import java.math.BigInteger;
|
---|
25 |
|
---|
26 | public class SSHDataInputStream extends DataInputStream {
|
---|
27 |
|
---|
28 | SSHDataInputStream(InputStream in) {
|
---|
29 | super(in);
|
---|
30 | }
|
---|
31 |
|
---|
32 | public BigInteger readBigInteger() throws IOException {
|
---|
33 | short bits = readShort();
|
---|
34 | byte[] raw = new byte[(bits + 7) / 8 + 1];
|
---|
35 |
|
---|
36 | raw[0] = 0;
|
---|
37 | read(raw, 1, raw.length - 1);
|
---|
38 |
|
---|
39 | return new BigInteger(raw);
|
---|
40 | }
|
---|
41 |
|
---|
42 | public String readString() throws IOException {
|
---|
43 | int len = readInt();
|
---|
44 | byte[] raw = new byte[len];
|
---|
45 | read(raw, 0, raw.length);
|
---|
46 | return new String(raw);
|
---|
47 | }
|
---|
48 |
|
---|
49 | public byte[] readStringAsBytes() throws IOException {
|
---|
50 | int len = readInt();
|
---|
51 | byte[] raw = new byte[len];
|
---|
52 | read(raw, 0, raw.length);
|
---|
53 | return raw;
|
---|
54 | }
|
---|
55 |
|
---|
56 | }
|
---|