99
1010import pytest
1111
12- from cwt import COSE , COSEKey
12+ from cwt import COSE , COSEAlgs , COSEKey , COSEHeaders
1313
1414
1515class TestCOSE_HPKE :
@@ -20,8 +20,8 @@ class TestCOSE_HPKE:
2020 @pytest .mark .parametrize (
2121 "alg" ,
2222 [
23- 35 ,
24- 36 ,
23+ COSEAlgs . HPKE_BASE_P256_SHA256_AES128GCM ,
24+ COSEAlgs . HPKE_BASE_P256_SHA256_CHACHA20POLY1305 ,
2525 ],
2626 )
2727 def test_cose_hpke_kem_0x0010 (self , alg ):
@@ -40,10 +40,10 @@ def test_cose_hpke_kem_0x0010(self, alg):
4040 b"This is the content." ,
4141 rpk ,
4242 protected = {
43- 1 : alg ,
43+ COSEHeaders . ALG : alg ,
4444 },
4545 unprotected = {
46- 4 : b"01" , # kid: "01"
46+ COSEHeaders . KID : b"01" , # kid: "01"
4747 },
4848 )
4949
@@ -64,8 +64,8 @@ def test_cose_hpke_kem_0x0010(self, alg):
6464 @pytest .mark .parametrize (
6565 "alg" ,
6666 [
67- 37 ,
68- 38 ,
67+ COSEAlgs . HPKE_BASE_P384_SHA384_AES256GCM ,
68+ COSEAlgs . HPKE_BASE_P384_SHA384_CHACHA20POLY1305 ,
6969 ],
7070 )
7171 def test_cose_hpke_kem_0x0011 (self , alg ):
@@ -84,10 +84,10 @@ def test_cose_hpke_kem_0x0011(self, alg):
8484 b"This is the content." ,
8585 rpk ,
8686 protected = {
87- 1 : alg ,
87+ COSEHeaders . ALG : alg ,
8888 },
8989 unprotected = {
90- 4 : b"01" , # kid: "01"
90+ COSEHeaders . KID : b"01" , # kid: "01"
9191 },
9292 )
9393
@@ -108,8 +108,8 @@ def test_cose_hpke_kem_0x0011(self, alg):
108108 @pytest .mark .parametrize (
109109 "alg" ,
110110 [
111- 39 ,
112- 40 ,
111+ COSEAlgs . HPKE_BASE_P521_SHA512_AES256GCM ,
112+ COSEAlgs . HPKE_BASE_P521_SHA512_CHACHA20POLY1305 ,
113113 ],
114114 )
115115 def test_cose_hpke_kem_0x0012 (self , alg ):
@@ -128,10 +128,10 @@ def test_cose_hpke_kem_0x0012(self, alg):
128128 b"This is the content." ,
129129 rpk ,
130130 protected = {
131- 1 : alg ,
131+ COSEHeaders . ALG : alg ,
132132 },
133133 unprotected = {
134- 4 : b"01" , # kid: "01"
134+ COSEHeaders . KID : b"01" , # kid: "01"
135135 },
136136 )
137137
@@ -152,8 +152,8 @@ def test_cose_hpke_kem_0x0012(self, alg):
152152 @pytest .mark .parametrize (
153153 "alg" ,
154154 [
155- 41 ,
156- 42 ,
155+ COSEAlgs . HPKE_BASE_X25519_SHA256_AES128GCM ,
156+ COSEAlgs . HPKE_BASE_X25519_SHA256_CHACHA20POLY1305 ,
157157 ],
158158 )
159159 def test_cose_hpke_kem_0x0020 (self , alg ):
@@ -163,7 +163,7 @@ def test_cose_hpke_kem_0x0020(self, alg):
163163 "crv" : "X25519" ,
164164 "kid" : "01" ,
165165 "x" : "y3wJq3uXPHeoCO4FubvTc7VcBuqpvUrSvU6ZMbHDTCI" ,
166- "key_ops" : ["deriveKey" , "deriveBits" ],
166+ "key_ops" : [],
167167 }
168168 )
169169
@@ -172,10 +172,10 @@ def test_cose_hpke_kem_0x0020(self, alg):
172172 b"This is the content." ,
173173 rpk ,
174174 protected = {
175- 1 : alg ,
175+ COSEHeaders . ALG : alg ,
176176 },
177177 unprotected = {
178- 4 : b"01" , # kid: "01"
178+ COSEHeaders . KID : b"01" , # kid: "01"
179179 },
180180 )
181181
@@ -187,7 +187,7 @@ def test_cose_hpke_kem_0x0020(self, alg):
187187 "kid" : "01" ,
188188 "x" : "y3wJq3uXPHeoCO4FubvTc7VcBuqpvUrSvU6ZMbHDTCI" ,
189189 "d" : "vsJ1oX5NNi0IGdwGldiac75r-Utmq3Jq4LGv48Q_Qc4" ,
190- "key_ops" : ["deriveKey" , " deriveBits" ],
190+ "key_ops" : ["deriveBits" ],
191191 }
192192 )
193193 recipient = COSE .new ()
@@ -196,8 +196,8 @@ def test_cose_hpke_kem_0x0020(self, alg):
196196 @pytest .mark .parametrize (
197197 "alg" ,
198198 [
199- 43 ,
200- 44 ,
199+ COSEAlgs . HPKE_BASE_X448_SHA512_AES256GCM ,
200+ COSEAlgs . HPKE_BASE_X448_SHA512_CHACHA20POLY1305 ,
201201 ],
202202 )
203203 def test_cose_hpke_kem_0x0021 (self , alg ):
@@ -207,7 +207,6 @@ def test_cose_hpke_kem_0x0021(self, alg):
207207 "crv" : "X448" ,
208208 "kid" : "01" ,
209209 "x" : "IkLmc0klvEMXYneHMKAB6ePohryAwAPVe2pRSffIDY6NrjeYNWVX5J-fG4NV2OoU77C88A0mvxI" ,
210- "key_ops" : ["deriveKey" ],
211210 }
212211 )
213212
@@ -216,10 +215,10 @@ def test_cose_hpke_kem_0x0021(self, alg):
216215 b"This is the content." ,
217216 rpk ,
218217 protected = {
219- 1 : alg ,
218+ COSEHeaders . ALG : alg ,
220219 },
221220 unprotected = {
222- 4 : b"01" , # kid: "01"
221+ COSEHeaders . KID : b"01" , # kid: "01"
223222 },
224223 )
225224
@@ -231,7 +230,7 @@ def test_cose_hpke_kem_0x0021(self, alg):
231230 "kid" : "01" ,
232231 "x" : "IkLmc0klvEMXYneHMKAB6ePohryAwAPVe2pRSffIDY6NrjeYNWVX5J-fG4NV2OoU77C88A0mvxI" ,
233232 "d" : "rJJRG3nshyCtd9CgXld8aNaB9YXKR0UOi7zj7hApg9YH4XdBO0G8NcAFNz_uPH2GnCZVcSDgV5c" ,
234- "key_ops" : ["deriveKey " ],
233+ "key_ops" : ["deriveBits " ],
235234 }
236235 )
237236 recipient = COSE .new ()
0 commit comments