Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1152)

Delta Between Two Patch Sets: ssh/common.go

Issue 6061052: code review 6061052: ssh: cosmetic cleanups (Closed)
Left Patch Set: diff -r 8e4015d2d681 https://agl%40golang.org@code.google.com/p/go.crypto/ Created 12 years, 11 months ago
Right Patch Set: diff -r 1ce0f2904ef1 https://agl%40golang.org@code.google.com/p/go.crypto/ Created 12 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « ssh/client_auth_test.go ('k') | ssh/keys.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2011 The Go Authors. All rights reserved. 1 // Copyright 2011 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/dsa" 8 "crypto/dsa"
9 "crypto/rsa" 9 "crypto/rsa"
10 "errors"
10 "math/big" 11 "math/big"
11 "strconv" 12 "strconv"
12 "sync" 13 "sync"
13 ) 14 )
14 15
15 // These are string constants in the SSH protocol. 16 // These are string constants in the SSH protocol.
16 const ( 17 const (
17 keyAlgoDH1SHA1 = "diffie-hellman-group1-sha1" 18 keyAlgoDH1SHA1 = "diffie-hellman-group1-sha1"
18 kexAlgoDH14SHA1 = "diffie-hellman-group14-sha1" 19 kexAlgoDH14SHA1 = "diffie-hellman-group14-sha1"
19 hostAlgoRSA = "ssh-rsa" 20 hostAlgoRSA = "ssh-rsa"
20 hostAlgoDSA = "ssh-dss" 21 hostAlgoDSA = "ssh-dss"
21 compressionNone = "none" 22 compressionNone = "none"
22 serviceUserAuth = "ssh-userauth" 23 serviceUserAuth = "ssh-userauth"
23 serviceSSH = "ssh-connection" 24 serviceSSH = "ssh-connection"
24 ) 25 )
25 26
26 var supportedKexAlgos = []string{kexAlgoDH14SHA1, keyAlgoDH1SHA1} 27 var supportedKexAlgos = []string{kexAlgoDH14SHA1, keyAlgoDH1SHA1}
27 var supportedHostKeyAlgos = []string{hostAlgoRSA} 28 var supportedHostKeyAlgos = []string{hostAlgoRSA}
28 var supportedCompressions = []string{compressionNone} 29 var supportedCompressions = []string{compressionNone}
29 30
30 // dhGroup is a multiplicative group suitable for implementing Diffie-Hellman ke y agreement. 31 // dhGroup is a multiplicative group suitable for implementing Diffie-Hellman ke y agreement.
31 type dhGroup struct { 32 type dhGroup struct {
32 g, p *big.Int 33 g, p *big.Int
34 }
35
36 func (group *dhGroup) diffieHellman(theirPublic, myPrivate *big.Int) (*big.Int, error) {
37 if theirPublic.Sign() <= 0 || theirPublic.Cmp(group.p) >= 0 {
38 return nil, errors.New("ssh: DH parameter out of bounds")
39 }
40 return new(big.Int).Exp(theirPublic, myPrivate, group.p), nil
33 } 41 }
34 42
35 // dhGroup1 is the group called diffie-hellman-group1-sha1 in RFC 4253 and 43 // dhGroup1 is the group called diffie-hellman-group1-sha1 in RFC 4253 and
36 // Oakley Group 2 in RFC 2409. 44 // Oakley Group 2 in RFC 2409.
37 var dhGroup1 *dhGroup 45 var dhGroup1 *dhGroup
38 46
39 var dhGroup1Once sync.Once 47 var dhGroup1Once sync.Once
40 48
41 func initDHGroup1() { 49 func initDHGroup1() {
42 p, _ := new(big.Int).SetString("FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B 80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6D F25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB 5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF", 16) 50 p, _ := new(big.Int).SetString("FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B 80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6D F25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB 5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF", 16)
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 return append(buf, byte(n>>8), byte(n)) 278 return append(buf, byte(n>>8), byte(n))
271 } 279 }
272 280
273 func appendU32(buf []byte, n uint32) []byte { 281 func appendU32(buf []byte, n uint32) []byte {
274 return append(buf, byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) 282 return append(buf, byte(n>>24), byte(n>>16), byte(n>>8), byte(n))
275 } 283 }
276 284
277 func appendInt(buf []byte, n int) []byte { 285 func appendInt(buf []byte, n int) []byte {
278 return appendU32(buf, uint32(n)) 286 return appendU32(buf, uint32(n))
279 } 287 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b