Implementing RSACryptoServiceProvider *and* JavaScript

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

  1. #1

    Default Implementing RSACryptoServiceProvider *and* JavaScript

    I'm currently trying to strengthen up the security on a large ASP.NET
    application (a web content management system). The primary objective is to
    prevent people from evesdropping for passwords and other sensitive
    information, with a secondary objective of preventing Harry the Hacker from
    having his (her) evil way.

    Logging on is secured by never storing the passwords in plain text and using
    a combination of MD5 hashes for the user/password, and a single-use token to
    'salt' the resultant hash. This is secure as the password (or its hash) are
    completely obscured by the salt.

    The next step -- and I'm *really* surprised that *everyone* doesn't do this
    -- is to prevent 'Evil Eve' from listening in to the network when the
    passwords and other sensitive information is passed from the client back to
    the server. At this point I should point out that SSL isn't an option
    because of its cost. The application is aimed at small businesses who baulk
    at the thought of paying $400/year for a certificate (it's hard enough
    getting $500 out of them for the website!). Also it is often not possible to
    implement SSL on public shared web servers.

    The way I propose this to work is as follows:

    1) The server creates a RSACryptoServiceProvider object and keeps this as an
    application variable. When the object is created, it creates the public and
    private keys.

    2) When the user requests the form to change a password, the form is
    rendered with a JavaScript RSA implementation and with the *public* keys
    embedded in the form (probably in the onSubmit event). Note that Java or
    ActiveX is absolutely out of the question, therefore I can only implement
    RSA on the client in JavaScript.

    3) On the client, the user fills in the form and the onSubmit event takes
    the variables and encrypts them using the JavaScript RSA implementation using
    the supplied public keys. The existing form fields are cleared (don't want
    the plain text information being passed over!). The RSA encrypted field is
    sent back to the server.

    4) On the server the RSACryptoServiceProvider object is called to decrypt
    the data sent from the client using the *private* keys.

    5) Voila!

    The strength of this is based on RSA and the fact that you can't break 1024
    bit encryption (without an enormous effort). Although it will take a couple
    of seconds to encrypt the data on the client, this doesn't matter.

    Having hunted around the internet, I keep drawing a blank here. There are
    several implementations of RSA on JavaScript, but none of them are compatible
    with the RSACryptoServiceProvider object. The bottom line is there's some
    enormous numbers involved here (1024 bits worth!), so there's a shed load of
    scary maths involved.

    I would *really* appreciate it if someone could point me in the direction of
    a JavaScript RSA implementation that works with the RSACryptoServiceProvider.

    Oh, as a footnote, I'm really surprised that this isn't a common
    requirement. It seems so obvious and so cheap; well it would be if I could
    get the damn thing working!


    TIA,
    Glenn

    Glenn Guest

  2. Similar Questions and Discussions

    1. implementing paypal
      hi. i'm just getting started trying to implement PayPal into my application. i've downloaded the PayPal MX 1.0 files for use with ColdFusion....
    2. Error instantiating RSACryptoServiceProvider
      Please help me, I'm bleeding here! Problem outlined below: Ignus "Ignus Fast" <junk@no.com> wrote in message...
    3. RSACryptoServiceProvider
      Is there any information anywhere showing how RSACryptoServiceProvider actually generates the private keys? Thanks, Steven
    4. Implementing FontInfo
      Can anyone tell me how to implement the Font (FontInfo) property in my custom control so that it appears as a property in the properties window?...
    5. Implementing DCRs
      I want to import a ready DCR File into another Director File! Is this possible? How does it work? Or is there a possibility to make a link to an...
  3. #2

    Default RE: Implementing RSACryptoServiceProvider *and* JavaScript

    Glenn, this is a good idea to overcome the problem of having to pay the SSL
    Certificate, here in Argentina, costs are a big issue that usualy stops
    clients from buying our software. Your solution of trying to simulate a SSL
    style mechanism is great and I would like to help you in order to make this
    work.
    Could you please tell me what JavaScript RSA implementations you found and
    point me to them so I can start helping?

    Thanks,

    Patricio Jutard

    "Glenn" wrote:
    > I'm currently trying to strengthen up the security on a large ASP.NET
    > application (a web content management system). The primary objective is to
    > prevent people from evesdropping for passwords and other sensitive
    > information, with a secondary objective of preventing Harry the Hacker from
    > having his (her) evil way.
    >
    > Logging on is secured by never storing the passwords in plain text and using
    > a combination of MD5 hashes for the user/password, and a single-use token to
    > 'salt' the resultant hash. This is secure as the password (or its hash) are
    > completely obscured by the salt.
    >
    > The next step -- and I'm *really* surprised that *everyone* doesn't do this
    > -- is to prevent 'Evil Eve' from listening in to the network when the
    > passwords and other sensitive information is passed from the client back to
    > the server. At this point I should point out that SSL isn't an option
    > because of its cost. The application is aimed at small businesses who baulk
    > at the thought of paying $400/year for a certificate (it's hard enough
    > getting $500 out of them for the website!). Also it is often not possible to
    > implement SSL on public shared web servers.
    >
    > The way I propose this to work is as follows:
    >
    > 1) The server creates a RSACryptoServiceProvider object and keeps this as an
    > application variable. When the object is created, it creates the public and
    > private keys.
    >
    > 2) When the user requests the form to change a password, the form is
    > rendered with a JavaScript RSA implementation and with the *public* keys
    > embedded in the form (probably in the onSubmit event). Note that Java or
    > ActiveX is absolutely out of the question, therefore I can only implement
    > RSA on the client in JavaScript.
    >
    > 3) On the client, the user fills in the form and the onSubmit event takes
    > the variables and encrypts them using the JavaScript RSA implementation using
    > the supplied public keys. The existing form fields are cleared (don't want
    > the plain text information being passed over!). The RSA encrypted field is
    > sent back to the server.
    >
    > 4) On the server the RSACryptoServiceProvider object is called to decrypt
    > the data sent from the client using the *private* keys.
    >
    > 5) Voila!
    >
    > The strength of this is based on RSA and the fact that you can't break 1024
    > bit encryption (without an enormous effort). Although it will take a couple
    > of seconds to encrypt the data on the client, this doesn't matter.
    >
    > Having hunted around the internet, I keep drawing a blank here. There are
    > several implementations of RSA on JavaScript, but none of them are compatible
    > with the RSACryptoServiceProvider object. The bottom line is there's some
    > enormous numbers involved here (1024 bits worth!), so there's a shed load of
    > scary maths involved.
    >
    > I would *really* appreciate it if someone could point me in the direction of
    > a JavaScript RSA implementation that works with the RSACryptoServiceProvider.
    >
    > Oh, as a footnote, I'm really surprised that this isn't a common
    > requirement. It seems so obvious and so cheap; well it would be if I could
    > get the damn thing working!
    >
    >
    > TIA,
    > Glenn
    >
    Patricio Jutard Guest

  4. #3

    Default RE: Implementing RSACryptoServiceProvider *and* JavaScript

    I'm still working on this.

    Some of the most useful articles are:
    * [url]http://www.codeproject.com/csharp/TotalSecurity.asp[/url]
    * [url]http://pages.infinit.net/ctech/20031101-0151.html[/url]
    * [url]http://pajhome.org.uk/crypt/rsa/rsa.html[/url]
    * [url]http://www.leemon.com/crypto/bigInt.html[/url]


    I've come to the conclusion that I need to create all three systems in
    JavaScript: hashing (MD5), synchronous encryption (3DES), and asynchronous
    encryption (RSA). This will enable me to ensure security between the client
    and the server in all ways:

    1) Password entry
    User enters username and password. Do the following:
    - Transform the password as --> MD5( Username + MD5( Password ) )
    - Transform the username as MD5( Username )
    (where MD5( Username ) means get the MD5 hash of the username).
    Send these back to the server.

    On the server, use the username hash string to search for the user record
    (have an extra field in the user record that contains the hash). With this
    record, read the username and password hash from this record (*never* store
    the password in plain text, always as a hash). Create a local transform:
    MD5(Username + MD5(Password)) and compare this with the string sent back from
    the client. If they're the same, let them in. If not...

    Reasoning: have to hash the username to prevent evesdroppers getting half
    of the password.


    2) Changing passwords = protecting postback data using PGP style crypto
    Server creates the form page and sends a public key to the client in the page.
    - User enters data that is to be secured and clicks submit.
    - Generate a random password on the client. Hash this using MD5 to get a
    trully random password.
    - Build a string containing name=value pairs of all the data that is to be
    protected.
    - Encrypt this data using 3DES
    - Encrypt the password with RSA using the public key
    - Send the encrypted data and encrypted password back to the server

    At the server...
    - Decrypt the password using the RSA private keys
    - Using this password, decrypt the returned data using 3DES
    - Check the decrypted data for sanity (e.g. does it contain name=value
    strings?)
    - Extract the name=value pairs.

    The above algorithm is pretty much what PGP does; combining synchronous and
    asynchronous encryption.

    Comments for the SSL zealots: this ISN'T a replacement for SSL. It's just
    a way of encrypting data returning back to the client so that script kiddies
    can't sniff the data. Any encryption's better than no encryption. It's
    still vulnerable to the man-in-the-middle attack, but as this is difficult
    to perform, the risks are low.


    You can also toughen up the above by adding additional checks, adding SALT
    to the hashes, and obfuscating the code, etc.

    Regards,
    Glenn


    "Patricio Jutard" wrote:
    > Glenn, this is a good idea to overcome the problem of having to pay the SSL
    > Certificate, here in Argentina, costs are a big issue that usualy stops
    > clients from buying our software. Your solution of trying to simulate a SSL
    > style mechanism is great and I would like to help you in order to make this
    > work.
    > Could you please tell me what JavaScript RSA implementations you found and
    > point me to them so I can start helping?
    >
    > Thanks,
    >
    > Patricio Jutard
    >
    > "Glenn" wrote:
    >
    > > I'm currently trying to strengthen up the security on a large ASP.NET
    > > application (a web content management system). The primary objective is to
    > > prevent people from evesdropping for passwords and other sensitive
    > > information, with a secondary objective of preventing Harry the Hacker from
    > > having his (her) evil way.
    > >
    > > Logging on is secured by never storing the passwords in plain text and using
    > > a combination of MD5 hashes for the user/password, and a single-use token to
    > > 'salt' the resultant hash. This is secure as the password (or its hash) are
    > > completely obscured by the salt.
    > >
    > > The next step -- and I'm *really* surprised that *everyone* doesn't do this
    > > -- is to prevent 'Evil Eve' from listening in to the network when the
    > > passwords and other sensitive information is passed from the client back to
    > > the server. At this point I should point out that SSL isn't an option
    > > because of its cost. The application is aimed at small businesses who baulk
    > > at the thought of paying $400/year for a certificate (it's hard enough
    > > getting $500 out of them for the website!). Also it is often not possible to
    > > implement SSL on public shared web servers.
    > >
    > > The way I propose this to work is as follows:
    > >
    > > 1) The server creates a RSACryptoServiceProvider object and keeps this as an
    > > application variable. When the object is created, it creates the public and
    > > private keys.
    > >
    > > 2) When the user requests the form to change a password, the form is
    > > rendered with a JavaScript RSA implementation and with the *public* keys
    > > embedded in the form (probably in the onSubmit event). Note that Java or
    > > ActiveX is absolutely out of the question, therefore I can only implement
    > > RSA on the client in JavaScript.
    > >
    > > 3) On the client, the user fills in the form and the onSubmit event takes
    > > the variables and encrypts them using the JavaScript RSA implementation using
    > > the supplied public keys. The existing form fields are cleared (don't want
    > > the plain text information being passed over!). The RSA encrypted field is
    > > sent back to the server.
    > >
    > > 4) On the server the RSACryptoServiceProvider object is called to decrypt
    > > the data sent from the client using the *private* keys.
    > >
    > > 5) Voila!
    > >
    > > The strength of this is based on RSA and the fact that you can't break 1024
    > > bit encryption (without an enormous effort). Although it will take a couple
    > > of seconds to encrypt the data on the client, this doesn't matter.
    > >
    > > Having hunted around the internet, I keep drawing a blank here. There are
    > > several implementations of RSA on JavaScript, but none of them are compatible
    > > with the RSACryptoServiceProvider object. The bottom line is there's some
    > > enormous numbers involved here (1024 bits worth!), so there's a shed load of
    > > scary maths involved.
    > >
    > > I would *really* appreciate it if someone could point me in the direction of
    > > a JavaScript RSA implementation that works with the RSACryptoServiceProvider.
    > >
    > > Oh, as a footnote, I'm really surprised that this isn't a common
    > > requirement. It seems so obvious and so cheap; well it would be if I could
    > > get the damn thing working!
    > >
    > >
    > > TIA,
    > > Glenn
    > >
    Glenn Guest

  5. #4

    Default RE: Implementing RSACryptoServiceProvider *and* JavaScript

    One of the things I discovered is the 'standard' RSA algorithms, as
    implemented in [url]http://www.leemon.com/crypto/bigInt.html[/url] for example, WILL
    NOT DECRYPT using the .net RSACryptoServiceProvider. I've been working on
    the idea that .NET encrypts using OAEP or PKCS, but still need to research
    this.

    The bottom line is if you use the .NET-generated public keys in the leemon
    example to encrypt a known string (e.g. "hello") and then compare this with
    the output from .NET. THEY'RE DIFFERENT.

    I've more-or-less come to the conclusion that the RSACryptoServiceProvider
    is more trouble than it's worth, so I'm going to use the bigint.cs code
    from the [url]http://www.codeproject.com/csharp/TotalSecurity.asp[/url] article as I
    need to guarentee the client and server code to be compatible, and it's
    risky relying on Microsoft to not change the algorithm when they feel like it
    (that's assuming I'll ever get the damn thing working in the first place).


    Regards,
    Glenn






    "Patricio Jutard" wrote:
    > Glenn, this is a good idea to overcome the problem of having to pay the SSL
    > Certificate, here in Argentina, costs are a big issue that usualy stops
    > clients from buying our software. Your solution of trying to simulate a SSL
    > style mechanism is great and I would like to help you in order to make this
    > work.
    > Could you please tell me what JavaScript RSA implementations you found and
    > point me to them so I can start helping?
    >
    > Thanks,
    >
    > Patricio Jutard
    >
    > "Glenn" wrote:
    >
    > > I'm currently trying to strengthen up the security on a large ASP.NET
    > > application (a web content management system). The primary objective is to
    > > prevent people from evesdropping for passwords and other sensitive
    > > information, with a secondary objective of preventing Harry the Hacker from
    > > having his (her) evil way.
    > >
    > > Logging on is secured by never storing the passwords in plain text and using
    > > a combination of MD5 hashes for the user/password, and a single-use token to
    > > 'salt' the resultant hash. This is secure as the password (or its hash) are
    > > completely obscured by the salt.
    > >
    > > The next step -- and I'm *really* surprised that *everyone* doesn't do this
    > > -- is to prevent 'Evil Eve' from listening in to the network when the
    > > passwords and other sensitive information is passed from the client back to
    > > the server. At this point I should point out that SSL isn't an option
    > > because of its cost. The application is aimed at small businesses who baulk
    > > at the thought of paying $400/year for a certificate (it's hard enough
    > > getting $500 out of them for the website!). Also it is often not possible to
    > > implement SSL on public shared web servers.
    > >
    > > The way I propose this to work is as follows:
    > >
    > > 1) The server creates a RSACryptoServiceProvider object and keeps this as an
    > > application variable. When the object is created, it creates the public and
    > > private keys.
    > >
    > > 2) When the user requests the form to change a password, the form is
    > > rendered with a JavaScript RSA implementation and with the *public* keys
    > > embedded in the form (probably in the onSubmit event). Note that Java or
    > > ActiveX is absolutely out of the question, therefore I can only implement
    > > RSA on the client in JavaScript.
    > >
    > > 3) On the client, the user fills in the form and the onSubmit event takes
    > > the variables and encrypts them using the JavaScript RSA implementation using
    > > the supplied public keys. The existing form fields are cleared (don't want
    > > the plain text information being passed over!). The RSA encrypted field is
    > > sent back to the server.
    > >
    > > 4) On the server the RSACryptoServiceProvider object is called to decrypt
    > > the data sent from the client using the *private* keys.
    > >
    > > 5) Voila!
    > >
    > > The strength of this is based on RSA and the fact that you can't break 1024
    > > bit encryption (without an enormous effort). Although it will take a couple
    > > of seconds to encrypt the data on the client, this doesn't matter.
    > >
    > > Having hunted around the internet, I keep drawing a blank here. There are
    > > several implementations of RSA on JavaScript, but none of them are compatible
    > > with the RSACryptoServiceProvider object. The bottom line is there's some
    > > enormous numbers involved here (1024 bits worth!), so there's a shed load of
    > > scary maths involved.
    > >
    > > I would *really* appreciate it if someone could point me in the direction of
    > > a JavaScript RSA implementation that works with the RSACryptoServiceProvider.
    > >
    > > Oh, as a footnote, I'm really surprised that this isn't a common
    > > requirement. It seems so obvious and so cheap; well it would be if I could
    > > get the damn thing working!
    > >
    > >
    > > TIA,
    > > Glenn
    > >
    Glenn 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