Re: Add Private Keys in System Store MY

From: Michel Gallant (neutron_at_istar.ca)
Date: 10/15/05


Date: Sat, 15 Oct 2005 11:11:42 -0400

The --- BEGIN RSA PRIVATE KEY ---- delimited blob (in b64 form) is just a standard
PKCS#8 unencrypted private key format.
Here's a cheat-cheat for openssl/PEM for windows users:
  http://www.jensign.com/JavaScience/PEM/pemformats.txt

You can convert that pkcs#8 private key blob into a CryptoAPI PRIVATEKEYBLOB
using one of these converters I wrote:
   http://www.jensign.com/JavaScience/PvkConvert
If you don't like Java ;-) you can just read the Java source code and see how the
conversion works.

Cheers,
 - Mitch Gallant
   MVP Security

  "sunit" <sunit@newsgroup.nospam> wrote in message news:uGDnBaY0FHA.2076@TK2MSFTNGP14.phx.gbl...

  [lelteto wrote]
> Next you would need to import the key blob (assuming it is in the proper
> PRIVATEKEYBLOB format - if not, you would need to put it into this format;
> note that you may need to change the endianness: CAPI require the key values
> in little endian order; usually other formats store the key values in big
> endian order). Use CryptImportKey.

  I got my certificate and private keys using openssl.I installed the openssl and used a command on the command prompt to generate
certificate request and private keys

   openssl.exe req -newkey rsa:1024 -keyout server.key -nodes -days 365 -out server.crt
  server.key :RSA private keys
  server.crt:certificate Request

  I dont know whether it is my private keys r in correct format.My server.key(private keys) contents look like

  -----BEGIN RSA PRIVATE KEY-----
  MIICXAIBAAKBgQDUjf19133k8AcYmu9V54eQUKDTRKBUexhJ7ncRDB+l2eh73mu4
  Z5Dj1k1U+Cjj2rubg4zY3fO6hnYC269hbyG8XIu41cyW6YL8ytetA+Zl+xRkX2WC
  YmqUnWTQ9rz2CeDQRWed+ekFsnVgH2J57ww5zkVFzCpjFihl/d1m3ZovlwIDAQAB
  AoGAMTanCKoKRiWlHvdQju1KoAlrEz+Cd80AdK2398R812O6xmNbQZkJHReTVCcZ
  IJiWc41j4RqSwg8757GBy+d1QcGOfPjtewhPoT4lVocEbRRkGBHX0jruKBkZpfgp
  az6MO+4at4YAy8/H/DZVTThtxmN/9x+WlaxYwf8dIRvMjpECQQDpw9yaH0AmDMdE
  fnTvIGXyXOBfzJLTNCOi3YH4bNX5ZAWDqYSXkKeJNnzMEkzLVM9t1VLlHP6izYkN
  r9tyJzUtAkEA6MWoe5xEJDjw9wlodgkLMFgEqE8SzptygnH/1oqkzkLIFeJPfnsG
  HmJZ0lwYQf/7CmOwpBRbDfymWI5ymo76UwJAJ7e2gJ00qgJbzQBrX8GycJZlLQG2
  JJpkP6TBE3Nye5gJ88/WjmXugTq3w3iMgbOcNr4bAoCFpyWi1qd9cozE1QJBAJBi
  AlbiIBZDx5vEFyqYA3uyLPllSuoi281z/thJ2V4jaE7CuMJgdvQj10k3XMibilDw
  cyHjinNLkrb9bLLYGwcCQHzzCW2obyRQEIXHo8HLnpeZvNnH+9eKtks0Z1uRfd4m
  ECeTLHBzr67MY8s4W2rcINQlLbp4s9FOcaDAFWDBeoY=
  -----END RSA PRIVATE KEY-----

  Also in CryptImportKey , PRIVATEKEYBLOB, it wants the handle of the session keys which encryted the private key.I m not
understanding how to get this handle.

  Pls Help me .Thanx in advance