generateECDHEKey returns a PrivateKey that implements Diffie-Hellman according to RFC 8446, Section 4.2.8.2.
(rand io.Reader, curveID CurveID)
| 61 | // generateECDHEKey returns a PrivateKey that implements Diffie-Hellman |
| 62 | // according to RFC 8446, Section 4.2.8.2. |
| 63 | func generateECDHEKey(rand io.Reader, curveID CurveID) (*ecdh.PrivateKey, error) { |
| 64 | curve, ok := curveForCurveID(curveID) |
| 65 | if !ok { |
| 66 | return nil, errors.New("tls: internal error: unsupported curve") |
| 67 | } |
| 68 | |
| 69 | return curve.GenerateKey(rand) |
| 70 | } |
| 71 | |
| 72 | func curveForCurveID(id CurveID) (ecdh.Curve, bool) { |
| 73 | switch id { |
no test coverage detected
searching dependent graphs…