2020-09-09 02:26:32 +00:00
|
|
|
package apiv1
|
|
|
|
|
|
|
|
import (
|
2020-10-23 22:04:09 +00:00
|
|
|
"crypto"
|
2020-09-09 02:26:32 +00:00
|
|
|
"crypto/x509"
|
|
|
|
"time"
|
2020-10-23 22:04:09 +00:00
|
|
|
|
2022-08-09 00:58:18 +00:00
|
|
|
"go.step.sm/crypto/kms/apiv1"
|
2020-10-23 22:04:09 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// CertificateAuthorityType indicates the type of Certificate Authority to
|
|
|
|
// create.
|
|
|
|
type CertificateAuthorityType int
|
|
|
|
|
|
|
|
const (
|
|
|
|
// RootCA is the type used to create a self-signed certificate suitable for
|
|
|
|
// use as a root CA.
|
|
|
|
RootCA CertificateAuthorityType = iota + 1
|
|
|
|
|
|
|
|
// IntermediateCA is the type used to create a subordinated certificate that
|
|
|
|
// can be used to sign additional leaf certificates.
|
|
|
|
IntermediateCA
|
|
|
|
)
|
|
|
|
|
|
|
|
// SignatureAlgorithm used for cryptographic signing.
|
|
|
|
type SignatureAlgorithm int
|
|
|
|
|
|
|
|
const (
|
|
|
|
// Not specified.
|
|
|
|
UnspecifiedSignAlgorithm SignatureAlgorithm = iota
|
|
|
|
// RSASSA-PKCS1-v1_5 key and a SHA256 digest.
|
|
|
|
SHA256WithRSA
|
|
|
|
// RSASSA-PKCS1-v1_5 key and a SHA384 digest.
|
|
|
|
SHA384WithRSA
|
|
|
|
// RSASSA-PKCS1-v1_5 key and a SHA512 digest.
|
|
|
|
SHA512WithRSA
|
|
|
|
// RSASSA-PSS key with a SHA256 digest.
|
|
|
|
SHA256WithRSAPSS
|
|
|
|
// RSASSA-PSS key with a SHA384 digest.
|
|
|
|
SHA384WithRSAPSS
|
|
|
|
// RSASSA-PSS key with a SHA512 digest.
|
|
|
|
SHA512WithRSAPSS
|
|
|
|
// ECDSA on the NIST P-256 curve with a SHA256 digest.
|
|
|
|
ECDSAWithSHA256
|
|
|
|
// ECDSA on the NIST P-384 curve with a SHA384 digest.
|
|
|
|
ECDSAWithSHA384
|
|
|
|
// ECDSA on the NIST P-521 curve with a SHA512 digest.
|
|
|
|
ECDSAWithSHA512
|
|
|
|
// EdDSA on Curve25519 with a SHA512 digest.
|
|
|
|
PureEd25519
|
2020-09-09 02:26:32 +00:00
|
|
|
)
|
|
|
|
|
2020-09-15 02:12:49 +00:00
|
|
|
// CreateCertificateRequest is the request used to sign a new certificate.
|
2020-09-09 02:26:32 +00:00
|
|
|
type CreateCertificateRequest struct {
|
2022-08-11 22:14:26 +00:00
|
|
|
Template *x509.Certificate
|
|
|
|
CSR *x509.CertificateRequest
|
|
|
|
Lifetime time.Duration
|
|
|
|
Backdate time.Duration
|
|
|
|
RequestID string
|
|
|
|
Provisioner *ProvisionerInfo
|
|
|
|
IsCAServerCert bool
|
2022-08-03 02:28:49 +00:00
|
|
|
}
|
|
|
|
|
2022-08-04 17:07:20 +00:00
|
|
|
// ProvisionerInfo contains information of the provisioner used to authorize a
|
2022-08-03 02:28:49 +00:00
|
|
|
// certificate.
|
|
|
|
type ProvisionerInfo struct {
|
2022-08-11 00:44:14 +00:00
|
|
|
ID string
|
|
|
|
Type string
|
|
|
|
Name string
|
2020-09-09 02:26:32 +00:00
|
|
|
}
|
2020-09-15 02:12:49 +00:00
|
|
|
|
|
|
|
// CreateCertificateResponse is the response to a create certificate request.
|
2020-09-09 02:26:32 +00:00
|
|
|
type CreateCertificateResponse struct {
|
|
|
|
Certificate *x509.Certificate
|
|
|
|
CertificateChain []*x509.Certificate
|
|
|
|
}
|
|
|
|
|
2020-09-15 02:12:49 +00:00
|
|
|
// RenewCertificateRequest is the request used to re-sign a certificate.
|
2020-09-10 23:19:18 +00:00
|
|
|
type RenewCertificateRequest struct {
|
|
|
|
Template *x509.Certificate
|
2021-03-18 02:33:35 +00:00
|
|
|
CSR *x509.CertificateRequest
|
2020-09-10 23:19:18 +00:00
|
|
|
Lifetime time.Duration
|
|
|
|
Backdate time.Duration
|
|
|
|
RequestID string
|
|
|
|
}
|
2020-09-15 02:12:49 +00:00
|
|
|
|
|
|
|
// RenewCertificateResponse is the response to a renew certificate request.
|
2020-09-10 23:19:18 +00:00
|
|
|
type RenewCertificateResponse struct {
|
|
|
|
Certificate *x509.Certificate
|
|
|
|
CertificateChain []*x509.Certificate
|
|
|
|
}
|
2020-09-09 02:26:32 +00:00
|
|
|
|
2020-09-10 23:19:18 +00:00
|
|
|
// RevokeCertificateRequest is the request used to revoke a certificate.
|
|
|
|
type RevokeCertificateRequest struct {
|
2021-03-18 02:33:35 +00:00
|
|
|
Certificate *x509.Certificate
|
|
|
|
SerialNumber string
|
|
|
|
Reason string
|
|
|
|
ReasonCode int
|
2021-03-18 02:47:36 +00:00
|
|
|
PassiveOnly bool
|
2021-03-18 02:33:35 +00:00
|
|
|
RequestID string
|
2020-09-10 23:19:18 +00:00
|
|
|
}
|
2020-09-15 02:12:49 +00:00
|
|
|
|
|
|
|
// RevokeCertificateResponse is the response to a revoke certificate request.
|
2020-09-10 23:19:18 +00:00
|
|
|
type RevokeCertificateResponse struct {
|
|
|
|
Certificate *x509.Certificate
|
|
|
|
CertificateChain []*x509.Certificate
|
|
|
|
}
|
2020-09-21 22:27:20 +00:00
|
|
|
|
|
|
|
// GetCertificateAuthorityRequest is the request used to get the root
|
|
|
|
// certificate from a CAS.
|
|
|
|
type GetCertificateAuthorityRequest struct {
|
|
|
|
Name string
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetCertificateAuthorityResponse is the response that contains
|
|
|
|
// the root certificate.
|
|
|
|
type GetCertificateAuthorityResponse struct {
|
|
|
|
RootCertificate *x509.Certificate
|
|
|
|
}
|
2020-10-23 22:04:09 +00:00
|
|
|
|
2021-10-07 21:19:39 +00:00
|
|
|
// CreateKeyRequest is the request used to generate a new key using a KMS.
|
|
|
|
type CreateKeyRequest = apiv1.CreateKeyRequest
|
|
|
|
|
2020-11-03 18:55:39 +00:00
|
|
|
// CreateCertificateAuthorityRequest is the request used to generate a root or
|
|
|
|
// intermediate certificate.
|
2020-10-23 22:04:09 +00:00
|
|
|
type CreateCertificateAuthorityRequest struct {
|
|
|
|
Name string
|
|
|
|
Type CertificateAuthorityType
|
|
|
|
Template *x509.Certificate
|
|
|
|
Lifetime time.Duration
|
|
|
|
Backdate time.Duration
|
|
|
|
RequestID string
|
|
|
|
Project string
|
|
|
|
Location string
|
|
|
|
|
|
|
|
// Parent is the signer of the new CertificateAuthority.
|
|
|
|
Parent *CreateCertificateAuthorityResponse
|
|
|
|
|
|
|
|
// CreateKey defines the KMS CreateKeyRequest to use when creating a new
|
|
|
|
// CertificateAuthority. If CreateKey is nil, a default algorithm will be
|
|
|
|
// used.
|
2021-10-07 21:19:39 +00:00
|
|
|
CreateKey *CreateKeyRequest
|
2020-10-23 22:04:09 +00:00
|
|
|
}
|
|
|
|
|
2020-11-03 18:55:39 +00:00
|
|
|
// CreateCertificateAuthorityResponse is the response for
|
2020-11-03 20:48:48 +00:00
|
|
|
// CreateCertificateAuthority method and contains the root or intermediate
|
2020-11-03 18:55:39 +00:00
|
|
|
// certificate generated as well as the CA chain.
|
2020-10-23 22:04:09 +00:00
|
|
|
type CreateCertificateAuthorityResponse struct {
|
|
|
|
Name string
|
|
|
|
Certificate *x509.Certificate
|
|
|
|
CertificateChain []*x509.Certificate
|
2021-10-07 21:19:39 +00:00
|
|
|
KeyName string
|
2020-10-23 22:04:09 +00:00
|
|
|
PublicKey crypto.PublicKey
|
|
|
|
PrivateKey crypto.PrivateKey
|
|
|
|
Signer crypto.Signer
|
|
|
|
}
|