()
| 470 | |
| 471 | #[test] |
| 472 | fn encrypt_decrypt_roundtrip() { |
| 473 | let key = test_key(); |
| 474 | let epoch = *key.epoch(); |
| 475 | let header = test_header(1); |
| 476 | let plaintext = b"hello nodedb encryption"; |
| 477 | |
| 478 | let ciphertext = key.encrypt(1, &header, plaintext).unwrap(); |
| 479 | assert_ne!(&ciphertext[..plaintext.len()], plaintext); |
| 480 | assert_eq!(ciphertext.len(), plaintext.len() + AUTH_TAG_SIZE); |
| 481 | |
| 482 | let decrypted = key.decrypt(&epoch, 1, &header, &ciphertext).unwrap(); |
| 483 | assert_eq!(decrypted, plaintext); |
| 484 | } |
| 485 | |
| 486 | #[test] |
| 487 | fn wrong_key_fails() { |
nothing calls this directly
no test coverage detected