I have a C++ DLL, foo.dll, that provides API methods that give cleartext answers to encrypted data. I want to come up with a robust solution to only allow friendlies (eg. user.dll) to load this DLL and use its functions.
This is not a problem of DLL spoofing, but rather a question of how to hobble a DLL to only work in certain contexts. I'm in a potentially non-networked context on multiple platforms, so phoning home or relying on a system call is not a likely solution.
Something I've considered is a home brewed initialization step sharing a 'magic key' for initialization. With security, 'roll your own' is often bad.
Any advice of accepted practices for this kind of DLL level security?