comparison src/ch/ethz/ssh2/crypto/dh/DhExchange.java @ 313:1d400fd78e4a ganymed

add ecdsa key support everywhere
author Carl Byington <carl@five-ten-sg.com>
date Wed, 30 Jul 2014 16:19:33 -0700
parents cb179051f0f2
children
comparison
equal deleted inserted replaced
312:1442be38051b 313:1d400fd78e4a
56 private DHPublicKey clientPublic; 56 private DHPublicKey clientPublic;
57 57
58 /* Server public */ 58 /* Server public */
59 59
60 private DHPublicKey serverPublic; 60 private DHPublicKey serverPublic;
61 private byte[] f;
61 62
62 @Override 63 @Override
63 public void init(String name) throws IOException { 64 public void init(String name) throws IOException {
64 final DHParameterSpec spec; 65 final DHParameterSpec spec;
65 66
103 104
104 return serverPublic.getY().toByteArray(); 105 return serverPublic.getY().toByteArray();
105 } 106 }
106 107
107 @Override 108 @Override
109 public byte[] getF() {
110 return f;
111 }
112
113 @Override
108 public void setF(byte[] f) throws IOException { 114 public void setF(byte[] f) throws IOException {
109 if (clientPublic == null) 115 if (clientPublic == null)
110 throw new IllegalStateException("DhExchange not initialized!"); 116 throw new IllegalStateException("DhExchange not initialized!");
111 117
112 final KeyAgreement ka; 118 final KeyAgreement ka;
113 119
114 try { 120 try {
115 KeyFactory kf = KeyFactory.getInstance("DH"); 121 KeyFactory kf = KeyFactory.getInstance("DH");
116 DHParameterSpec params = clientPublic.getParams(); 122 DHParameterSpec params = clientPublic.getParams();
123 this.f = f;
117 this.serverPublic = (DHPublicKey) kf.generatePublic(new DHPublicKeySpec( 124 this.serverPublic = (DHPublicKey) kf.generatePublic(new DHPublicKeySpec(
118 new BigInteger(f), params.getP(), params.getG())); 125 new BigInteger(f), params.getP(), params.getG()));
119 ka = KeyAgreement.getInstance("DH"); 126 ka = KeyAgreement.getInstance("DH");
120 ka.init(clientPrivate); 127 ka.init(clientPrivate);
121 ka.doPhase(serverPublic, true); 128 ka.doPhase(serverPublic, true);