Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 22nd, 2007, 11:51 AM   #1
paulmedic555
Newbie
 
paulmedic555's Avatar
 
Join Date: Jan 2005
Location: Greece
Posts: 18
Rep Power: 0 paulmedic555 is on a distinguished road
Send a message via MSN to paulmedic555
java encryption

Hi all i am trying to make an application in java that achieve confidentiality/authentication. There is any way to encrypt any data with my private Key an then with an other's Public Key and the other decrypt it with his private Key and my publicKey?
paulmedic555 is offline   Reply With Quote
Old Feb 22nd, 2007, 12:03 PM   #2
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,031
Rep Power: 5 lectricpharaoh will become famous soon enough
Yes, you can do that. Encryption/decryption is essentially applying a transformation to a stream of bytes, which Java (and most any other language) can do. The catch is you need to code the algorithms, and for this, I'd advise looking for an open source implementation that's out there, and seeing how it works. Remember that if you use such code, you may very well have to release your app as open source as well, so another option is finding a specification of how the algorithm works, and using that to write your own implementation of that algorithm from scratch.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is offline   Reply With Quote
Old Feb 22nd, 2007, 12:12 PM   #3
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
Originally Posted by paulmedic555 View Post
Hi all i am trying to make an application in java that achieve confidentiality/authentication. There is any way to encrypt any data with my private Key an then with an other's Public Key and the other decrypt it with his private Key and my publicKey?
Decrypt it with your public key? Are you talking about encrypting and signing the message?
Arevos is offline   Reply With Quote
Old Feb 23rd, 2007, 4:13 AM   #4
paulmedic555
Newbie
 
paulmedic555's Avatar
 
Join Date: Jan 2005
Location: Greece
Posts: 18
Rep Power: 0 paulmedic555 is on a distinguished road
Send a message via MSN to paulmedic555
I want to find a way such as the sender wants to make sure that ONLY the receiver can read the data and the receiver know that ONLY that sender send the data. I tried this by sequentially encrypt the data with the private key of the sender and then with public key of the receiver. Then the receiver decrypt it wit his private key and then with the senders public key. But during the decryption at the receiver i had a Bad Padding Exception. So i ask if there is another way
paulmedic555 is offline   Reply With Quote
Old Feb 23rd, 2007, 4:32 AM   #5
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
I want to find a way such as the sender wants to make sure that ONLY the receiver can read the data and the receiver know that ONLY that sender send the data.
Then you want to encrypt the message, and then sign it.

In effect the steps you'll take are:

1. Take a hash of the message (such as SHA1, Whirlpool or whatever)
2. Sign the hash, by which I mean "decrypt" it with your private key.
3. Generate a random key (make sure to use cryptographic random functions for this!) for a symmetric encryption algorithm (such as AES or Twofish).
4. Add the hash to your message, and encrypt the whole thing using this random key.
5. Now encrypt the random key using their public key.
6. Send them the fully encrypted message and key.

At their end:

1. They'll decrypt the symmetric key using their private key.
2. They'll decrypt the message and hash using the symmetric key. They can now read the message.
3. They'll then "encrypt" the hash with your public key, returning the hash to its original state.
4. They'll take a hash of the message, and compare it against the hash you sent. If it matches, the message is genuine.

However, with a decent encryption library, a lot of this will happen behind the scenes. What encryption library are you using for this?
Arevos is offline   Reply With Quote
Old Mar 4th, 2007, 5:43 PM   #6
ownagesbot
Newbie
 
Join Date: Mar 2007
Posts: 3
Rep Power: 0 ownagesbot is on a distinguished road
Yeh, also watch out for hash collisions, makes it easier for "crackers" to "crack" your system (i.e. there would be more than 1 possible hash), they also suck solely because it makes your encryption unstable.
ownagesbot is offline   Reply With Quote
Old Mar 5th, 2007, 4:32 AM   #7
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
There have been some prominent attacks on SHA1, where a piece of data that produces an identical hash to the one supplied can be found, given enough computing hardware (I'd have to check this; it might take an infeasibly large amount of hardware, even with the new collision-finding algorithms). However, just finding a random piece of data with the same hash, is very different from finding a specific piece of data with the same hash. In other words, it's possible, barely, to create a set of random data with a valid signature - so long as you have access to a message signed by this signature, and are willing to spend a lot of computing time generating the message that corresponds to the hash. But that's not really going to do you any good - the text is essentially random and thus carries no specific information.

If you're that worried about hash collisions, it would make sense to use a hashing protocol that has no known attacks against it, such as Whirlpool. However, even with SHA1, your cryptographic signature is likely to be secure for quite some time, and certainly no cracker is going to be able to fake it any time soon, even if he or she has access to enough hardware to generate collisions. Also, it's worth noting that vulnerabilities in the hashing algorithm only affect the cryptographic signature, not the encryption itself.
Arevos is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Programming with Java: Tutorial ReggaetonKing Java 7 May 20th, 2008 10:58 AM
Special browser in Java (Project) stalefish Java 3 Feb 9th, 2008 4:22 PM
First Java Program duale2005 Java 3 May 22nd, 2006 5:17 PM
Java programmers, game developers, artists, be ware! RPG game team is recruiting! atcomputers.us Paid Job Offers 7 Sep 25th, 2005 7:25 PM
Begin my first lesson to learn Java satimis Java 7 Mar 3rd, 2005 2:45 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:16 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC