cryptoapi

I'm using Wincrypt for Diffie-Hellman— can I export the shared secret in plain text?

偶尔善良 提交于 2019-12-03 16:59:07
OK-- thanks to Mike , I was able to get Wincrypt to generate a Diffie-Hellman keypair. I figured out out to export the public key, and how to import the other party's public key. According to the docs, upon import of the other party's public key, the shared secret has been computed. Great. I now need to get ahold of that shared secret, but I don't think its possible. Simply calling CryptExportKey with a type of PLAINTEXTKEYBLOB fails unless I call CryptSetKeyParam to change the algorithm id from CALG_AGREEDKEY_ANY to something... else. But I don't want something else, I want the shared secret.

Random numbers for Windows Phone 8 and Windows Store 8?

南笙酒味 提交于 2019-12-02 13:00:01
I'm struggling with a port of a couple of security libraries to the Windows Phone 8 and Windows Store 8 platform. I need a function which provides random numbers. Win32 has CryptGenRandom and even RtlGenRandom . Windows Store 10 and Universal Windows has BCryptGenRandom . However, there's a hole for Windows Phone 8 and Windows Store 8 because CryptoAPI is not available, and CNG is only available on Windows 10 and Universal Windows. The MSDN docs say BCryptGenRandom is available for "Windows Store", but they don't say its Windows Store 10 and UWP ( thanks CW ). The libraries are unmanaged C/C++

Microsoft CryptoAPI: how to convert PUBLICKEYBLOB to DER/PEM?

痴心易碎 提交于 2019-12-02 12:59:46
I have a generated RSA key pair stored as PRIVATEKEYBLOB and PUBLICKEYBLOB, and I need to be able to convert these keys to DER or PEM formats so I could use it in PHP or Python. I figured out that I could use CryptEncodeObject function to convert my PRIVATEKEYBLOB to DER. In order to do that I need to use PKCS_RSA_PRIVATE_KEY encoding flag. But I couldn't find any clue on how to convert PUBLICKEYBLOB to DER. Here is my code for PRIVATEKEYBLOB convertion: LPCSTR type = PKCS_RSA_PRIVATE_KEY; DWORD encd = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING; DWORD dlen = 0; if(!CryptEncodeObject(encd, type,

Wrong result for base64 string of HMAC_SHA1 using Crypto*** API

拟墨画扇 提交于 2019-12-02 11:30:45
问题 I'm trying to use the winapi crypto api to get a base64 encoded hash. I copied and modified to get the function below. I got it from here mostly - https://msdn.microsoft.com/en-us/library/windows/desktop/aa382379(v=vs.85).aspx Running it with calcHmacSha1("message", "key") should give IIjfdNXyFGtIFGyvSWU3fp0L46Q= . However it gives me SlLDwKvAoGBJ0atki7QFfj/181k= , the non base64 version it gives is 4a 52 c3 c0 ab c0 a0 60 49 d1 ab 64 8b b4 05 7e 3f f5 f3 59 . This is a same situation

What's the difference between templated mode object and external cipher object?

☆樱花仙子☆ 提交于 2019-12-02 01:15:29
As in the title, I am looking for the difference in the cryptopp library between this declaration: CBC_Mode<AES>::Decryption cbcDecryption.SetKeyWithIV(key, AES::DEFAULT_KEYLENGTH, iv); and this one: AES::Decryption aesDecryption(key, AES::DEFAULT_KEYLENGTH); CBC_Mode_ExternalCipher::Decryption cbcDecryption( aesDecryption, iv ); Moreover, I can't understand why with this: AES::Decryption aesDecryption(key, AES::DEFAULT_KEYLENGTH); CBC_Mode_ExternalCipher::Decryption cbcDecryption( aesDecryption, iv ); StreamTransformationFilter stfDecryptor( cbcDecryption, new StringSink( recoveredtext ) );

SSL Connection, Windows Certificate Store and CAPI engine

血红的双手。 提交于 2019-12-01 08:57:28
I am creating an SSL connection using OpenSSL API. As we know in a SSL handshake, series of Certificate Authentication occurs for Server or Client. Now for client certificate authentication, the client's certificate and associated private key are stored in Windows Certificate Store . This certificate with private key is imported into the store after combining them into a pfx format and then that pfx file is imported to the windows Cert store. Now while importing this pfx file using mmc snap-in it asks whether we want to make the private key exportable or not. Now OpenSSL comes into picture for

What's the difference between templated mode object and external cipher object?

别说谁变了你拦得住时间么 提交于 2019-12-01 08:40:13
问题 As in the title, I am looking for the difference in the cryptopp library between this declaration: CBC_Mode<AES>::Decryption cbcDecryption.SetKeyWithIV(key, AES::DEFAULT_KEYLENGTH, iv); and this one: AES::Decryption aesDecryption(key, AES::DEFAULT_KEYLENGTH); CBC_Mode_ExternalCipher::Decryption cbcDecryption( aesDecryption, iv ); Moreover, I can't understand why with this: AES::Decryption aesDecryption(key, AES::DEFAULT_KEYLENGTH); CBC_Mode_ExternalCipher::Decryption cbcDecryption(

OpenSSL and MS CryptoAPI: different digital signatures

故事扮演 提交于 2019-12-01 05:54:41
I generated X509 certificate with private key using makecert utility makecert -n "CN=RootCATest" -r -sv RootCATest.pvk RootCATest.cer makecert -sk MyKeyName -iv RootCATest.pvk -n "CN=tempCert" -ic RootCATest.cer -sr currentuser -ss my -sky signature —pe Then I converted RootCATest.pvk to RootCATest.pem with OpenSSL. And I extracted public key: pubRootCATest.pem I have small file called 'msg'. And I sign this file using SHA1. openssl dgst -sha1 -sign c:\RootCATest.pem -out c:\openssl c:\msg Then I want to obtain the same digital signature using MS CryptoAPI. Here is my code (Note: this is the

OpenSSL and MS CryptoAPI: different digital signatures

你。 提交于 2019-12-01 04:08:20
问题 I generated X509 certificate with private key using makecert utility makecert -n "CN=RootCATest" -r -sv RootCATest.pvk RootCATest.cer makecert -sk MyKeyName -iv RootCATest.pvk -n "CN=tempCert" -ic RootCATest.cer -sr currentuser -ss my -sky signature —pe Then I converted RootCATest.pvk to RootCATest.pem with OpenSSL. And I extracted public key: pubRootCATest.pem I have small file called 'msg'. And I sign this file using SHA1. openssl dgst -sha1 -sign c:\RootCATest.pem -out c:\openssl c:\msg

Restore RSA private key by modulus, public and private exponents using Java Security

落爺英雄遲暮 提交于 2019-12-01 00:20:33
I'm trying to find Java (native or BouncyCastle provider) implementation for generating a RSA private key in PKCS#1 using given params {e,n,d}. There is paper by Dan Boneh that describes an algorithm for doing so. The solution is available in PyCrypto (Python), as well as there is a standalone utility posted by Mounir IDRASSI that converts RSA keys between the SFM format (n,e,d) and CRT format (p,q,dp,dq,u), and the other way around. However I was not able to find anything ready to use for Java. Update: I found such implementation at https://github.com/martinpaljak/RSAKeyConverter/blob/master