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/ecdsa" | 10 "crypto/ecdsa" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 block, _ := pem.Decode(pemBytes) | 75 block, _ := pem.Decode(pemBytes) |
76 if block == nil { | 76 if block == nil { |
77 return errors.New("ssh: no key found") | 77 return errors.New("ssh: no key found") |
78 } | 78 } |
79 var err error | 79 var err error |
80 s.rsa, err = x509.ParsePKCS1PrivateKey(block.Bytes) | 80 s.rsa, err = x509.ParsePKCS1PrivateKey(block.Bytes) |
81 if err != nil { | 81 if err != nil { |
82 return err | 82 return err |
83 } | 83 } |
84 | 84 |
85 » s.rsaSerialized = marshalPrivRSA(s.rsa) | 85 » s.rsaSerialized = serializePublicKey(&s.rsa.PublicKey) |
86 return nil | 86 return nil |
87 } | 87 } |
88 | 88 |
89 func parseRSASig(in []byte) (sig []byte, ok bool) { | 89 func parseRSASig(in []byte) (sig []byte, ok bool) { |
90 algo, in, ok := parseString(in) | 90 algo, in, ok := parseString(in) |
91 if !ok || string(algo) != hostAlgoRSA { | 91 if !ok || string(algo) != hostAlgoRSA { |
92 return nil, false | 92 return nil, false |
93 } | 93 } |
94 sig, in, ok = parseString(in) | 94 sig, in, ok = parseString(in) |
95 if len(in) > 0 { | 95 if len(in) > 0 { |
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 func Listen(network, addr string, config *ServerConfig) (*Listener, error) { | 903 func Listen(network, addr string, config *ServerConfig) (*Listener, error) { |
904 l, err := net.Listen(network, addr) | 904 l, err := net.Listen(network, addr) |
905 if err != nil { | 905 if err != nil { |
906 return nil, err | 906 return nil, err |
907 } | 907 } |
908 return &Listener{ | 908 return &Listener{ |
909 l, | 909 l, |
910 config, | 910 config, |
911 }, nil | 911 }, nil |
912 } | 912 } |
OLD | NEW |