|
 |
|
|
Hello. First of all congratulations...
I've successfully compiled that sources on linux by making the following changes:
in DrmCrypto.h line 62:
typedef int64_t __int64;
In the DrmCrypto.cpp method __int64 CDrmCrypto::GetRTSC( void ) I've changed to:
__int64 CDrmCrypto::GetRTSC( void ) { #ifdef _WIN32 int tmp1 = 0; int tmp2 = 0; __asm { RDTSC; // Clock cycles since CPU started mov tmp1, eax; mov tmp2, edx; } return ((__int64)tmp1 * (__int64)tmp2); #else __int64 result; asm ("RDTSC" : "=A" (result)); return result; #endif }
That's all...
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
|
Hi Wygno,
Can you elaborate a bit further? What operating system and what compiler are you using? Also what is the full description of the link error/
Thanks.
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
Hi, I'm a beginner and I'm wondering what DRMCrypto class is? Could you be kind enough to provide a bit of explanation? Thanks
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi wygno, the DRMCrypto class is something I wrote to demonstrate the use of the Diffie Hellman Key Exchange protocol. It isn't a Windows API.
Thanks.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hello
My concept on diffie key exchange is not clear. If any one has diffie hellman code. Please send me simple diffie hellman code. I really need it?
Regards Muhammad Naeem
Naeem Qazi
|
| Sign In·View Thread·PermaLink | 2.50/5 (2 votes) |
|
|
|
 |
|
|
this might explain it a bit better (from a post further down the page) http://www.codeproject.com/cpp/DiffieHellmanExample.asp?msg=1769062#xx1769062xx[^]
as for simple ? there's easy to use, there's a good implementation or a bad implementation of an algorithm, but simple ? would you trust a 'simple' encryption algorithm .. I hope not
Modified - you might also want to google for Wei Dai's Crypto++ or CryptLib from Peter Guttman, or LibTomCrypt - all good libraries implementing algorithms in different ways - but simple ?? I think not
'g'
|
| Sign In·View Thread·PermaLink | 3.00/5 (2 votes) |
|
|
|
 |
|
|
Hello
Thank you very much for reply. Actually by simple I mean that I dont need its GUI coding. I need the diffie hellman key exchange coding but without the use of libraries. I m mean to not use the libraries for it.
Regards Muhammad Naeem
Naeem Qazi
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
I know the concept of Diffie Hellman Key Exchange. But i am badly in need of Diffie Hellman key exchange program written in java. If anybody finds it kindly provide me the program as early as possible. Its very urgent. thank you one and all
Gokulakrishnan
|
| Sign In·View Thread·PermaLink | 2.00/5 (2 votes) |
|
|
|
 |
|
|
Hi All,
I have now modified the class so that it does not use the GUID structure or the Windows API (CoCreateGuid). I have requested the download to be updated, but in the meantime if you reply to this message with your email address I can send you the latest version.
Thanks.
Lee
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Please send me the code of Deffie Hellman algorithm to the email address i.e. qaziejaz@hotmail.com, please send me the code as soon as possible, I am doing my research work and in my research I need the said code. thank's Qazi Ejaz
31081979
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I have to implement IPSEC n using omnet with .net to code it.... I find ur example very helpful... It is very easy to understand even for me when i dont know the details of the Diffie Helliman key exchange algorithm......
The compiler for ipv6suitewithinet (based on omnet n vc.net) doesnt support to resolve GUID u use in ur example....... It is giving me the Linking error to the external symbol to the function CoCreate()..... Can u plz help me... if i need to include certain file for it???? or is there any alternative i can use????
thanks a lot in advance...
Regards, Maria
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
|
Hye Lee Your project is very interesting. I have a questions. I wanted to ask you what is/are the limitation in your project. I am waiting for your response,
Thanks
Garima Thakral
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi Garima,
The only limitation to this current project is that the ephemeral and exchange keys are limited to the size of an __int64 (e.g. 64-bit keys).
If you look under the post/reply to this article (below this one) - you should see Runtime Optimization - in my relpy you will see the best way to use Diffie-Hellman key exchange is by using the Microsoft Crypto API functions.
If you do want to use my code instead though, feel free to do so (like I said only limitiation is 64-bit keys)
Best Regards,
Lee Griffiths
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
first of it's a very nice code you got there  I've noticed you have a define for maximum number, so i tried to change it to a larger number and the algorithm became extremely slow, so i haven't been able to get a 64 bit prime number, to be able to use in DES for example.. any suggestions???
H.A.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
First off, the best way to use Diffie Hellman should be to use tried and tested API's [Microsoft Cryptographic Libraries for Diffie-Hellman]
You can use the Microsoft Cryptographic Service Providers to achieve a lot of your cryptography needs. Lookup CryptAcquireContext and go from there - everything from RSA to DES to Diffie-Hellman and so on. I've included an example here of how to generate a prime using the Microsoft CryptoAPI. At first glance the prime doesn't always seem to look prime because it's last byte is an even number. However please note that the BYTE array contains octects!
To use the GeneratePrime function shown below, include and then something like:
BYTE *prime = NULL; DWORD primesize = 0;
GeneratePrime(&prime, &primesize);
Here is the GeneratePrime function (using RSA).
BOOL GeneratePrime(BYTE **prime, DWORD *cbPrime) { HCRYPTPROV hCryptProv = NULL; HCRYPTHASH hHash = NULL; BOOL AcquiredContext = FALSE; BOOL AcquiredPrime = FALSE;
//Attempt to acquire a cryptographic context if(CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, 0)== FALSE) { //No context established for this machine, create new key set if(GetLastError() == NTE_BAD_KEYSET) AcquiredContext = CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET); } else AcquiredContext = TRUE; //Context Acquired lets Generate a key if (AcquiredContext==TRUE) { HCRYPTKEY hEncryptionKey = NULL; //Generate a 512-bit key BOOL bGenEncKey = CryptGenKey(hCryptProv, CALG_RSA_KEYX, (512 << 16) | CRYPT_EXPORTABLE, &hEncryptionKey); if (bGenEncKey) { //Get the size of the key blob DWORD KeyLength = 0; if (CryptExportKey(hEncryptionKey, NULL, PRIVATEKEYBLOB ,0, NULL, &KeyLength)==TRUE) { if (KeyLength>0) { //Allocate a key blob BYTE *PrivateKeyBlob = (BYTE *) malloc((size_t)KeyLength); if (PrivateKeyBlob) { //Export the blob if (CryptExportKey(hEncryptionKey, NULL, PRIVATEKEYBLOB ,0, PrivateKeyBlob, &KeyLength)==TRUE) { PUBLICKEYSTRUC pks = {0}; RSAPUBKEY rsapub = {0};
//Get the Public Key and RSA information memcpy(&pks, PrivateKeyBlob, sizeof(PUBLICKEYSTRUC)); memcpy(&rsapub, PrivateKeyBlob + sizeof(PUBLICKEYSTRUC), sizeof(RSAPUBKEY));
//Calculate the size and offset of the prime numbers DWORD KeySizeBytes = rsapub.bitlen / 16; DWORD ModSizeBytes = rsapub.bitlen / 8; DWORD OffsetPrimeP = sizeof(PUBLICKEYSTRUC) + sizeof(RSAPUBKEY) + ModSizeBytes; DWORD OffsetPrimeQ = sizeof(PUBLICKEYSTRUC) + sizeof(RSAPUBKEY) + ModSizeBytes + KeySizeBytes;
//Allocate sufficient memory to hold the primes *prime = (BYTE *) malloc((size_t) KeySizeBytes); if (*prime) { //Copy the prime from the key blob *cbPrime = KeySizeBytes; memcpy(*prime, PrivateKeyBlob + OffsetPrimeP, KeySizeBytes); AcquiredPrime = TRUE; } } } } }
CryptDestroyKey(hEncryptionKey); }
CryptReleaseContext(hCryptProv, 0); }
return AcquiredPrime; }
Anyway hope this helps. If you look at the CryptoAPI by Microsoft you will see that encrypting with DES is simple! It also supports many other encryption algorithms along with hashing Algorithms, Public-Private Key and Signature algorithms - it's a very powerful library indeed.
If you need any more help, let me know.
Best Regards,
Lee
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I've tested your implementation of GeneratePrime function and I found out that it doesn't generate a 512-bit key, it always returns 256bit key ! KeySizeBytes was always set to 32. If I change the code to: ... //Generate a 512-bit key BOOL bGenEncKey = CryptGenKey(hCryptProv, CALG_RSA_KEYX, (1024 << 16) | CRYPT_EXPORTABLE, &hEncryptionKey); ... it returns a 512bit key. Any idea why?
Thanks
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
I'm not sure I quite understand your question? The whole point of the article was to describe a way to EXCHANGE ENCRYPTION KEYS between two parties.
If you're just looking for encryption/decryption algorithms I'm sure there are plenty here on CodeProject!
All the best!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
The Diffie-Hellman algo implementation was quite useful. I'm doing some study in IKE which uses the Diffie-Hellman algo. I'm looking for a sample implementation of IKE. Any help? or any links?
Thanks
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |