MCPcopy Index your code
hub / github.com/smallstep/cli / parseRSA

Function parseRSA

internal/sshutil/sshutil.go:160–181  ·  view source on GitHub ↗

parseRSA parses an RSA key according to RFC 4253, section 6.6.

(in []byte)

Source from the content-addressed store, hash-verified

158
159// parseRSA parses an RSA key according to RFC 4253, section 6.6.
160func parseRSA(in []byte) (*rsa.PublicKey, error) {
161 var w struct {
162 E *big.Int
163 N *big.Int
164 Rest []byte `ssh:"rest"`
165 }
166 if err := ssh.Unmarshal(in, &w); err != nil {
167 return nil, errors.Wrap(err, "error unmarshaling public key")
168 }
169 if w.E.BitLen() > 24 {
170 return nil, errors.New("invalid public key: exponent too large")
171 }
172 e := w.E.Int64()
173 if e < 3 || e&1 == 0 {
174 return nil, errors.New("invalid public key: incorrect exponent")
175 }
176
177 var key rsa.PublicKey
178 key.E = int(e)
179 key.N = w.N
180 return &key, nil
181}
182
183// parseECDSA parses an ECDSA key according to RFC 5656, section 3.1.
184//

Callers 2

PublicKeyFunction · 0.85
publicKeyTypeAndSizeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…