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

List:       ms-cryptoapi
Subject:    Re: Encrypting a Symmetric key with Public key
From:       Suhail Ansari <sansari () MEDNA ! COM>
Date:       2000-06-23 15:34:01
[Download RAW message or body]


I guess you are getting this error while encryption, that is calling
CryptEncrypt and this happens when you get a NTE_BAD_LEN error. I havent
used CryptoAPI in VB and thats why am not able to understand your code
fully. I have never been a VB developer so i cant see where you have used
your public key.

Suhail

-----Original Message-----
From: Anand Mohan [mailto:avamohan@HOTMAIL.COM]
Sent: Friday, June 23, 2000 10:21 AM
To: CryptoAPI@DISCUSS.MICROSOFT.COM
Subject: Encrypting a Symmetric key with Public key


Hi All,
Can u please help me to sort this problem.

I am evaluating cryptoobject.I have a strange situation here.I need to
encrypt a 3DES Symmetric Key with a Public Key, and they call the result as
a cipher key.I have these two keys stored in text files as text.

And i am writing the following code in visual basic to perform the task. But
i get an error as 'Bad Length'
Run-time error'-2146893820(80090004)':

Can you please find out the fault in my code and suggest the right thing.
Help is much needed.

Thnx in advance.,


-------------------------------------------------------
Set objCryptoObject = CreateObject("CryptoObject")
Set objCryptoProvider = objCryptoObject.CryptAcquireContext(, ,
PROV_RSA_FULL)

Open "D:\Security\Last\3DESkey.txt" For Input As #123
Line Input #123, strline
Close #123

Open "D:\Security\Last\Public.txt" For Input As #123
Line Input #123, sstr1
Close #123

strSessionExchangeKey = sstr1

binkeyblob = objCryptoObject.CryptDecode(strSessionExchangeKey,
CRYPT_BASE64_ENCODING)
Set objSessionKey = objCryptoProvider.CryptImportKey(binkeyblob)

binEncryptedLine = objSessionKey.CryptEncrypt(0, True, 0, strline)
strEncryptedLine = objCryptoObject.CryptEncode(binEncryptedLine,
CRYPT_BASE64_ENCODING)

Open "D:\Security\Last\cipherkey.txt" For Output As #123
Print #123, strEncryptedLine
Close #123


>From: miro masnoglav <miro.masnoglav@ADACTA.SI>
>Reply-To: Microsoft Cryptographic API <CryptoAPI@DISCUSS.MICROSOFT.COM>
>To: CryptoAPI@DISCUSS.MICROSOFT.COM
>Subject: Re: CryptDuplicateHash using nt4 ...
>Date: Fri, 23 Jun 2000 15:42:45 +0200
>
>I guess you can use CryptGetHashParam and CryptSetHashParam with
>dwParam=HP_HASHSIZE first and than witn dwParam=HP_HASHVAL.
>
>Regards Miro
>
>----- Original Message -----
>From: Petrona Salvatore <Salvatore.Petrona@SNI.IT>
>To: <CryptoAPI@DISCUSS.MICROSOFT.COM>
>Sent: Thursday, June 22, 2000 12:53 PM
>Subject: CryptDuplicateHash using nt4 ...
>
>
> > I'm writing an application using hashing, and i wish to use
> > CryptDuplicateHash with nt4,
> > but it works only with win2k.
> > There's another way to save the hash internal state?
> >
> >
> > Salvatore Petrona
> > Siemens Informatica S.p.A.
> > Via del Maggiolino, 151-163
> > 00155 Roma (ITALY)
> >
> > Tel.: +39 06 22133876
> > email: salvatore.petrona@sni.it
> >
> > ----------------------------------------------------------------
> > Users Guide http://msdn.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://msdn.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

________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

----------------------------------------------------------------
Users Guide http://msdn.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://msdn.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