473,473 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Cookie encryption?

The connection is ssl encrypted and I need to write some sensitive
information in a cookie. I'd like to encrypt the cookie on the client so
it could be decrypted later on the server.

1. If I use a symmetric algorithm how do I send the encryption key?
2. Is there any asymmetric algorithm that doesn't have an impact on
performance?
3. Is there a difference in writing cookies with http an https?
I think https in that case doesn't help.

Thanks in advance for any suggestions.
Aug 29 '08 #1
7 5236
In article <g9**********@news.metronet.hr>, Walter Sobchak <ge*******@yahoo.comwrote:
>The connection is ssl encrypted and I need to write some sensitive
information in a cookie. I'd like to encrypt the cookie on the client so
it could be decrypted later on the server.
Posting this question in a javascript newsgroup implies that you intend to
write your encryption algorithm in javascript.

Consider that doing so exposes your encryption algorithm, including the
encryption key, to anyone with the wit to click View Source.

Does this seem like a good plan?
--
Regards,
Doug Miller (alphageek-at-milmac-dot-com)

Join the UseNet Improvement Project: killfile Google Groups.
http://www.improve-usenet.org

Get a copy of my NEW AND IMPROVED TrollFilter for NewsProxy/Nfilter
by sending email to autoresponder at filterinfo-at-milmac-dot-com
You must use your REAL email address to get a response.

Download Nfilter at http://www.milmac.com/np-120.exe

Aug 29 '08 #2
Walter Sobchak wrote:
The connection is ssl encrypted and I need to write some sensitive
information in a cookie. I'd like to encrypt the cookie on the client so
it could be decrypted later on the server.
I would usually not perform such a task at the client. The server
could both encrypt the value and set the cookie via a HTTP-header
(still better than document.cookie IMHO).
1. If I use a symmetric algorithm how do I send the encryption key?
If you would use javascript, there is no other choice than making the
key/salt available as plaintext for the script in the web page; thus
making it interceptable for the viewer of the page. I think there can
be little doubt that a server-side solution would be better in this
case.
2. Is there any asymmetric algorithm that doesn't have an impact on
performance?
Encryption is memory-intensive by nature; but I wouldn't care much
about only one en-/decrypt action. The difficuly for asymmetric
cryptography is that there are both the private key (encrypt) and the
public key (decrypt).

A somewhat safe strategy could be to make only the public key
available to the client; so he can only decrypt the cookie with it.
But I believe this would be the opposite of your plan: when you want
to encrypt asymmetrically in javascript, you always need the private
key.

But I think that symmetric cryptography is more recommended in your
scenario (and preferably done at the server).
3. Is there a difference in writing cookies with http an https?
I think https in that case doesn't help.
HTTPS secures the transmission of data along the line, but nothing
more. You are only reasonably safe that nobody can intercept data
between server and client. Most security problems do not relate to
this area.

--
Bart
Aug 29 '08 #3
sp******@milmac.com (Doug Miller) wrote in
news:mj******************@nlpi064.nbdc.sbc.com:
In article <g9**********@news.metronet.hr>, Walter Sobchak
<ge*******@yahoo.comwrote:
>
Consider that doing so exposes your encryption algorithm, including
the encryption key, to anyone with the wit to click View Source.

Does this seem like a good plan?

You could ask the end user for a password. Then you end up with something
that can only be decrypted by the client. You would need to prompt the user
again for the password when it is needed to decrypt the cookie.
Aug 29 '08 #4
i think it'd be prudent to change your approach on this one, since
you're running into a fundamental roadblock: you want to put secure
info somewhere that's inherently insecure.

personally, i'd just write the data to the server and associate it
with that user's account. if there isn't a logged-in user involved in
this operation then... well... what sensitive information could/would
you give to someone you haven't authenticated?

-micah

On Aug 29, 7:17*am, Walter Sobchak <genija...@yahoo.comwrote:
The connection is ssl encrypted and I need to write some sensitive
information in a cookie. I'd like to encrypt the cookie on the client so
it could be decrypted later on the server.

1. If I use a symmetric algorithm how do I send the encryption key?
2. Is there any asymmetric algorithm that doesn't have an impact on
performance?
3. Is there a difference in writing cookies with http an https?
I think https in that case doesn't help.

Thanks in advance for any suggestions.
Aug 29 '08 #5
Bart Van der Donck wrote:
Walter Sobchak wrote:
>The connection is ssl encrypted and I need to write some sensitive
information in a cookie. I'd like to encrypt the cookie on the client so
it could be decrypted later on the server.

I would usually not perform such a task at the client. The server
could both encrypt the value and set the cookie via a HTTP-header
(still better than document.cookie IMHO).
>1. If I use a symmetric algorithm how do I send the encryption key?

If you would use javascript, there is no other choice than making the
key/salt available as plaintext for the script in the web page; thus
making it interceptable for the viewer of the page. I think there can
be little doubt that a server-side solution would be better in this
case.
>2. Is there any asymmetric algorithm that doesn't have an impact on
performance?

Encryption is memory-intensive by nature; but I wouldn't care much
about only one en-/decrypt action. The difficuly for asymmetric
cryptography is that there are both the private key (encrypt) and the
public key (decrypt).

A somewhat safe strategy could be to make only the public key
available to the client; so he can only decrypt the cookie with it.
But I believe this would be the opposite of your plan: when you want
to encrypt asymmetrically in javascript, you always need the private
key.

But I think that symmetric cryptography is more recommended in your
scenario (and preferably done at the server).
>3. Is there a difference in writing cookies with http an https?
I think https in that case doesn't help.

HTTPS secures the transmission of data along the line, but nothing
more. You are only reasonably safe that nobody can intercept data
between server and client. Most security problems do not relate to
this area.

--
Bart
The thing is that I have the information on the client side. So I want
to encrypt it and out it in a cookie.
I know that should be done on the server side but I don't know how.
Is there a way to call a server function from a client in a way that you
send a parameter to that function and receive the result??
Aug 31 '08 #6
It sounds like a good solution but the problem is that user enters some
information on the client side and I need to have this information in a
cookie because it is some kind of an authentication ticket.

micah wrote:
i think it'd be prudent to change your approach on this one, since
you're running into a fundamental roadblock: you want to put secure
info somewhere that's inherently insecure.

personally, i'd just write the data to the server and associate it
with that user's account. if there isn't a logged-in user involved in
this operation then... well... what sensitive information could/would
you give to someone you haven't authenticated?

-micah

On Aug 29, 7:17 am, Walter Sobchak <genija...@yahoo.comwrote:
>The connection is ssl encrypted and I need to write some sensitive
information in a cookie. I'd like to encrypt the cookie on the client so
it could be decrypted later on the server.

1. If I use a symmetric algorithm how do I send the encryption key?
2. Is there any asymmetric algorithm that doesn't have an impact on
performance?
3. Is there a difference in writing cookies with http an https?
I think https in that case doesn't help.

Thanks in advance for any suggestions.
Aug 31 '08 #7
Walter Sobchak wrote:

....
>Walter Sobchak wrote:
>>The connection is ssl encrypted and I need to write some sensitive
information in a cookie. I'd like to encrypt the cookie on the client
so it could be decrypted later on the server.
...
The thing is that I have the information on the client side. So I want
to encrypt it and out it in a cookie.
I know that should be done on the server side but I don't know how.
I think the most classic design would be like this:

1. Put the information in an <input(type=hidden?)
2. submit the form (manually?) as post-request over HTTPS to server
3. server encrypts it (+probably stores it?)
4. send next 'you-are-now-logged-in'-page with cookie in HTTP-header

The javascript way:

1. offer string+salt to the encryption alghoritm on the page
http://www.google.com/search?q=javascript+encryption
2. use document.cookie() to store it
http://www.w3schools.com/JS/js_cookies.asp
Is there a way to call a server function from a client in a way that you
send a parameter to that function and receive the result??
http://en.wikipedia.org/wiki/XMLHttpRequest

--
Bart
Sep 1 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Shabam | last post by:
I'm developing an application and want to have the "remember me" feature, so that users don't have to log back in again in the next visit. The problem here is, what happens if the user's cookie...
9
by: Don | last post by:
I understand that when I send a cookie in a client-side page containing JS, it isn't actually "set" until the next page is loaded. Is there some way to "set" it within the same html/JS page so it...
1
by: Paul W | last post by:
Hi - I'm doing simple XOR encryption on a password before storing it in a cookie. I use the same 2-way encryption/decryption routine at each end (before writing/after reading). Something is getting...
4
by: craigkenisston | last post by:
I have an asp.net application in which I sometimes store a persistent cookie once the user has logged in and this has been working great. However, I now add some user information like, username,...
4
by: gl | last post by:
I'm currently making a web app that stores a user id in a cookie, and builds user information off of that in the differnt pages of the site. The cookie is created on login, and is separate from the...
0
by: Chris Newby | last post by:
I'm looking for a way to transparently encrypt cookie data using Asp.Net 1.1. Ideally, developers could still do things like: HttpCookie cookie = new HttpCookie( "clearTextKey",...
2
by: quintesv via DotNetMonster.com | last post by:
Hi all, On WinXP, VS 2003, .net 1.1 I have written an encryption class which uses rijndael method to encrypt a string AND then convert the string to unicode using System.Text. Unicodeencoder....
19
by: klenwell | last post by:
Another request for comments here. I'd like to accomplish something like the scheme outlined at this page here: http://tinyurl.com/3dtcdr In a nutshell, the form uses javascript to hash...
2
by: Rodrigo m. Ferreira | last post by:
Hi, How do I encrypt information for storing in cookies? I used the MD5, but I don't know how to decrypt information. Can you help me? Rodrigo M. Ferreira
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.