Need the equivalent of CryptGenKey for PUBLIC/PRIVATE pairs

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default Need the equivalent of CryptGenKey for PUBLIC/PRIVATE pairs

    I have found the GenerateKey method for SymmerticAlgorithm based CSP classes, but I can not find any way to create a
    public/private pair for use with AsymmerticAlgorithm classes. In particular I need a key that I can use to sign hashes with.

    Thanks for a pointer to the right item.

    -------------------------------------------
    Roy Chastain
    KMSystems, Inc.
    Roy Chastain Guest

  2. Similar Questions and Discussions

    1. Sharing Constants in Multiple Applications - Public vs.Private
      I use private and public constants throughout my application to store hardcoded WSDL URLs and WebService methods. Many of these are the same in...
    2. #40372 [NEW]: Unlogical behaviour with private/public properties and __get
      From: djungowski at chipxonio dot de Operating system: Ubuntu PHP version: 5.2.0 PHP Bug Type: Class/Object related Bug...
    3. private/public sub?
      I have the following like in an asp.net application in the vb.net codebehind page: Compiler Error Message: BC30390: 'Care.Search.Private Sub...
    4. Question about "Public Sub" vs "Private Sub" vs "Sub"
      In my INCLUDE.INC file I have noticed that I can create subs three ways... Public Sub Test1(x) response.write(x) End Sub Private Sub Test2(x)...
    5. Private Fotopages - private Web Galleries WANTED!
      Hello NG I am still seeking links to private (hobby / non professional/ amateur) fotopages in Australia -or any other Country to be used at...
  3. #2

    Default RE: Need the equivalent of CryptGenKey for PUBLIC/PRIVATE pairs

    Hello Roy,

    A public/private key pair is generated whenever a new instance of an
    asymmetric algorithm class is created. Once a new instance of the class is
    created, the key information can be extracted using one of two methods:

    1. The ToXMLString method, which returns an XML representation of the key
    information.
    2. The ExportParameters method, which returns an RSAParameters enumeration
    to hold the key information.

    For more information on this, you may refer to this article:

    Generating Keys for Encryption and Decryption
    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm[/url]
    l/cpcongeneratingkeysforencryptiondecryption.asp

    Hope this help,

    Luke

    [MSFT] Guest

  4. #3

    Default Re: Need the equivalent of CryptGenKey for PUBLIC/PRIVATE pairs

    Luke,
    Thanks for the pointer to the article. I had not found that one. It has cleared up some issues, but it has left others even more
    confused.

    1) - Am I to understand that EVERY 'new RSACryptoServiceProvider()' call creates a NEW key. Is this true even if a key container
    is specified and there is already a key in it?

    2) - You indicate that ExportParameters actually exports a key along with the parameters used to create the key. Is that really
    true? I don't see any reference to the key in the RSAParameters documentation.

    3) - Speaking of documentation, the CspProviderFlags enum has a UseExistingKey flag that is not even mentioned in the
    documentation. Is it really valid and operational? If so, I would assume that its use would really prevent the creation of a new
    key when new RSACryptoServiceProvider() is called.

    4) - The routines in the article GenKey_SaveInContainer and GetKeyFromContainer are identical with the exception of the text of
    the WriteLine. This would make be believe that a key being generated each time.

    5) - The flag PersistKeyInCsp?
    5a) - Does that really mean "keep the key in the key store (machine or user as specified"?
    5b) - If I create a key (call new RSACryptoServiceProvider()) and set PersistKeyInCsp, is the key stored right then?
    5c) - If I open an existing key (assuming that can be done with UseExistingKey in the CspParameters in the call to new
    RSACryptoServiceProvider(csp_parameters)), and then clear PersistKeyInCsp, is the key removed form the store right then or does it
    get removed when the RSACryptoServiceProvider object is destroyed?

    6) - Exporting a key. What the heck happened to the concept of opaque key blobs. Exporting to XML hardly makes it opaque
    anymore?

    Thanks


    On Thu, 24 Mar 2005 02:27:41 GMT, [email]lukezhan@online.microsoft.com[/email] ([MSFT]) wrote:
    >Hello Roy,
    >
    >A public/private key pair is generated whenever a new instance of an
    >asymmetric algorithm class is created. Once a new instance of the class is
    >created, the key information can be extracted using one of two methods:
    >
    >1. The ToXMLString method, which returns an XML representation of the key
    >information.
    >2. The ExportParameters method, which returns an RSAParameters enumeration
    >to hold the key information.
    >
    >For more information on this, you may refer to this article:
    >
    >Generating Keys for Encryption and Decryption
    >[url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm[/url]
    >l/cpcongeneratingkeysforencryptiondecryption.asp
    >
    >Hope this help,
    >
    >Luke
    -------------------------------------------
    Roy Chastain
    KMSystems, Inc.
    Roy Chastain Guest

  5. #4

    Default Re: Need the equivalent of CryptGenKey for PUBLIC/PRIVATE pairs

    Hello,

    (1) If a key container is specified and there is already a key in it, the
    key will be remained in the container even we new a
    RSACryptoServiceProvider object. this can be confirm with following code:

    CspParameters cp = new CspParameters();
    cp.KeyContainerName = ContainerName;

    RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(cp);
    Console.WriteLine("Key added to container: \n {0}", rsa.ToXmlString(true));

    rsa = new RSACryptoServiceProvider(cp);
    Console.WriteLine("Key added to container: \n {0}", rsa.ToXmlString(true));

    (2) You may refer to this article to see how to use ExportParameters()

    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/[/url]
    frlrfsystemsecuritycryptographyrsacryptoservicepro viderclasssigndatatopic.as
    p

    (3) It is a undocument item and We don't recommend using it yet.

    (5a) It means whether the key should be persisted in the cryptographic
    service provider
    (5b) Yes. ANd its defualt value is true.
    (5c) The key removed form the store right away.

    (4&6) This may deal with the cource code of RSACryptoServiceProvider class,
    I have to say I have no idea yet.

    Hope this help,

    Luke

    [MSFT] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139