feat: Update SAL Vault examples and documentation
- Renamed examples directory to `_archive` to reflect legacy status. - Updated README.md to reflect current status of vault module, including migration from Sameh's implementation to Lee's. - Temporarily disabled Rhai scripting integration for the vault. - Added notes regarding current and future development steps.
This commit is contained in:
83
vault/_archive/tests/rhai/basic_crypto.rhai
Normal file
83
vault/_archive/tests/rhai/basic_crypto.rhai
Normal file
@@ -0,0 +1,83 @@
|
||||
// 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! ===");
|
Reference in New Issue
Block a user