Re: CryptoAPI and private key /not public/ encryption with CryptEncrypt - can not use CryptHash* functions

From: Valery Pryamikov (Valery_at_nospam.harper.no)
Date: 12/26/04


Date: Sun, 26 Dec 2004 20:10:56 +0100

Hi,
if you have hash value that fits some standard hash (ex. use MD5 if it is
128 bits or SHA1 if hash is 160 bits or CALG_SSL3_SHAMD5 if it is 288 bits)
then you can use CryptSetHashParam with HP_HASHVAL, and use CryptSignHash to
sign it.
Since cryptographic hash value is essentially a random number - no
restrictions could be added to CryptSetHashParam with HP_HASHVAL except for
bitlength. So, if you have value of RIPEMD-160 or HAVAL you can just stick
it's value into SHA1/MD5 hash and sign it.

-Valery.
http://www.harper.no/valery

"Przemek Wasylko" <wasylek@remove-me.megapolis.pl> wrote in message
news:%230pEWR16EHA.2488@TK2MSFTNGP14.phx.gbl...
> Hello All :)
>
> I have 3rd party library that supplies me with calculated by itself hash
> of some data (so I can not use CryptHashData, etc). I don't know hash
> method, I'm only supposed to encrypt that hash using private key in order
> to create digital signature. I have SmartCard CSP with public/private
> keypair stored on it. I would like to encrypt that SHA1 hash, but using
> private key not the public one (in order to have another party validate
> signature by using public key provided by me - i can extract public key
> from smartcard ). But unfortunatelly I have found no obvious way to do
> that by using CryptoAPI, maybe I am missing something. MSDN and other
> sources force me to use CryptCreateHash/CryptHashData/CryptSignHash, but,
> as I mentioned before, I can't do that (my code does not calculate hash).
> I would like to use CryptEncrypt with private key and CryptDecrypt with
> public key. Is there solution to my problem ?
>
> Best regards
> Przemek Wasylko



Relevant Pages

  • Re: Reverse usage of public/private RSA encryption keys for licensing?
    ... It works both ways otherwise you would not be able to decrypt the signature ... to get the clear hash to validate the new calculated hash against. ... Keeping your private key private is the major idea. ... the client's public key still ...
    (microsoft.public.dotnet.framework)
  • Re: Reverse usage of public/private RSA encryption keys for licensing?
    ... It works both ways otherwise you would not be able to decrypt the signature ... to get the clear hash to validate the new calculated hash against. ... Keeping your private key private is the major idea. ... the client's public key still ...
    (microsoft.public.dotnet.security)
  • RE: integrity and mail encryption
    ... I gave my private key to somebody else. ... > so a public key infra-structure by itself does not provide ... > the corresponding private key can make a digital signature. ... you encrypt this hash with your private key. ...
    (Security-Basics)
  • CryptoAPI and private key /not public/ encryption with CryptEncrypt - can not use CryptHash* functio
    ... I don't know hash method, ... I'm only supposed to encrypt that hash using private key in order to create ... I have SmartCard CSP with public/private keypair stored ... public key provided by me - i can extract public key from smartcard). ...
    (microsoft.public.platformsdk.security)
  • Re: private key encryption - doubts
    ... > Alice creates a one-way hash and encrypt it with her private key ... So Bob now knows the private key of Alice. ... > I need to know what exactly is a digital signature. ... same symmetric key for both encryption and decryption). ...
    (comp.security.ssh)