cryptoapi

Saving/Restoring certs with MS CryptoAPI invalidates attached private key

ε祈祈猫儿з 提交于 2019-12-18 18:29:46
问题 I've written a program which is supposed to save and restore a users certificates using the windows Crypto API. I was under the impression that it was working fine but now a user has complained that the private key that was attached to the certificate is invalid after the cert has been restored. I was saving the certificates using: HCERTSTORE hCertStore = CertOpenStore(CERT_STORE_PROV_PHYSICAL_W, 0, NULL, CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG | CERT_STORE_READONLY

Import CSP blob exported from .NET into python pyCrypto

末鹿安然 提交于 2019-12-13 16:45:00
问题 I have a CPS Blob exported from certificate using RSACryptoServiceProvider.ExportCspBlob in my .NET application. return Convert.ToBase64String(rsaAlg.ExportCspBlob(false /*includePrivateParameters*/)); Now, I need to import that blob in python application. I tried using pyCrypto, but with no luck. # that's the value I'm getting from .NET code above key = 'BgIAAAAkAABSU0ExAAgAAAEAAQARMnLlzOgHkmHssf6ZSFJn8TlTiOBSoRSEnkI4U0UI6n1jFY2bTWS9O5uApMNXz1vr5OyxoXsNVF2XrNM4DOC+lRn3R/H

CryptAcquireContextA fails in C++ CLR for “Aloaha Cryptographic Provider”

喜欢而已 提交于 2019-12-13 05:18:26
问题 I have C++ CLR project with both managed and unmanaged code. In this project I loop through list of cryptoproviders and search for suitable. So I use functions CryptEnumProvidersA CryptAcquireContextA I have C# project which uses C++ project. When I call the method to loop through list of cryptoproviders twice, my application crashes. And it crashes on CryptAcquireContextA. And only on "Aloaha Cryptographic Provider". When i use debug mode, it also crashes. But when i use debug mode, set

How to generate and use public key cryptography in WinCrypt

拥有回忆 提交于 2019-12-12 16:14:15
问题 I'm currently experimenting with the Windows Cryptography API and running into some problems with Public-Key-Cryptography. I can find lots of examples of how to encrypt items, but nothing directly addressing a start-to-finish public key model. Here's a rough outline of how my current code looks to generate an encryption key pair, I've removed the error checking code for readability // MAKE AN RSA PUBLIC/PRIVATE KEY: CryptGenKey(hProv, CALG_RSA_KEYX, CRYPT_EXPORTABLE, &hKey); // NOW LET'S

MS CryptoAPI doesn't work on Windows XP with CryptAcquireContext()

泄露秘密 提交于 2019-12-12 09:52:00
问题 I wrote some code using the Microsoft CryptoAPI to calculate a SHA-1 and got the compiled exe working on Windows 7, Win Server 2008, Win Server 2003. However, when I run it under Windows XP SP3, it does not work. I narrowed down the failure to the CryptAcquireContext() call. I did notice that a previous post talked about the XP faulty naming of " … (Prototype) " and it must be accounted for by using a WinXP specific macro MS_ENH_RSA_AES_PROV_XP. I did the XP specific code modifications and it

How to query the root certificate?

懵懂的女人 提交于 2019-12-12 03:17:00
问题 I have a file. This file is digitally signed with our companys certificate. This certificate, has a countersignature (for example by Microsoft ). However this certificate also has a Certification Path, where on the top there is a root certificate ( like Symantec ), under that is another certificate ( like Symantec code signing ), and under that is our companys certificate. I found This link, and rewrote it, so i can query everything i need. Well almost everything. I couldn't figure out, how

Error with CryptDecrypt winapi function?

故事扮演 提交于 2019-12-12 02:53:33
问题 i have write simple program to load a public key generated by openssl to decrypt a string encrypted by private key of the public key. But I don't know why I fail at b = CryptDecrypt(hKey,NULL,FALSE,0,pbEncrypt,&cbEncrypt); And i get error "8009000D NTE_NO_KEY Key does not exist.". Can someone explain this to me ? void DecodeString() { CHAR* publicKey = "-----BEGIN PUBLIC KEY-----" "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv+yyzdZaqcE7qOOZ8pyN" "o1n3PS2U/ewT2gGSQeixP+VixQGrxnssT3zlbeUND8CVX

I have P & G— how do I use the Wincrypt API to generate a Diffie-Hellman keypair?

天涯浪子 提交于 2019-12-11 15:09:49
问题 There's an MSDN article here, but I'm not getting very far: p = 139; g = 5; CRYPT_DATA_BLOB pblob; pblob.cbData = sizeof( ULONG ); pblob.pbData = ( LPBYTE ) &p; CRYPT_DATA_BLOB gblob; gblob.cbData = sizeof( ULONG ); gblob.pbData = ( LPBYTE ) &g; HCRYPTKEY hKey; if ( ::CryptGenKey( m_hCryptoProvider, CALG_DH_SF, CRYPT_PREGEN, &hKey ) ) { ::CryptSetKeyParam( hKey, KP_P, ( LPBYTE ) &pblob, 0 ); Fails here with NTE_BAD_DATA . I'm using MS_DEF_DSS_DH_PROV . What gives? 回答1: It may be that it just

Understanding BCryptSignHash output signature

五迷三道 提交于 2019-12-11 13:46:24
问题 I have signed a hash value in windows using BCryptSignHash with ECDSA algorithm. The output signature buffer is of length 64 bytes. I also generated the public and private key blobs using BCryptGenerateKeyPair function (BCRYPT_ECDSA_P256_ALGORITHM algorithm) with which i signed the hash. I have to verify this signature with this key pair in linux. I am able to decipher the public-private key pair that got generated, using the link "http://msdn.microsoft.com/en-us/library/windows/desktop

CryptEncrypt() API

坚强是说给别人听的谎言 提交于 2019-12-11 06:13:25
问题 is it normal to get the junk bytes at end of buffer when this function returns? 回答1: If you're using a block cipher, it's normal for the output to be padded to a multiple of the block size. With a stream cipher, the result will normally be exactly the same length as the input. 来源: https://stackoverflow.com/questions/1591070/cryptencrypt-api