pkcs11_no_cgo.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //go:build !cgo
  2. // +build !cgo
  3. package pkcs11
  4. import (
  5. "context"
  6. "crypto"
  7. "os"
  8. "path/filepath"
  9. "github.com/pkg/errors"
  10. "github.com/smallstep/certificates/kms/apiv1"
  11. )
  12. var errUnsupported error
  13. func init() {
  14. name := filepath.Base(os.Args[0])
  15. errUnsupported = errors.Errorf("unsupported kms type 'pkcs11': %s is compiled without cgo support", name)
  16. apiv1.Register(apiv1.PKCS11, func(ctx context.Context, opts apiv1.Options) (apiv1.KeyManager, error) {
  17. return nil, errUnsupported
  18. })
  19. }
  20. // PKCS11 is the implementation of a KMS using the PKCS #11 standard.
  21. type PKCS11 struct{}
  22. // New implements the kms.KeyManager interface and without CGO will always
  23. // return an error.
  24. func New(ctx context.Context, opts apiv1.Options) (*PKCS11, error) {
  25. return nil, errUnsupported
  26. }
  27. // GetPublicKey implements the kms.KeyManager interface and without CGO will always
  28. // return an error.
  29. func (*PKCS11) GetPublicKey(req *apiv1.GetPublicKeyRequest) (crypto.PublicKey, error) {
  30. return nil, errUnsupported
  31. }
  32. // CreateKey implements the kms.KeyManager interface and without CGO will always
  33. // return an error.
  34. func (*PKCS11) CreateKey(req *apiv1.CreateKeyRequest) (*apiv1.CreateKeyResponse, error) {
  35. return nil, errUnsupported
  36. }
  37. // CreateSigner implements the kms.KeyManager interface and without CGO will always
  38. // return an error.
  39. func (*PKCS11) CreateSigner(req *apiv1.CreateSignerRequest) (crypto.Signer, error) {
  40. return nil, errUnsupported
  41. }
  42. // Close implements the kms.KeyManager interface and without CGO will always
  43. // return an error.
  44. func (*PKCS11) Close() error {
  45. return errUnsupported
  46. }