~ubuntu-branches/ubuntu/trusty/jsch/trusty-proposed

« back to all changes in this revision

Viewing changes to src/com/jcraft/jsch/DHG1.java

  • Committer: Bazaar Package Importer
  • Author(s): Michael Koch
  • Date: 2008-03-21 11:41:01 UTC
  • mfrom: (3.1.2 hardy)
  • Revision ID: james.westby@ubuntu.com-20080321114101-2g9w5l8ynwf6pbsq
Tags: 0.1.37-3
Add OSGi manifest patch. Thanks to Roberto Jimenoca. Closes: #471209.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
2
2
/*
3
 
Copyright (c) 2002,2003,2004,2005,2006 ymnk, JCraft,Inc. All rights reserved.
 
3
Copyright (c) 2002-2008 ymnk, JCraft,Inc. All rights reserved.
4
4
 
5
5
Redistribution and use in source and binary forms, with or without
6
6
modification, are permitted provided that the following conditions are met:
52
52
(byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF
53
53
};
54
54
 
55
 
  static final int SSH_MSG_KEXDH_INIT=                     30;
56
 
  static final int SSH_MSG_KEXDH_REPLY=                    31;
 
55
  private static final int SSH_MSG_KEXDH_INIT=                     30;
 
56
  private static final int SSH_MSG_KEXDH_REPLY=                    31;
57
57
 
58
58
  static final int RSA=0;
59
59
  static final int DSS=1;
126
126
    buf.putMPInt(e);
127
127
    session.write(packet);
128
128
 
 
129
    if(JSch.getLogger().isEnabled(Logger.INFO)){
 
130
      JSch.getLogger().log(Logger.INFO, 
 
131
                           "SSH_MSG_KEXDH_INIT sent");
 
132
      JSch.getLogger().log(Logger.INFO, 
 
133
                           "expecting SSH_MSG_KEXDH_REPLY");
 
134
    }
 
135
 
129
136
    state=SSH_MSG_KEXDH_REPLY;
130
137
  }
131
138
 
154
161
      // impint q of dsa
155
162
      // impint g of dsa
156
163
      // impint pub_key of dsa
157
 
      //System.out.print("K_S: "); //dump(K_S, 0, K_S.length);
 
164
      //System.err.print("K_S: "); //dump(K_S, 0, K_S.length);
158
165
      byte[] f=_buf.getMPInt();
159
166
      byte[] sig_of_H=_buf.getString();
160
167
      /*
161
168
for(int ii=0; ii<sig_of_H.length;ii++){
162
 
  System.out.print(Integer.toHexString(sig_of_H[ii]&0xff));
163
 
  System.out.print(": ");
 
169
  System.err.print(Integer.toHexString(sig_of_H[ii]&0xff));
 
170
  System.err.print(": ");
164
171
}
165
 
System.out.println("");
 
172
System.err.println("");
166
173
      */
167
174
 
168
175
      dh.setF(f);
190
197
      buf.getByte(foo);
191
198
      sha.update(foo, 0, foo.length);
192
199
      H=sha.digest();
193
 
      //System.out.print("H -> "); //dump(H, 0, H.length);
 
200
      //System.err.print("H -> "); //dump(H, 0, H.length);
194
201
 
195
202
      i=0;
196
203
      j=0;
233
240
        sig.setPubKey(ee, n);   
234
241
        sig.update(H);
235
242
        result=sig.verify(sig_of_H);
 
243
 
 
244
        if(JSch.getLogger().isEnabled(Logger.INFO)){
 
245
          JSch.getLogger().log(Logger.INFO, 
 
246
                               "ssh_rsa_verify: signature "+result);
 
247
        }
 
248
 
236
249
      }
237
250
      else if(alg.equals("ssh-dss")){
238
251
        byte[] q=null;
272
285
        sig.setPubKey(f, p, q, g);   
273
286
        sig.update(H);
274
287
        result=sig.verify(sig_of_H);
 
288
 
 
289
        if(JSch.getLogger().isEnabled(Logger.INFO)){
 
290
          JSch.getLogger().log(Logger.INFO, 
 
291
                               "ssh_dss_verify: signature "+result);
 
292
        }
 
293
 
275
294
      }
276
295
      else{
277
 
        System.out.println("unknow alg");
 
296
        System.err.println("unknown alg");
278
297
      }     
279
298
      state=STATE_END;
280
299
      return result;