OLD | NEW |
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 "bytes" | 8 "bytes" |
9 "crypto" | 9 "crypto" |
10 "crypto/dsa" | 10 "crypto/dsa" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 func (k *keychain) Sign(i int, rand io.Reader, data []byte) (sig []byte, err err
or) { | 79 func (k *keychain) Sign(i int, rand io.Reader, data []byte) (sig []byte, err err
or) { |
80 hashFunc := crypto.SHA1 | 80 hashFunc := crypto.SHA1 |
81 h := hashFunc.New() | 81 h := hashFunc.New() |
82 h.Write(data) | 82 h.Write(data) |
83 digest := h.Sum(nil) | 83 digest := h.Sum(nil) |
84 switch key := k.keys[i].(type) { | 84 switch key := k.keys[i].(type) { |
85 case *rsa.PrivateKey: | 85 case *rsa.PrivateKey: |
86 return rsa.SignPKCS1v15(rand, key, hashFunc, digest) | 86 return rsa.SignPKCS1v15(rand, key, hashFunc, digest) |
87 } | 87 } |
88 » return nil, errors.New("unknown key type") | 88 » return nil, errors.New("ssh: unknown key type") |
89 } | 89 } |
90 | 90 |
91 func (k *keychain) loadPEM(file string) error { | 91 func (k *keychain) loadPEM(file string) error { |
92 buf, err := ioutil.ReadFile(file) | 92 buf, err := ioutil.ReadFile(file) |
93 if err != nil { | 93 if err != nil { |
94 return err | 94 return err |
95 } | 95 } |
96 block, _ := pem.Decode(buf) | 96 block, _ := pem.Decode(buf) |
97 if block == nil { | 97 if block == nil { |
98 return errors.New("ssh: no key found") | 98 return errors.New("ssh: no key found") |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 MACs: []string{mac}, | 269 MACs: []string{mac}, |
270 }, | 270 }, |
271 } | 271 } |
272 c, err := Dial("tcp", newMockAuthServer(t), config) | 272 c, err := Dial("tcp", newMockAuthServer(t), config) |
273 if err != nil { | 273 if err != nil { |
274 t.Fatalf("client could not authenticate with mac algo %s
: %v", mac, err) | 274 t.Fatalf("client could not authenticate with mac algo %s
: %v", mac, err) |
275 } | 275 } |
276 c.Close() | 276 c.Close() |
277 } | 277 } |
278 } | 278 } |
OLD | NEW |