@@ -57,8 +57,7 @@ func validGenerateBody() []byte {
5757 KemID : KemAlgorithmDHKEMX25519HKDFSHA256 ,
5858 },
5959 },
60- KeyProtectionMechanism : KeyProtectionMechanismVMEmulated ,
61- Lifespan : ProtoDuration {Seconds : 3600 },
60+ Lifespan : ProtoDuration {Seconds : 3600 },
6261 })
6362 return body
6463}
@@ -150,23 +149,19 @@ func TestHandleGenerateKeyBadRequest(t *testing.T) {
150149 }{
151150 {
152151 name : "unsupported algorithm type" ,
153- body : GenerateKeyRequest {Algorithm : AlgorithmDetails {Type : "mac" , Params : AlgorithmParams {KemID : KemAlgorithmDHKEMX25519HKDFSHA256 }}, KeyProtectionMechanism : KeyProtectionMechanismVMEmulated , Lifespan : ProtoDuration {Seconds : 3600 }},
152+ body : GenerateKeyRequest {Algorithm : AlgorithmDetails {Type : "mac" , Params : AlgorithmParams {KemID : KemAlgorithmDHKEMX25519HKDFSHA256 }}, Lifespan : ProtoDuration {Seconds : 3600 }},
154153 },
155154 {
156155 name : "unsupported algorithm" ,
157- body : GenerateKeyRequest {Algorithm : AlgorithmDetails {Type : "kem" , Params : AlgorithmParams {KemID : KemAlgorithmUnspecified }}, KeyProtectionMechanism : KeyProtectionMechanismVMEmulated , Lifespan : ProtoDuration {Seconds : 3600 }},
158- },
159- {
160- name : "unsupported key protection mechanism" ,
161- body : GenerateKeyRequest {Algorithm : AlgorithmDetails {Type : "kem" , Params : AlgorithmParams {KemID : KemAlgorithmDHKEMX25519HKDFSHA256 }}, KeyProtectionMechanism : KeyProtectionMechanism (99 ), Lifespan : ProtoDuration {Seconds : 3600 }},
156+ body : GenerateKeyRequest {Algorithm : AlgorithmDetails {Type : "kem" , Params : AlgorithmParams {KemID : KemAlgorithmUnspecified }}, Lifespan : ProtoDuration {Seconds : 3600 }},
162157 },
163158 {
164159 name : "zero lifespan" ,
165- body : GenerateKeyRequest {Algorithm : AlgorithmDetails {Type : "kem" , Params : AlgorithmParams {KemID : KemAlgorithmDHKEMX25519HKDFSHA256 }}, KeyProtectionMechanism : KeyProtectionMechanismVMEmulated , Lifespan : ProtoDuration {Seconds : 0 }},
160+ body : GenerateKeyRequest {Algorithm : AlgorithmDetails {Type : "kem" , Params : AlgorithmParams {KemID : KemAlgorithmDHKEMX25519HKDFSHA256 }}, Lifespan : ProtoDuration {Seconds : 0 }},
166161 },
167162 {
168163 name : "missing algorithm (defaults to 0, type empty)" ,
169- body : GenerateKeyRequest {KeyProtectionMechanism : KeyProtectionMechanismVMEmulated , Lifespan : ProtoDuration {Seconds : 3600 }},
164+ body : GenerateKeyRequest {Lifespan : ProtoDuration {Seconds : 3600 }},
170165 },
171166 }
172167
@@ -207,9 +202,9 @@ func TestHandleGenerateKeyBadJSON(t *testing.T) {
207202 body string
208203 }{
209204 {"not json" , "not json" },
210- {"lifespan as string" , `{"algorithm":1,"key_protection_mechanism":2," lifespan":"3600"}` },
211- {"lifespan as string with suffix" , `{"algorithm":1,"key_protection_mechanism":2," lifespan":"3600s"}` },
212- {"lifespan negative" , `{"algorithm":1,"key_protection_mechanism":2," lifespan":-1}` },
205+ {"lifespan as string" , `{"algorithm":1,"lifespan":"3600"}` },
206+ {"lifespan as string with suffix" , `{"algorithm":1,"lifespan":"3600s"}` },
207+ {"lifespan negative" , `{"algorithm":1,"lifespan":-1}` },
213208 }
214209
215210 for _ , tc := range badBodies {
@@ -255,17 +250,17 @@ func TestHandleGenerateKeyFlexibleLifespan(t *testing.T) {
255250 }{
256251 {
257252 name : "integer seconds" ,
258- body : `{"algorithm":{"type":"kem","params":{"kem_id":"DHKEM_X25519_HKDF_SHA256"}},"key_protection_mechanism":"KEY_PROTECTION_VM_EMULATED"," lifespan":3600}` ,
253+ body : `{"algorithm":{"type":"kem","params":{"kem_id":"DHKEM_X25519_HKDF_SHA256"}},"lifespan":3600}` ,
259254 expected : 3600 ,
260255 },
261256 {
262257 name : "float seconds" ,
263- body : `{"algorithm":{"type":"kem","params":{"kem_id":"DHKEM_X25519_HKDF_SHA256"}},"key_protection_mechanism":"KEY_PROTECTION_VM_EMULATED"," lifespan":1.5}` ,
258+ body : `{"algorithm":{"type":"kem","params":{"kem_id":"DHKEM_X25519_HKDF_SHA256"}},"lifespan":1.5}` ,
264259 expected : 1 , // Truncated to 1
265260 },
266261 {
267262 name : "float seconds round down" ,
268- body : `{"algorithm":{"type":"kem","params":{"kem_id":"DHKEM_X25519_HKDF_SHA256"}},"key_protection_mechanism":"KEY_PROTECTION_VM_EMULATED"," lifespan":3600.9}` ,
263+ body : `{"algorithm":{"type":"kem","params":{"kem_id":"DHKEM_X25519_HKDF_SHA256"}},"lifespan":3600.9}` ,
269264 expected : 3600 ,
270265 },
271266 }
0 commit comments