Some checks are pending
Rhai Tests / Run Rhai Tests (push) Waiting to run
- Removed the `herodo` binary from the monorepo. This was done as part of the monorepo conversion process. - Updated the `Cargo.toml` file to reflect the removal of `herodo` and adjust dependencies accordingly. - Updated `src/lib.rs` and `src/rhai/mod.rs` to use the new `sal-vault` crate for vault functionality. This improves the modularity and maintainability of the project.
84 lines
2.2 KiB
Plaintext
84 lines
2.2 KiB
Plaintext
// basic_crypto.rhai
|
|
// Basic cryptographic operations test
|
|
|
|
print("=== Testing Basic Cryptographic Operations ===");
|
|
|
|
// Test symmetric encryption
|
|
print("Testing symmetric encryption...");
|
|
let key = generate_key();
|
|
let message = "Hello, World!";
|
|
|
|
let encrypted = encrypt(key, message);
|
|
let decrypted = decrypt(key, encrypted);
|
|
|
|
if decrypted != message {
|
|
throw "Symmetric encryption/decryption failed";
|
|
}
|
|
print("✓ Symmetric encryption works correctly");
|
|
|
|
// Test keyspace creation
|
|
print("Testing keyspace creation...");
|
|
clear_session();
|
|
|
|
let created = create_key_space("test_space", "secure_password");
|
|
if !created {
|
|
throw "Failed to create keyspace";
|
|
}
|
|
print("✓ Keyspace created successfully");
|
|
|
|
// Test keyspace selection
|
|
print("Testing keyspace selection...");
|
|
let selected = select_keyspace("test_space");
|
|
if !selected {
|
|
throw "Failed to select keyspace";
|
|
}
|
|
print("✓ Keyspace selected successfully");
|
|
|
|
// Test keypair creation
|
|
print("Testing keypair creation...");
|
|
let keypair_created = create_keypair("test_keypair");
|
|
if !keypair_created {
|
|
throw "Failed to create keypair";
|
|
}
|
|
print("✓ Keypair created successfully");
|
|
|
|
// Test keypair selection
|
|
print("Testing keypair selection...");
|
|
let keypair_selected = select_keypair("test_keypair");
|
|
if !keypair_selected {
|
|
throw "Failed to select keypair";
|
|
}
|
|
print("✓ Keypair selected successfully");
|
|
|
|
// Test public key retrieval
|
|
print("Testing public key retrieval...");
|
|
let pub_key = keypair_pub_key();
|
|
if pub_key == "" {
|
|
throw "Failed to get public key";
|
|
}
|
|
print("✓ Public key retrieved: " + pub_key);
|
|
|
|
// Test signing and verification
|
|
print("Testing digital signatures...");
|
|
let test_message = "This is a test message for signing";
|
|
let signature = sign(test_message);
|
|
|
|
if signature == "" {
|
|
throw "Failed to sign message";
|
|
}
|
|
|
|
let is_valid = verify(test_message, signature);
|
|
if !is_valid {
|
|
throw "Signature verification failed";
|
|
}
|
|
print("✓ Digital signature works correctly");
|
|
|
|
// Test with wrong message
|
|
let wrong_valid = verify("Wrong message", signature);
|
|
if wrong_valid {
|
|
throw "Signature should not be valid for wrong message";
|
|
}
|
|
print("✓ Signature correctly rejects wrong message");
|
|
|
|
print("=== All basic crypto tests passed! ===");
|