public byte[] sign() throws Exception { byte[] sig = signature.sign(); if (sig[0] == 0x30 && ((sig[1] + 2 == sig.length) || ((sig[1] & 0x80) != 0 && (sig[2] & 0xff) + 3 == sig.length))) { int index = 3; if ((sig[1] & 0x80) != 0 && (sig[2] & 0xff) + 3 == sig.length) { index = 4; } byte[] r = new byte[sig[index]]; byte[] s = new byte[sig[index + 2 + sig[index]]]; System.arraycopy(sig, index + 1, r, 0, r.length); System.arraycopy(sig, index + 3 + sig[index], s, 0, s.length); r = chop0(r); s = chop0(s); Buffer buf = new Buffer(); buf.putMPInt(r); buf.putMPInt(s); sig = new byte[buf.getLength()]; buf.setOffSet(0); buf.getByte(sig); } return sig; }
public byte[] sign() throws Exception{ byte[] sig=signature.sign(); // It seems that the output from SunEC is in ASN.1, // so we have to convert it. if(sig[0]==0x30 && // in ASN.1 ((sig[1]+2 == sig.length) || ((sig[1]&0x80)!=0 && (sig[2]&0xff)+3==sig.length))){// 2bytes for len int index=3; if((sig[1]&0x80)!=0 && (sig[2]&0xff)+3==sig.length) index=4; byte[] r = new byte[sig[index]]; byte[] s = new byte[sig[index+2+sig[index]]]; System.arraycopy(sig, index+1, r, 0, r.length); System.arraycopy(sig, index+3+sig[index], s, 0, s.length); r = chop0(r); s = chop0(s); Buffer buf = new Buffer(); buf.putMPInt(r); buf.putMPInt(s); sig=new byte[buf.getLength()]; buf.setOffSet(0); buf.getByte(sig); } return sig; } public void update(byte[] foo) throws Exception{
public byte[] sign() throws Exception{ byte[] sig=signature.sign(); // It seems that the output from SunEC is in ASN.1, // so we have to convert it. if(sig[0]==0x30 && // in ASN.1 ((sig[1]+2 == sig.length) || ((sig[1]&0x80)!=0 && (sig[2]&0xff)+3==sig.length))){// 2bytes for len int index=3; if((sig[1]&0x80)!=0 && (sig[2]&0xff)+3==sig.length) index=4; byte[] r = new byte[sig[index]]; byte[] s = new byte[sig[index+2+sig[index]]]; System.arraycopy(sig, index+1, r, 0, r.length); System.arraycopy(sig, index+3+sig[index], s, 0, s.length); r = chop0(r); s = chop0(s); Buffer buf = new Buffer(); buf.putMPInt(r); buf.putMPInt(s); sig=new byte[buf.getLength()]; buf.setOffSet(0); buf.getByte(sig); } return sig; } public void update(byte[] foo) throws Exception{
public byte[] sign() throws Exception{ byte[] sig=signature.sign(); // It seems that the output from SunEC is in ASN.1, // so we have to convert it. if(sig[0]==0x30 && // in ASN.1 ((sig[1]+2 == sig.length) || ((sig[1]&0x80)!=0 && (sig[2]&0xff)+3==sig.length))){// 2bytes for len int index=3; if((sig[1]&0x80)!=0 && (sig[2]&0xff)+3==sig.length) index=4; byte[] r = new byte[sig[index]]; byte[] s = new byte[sig[index+2+sig[index]]]; System.arraycopy(sig, index+1, r, 0, r.length); System.arraycopy(sig, index+3+sig[index], s, 0, s.length); r = chop0(r); s = chop0(s); Buffer buf = new Buffer(); buf.putMPInt(r); buf.putMPInt(s); sig=new byte[buf.getLength()]; buf.setOffSet(0); buf.getByte(sig); } return sig; } public void update(byte[] foo) throws Exception{
private byte[] expandKey(Buffer buf, byte[] K, byte[] H, byte[] key, HASH hash, int required_length) throws Exception { byte[] result = key; int size = hash.getBlockSize(); while(result.length < required_length){ buf.reset(); buf.putMPInt(K); buf.putByte(H); buf.putByte(result); hash.update(buf.buffer, 0, buf.index); byte[] tmp = new byte[result.length+size]; System.arraycopy(result, 0, tmp, 0, result.length); System.arraycopy(hash.digest(), 0, tmp, result.length, size); Util.bzero(result); result = tmp; } return result; }
buf.putMPInt(e); session.write(packet);
private byte[] expandKey(Buffer buf, byte[] K, byte[] H, byte[] key, HASH hash, int required_length) throws Exception { byte[] result = key; int size = hash.getBlockSize(); while(result.length < required_length){ buf.reset(); buf.putMPInt(K); buf.putByte(H); buf.putByte(result); hash.update(buf.buffer, 0, buf.index); byte[] tmp = new byte[result.length+size]; System.arraycopy(result, 0, tmp, 0, result.length); System.arraycopy(hash.digest(), 0, tmp, result.length, size); Util.bzero(result); result = tmp; } return result; }
packet.reset(); buf.putByte((byte) SSH_MSG_KEXDH_INIT); buf.putMPInt(e);
private byte[] expandKey(Buffer buf, byte[] K, byte[] H, byte[] key, HASH hash, int required_length) throws Exception { byte[] result = key; int size = hash.getBlockSize(); while(result.length < required_length){ buf.reset(); buf.putMPInt(K); buf.putByte(H); buf.putByte(result); hash.update(buf.buffer, 0, buf.index); byte[] tmp = new byte[result.length+size]; System.arraycopy(result, 0, tmp, 0, result.length); System.arraycopy(hash.digest(), 0, tmp, result.length, size); Util.bzero(result); result = tmp; } return result; }
private byte[] expandKey(Buffer buf, byte[] K, byte[] H, byte[] key, HASH hash, int required_length) throws Exception { byte[] result = key; int size = hash.getBlockSize(); while (result.length < required_length) { buf.reset(); buf.putMPInt(K); buf.putByte(H); buf.putByte(result); hash.update(buf.buffer, 0, buf.index); byte[] tmp = new byte[result.length + size]; System.arraycopy(result, 0, tmp, 0, result.length); System.arraycopy(hash.digest(), 0, tmp, result.length, size); Util.bzero(result); result = tmp; } return result; }
buf.putMPInt(e); session.write(packet);
buf.putMPInt(e); session.write(packet);
packet.reset(); buf.putByte((byte)SSH_MSG_KEXDH_INIT); buf.putMPInt(e);
buf.putMPInt(e); session.write(packet);
packet.reset(); buf.putByte((byte)SSH_MSG_KEXDH_INIT); buf.putMPInt(e);
buf.putMPInt(e); session.write(packet);
packet.reset(); buf.putByte((byte)SSH_MSG_KEXDH_INIT); buf.putMPInt(e);