de.mud.ssh
Class SshMisc

java.lang.Object
  extended by de.mud.ssh.SshMisc

public class SshMisc
extends java.lang.Object

Version:
$Id: SshMisc.java 499 2005-09-29 08:24:54Z leo $
Author:
Marcus Meissner

Constructor Summary
SshMisc()
           
 
Method Summary
static byte[] addArrayOfBytes(byte[] a, byte[] b)
           
static long crc32(byte[] s, int len)
          Compute the crc Cyclic Redundancy Check, with the polynomial 0xedb88320, The polynomial is X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 We take it "backwards" and put the highest-order term in the lowest-order bit.
static byte[] createString(java.lang.String str)
          Return a Arbitrary length binary string First 4 bytes are the length of the string, msb first (not including the length itself).
static byte[] getMpInt(int offset, byte[] byteArray)
          Return the mp-int at the position offset in the data First 2 bytes are the number of bits in the integer, msb first (for example, the value 0x00012345 would have 17 bits).
static byte getNotZeroRandomByte()
           
static java.lang.String getString(int offset, byte[] byteArray)
          return the strint at the position offset in the data First 4 bytes are the length of the string, msb first (not including the length itself).
static byte[] XORArrayOfBytes(byte[] a, byte[] b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SshMisc

public SshMisc()
Method Detail

getString

public static java.lang.String getString(int offset,
                                         byte[] byteArray)
                                  throws java.io.IOException
return the strint at the position offset in the data First 4 bytes are the length of the string, msb first (not including the length itself). The following "length" bytes are the string value. There are no terminating null characters.

Throws:
java.io.IOException

getNotZeroRandomByte

public static byte getNotZeroRandomByte()

addArrayOfBytes

public static byte[] addArrayOfBytes(byte[] a,
                                     byte[] b)

XORArrayOfBytes

public static byte[] XORArrayOfBytes(byte[] a,
                                     byte[] b)

getMpInt

public static byte[] getMpInt(int offset,
                              byte[] byteArray)
                       throws java.io.IOException
Return the mp-int at the position offset in the data First 2 bytes are the number of bits in the integer, msb first (for example, the value 0x00012345 would have 17 bits). The value zero has zero bits. It is permissible that the number of bits be larger than the real number of bits. The number of bits is followed by (bits + 7) / 8 bytes of binary data, msb first, giving the value of the integer.

Throws:
java.io.IOException

createString

public static byte[] createString(java.lang.String str)
                           throws java.io.IOException
Return a Arbitrary length binary string First 4 bytes are the length of the string, msb first (not including the length itself). The following "length" bytes are the string value. There are no terminating null characters.

Throws:
java.io.IOException

crc32

public static long crc32(byte[] s,
                         int len)
Compute the crc Cyclic Redundancy Check, with the polynomial 0xedb88320, The polynomial is X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 We take it "backwards" and put the highest-order term in the lowest-order bit. The X^32 term is "implied"; the LSB is the X^31 term, etc. The X^0 term (usually shown as "+1") results in the MSB being 1. so the poly is 0x04c11db7 (used for Ethernet) The buf will be the Padding, Packet type, and Data fields. The crc is computed before any encryption. R =X^n * M rem P M message P polynomial crc R : crc calculated. T(x) = x^n * M(x) + R(x) property: T rem P = 0