1. #1
    Sencha User
    Join Date
    Mar 2008
    Location
    Silver Spring, MD
    Posts
    79
    Vote Rating
    0
    atchijov is on a distinguished road

      0  

    Default Best way to implement form with client side encryption/decryption

    Best way to implement form with client side encryption/decryption


    What is the best way to implement form which will perform transparent encryption/decryption of some of its fields? I already have encryption/decryption part, all I need is an advice on best way to extend form functionality to make it use it.

    As of now, I am implementing Form subclass which auto-magically creates hidden input for each "encrypted" field and then adding my code which does encryption/decryption and copying from "hidden" to "visible" input (and other way around) in even handlers ("decrypt" in "actioncomplete" for "load" action and "encrypt" in "beforeaction" for "submit" action). Is there better way of doing it?

    Your comments will be highly appreciated.

    Andrei Tchijov

  2. #2
    Ext User
    Join Date
    Jul 2007
    Posts
    3,128
    Vote Rating
    1
    devnull is an unknown quantity at this point

      0  

    Default


    Better way? yeah, use ssl for the entire thing. Any encryption done in javascript will just provide an illusion of security, as there is no way to make it truly secure.
    If you really insist on taking this path, the better way would probably be to use a beforeaction listener on the form, and manipulate the params in the passed in Action object.

  3. #3
    Sencha User
    Join Date
    Mar 2008
    Location
    Silver Spring, MD
    Posts
    79
    Vote Rating
    0
    atchijov is on a distinguished road

      0  

    Default Encryption on client side is NOT to secure communications

    Encryption on client side is NOT to secure communications


    We are using SSL. Client side encryption done not to secure communications, but to protect data once they got stored on server side. In our application some data has to be "private". It should not be possible to "read" these data even if you got full access to the server.

    Andrei

  4. #4
    Ext User
    Join Date
    Jul 2007
    Posts
    3,128
    Vote Rating
    1
    devnull is an unknown quantity at this point

      0  

    Default


    You will never achieve that goal through code alone. In order for the client to decrypt the data, it must also have access to the decryption key. Since the code almost certainly comes from the same server that the data is on, anyone that gains access to the server will also gain access to the means to decrypt the data. Even failing that, the decryption routine will be right there in the client side javascript for them to do whatever they want with.
    In order for something like this to work, the encryption key must come from a third party (most likely the user) and never be stored on the server. The only other option is to use some form of asymetrical encryption in which the data can be easily encrypted using a public key, but requires someone to enter a private key to decrypt. Of course this is only practical if the user never gets to see the data again, but rather it is only needed occasionally for some kind of batch process (credit card information needing to be accessed for during a billing cycle for instance). And in this case with ssl already being used to protect the datastream, the actual encryption needs to be done on the server just prior to database insertion.

  5. #5
    Sencha User
    Join Date
    Mar 2008
    Location
    Silver Spring, MD
    Posts
    79
    Vote Rating
    0
    atchijov is on a distinguished road

      0  

    Default once again ... I am not asking about encryption part

    once again ... I am not asking about encryption part


    all your comments are correct, but not very relevant. the way encryption/decryption is implemented is not an issue (just for the records, all your concerns are addressed in our solution). my question was about Ext. More precise, about best way to extend Ext.form.FormPanel to make it use our encryption/decryption facilities in less obtrusive way.

    Andrei

  6. #6
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    6
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    I have a password field in a login form that has this:
    Code:
                }, {
                    fieldLabel: this.passwordLabel,
                    name: 'password',
                    allowBlank: false,
                    blankText: this.passwordBlankText,
                    id: 'pass',
                    inputType: 'password',
                    minLength: 6,
                    qtip: {
                        text: this.passwordQtipText,
                        width: 150
                    },
                    listeners: {
                        //obfuscate the password from prying eyes
                        change: {
                            fn: function(field, newValue, oldValue){
                                field.setRawValue(this.hash(newValue));
                            },
                            scope: this
                        }
                    }
                }, {
    So in this case I was avoiding storing the original typed value in the field. You could 'render' the field to show ***** or whatever, but I also made some (useless?) effort to hide the typed value.

    I take that hashed value and decrypt it server side. I then re-crypt it server side with the server side algorithm.

    There are some extensions floating about for encrypting client side in various forms. I'm must using simple str_rot13 function in this case.

    I think if you're looking for more specific suggestions insight you're going to need to flush out better what you're actually doing. You don't say if you're dealing with new data, read data, changed data, etc. in your form.

  7. #7
    Ext User
    Join Date
    Jul 2007
    Posts
    3,128
    Vote Rating
    1
    devnull is an unknown quantity at this point

      0  

    Default


    I guess I just fail to see the significance of encrypting the form data when its already being encrypted by the ssl connection, and it will have to be encrypted again on the server prior to storage anyway (there is NO possibility of a secure encryption technique that can be used strictly on the client).
    As with MJ, I need a better understanding of what is actually needed and why my ideas arent sufficient before I can offer anything more specific.

  8. #8
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,361
    Vote Rating
    81
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    Quote Originally Posted by devnull View Post
    I guess I just fail to see the significance of encrypting the form data when its already being encrypted by the ssl connection, and it will have to be encrypted again on the server prior to storage anyway (there is NO possibility of a secure encryption technique that can be used strictly on the client).
    As with MJ, I need a better understanding of what is actually needed and why my ideas arent sufficient before I can offer anything more specific.
    I agree with you. The main reason people encrypt passwords to be sent over the wire is to reduce sniffing attacks.