requests.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. package apiv1
  2. import (
  3. "crypto"
  4. "crypto/x509"
  5. "fmt"
  6. )
  7. // ProtectionLevel specifies on some KMS how cryptographic operations are
  8. // performed.
  9. type ProtectionLevel int
  10. const (
  11. // Protection level not specified.
  12. UnspecifiedProtectionLevel ProtectionLevel = iota
  13. // Crypto operations are performed in software.
  14. Software
  15. // Crypto operations are performed in a Hardware Security Module.
  16. HSM
  17. )
  18. // String returns a string representation of p.
  19. func (p ProtectionLevel) String() string {
  20. switch p {
  21. case UnspecifiedProtectionLevel:
  22. return "unspecified"
  23. case Software:
  24. return "software"
  25. case HSM:
  26. return "hsm"
  27. default:
  28. return fmt.Sprintf("unknown(%d)", p)
  29. }
  30. }
  31. // SignatureAlgorithm used for cryptographic signing.
  32. type SignatureAlgorithm int
  33. const (
  34. // Not specified.
  35. UnspecifiedSignAlgorithm SignatureAlgorithm = iota
  36. // RSASSA-PKCS1-v1_5 key and a SHA256 digest.
  37. SHA256WithRSA
  38. // RSASSA-PKCS1-v1_5 key and a SHA384 digest.
  39. SHA384WithRSA
  40. // RSASSA-PKCS1-v1_5 key and a SHA512 digest.
  41. SHA512WithRSA
  42. // RSASSA-PSS key with a SHA256 digest.
  43. SHA256WithRSAPSS
  44. // RSASSA-PSS key with a SHA384 digest.
  45. SHA384WithRSAPSS
  46. // RSASSA-PSS key with a SHA512 digest.
  47. SHA512WithRSAPSS
  48. // ECDSA on the NIST P-256 curve with a SHA256 digest.
  49. ECDSAWithSHA256
  50. // ECDSA on the NIST P-384 curve with a SHA384 digest.
  51. ECDSAWithSHA384
  52. // ECDSA on the NIST P-521 curve with a SHA512 digest.
  53. ECDSAWithSHA512
  54. // EdDSA on Curve25519 with a SHA512 digest.
  55. PureEd25519
  56. )
  57. // String returns a string representation of s.
  58. func (s SignatureAlgorithm) String() string {
  59. switch s {
  60. case UnspecifiedSignAlgorithm:
  61. return "unspecified"
  62. case SHA256WithRSA:
  63. return "SHA256-RSA"
  64. case SHA384WithRSA:
  65. return "SHA384-RSA"
  66. case SHA512WithRSA:
  67. return "SHA512-RSA"
  68. case SHA256WithRSAPSS:
  69. return "SHA256-RSAPSS"
  70. case SHA384WithRSAPSS:
  71. return "SHA384-RSAPSS"
  72. case SHA512WithRSAPSS:
  73. return "SHA512-RSAPSS"
  74. case ECDSAWithSHA256:
  75. return "ECDSA-SHA256"
  76. case ECDSAWithSHA384:
  77. return "ECDSA-SHA384"
  78. case ECDSAWithSHA512:
  79. return "ECDSA-SHA512"
  80. case PureEd25519:
  81. return "Ed25519"
  82. default:
  83. return fmt.Sprintf("unknown(%d)", s)
  84. }
  85. }
  86. // GetPublicKeyRequest is the parameter used in the kms.GetPublicKey method.
  87. type GetPublicKeyRequest struct {
  88. Name string
  89. }
  90. // CreateKeyRequest is the parameter used in the kms.CreateKey method.
  91. type CreateKeyRequest struct {
  92. // Name represents the key name or label used to identify a key.
  93. //
  94. // Used by: awskms, cloudkms, pkcs11, yubikey.
  95. Name string
  96. // SignatureAlgorithm represents the type of key to create.
  97. SignatureAlgorithm SignatureAlgorithm
  98. // Bits is the number of bits on RSA keys.
  99. Bits int
  100. // ProtectionLevel specifies how cryptographic operations are performed.
  101. // Used by: cloudkms
  102. ProtectionLevel ProtectionLevel
  103. }
  104. // CreateKeyResponse is the response value of the kms.CreateKey method.
  105. type CreateKeyResponse struct {
  106. Name string
  107. PublicKey crypto.PublicKey
  108. PrivateKey crypto.PrivateKey
  109. CreateSignerRequest CreateSignerRequest
  110. }
  111. // CreateSignerRequest is the parameter used in the kms.CreateSigner method.
  112. type CreateSignerRequest struct {
  113. Signer crypto.Signer
  114. SigningKey string
  115. SigningKeyPEM []byte
  116. TokenLabel string
  117. PublicKey string
  118. PublicKeyPEM []byte
  119. Password []byte
  120. }
  121. // CreateDecrypterRequest is the parameter used in the kms.Decrypt method.
  122. type CreateDecrypterRequest struct {
  123. Decrypter crypto.Decrypter
  124. DecryptionKey string
  125. DecryptionKeyPEM []byte
  126. Password []byte
  127. }
  128. // LoadCertificateRequest is the parameter used in the LoadCertificate method of
  129. // a CertificateManager.
  130. type LoadCertificateRequest struct {
  131. Name string
  132. }
  133. // StoreCertificateRequest is the parameter used in the StoreCertificate method
  134. // of a CertificateManager.
  135. type StoreCertificateRequest struct {
  136. Name string
  137. Certificate *x509.Certificate
  138. }