46 lines (36 with data), 967 Bytes
//
// Crypto stuff.
//
// Note - this needs to be in a secure place
// otherwise keys maybe intercepted (by modifying this code!)
//
// Relies on a handshake mechanism to get the key
// to ensure keys are only fetchable from the object doing
// the encrypt/decryption
//
int handle;
reset()
{
int x;
handle = load_shared_object("secure/crypt.so");
}
string crypt(string str, (int|string) salt)
{
return ext_c_call(handle, "lpc_crypt", str, salt);
}
string blowfish_encrypt(string str, int hs)
{
string key = caller()->get_handshake(hs);
if (!stringp(key)) throw("illegal encryption handshake");
return ext_c_call(handle, "lpc_blowfish_encrypt", str, key);
}
string blowfish_decrypt(string str, int hs)
{
string key = caller()->get_handshake(hs);
if (!stringp(key)) throw("illegal decryption handshake");
return ext_c_call(handle, "lpc_blowfish_decrypt", str, key);
}
query_destruct()
{
unload_shared_object(handle);
}