code: func (kr *BasicKeyRequest) Generate() (crypto.PrivateKey, error) {
  	log.Debugf("generate key from request: algo=%s, size=%d", kr.Algo(), kr.Size())
  	switch kr.Algo() {
  	case "rsa":
  		if kr.Size() < 2048 {
  			return nil, errors.New("RSA key is too weak")
  		}
  		if kr.Size() > 8192 {
  			return nil, errors.New("RSA key size too large")
  		}
  		return rsa.GenerateKey(rand.Reader, kr.Size())
  	case "ecdsa":
  		var curve elliptic.Curve
  		switch kr.Size() {
  		case curveP256:
  			curve = elliptic.P256()
  		case curveP384:
  			curve = elliptic.P384()
  		case curveP521:
  			curve = elliptic.P521()
  		default:
  			return nil, errors.New("invalid curve")
  		}
  		return ecdsa.GenerateKey(curve, rand.Reader)
  	default:
  		return nil, errors.New("invalid algorithm")
  	}
  }
docs: // Generate generates a key as specified in the request. Currently,
  // only ECDSA and RSA are supported.