[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ms-cryptoapi
Subject:    Re: How can I decrypt my message
From:       Martin Bell <Martin.Bell () BTINTERNET ! COM>
Date:       1999-01-21 16:09:36
[Download RAW message or body]


> -----Original Message-----
> From: Microsoft Cryptographic API
> [mailto:CryptoAPI@DISCUSS.MICROSOFT.COM]On Behalf Of Sébastien Fouss
> Sent: 21 January 1999 11:17
> To: CryptoAPI@DISCUSS.MICROSOFT.COM
> Subject: Re: How can I decrypt my message
> 
> 
> Martin,
> 
> this is the missing code for CryptAcquireContext:
> 
> if(!CryptAcquireContext(&hProv, NULL, "Schlumberger 
> Cryptographic Service Provider", PROV_RSA_FULL , 0)) {
>  if(GetLastError()!=NTE_BAD_KEYSET) {
>   return NULL;
>  }
>  if(!CryptAcquireContext(&hProv, "Main Container", 
> "Schlumberger Cryptographic Service Provider", PROV_RSA_FULL, 
> CRYPT_NEWKEYSET)) {
>   return NULL;
>  }
> }
It may be the case that "Main Container" is the default container for this
CSP but it may not be the case. I would specify "Main Container" in the
first CryptAcquireContext as well.

You may want to look at CryptGetProvParam with PP_CONTAINER and PP_VERSION
to add additional checks.

I am slightly surprised that you aren't getting the error NTE_BAD_ALGID with
the AT_SIGNATURE.

If the documentation for the CSP is any good it should have examples of how
to encrypt/decrypt. How is it encrypted in the first place ? Do you have
access to this program ?

Martin


> 
> 
> I'm using JNI. So here is the way I use to calculate the data 
> length. But I'm sure this part of the code is correct.
> 
> Hope you can help.
> Sébastien
> 
> length = (*env)->GetArrayLength(env, _jCipherText);
> encrjbyte = (*env)->GetByteArrayElements (env, _jCipherText, NULL);
> cipherText = (BYTE*)malloc(length);
> if(cipherText == NULL) {
>  MessageBox(NULL, "cryptDecryptPrivateKey Error: cipherText 
> malloc", "NativeCAPI", MB_OK);
>  return NULL;
> }
> dummyByte = cipherText;
> i=0;
> while(i<length) {
>  *dummyByte= (BYTE) *encrjbyte;
>  dummyByte++;
>  encrjbyte++;
>  i++;
> }
> 
> ----------------------------------------------------------------
> Users Guide http://www.microsoft.com/workshop/essentials/mail.asp
> contains important info including how to unsubscribe.  Save 
> time, search
> the archives at http://discuss.microsoft.com/archives/index.html
> 

----------------------------------------------------------------
Users Guide http://www.microsoft.com/workshop/essentials/mail.asp
contains important info including how to unsubscribe.  Save time, search
the archives at http://discuss.microsoft.com/archives/index.html

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic