requests.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. package apiv1
  2. import (
  3. "crypto"
  4. "crypto/x509"
  5. "time"
  6. "github.com/smallstep/certificates/kms/apiv1"
  7. )
  8. // CertificateAuthorityType indicates the type of Certificate Authority to
  9. // create.
  10. type CertificateAuthorityType int
  11. const (
  12. // RootCA is the type used to create a self-signed certificate suitable for
  13. // use as a root CA.
  14. RootCA CertificateAuthorityType = iota + 1
  15. // IntermediateCA is the type used to create a subordinated certificate that
  16. // can be used to sign additional leaf certificates.
  17. IntermediateCA
  18. )
  19. // SignatureAlgorithm used for cryptographic signing.
  20. type SignatureAlgorithm int
  21. const (
  22. // Not specified.
  23. UnspecifiedSignAlgorithm SignatureAlgorithm = iota
  24. // RSASSA-PKCS1-v1_5 key and a SHA256 digest.
  25. SHA256WithRSA
  26. // RSASSA-PKCS1-v1_5 key and a SHA384 digest.
  27. SHA384WithRSA
  28. // RSASSA-PKCS1-v1_5 key and a SHA512 digest.
  29. SHA512WithRSA
  30. // RSASSA-PSS key with a SHA256 digest.
  31. SHA256WithRSAPSS
  32. // RSASSA-PSS key with a SHA384 digest.
  33. SHA384WithRSAPSS
  34. // RSASSA-PSS key with a SHA512 digest.
  35. SHA512WithRSAPSS
  36. // ECDSA on the NIST P-256 curve with a SHA256 digest.
  37. ECDSAWithSHA256
  38. // ECDSA on the NIST P-384 curve with a SHA384 digest.
  39. ECDSAWithSHA384
  40. // ECDSA on the NIST P-521 curve with a SHA512 digest.
  41. ECDSAWithSHA512
  42. // EdDSA on Curve25519 with a SHA512 digest.
  43. PureEd25519
  44. )
  45. // CreateCertificateRequest is the request used to sign a new certificate.
  46. type CreateCertificateRequest struct {
  47. Template *x509.Certificate
  48. CSR *x509.CertificateRequest
  49. Lifetime time.Duration
  50. Backdate time.Duration
  51. RequestID string
  52. }
  53. // CreateCertificateResponse is the response to a create certificate request.
  54. type CreateCertificateResponse struct {
  55. Certificate *x509.Certificate
  56. CertificateChain []*x509.Certificate
  57. }
  58. // RenewCertificateRequest is the request used to re-sign a certificate.
  59. type RenewCertificateRequest struct {
  60. Template *x509.Certificate
  61. CSR *x509.CertificateRequest
  62. Lifetime time.Duration
  63. Backdate time.Duration
  64. RequestID string
  65. }
  66. // RenewCertificateResponse is the response to a renew certificate request.
  67. type RenewCertificateResponse struct {
  68. Certificate *x509.Certificate
  69. CertificateChain []*x509.Certificate
  70. }
  71. // RevokeCertificateRequest is the request used to revoke a certificate.
  72. type RevokeCertificateRequest struct {
  73. Certificate *x509.Certificate
  74. SerialNumber string
  75. Reason string
  76. ReasonCode int
  77. PassiveOnly bool
  78. RequestID string
  79. }
  80. // RevokeCertificateResponse is the response to a revoke certificate request.
  81. type RevokeCertificateResponse struct {
  82. Certificate *x509.Certificate
  83. CertificateChain []*x509.Certificate
  84. }
  85. // GetCertificateAuthorityRequest is the request used to get the root
  86. // certificate from a CAS.
  87. type GetCertificateAuthorityRequest struct {
  88. Name string
  89. }
  90. // GetCertificateAuthorityResponse is the response that contains
  91. // the root certificate.
  92. type GetCertificateAuthorityResponse struct {
  93. RootCertificate *x509.Certificate
  94. }
  95. // CreateCertificateAuthorityRequest is the request used to generate a root or
  96. // intermediate certificate.
  97. type CreateCertificateAuthorityRequest struct {
  98. Name string
  99. Type CertificateAuthorityType
  100. Template *x509.Certificate
  101. Lifetime time.Duration
  102. Backdate time.Duration
  103. RequestID string
  104. Project string
  105. Location string
  106. // Parent is the signer of the new CertificateAuthority.
  107. Parent *CreateCertificateAuthorityResponse
  108. // CreateKey defines the KMS CreateKeyRequest to use when creating a new
  109. // CertificateAuthority. If CreateKey is nil, a default algorithm will be
  110. // used.
  111. CreateKey *apiv1.CreateKeyRequest
  112. }
  113. // CreateCertificateAuthorityResponse is the response for
  114. // CreateCertificateAuthority method and contains the root or intermediate
  115. // certificate generated as well as the CA chain.
  116. type CreateCertificateAuthorityResponse struct {
  117. Name string
  118. Certificate *x509.Certificate
  119. CertificateChain []*x509.Certificate
  120. PublicKey crypto.PublicKey
  121. PrivateKey crypto.PrivateKey
  122. Signer crypto.Signer
  123. }