content_encryption.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // this file was auto-generated by internal/cmd/gentypes/main.go: DO NOT EDIT
  2. package jwa
  3. import (
  4. "github.com/pkg/errors"
  5. )
  6. // ContentEncryptionAlgorithm represents the various encryption algorithms as described in https://tools.ietf.org/html/rfc7518#section-5
  7. type ContentEncryptionAlgorithm string
  8. // Supported values for ContentEncryptionAlgorithm
  9. const (
  10. A128CBC_HS256 ContentEncryptionAlgorithm = "A128CBC-HS256" // AES-CBC + HMAC-SHA256 (128)
  11. A128GCM ContentEncryptionAlgorithm = "A128GCM" // AES-GCM (128)
  12. A192CBC_HS384 ContentEncryptionAlgorithm = "A192CBC-HS384" // AES-CBC + HMAC-SHA384 (192)
  13. A192GCM ContentEncryptionAlgorithm = "A192GCM" // AES-GCM (192)
  14. A256CBC_HS512 ContentEncryptionAlgorithm = "A256CBC-HS512" // AES-CBC + HMAC-SHA512 (256)
  15. A256GCM ContentEncryptionAlgorithm = "A256GCM" // AES-GCM (256)
  16. )
  17. // Accept is used when conversion from values given by
  18. // outside sources (such as JSON payloads) is required
  19. func (v *ContentEncryptionAlgorithm) Accept(value interface{}) error {
  20. var tmp ContentEncryptionAlgorithm
  21. switch x := value.(type) {
  22. case string:
  23. tmp = ContentEncryptionAlgorithm(x)
  24. case ContentEncryptionAlgorithm:
  25. tmp = x
  26. default:
  27. return errors.Errorf(`invalid type for jwa.ContentEncryptionAlgorithm: %T`, value)
  28. }
  29. switch tmp {
  30. case A128CBC_HS256, A128GCM, A192CBC_HS384, A192GCM, A256CBC_HS512, A256GCM:
  31. default:
  32. return errors.Errorf(`invalid jwa.ContentEncryptionAlgorithm value`)
  33. }
  34. *v = tmp
  35. return nil
  36. }
  37. // String returns the string representation of a ContentEncryptionAlgorithm
  38. func (v ContentEncryptionAlgorithm) String() string {
  39. return string(v)
  40. }