-
Notifications
You must be signed in to change notification settings - Fork 22
/
options.go
51 lines (41 loc) · 1.1 KB
/
options.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
48
49
50
51
package biscuit
import "io"
type compositionOption interface {
builderOption
biscuitOption
}
type rngOption struct {
io.Reader
}
func (o rngOption) applyToBuilder(b *builderOptions) {
if r := o.Reader; r != nil {
b.rng = o
}
}
func (o rngOption) applyToBiscuit(b *biscuitOptions) error {
if r := o.Reader; r != nil {
b.rng = r
}
return nil
}
// WithRNG supplies a random number generator as a byte stream from which to read when generating
// key pairs with which to sign blocks within biscuits.
func WithRNG(r io.Reader) compositionOption {
return rngOption{r}
}
type rootKeyIDOption uint32
func (o rootKeyIDOption) applyToBuilder(b *builderOptions) {
id := uint32(o)
b.rootKeyID = &id
}
func (o rootKeyIDOption) applyToBiscuit(b *biscuitOptions) error {
id := uint32(o)
b.rootKeyID = &id
return nil
}
// WithRootKeyID specifies the identifier for the root key pair used to sign a biscuit's authority
// block, allowing a consuming party to later select the corresponding public key to validate that
// signature.
func WithRootKeyID(id uint32) compositionOption {
return rootKeyIDOption(id)
}