OLD | NEW |
1 // Copyright 2013 The Go Authors. All rights reserved. | 1 // Copyright 2013 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package ssh | 5 package ssh |
6 | 6 |
7 import ( | 7 import ( |
8 "crypto" | 8 "crypto" |
9 "crypto/ecdsa" | 9 "crypto/ecdsa" |
10 "crypto/elliptic" | 10 "crypto/elliptic" |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 return false | 275 return false |
276 } | 276 } |
277 | 277 |
278 if !curve.IsOnCurve(x, y) { | 278 if !curve.IsOnCurve(x, y) { |
279 return false | 279 return false |
280 } | 280 } |
281 | 281 |
282 // We don't check if N * PubKey == 0, since | 282 // We don't check if N * PubKey == 0, since |
283 // | 283 // |
284 // - the NIST curves have cofactor = 1, so this is implicit. | 284 // - the NIST curves have cofactor = 1, so this is implicit. |
285 » // (We don't forsee an implementation that supports non NIST | 285 » // (We don't foresee an implementation that supports non NIST |
286 // curves) | 286 // curves) |
287 // | 287 // |
288 // - for ephemeral keys, we don't need to worry about small | 288 // - for ephemeral keys, we don't need to worry about small |
289 // subgroup attacks. | 289 // subgroup attacks. |
290 return true | 290 return true |
291 } | 291 } |
292 | 292 |
293 func (kex *ecdh) Server(c packetConn, rand io.Reader, magics *handshakeMagics, p
riv Signer) (result *kexResult, err error) { | 293 func (kex *ecdh) Server(c packetConn, rand io.Reader, magics *handshakeMagics, p
riv Signer) (result *kexResult, err error) { |
294 packet, err := c.readPacket() | 294 packet, err := c.readPacket() |
295 if err != nil { | 295 if err != nil { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 | 377 |
378 kexAlgoMap[kexAlgoDH14SHA1] = &dhGroup{ | 378 kexAlgoMap[kexAlgoDH14SHA1] = &dhGroup{ |
379 g: new(big.Int).SetInt64(2), | 379 g: new(big.Int).SetInt64(2), |
380 p: p, | 380 p: p, |
381 } | 381 } |
382 | 382 |
383 kexAlgoMap[kexAlgoECDH521] = &ecdh{elliptic.P521()} | 383 kexAlgoMap[kexAlgoECDH521] = &ecdh{elliptic.P521()} |
384 kexAlgoMap[kexAlgoECDH384] = &ecdh{elliptic.P384()} | 384 kexAlgoMap[kexAlgoECDH384] = &ecdh{elliptic.P384()} |
385 kexAlgoMap[kexAlgoECDH256] = &ecdh{elliptic.P256()} | 385 kexAlgoMap[kexAlgoECDH256] = &ecdh{elliptic.P256()} |
386 } | 386 } |
OLD | NEW |