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