pkcs11_no_cgo.go 1.6 KB

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