...
1 package jwe
2
3 import (
4 "github.com/lestrrat-go/iter/mapiter"
5 "github.com/lestrrat-go/jwx/internal/iter"
6 "github.com/lestrrat-go/jwx/jwa"
7 "github.com/lestrrat-go/jwx/jwe/internal/keyenc"
8 "github.com/lestrrat-go/jwx/jwe/internal/keygen"
9 )
10
11
12 type Recipient interface {
13 Headers() Headers
14 EncryptedKey() []byte
15 SetHeaders(Headers) error
16 SetEncryptedKey([]byte) error
17 }
18
19 type stdRecipient struct {
20 headers Headers
21 encryptedKey []byte
22 }
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 type Message struct {
45 authenticatedData []byte
46 cipherText []byte
47 initializationVector []byte
48 tag []byte
49 recipients []Recipient
50 protectedHeaders Headers
51 unprotectedHeaders Headers
52
53
54
55 rawProtectedHeaders []byte
56
57
58
59 storeProtectedHeaders bool
60 }
61
62
63
64 type contentEncrypter interface {
65 Algorithm() jwa.ContentEncryptionAlgorithm
66 Encrypt([]byte, []byte, []byte) ([]byte, []byte, []byte, error)
67 }
68
69
70 type encryptCtx struct {
71 keyEncrypters []keyenc.Encrypter
72 protected Headers
73 contentEncrypter contentEncrypter
74 generator keygen.Generator
75 compress jwa.CompressionAlgorithm
76 }
77
78
79
80 type populater interface {
81 Populate(keygen.Setter) error
82 }
83
84 type Visitor = iter.MapVisitor
85 type VisitorFunc = iter.MapVisitorFunc
86 type HeaderPair = mapiter.Pair
87 type Iterator = mapiter.Iterator
88
89
90
91
92 type PostParser interface {
93 PostParse(DecryptCtx) error
94 }
95
96
97 type PostParseFunc func(DecryptCtx) error
98
99 func (fn PostParseFunc) PostParse(ctx DecryptCtx) error {
100 return fn(ctx)
101 }
102
View as plain text