code: func (sp *StandardProvider) Generate(algo string, size int) (err error) {
  	sp.resetKey()
  	sp.resetCert()
  
  	algo = strings.ToLower(algo)
  	switch algo {
  	case "rsa":
  		var priv *rsa.PrivateKey
  		if size < 2048 {
  			return errors.New("transport: RSA keys must be at least 2048 bits")
  		}
  
  		priv, err = rsa.GenerateKey(rand.Reader, size)
  		if err != nil {
  			return err
  		}
  
  		keyPEM := x509.MarshalPKCS1PrivateKey(priv)
  		p := &pem.Block{
  			Type:  "RSA PRIVATE KEY",
  			Bytes: keyPEM,
  		}
  		sp.internal.keyPEM = pem.EncodeToMemory(p)
  		sp.internal.priv = priv
  	case "ecdsa":
  		var priv *ecdsa.PrivateKey
  		var curve elliptic.Curve
  		switch size {
  		case curveP256:
  			curve = elliptic.P256()
  		case curveP384:
  			curve = elliptic.P384()
  		case curveP521:
  			curve = elliptic.P521()
  		default:
  			return errors.New("transport: invalid elliptic curve key size; only 256-, 384-, and 521-bit keys are accepted")
  		}
  
  		priv, err = ecdsa.GenerateKey(curve, rand.Reader)
  		if err != nil {
  			return err
  		}
  
  		var keyPEM []byte
  		keyPEM, err = x509.MarshalECPrivateKey(priv)
  		if err != nil {
  			return err
  		}
  
  		p := &pem.Block{
  			Type:  "EC PRIVATE KEY",
  			Bytes: keyPEM,
  		}
  		sp.internal.keyPEM = pem.EncodeToMemory(p)
  
  		sp.internal.priv = priv
  	default:
  		return errors.New("transport: invalid key algorithm; only RSA and ECDSA are supported")
  	}
  
  	return nil
  }
docs: // Generate generates a new private key.