forked from lestrrat-go/jwx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
elliptic.go
44 lines (37 loc) · 1.09 KB
/
elliptic.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
// this file was auto-generated by internal/cmd/gentypes/main.go: DO NOT EDIT
package jwa
import (
"github.com/pkg/errors"
)
// EllipticCurveAlgorithm represents the algorithms used for EC keys
type EllipticCurveAlgorithm string
// Supported values for EllipticCurveAlgorithm
const (
P256 EllipticCurveAlgorithm = "P-256"
P384 EllipticCurveAlgorithm = "P-384"
P521 EllipticCurveAlgorithm = "P-521"
)
// Accept is used when conversion from values given by
// outside sources (such as JSON payloads) is required
func (v *EllipticCurveAlgorithm) Accept(value interface{}) error {
var tmp EllipticCurveAlgorithm
switch x := value.(type) {
case string:
tmp = EllipticCurveAlgorithm(x)
case EllipticCurveAlgorithm:
tmp = x
default:
return errors.Errorf(`invalid type for jwa.EllipticCurveAlgorithm: %T`, value)
}
switch tmp {
case P256, P384, P521:
default:
return errors.Errorf(`invalid jwa.EllipticCurveAlgorithm value`)
}
*v = tmp
return nil
}
// String returns the string representation of a EllipticCurveAlgorithm
func (v EllipticCurveAlgorithm) String() string {
return string(v)
}