microsoft.web.services2.dll Key error when decrypting with Private key from local store
From: Rich Schaefer (SomeOne_at_SomeWhere.com)
Date: 07/21/05
- Previous message: Paul Carter: "Re: Access denied for OpenProcess(PROCESS_DUP_HANDLE) in service"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Thu, 21 Jul 2005 01:02:23 GMT
I am using microsoft.web.services2.dll so that I can access the Certificate stores.
When I try to Decrypy a buffer using the RSACryptoServiceProvider.Decrypy method
I get a bad key error. The Certificate is self signed (made with makecert.exe). Looks OK
when I look at it in Explore.exe The following is my guts of my code:
A little description: A Collection of encrypted files. The RSA encrypted AES keys
for the encrypted files are in the Collection with names equal to the Certificate hash
used to encrpt (Of course using the Cert Public key) the AES keys.
byte[] EncodedBuffer = null;
X509Certificate Cert;
X509CertificateStore store;
store = X509CertificateStore.CurrentUserStore(X509CertificateStore.MyStore);
bool open = store.OpenRead();
// The following is to find the Certificate and Data to Decrypt
// From my many Personal Certificats
X509CertificateCollection Certs = store.Certificates;
for (int i = 0; i < Certs.Count; i++) {
Cert = Certs[i];
HashCode = Cert.GetCertHashString();
if (m_ZipFile.Lookup(HashCode) != null) {
EncodedBuffer = m_ZipFile.GetData(HashCode);
s_DecryptCertificate = Cert;
break;
}
}
store.Close();
if (EncodedBuffer != null) {
Microsoft.Web.Services2.Security.Cryptography.RSACryptoServiceProvider sp =
(Microsoft.Web.Services2.Security.Cryptography.RSACryptoServiceProvider)
Cert.Key;
RSACryptoServic sp = (RSACryptoServiceProvider) Cert.Key;
byte[] DecodedBuffer = sp.Decrypt(EncodedBuffer, false);
...
- Previous message: Paul Carter: "Re: Access denied for OpenProcess(PROCESS_DUP_HANDLE) in service"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|