requests.go 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. Lifetime time.Duration
  49. Backdate time.Duration
  50. RequestID string
  51. }
  52. // CreateCertificateResponse is the response to a create certificate request.
  53. type CreateCertificateResponse struct {
  54. Certificate *x509.Certificate
  55. CertificateChain []*x509.Certificate
  56. }
  57. // RenewCertificateRequest is the request used to re-sign a certificate.
  58. type RenewCertificateRequest struct {
  59. Template *x509.Certificate
  60. Lifetime time.Duration
  61. Backdate time.Duration
  62. RequestID string
  63. }
  64. // RenewCertificateResponse is the response to a renew certificate request.
  65. type RenewCertificateResponse struct {
  66. Certificate *x509.Certificate
  67. CertificateChain []*x509.Certificate
  68. }
  69. // RevokeCertificateRequest is the request used to revoke a certificate.
  70. type RevokeCertificateRequest struct {
  71. Certificate *x509.Certificate
  72. Reason string
  73. ReasonCode int
  74. RequestID string
  75. }
  76. // RevokeCertificateResponse is the response to a revoke certificate request.
  77. type RevokeCertificateResponse struct {
  78. Certificate *x509.Certificate
  79. CertificateChain []*x509.Certificate
  80. }
  81. // GetCertificateAuthorityRequest is the request used to get the root
  82. // certificate from a CAS.
  83. type GetCertificateAuthorityRequest struct {
  84. Name string
  85. }
  86. // GetCertificateAuthorityResponse is the response that contains
  87. // the root certificate.
  88. type GetCertificateAuthorityResponse struct {
  89. RootCertificate *x509.Certificate
  90. }
  91. // CreateCertificateAuthorityRequest is the request used to generate a root or
  92. // intermediate certificate.
  93. type CreateCertificateAuthorityRequest struct {
  94. Name string
  95. Type CertificateAuthorityType
  96. Template *x509.Certificate
  97. Lifetime time.Duration
  98. Backdate time.Duration
  99. RequestID string
  100. Project string
  101. Location string
  102. // Parent is the signer of the new CertificateAuthority.
  103. Parent *CreateCertificateAuthorityResponse
  104. // CreateKey defines the KMS CreateKeyRequest to use when creating a new
  105. // CertificateAuthority. If CreateKey is nil, a default algorithm will be
  106. // used.
  107. CreateKey *apiv1.CreateKeyRequest
  108. }
  109. // CreateCertificateAuthorityResponse is the response for
  110. // CreateCertificateAuthority method and contains the root or intermediate
  111. // certificate generated as well as the CA chain.
  112. type CreateCertificateAuthorityResponse struct {
  113. Name string
  114. Certificate *x509.Certificate
  115. CertificateChain []*x509.Certificate
  116. PublicKey crypto.PublicKey
  117. PrivateKey crypto.PrivateKey
  118. Signer crypto.Signer
  119. }