May 9th, 2005, 10:50 AM
Statically link to C from .NET?
I have a some C code which does some security checks. From a C# .NET application I can access this through a DLL by using a DLLimport. However this is insecure because anyone could replace the DLL with one which always returns true to all my security checks.
Is there anyway I could statically link to the C library form .NET.
Or is there a good way to ensure the C DLL (not a .NET assembly) has not been tampered with?
May 9th, 2005, 05:34 PM
My recommnedation, get a simple commandline MD5 utility and call it from your C# program to verify the MD5 hash of your DLL before you load it. I believe md5checksum is a command line app, but not positive.
Intelligent people talk about ideas.
Average people talk about things.
Small people talk about other people.
May 10th, 2005, 12:54 AM
.net has built in crypto libraries for doing an assortment of things including hashing and public key crypto. There are some good books out there on it such as - http://www.amazon.com/exec/obidos/tg...books&n=507846
as far as linking C libraries into the c# code you need to look into .net interop services and pinvoke. You'd probably need to write your own verification methods for what you want....
If it was me I'd probably re-write the .dll using C#.
"When I get a little money I buy books; and if any is left I buy food and clothes." - Erasmus
"There is no programming language, no matter how structured, that will prevent programmers from writing bad programs." - L. Flon
"Mischief my ass, you are an unethical moron." - chsh
Blog of X