MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / test_open_sealed_box_with_wrong_key

Function test_open_sealed_box_with_wrong_key

sodiumbox/src/lib.rs:271–284  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

269
270 #[test]
271 fn test_open_sealed_box_with_wrong_key() {
272 // Use the first test vector
273 let vector = &TEST_VECTORS[0];
274
275 // Use the correct public key but wrong secret key (from vector 1)
276 let public_key = public_key_from_bytes(&vector.public_key);
277 let wrong_secret_key = secret_key_from_bytes(&TEST_VECTORS[1].secret_key);
278
279 // Try to open the sealed box with wrong key
280 let result = open_sealed_box(vector.sealed_box, &public_key, &wrong_secret_key);
281
282 // Verify the result is an error
283 assert!(result.is_err(), "Should fail with wrong key");
284 }
285
286 #[test]
287 fn test_open_sealed_box_with_corrupted_data() {

Callers

nothing calls this directly

Calls 3

public_key_from_bytesFunction · 0.85
secret_key_from_bytesFunction · 0.85
open_sealed_boxFunction · 0.85

Tested by

no test coverage detected