/* void dump(byte[] foo){ for(int i=0; i<foo.length; i++){ if((foo[i]&0xf0)==0)System.out.print("0"); System.out.print(Integer.toHexString(foo[i]&0xff)); if(i%16==15){System.out.println(""); continue;} if(i%2==1)System.out.print(" "); } } */ internal static SharpSSH.SharpSsh.java.String[] guess(byte[]I_S, byte[]I_C) { //System.out.println("guess: "); SharpSSH.SharpSsh.java.String[] guess=new SharpSSH.SharpSsh.java.String[PROPOSAL_MAX]; Buffer sb=new Buffer(I_S); sb.setOffSet(17); Buffer cb=new Buffer(I_C); cb.setOffSet(17); for(int i=0; i<PROPOSAL_MAX; i++) { byte[] sp=sb.getString(); // server proposal byte[] cp=cb.getString(); // client proposal //System.out.println("server-proposal: |"+new String(sp)+"|"); //System.out.println("client-proposal: |"+new String(cp)+"|"); int j=0; int k=0; //System.out.println(new String(cp)); //loop(using BREAK instead): while(j<cp.Length) { while(j<cp.Length && cp[j]!=',')j++; if(k==j) return null; String algorithm=Util.getString(cp, k, j-k); //System.out.println("algorithm: "+algorithm); int l=0; int m=0; while(l<sp.Length) { while(l<sp.Length && sp[l]!=',')l++; if(m==l) return null; //System.out.println(" "+new String(sp, m, l-m)); if(algorithm.Equals(Util.getString(sp, m, l-m))) { guess[i]=algorithm; //System.out.println(" "+algorithm); goto BREAK; } l++; m=l; } j++; k=j; } BREAK: if(j==0) { guess[i]=""; } else if(guess[i]==null) { //System.out.println(" fail"); return null; } } // for(int i=0; i<PROPOSAL_MAX; i++){ // System.out.println("guess: ["+guess[i]+"]"); // } return guess; }