Wrox Programmer Forums
|
BOOK: Beginning Cryptography with Java
This is the forum to discuss the Wrox book Beginning Cryptography with Java by David Hook; ISBN: 9780764596339
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Cryptography with Java section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 21st, 2010, 02:27 PM
Registered User
 
Join Date: Nov 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default El Gamal Encryption

Hello,

I am using Bouncy Castle's implementation of El Gamal to encrypt messages. I am trying to encrypt the same message twice. i.e., encrypt the encryption of a message. The issue I encounter is that the length of the plaintext can be at most keyLength-1, while the length of the message I have after the first encryption round is keyLength (not taking into acount the part of the cipher correcsponding to G^xy). What is the reason for that? The El Gamal cryptosystem is semantically secure, therefore, it is not required to add random values to prevent the situation where the same plaintext results in the same cipher text. Can I control the length of the input and set it to maximum of keyLength? Are there providers who implemented El Gamal with maximum plain text for encryption equal to keyLength? Do you have any other suggestions on how to go about encrypting the encryption of a message?
Thank you in advance,

Shay
 
Old November 21st, 2010, 07:25 PM
dgh dgh is offline
Wrox Author
 
Join Date: Aug 2005
Posts: 206
Thanks: 0
Thanked 20 Times in 20 Posts
Default

The BC API is currently set up to report safe lengths, strictly speaking the message can be any number up to p - 1. You should find that you can feed in a message that size though without an exception been raised as the API is also set up to allow you to ignore the maximum if you really know what you're doing.

Let me know if this fails to work.

Regards,

David
 
Old April 11th, 2011, 08:40 AM
Registered User
 
Join Date: Apr 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default hi reg elgamal encryption in java jce

Can you please tell how to encrypt string using elgamal in Bouncy Castle .
 
Old April 11th, 2011, 06:32 PM
dgh dgh is offline
Wrox Author
 
Join Date: Aug 2005
Posts: 206
Thanks: 0
Thanked 20 Times in 20 Posts
Default

ElGamal is really only designed for encrypting keys - you could encrypt a string if it was very short, however the recommended approach is to encrypt the data using a symmetric key, and then encrypt the symmetric key using ElGamal.

Bare in mind as well that with Java encrypting string data needs to take into account the available encodings on both the sending and receiving platform, it's often better just to process char arrays.

Regards,

David





Similar Threads
Thread Thread Starter Forum Replies Last Post
JSP2 EL / JSTL ignored ronMasters BOOK: Beginning JavaServer Pages 2 November 6th, 2008 07:09 AM
Problem with EL in JSP IronStar JSP Basics 1 January 31st, 2007 11:54 PM
EL Syntax error savoym JSP Basics 0 November 2nd, 2006 04:48 PM
About EL motofree Java Basics 0 March 1st, 2006 05:07 AM
JSP2 EL/JSTL being ignored ronMasters JSP Basics 0 February 23rd, 2006 07:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.