Reverse Encryption in .NET

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

  1. #1

    Default Reverse Encryption in .NET

    Hi,

    I saw several posts asking for reverse encryption (encrypt with
    private key instead of public key) in .NET. I am having the same
    question and wonder anybody has a good solution to it.

    Basically, my client application generates a key pair and exports the
    public key to server. The client application needs to encrypt a string
    with the private key and send it to server. Server authenticates the
    client after decrypts the stirng with the public key. It looks like a
    very simple procedure but it seems impossible with the RSA encryption
    provided by .NET. The Encrypt() method of RSACryptoServiceProvider
    seems to do encryption with public key ONLY. It does use private key
    to encrypt content when generating a signature though.

    Does anybody have a solution to it? If .NET doesn't support it, is
    there any way I can do it through Win32 CryptoAPI?


    Thanks

    James
    James Chou Guest

  2. Similar Questions and Discussions

    1. Reverse Printing
      Just thought I'd save this into Google : and I'm pleased it works so well. Sometimes I just love Linux. Wanted to reverse print the pages so I...
    2. Ldap AD with reverse encryption
      We have been using cfldap to authtenticate users against our Windows 2000 domain. We recently had to start storing our Active Directory password...
    3. A reverse Modelunderloc?
      Is there a way of returning a 2D reference (ie on the 3d sprite) from a model in a 3d environment? Basically I want to create an 2D overlay on the...
    4. Control IDs reverse?
      I have a WebControl, lets call it WebC. WebC has a Label control, with an ID of TheLabel. I have a UserControl, lets call it UserC. I drop WebC...
    5. Playing in reverse
      Im trying to build a solution that scrolls 3 sprites down, and then i need to find a way to check if its already been pressed, and have them scroll...
  3. #2

    Default Re: Reverse Encryption in .NET

    I don't know the value of this method for your business but certainly, from
    a security perspective, it's value is null. Worst yet, its highly
    "insecure". I wonder why you
    don't create the key pair on the server side and send the public key to the
    client, so he can use this key to encrypt the message (as normal practice)
    and decrypt it on the server with it's private key. In the signature
    scenario, the point is different because of the signature procedure nature
    (see specs), this procedure DO need to be done by encrypting the hash with
    the private key in order for the receiver to decrypt it with it's public
    key, therefore achieving the "non-repudiation" key goal of the digital
    signatures. The scenario you are describing applies to the signature case.


    "James Chou" <jameschou2000@yahoo.com> wrote in message
    news:73eb0fe0.0402251624.5d99aed4@posting.google.c om...
    > Hi,
    >
    > I saw several posts asking for reverse encryption (encrypt with
    > private key instead of public key) in .NET. I am having the same
    > question and wonder anybody has a good solution to it.
    >
    > Basically, my client application generates a key pair and exports the
    > public key to server. The client application needs to encrypt a string
    > with the private key and send it to server. Server authenticates the
    > client after decrypts the stirng with the public key. It looks like a
    > very simple procedure but it seems impossible with the RSA encryption
    > provided by .NET. The Encrypt() method of RSACryptoServiceProvider
    > seems to do encryption with public key ONLY. It does use private key
    > to encrypt content when generating a signature though.
    >
    > Does anybody have a solution to it? If .NET doesn't support it, is
    > there any way I can do it through Win32 CryptoAPI?
    >
    >
    > Thanks
    >
    > James

    Hernan de Lahitte Guest

  4. #3

    Default Re: Reverse Encryption in .NET

    Thanks for your reply. As I understand, one way to authenticate a client
    is to have server use client's public key to decrypt a token that is
    encrypted with client's private key. That is exactly how a signature is
    generated and verified except signature is generated by encrypting a
    digest of a message. If a private key can be used to encrypt a digest of
    a message, why can it be used to encrypt the message? I believe it is
    technically possible. As matter of fact, I even found a well known
    commercial PKI product that can do that. However, Windows cryptoAPI and
    Java JCE(with default provider) don't provide this capability.

    To keep the private key at server and distribute the public key to
    clients doesn't seem to work. Every client can use the public key to
    encrypt something and server will be able to decrypt it with no
    problems. The server won't be able to tell which client is which unless
    we have a keypair for each client. Since the public key is a public
    information, everyone including unauthorized users can get it and use it
    to access the server.

    For my usage, looks like the signature will do it. However, I am
    interested to the reason why reverse encryption is not provided in
    Windows CryptoAPI and Java JCE.

    Again, thanks for your information. Really appreciate that.



    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    james chou Guest

  5. #4

    Default Re: Reverse Encryption in .NET

    I agree with the singature scheme for your scenario. Regarding your question
    about ecripting with the private key, I guess (IMO) the CAPI and JCE might
    addere to the PKCS#1 standard
    ([url]ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-1/pkcs-1v2-1.pdf[/url]) and therefore
    only permits to encript with the public key and decrypt with the private
    key.

    See section 7 of the above document.

    7 Encryption schemes

    For the purposes of this document, an encryption scheme consists of an
    encryption operation and a decryption operation, where the encryption
    operation produces a ciphertext from a message with a recipient's RSA public
    key, and the decryption operation recovers the message from the ciphertext
    with the recipient's corresponding RSA private key.



    Hernan de Lahitte
    Lagash Systems S.A.
    [url]http://weblogs.asp.net/hernandl[/url]



    "james chou" <jameschou2000@yahoo.com> wrote in message
    news:%23Q8EHVN$DHA.3804@TK2MSFTNGP09.phx.gbl...
    > Thanks for your reply. As I understand, one way to authenticate a client
    > is to have server use client's public key to decrypt a token that is
    > encrypted with client's private key. That is exactly how a signature is
    > generated and verified except signature is generated by encrypting a
    > digest of a message. If a private key can be used to encrypt a digest of
    > a message, why can it be used to encrypt the message? I believe it is
    > technically possible. As matter of fact, I even found a well known
    > commercial PKI product that can do that. However, Windows cryptoAPI and
    > Java JCE(with default provider) don't provide this capability.
    >
    > To keep the private key at server and distribute the public key to
    > clients doesn't seem to work. Every client can use the public key to
    > encrypt something and server will be able to decrypt it with no
    > problems. The server won't be able to tell which client is which unless
    > we have a keypair for each client. Since the public key is a public
    > information, everyone including unauthorized users can get it and use it
    > to access the server.
    >
    > For my usage, looks like the signature will do it. However, I am
    > interested to the reason why reverse encryption is not provided in
    > Windows CryptoAPI and Java JCE.
    >
    > Again, thanks for your information. Really appreciate that.
    >
    >
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    Hernan de Lahitte Guest

  6. #5

    Default Re: Reverse Encryption in .NET

    Hi,

    Thank you for the link to the RSA document. I took a look at the
    document and was convinced that CAPI and JCE must follow that standard
    when implementing their encryption/decryption scheme. For folks that
    really want to do reverse encryption (for whatever reasons), they just
    have to look for something else.

    Thanks for your information.

    --James





    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    james chou Guest

  7. #6

    Default RE: Reverse Encryption in .NET

    Hi, I have the same problem, I checked out the answer you received I would like to know how you resolved the problem finally. I need to reverse the keys because I would like to use it like an authentication method. My model depends of it

    I would appreciate your help

    Johanna Espinos

    ----- James Chou wrote: ----

    Hi

    I saw several posts asking for reverse encryption (encrypt wit
    private key instead of public key) in .NET. I am having the sam
    question and wonder anybody has a good solution to it

    Basically, my client application generates a key pair and exports th
    public key to server. The client application needs to encrypt a strin
    with the private key and send it to server. Server authenticates th
    client after decrypts the stirng with the public key. It looks like
    very simple procedure but it seems impossible with the RSA encryptio
    provided by .NET. The Encrypt() method of RSACryptoServiceProvide
    seems to do encryption with public key ONLY. It does use private ke
    to encrypt content when generating a signature though

    Does anybody have a solution to it? If .NET doesn't support it, i
    there any way I can do it through Win32 CryptoAPI


    Thank

    Jame

    Johanna Espinosa Guest

  8. #7

    Default Re: Reverse Encryption in .NET

    Well, I dont' know if I'm missing something here but (IMO) I would call this
    "verifying a digital signature" procedure. In this scenario, you sign (hash
    and encrypt with private key) a kind of token and on the server side you
    verify the signature with the client public key.
    The .NET classes follow the PKCS1 standard and won't let you do "reverse
    encryption" as you described.
    On the other hand, I wonder if the main reason for this kind of unusual
    scenario may be "confidentiality" that might give you this "reverse
    encryption" strategy. As you may already know, if you use the public key to
    decrypt the message, anybody with the public key (the term "public" is
    crutial here) will be able to decrypt it as well.
    So if you want to authenticate the client and to provide confidentiality at
    the same time, you should use the already known and proven pratices and
    protocols and leave this kind of hack out of you security knowledge bag.

    --
    Hernan de Lahitte
    Lagash Systems S.A.
    [url]http://weblogs.asp.net/hernandl[/url]


    This posting is provided "AS IS" with no warranties, and confers no rights.

    "Johanna Espinosa" <papillongema@hotmail.com> wrote in message
    news:DE1BDB61-7794-4C1E-A12F-B5CE39B81D9E@microsoft.com...
    > Hi, I have the same problem, I checked out the answer you received I would
    like to know how you resolved the problem finally. I need to reverse the
    keys because I would like to use it like an authentication method. My model
    depends of it.
    >
    > I would appreciate your help,
    >
    > Johanna Espinosa
    >
    > ----- James Chou wrote: -----
    >
    > Hi,
    >
    > I saw several posts asking for reverse encryption (encrypt with
    > private key instead of public key) in .NET. I am having the same
    > question and wonder anybody has a good solution to it.
    >
    > Basically, my client application generates a key pair and exports the
    > public key to server. The client application needs to encrypt a
    string
    > with the private key and send it to server. Server authenticates the
    > client after decrypts the stirng with the public key. It looks like a
    > very simple procedure but it seems impossible with the RSA encryption
    > provided by .NET. The Encrypt() method of RSACryptoServiceProvider
    > seems to do encryption with public key ONLY. It does use private key
    > to encrypt content when generating a signature though.
    >
    > Does anybody have a solution to it? If .NET doesn't support it, is
    > there any way I can do it through Win32 CryptoAPI?
    >
    >
    > Thanks
    >
    > James
    >

    Hernan de Lahitte Guest

  9. #8

    Default Re: Reverse Encryption in .NET

    Thanks Hernan,

    I'm agree with you that reverse encryption isn't the a good idea for
    confidentiality but my problem is that funny me I have to propose a
    model for component authentication (academic porpuse), right now I just
    have a trivial idea but I would like your appreciation, do you have a
    e-mail to write you, you can send it to [email]papillongema@hotmail.com[/email]

    Any help will be appreciate,


    Johanna Espinosa L.

    *** Sent via Devdex [url]http://www.devdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Johanna Espinosa 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