I looking for a Windows replacement for Unix crypt(3), is there any native windows function equivalent to the Unix crypt function?
You want the Windows Crypto API. There's a pretty straightforward example available. If you're using C#, there are easier to use wrappers in the System.Security.Cryptography namespace.
Related
I'm in a situation that I need to use AES-256, SHA1,2 and RSA, but these functions need to be loaded from an intrinsic windows dll file (something like cryptoAPI in advapi32.dll, which can be found in C:\Windows\system32).
I've found almost everything I need in advapi32.dll except RSA encryption. So,do you know any other crypto libraries from windows (XP2 should be supported)?
In the worst case, any free external crypto library in dll format is appreciated.
RSA encryption/decryption is supported by the CryptoAPI.
From http://en.wikipedia.org/wiki/Microsoft_CryptoAPI:
[...]It is a set of dynamically linked libraries that provides an abstraction layer which isolates programmers from the code used to encrypt the data.
So, advapi32.dll ≠ CryptoAPI. However, since it is an abstraction of the CryptoAPI functions, linking to that dll should expose whichever functionality you need, algorithm-agnostic.
To answer the question strictly, the CSP library file that handles RSA stuff is rsaenh.dll. However, I'm not sure why you should need to know that necessarily; like #SimonMourier (and I) stated, CryptoAPI handles linking to the appropriate CSP. Calling the appropriate functions from advapi32.dll should allow the use of a variety of algorithms, including RSA.
If you're really that averse to using the built-in Windows stuff then there's always Crypto++. It supports being compiled as a DLL afaik. http://www.cryptopp.com/
Without using .Net or a 3rd party component, I've found no reasonable solution for RSA in windows. So, about .Net, please see klugerama's last comment. About 3rd party component, I've found a great library for VB6 user, which will works in Windows XP without the installation of .NetFramework 2.0+. It's called VBCOrLib :
http://www.kellyethridge.com/vbcorlib/
Alternative solution for C++ users was Crypto++ as suggested by RaptorFactor.
Thanks for all your helps !
I am trying to write my own CSP. I am trying to do this by implementing a dll file, but I am not sure if I am on right way.
I found something like this:
Cryptographic Service Provider Developer's Toolkit (CSPDK)
there are samples with CSP API
CPAcquireContext
CPGenKey
... etc.
(it looks for me like an old api or api for winCE)
And here comes my question, which functions should I implement to provide new CSP for windows 7 and XP.
Is my plan good? - should I implement simple DLL and put her reference in register?
Or am i missing something?
You might be missing CNG which is a (long term) replacement for the MS Crypto API. You can create modules for that as well. Unfortunately it is only available since Vista. Windows XP is too old (and you should probably not be producing new applications for XP anyway).
Your HSM vendor will have their CSP written for you. You will get this csp when you install their driver. All you will be required is to access this CSP from your code.
To interface with your HSM vendor's CSP(check what they support), either you should use PKCS#11 or use the cryptoAPI CSP functions.
I'm using Windows.
Is there a Ruby Way to make a dll call? I want to use the GetAsyncKeyState() function.
Haven't been a Windows user in a long time, but there's a Win32API library. Maybe this article helps:
http://www.rubytips.org/2008/05/13/accessing-windows-api-from-ruby-using-win32api-library/
You might want to look at the WIN32OLE library, or the DL library. They are designed for DLL access and Windows programing in Ruby. (NOTE: Although the librarys work, dynamic C access from Ruby does not seem to be an easy task, so use them only for sparse calls to the API. A Win32 program will do better in C, C++, C#, or .NET)
You may want to give FFI a look. It provides a fairly seamless interface to native libraries.
I want to use parallel port (LPT) to receive and send data, i have done that before in various language in different OS, like VB in windows, C in linux.
But now, i want to use a language (and a library for LPT access i guess) which is cross platform. So that i can write code in linux and can compile that on my father's windows without changing the code.
The java comm api would be a great choice but official api doesn't support windows and rxtx is 2 years old.
So which language and library will be easier and efficient, i mean, easy to bundle, easy to install etc... and i need linux and windows compatibly.
Parallel port i/o has no standard portable interface. On MSDOS, Windows, and Linux, significantly different paradigms and APIs are used.
The best you can do is write an application which uses an abstract API and then provide that API on each of the target platforms. There are probably already libraries available which does the lower part, but I don't know of any offhand.
The Windows API function CryptBinaryToString isn't supported on Windows 2000.
Is there and alternative?
The main use that I need, is to encode/decode BASE64
If you want BASE64, you can find some very short implementation like b64.c.
If you need more cryptocipher/certificate related stuff, try get openssl for win32.
You could roll your own from the MSDN description.