comparison src/ch/ethz/ssh2/KnownHosts.java @ 284:4ec87de11e71 ganymed

start conversion from trilead to ganymed
author Carl Byington <carl@five-ten-sg.com>
date Fri, 18 Jul 2014 18:08:56 -0700
parents d7e088fa2123
children 486df527ddc5
comparison
equal deleted inserted replaced
283:3855f58ffd2b 284:4ec87de11e71
428 fr.close(); 428 fr.close();
429 429
430 initialize(cw.toCharArray()); 430 initialize(cw.toCharArray());
431 } 431 }
432 432
433 private boolean matchKeys(Object key1, Object key2) { 433 private final boolean matchKeys(PublicKey key1, PublicKey key2) {
434 if((key1 instanceof RSAPublicKey) && (key2 instanceof RSAPublicKey)) { 434 return key1.equals(key2);
435 RSAPublicKey savedRSAKey = (RSAPublicKey) key1;
436 RSAPublicKey remoteRSAKey = (RSAPublicKey) key2;
437
438 if(savedRSAKey.getE().equals(remoteRSAKey.getE()) == false) {
439 return false;
440 }
441
442 if(savedRSAKey.getN().equals(remoteRSAKey.getN()) == false) {
443 return false;
444 }
445
446 return true;
447 }
448
449 if((key1 instanceof DSAPublicKey) && (key2 instanceof DSAPublicKey)) {
450 DSAPublicKey savedDSAKey = (DSAPublicKey) key1;
451 DSAPublicKey remoteDSAKey = (DSAPublicKey) key2;
452
453 if(savedDSAKey.getG().equals(remoteDSAKey.getG()) == false) {
454 return false;
455 }
456
457 if(savedDSAKey.getP().equals(remoteDSAKey.getP()) == false) {
458 return false;
459 }
460
461 if(savedDSAKey.getQ().equals(remoteDSAKey.getQ()) == false) {
462 return false;
463 }
464
465 if(savedDSAKey.getY().equals(remoteDSAKey.getY()) == false) {
466 return false;
467 }
468
469 return true;
470 }
471
472 return false;
473 } 435 }
474 436
475 private boolean pseudoRegex(char[] pattern, int i, char[] match, int j) { 437 private boolean pseudoRegex(char[] pattern, int i, char[] match, int j) {
476 /* This matching logic is equivalent to the one present in OpenSSH 4.1 */ 438 /* This matching logic is equivalent to the one present in OpenSSH 4.1 */
477 439