@@ -13,6 +13,13 @@ import (
13
13
// https://www.iacr.org/archive/pkc2011/65710074/65710074.pdf that
14
14
// apply the Boneh-Katz transform to Attribute based encryption.
15
15
16
+ // Seed size is chosen based on the proof for BK transform
17
+ // (https://eprint.iacr.org/2004/261.pdf - page 12, theorem 2) to maintain the
18
+ // statistical hiding property. Their input is 448 bits -> 128 bits,
19
+ // whereas we require a seed size of 576 bits to ensure a 2^(-65) statistical difference
20
+ // for our output size of 256 bits.
21
+ const macKeySeedSize = 72
22
+
16
23
func blakeEncrypt (key []byte , msg []byte ) ([]byte , error ) {
17
24
xof , err := blake2b .NewXOF (blake2b .OutputLengthUnknown , key )
18
25
if err != nil {
@@ -70,7 +77,7 @@ func DeriveAttributeKeysCCA(rand io.Reader, sp *SecretParams, attrs *Attributes)
70
77
}
71
78
72
79
func EncryptCCA (rand io.Reader , public * PublicParams , policy * Policy , msg []byte ) ([]byte , error ) {
73
- seed := make ([]byte , 16 )
80
+ seed := make ([]byte , macKeySeedSize )
74
81
_ , err := rand .Read (seed )
75
82
if err != nil {
76
83
return nil , err
@@ -173,12 +180,12 @@ func DecryptCCA(ciphertext []byte, key *AttributesKey) ([]byte, error) {
173
180
if err != nil {
174
181
return nil , err
175
182
}
176
- if len (decEnv ) < 16 {
183
+ if len (decEnv ) < macKeySeedSize {
177
184
return nil , fmt .Errorf ("envelope too short" )
178
185
}
179
186
180
- seed := decEnv [0 :16 ]
181
- ptx := make ([]byte , len (decEnv )- 16 )
187
+ seed := decEnv [0 :macKeySeedSize ]
188
+ ptx := make ([]byte , len (decEnv )- macKeySeedSize )
182
189
compID , macKey , err := expandSeed (seed )
183
190
if err != nil {
184
191
return nil , err
@@ -194,7 +201,7 @@ func DecryptCCA(ciphertext []byte, key *AttributesKey) ([]byte, error) {
194
201
idMatch := subtle .ConstantTimeCompare (compID , id )
195
202
check := tagMatch & idMatch
196
203
if check == 1 {
197
- copy (ptx , decEnv [16 :])
204
+ copy (ptx , decEnv [macKeySeedSize :])
198
205
return ptx , nil
199
206
}
200
207
return nil , fmt .Errorf ("failure of decryption" )
0 commit comments