Hi, I have the following question:
If I encrypted some text with the public key K, and tried to decrypt it
with a wrong key (i.e. a key which is NOT the corresponding private
key), will I get an exception, or is there is a boolean function to
test whether the right key has been used?
|
|
0
|
|
|
|
Reply
|
tmuldner (10)
|
10/28/2005 8:13:41 PM |
|
solid wrote:
> Hi, I have the following question:
> If I encrypted some text with the public key K, and tried to decrypt it
> with a wrong key (i.e. a key which is NOT the corresponding private
> key), will I get an exception, or is there is a boolean function to
> test whether the right key has been used?
If the encryption with the public key was done with a proper padding
method, e.g. OAEP, the decryption will fail if you use the wrong private
key.
--Mike Amling
|
|
0
|
|
|
|
Reply
|
Mike
|
10/28/2005 11:41:11 PM
|
|
By "fail" what do you mean? Exception?
And, is it using Java cryptography API?
|
|
0
|
|
|
|
Reply
|
solid
|
10/29/2005 3:53:45 AM
|
|
Hi,
There's no boolean function available in the JCE framework to tell if
the given private key is the correct one.
If your 'Cipher' instance was correctly initialised, then it will throw
either an 'IllegalBlockSizeException' or a 'BadPaddingException' during
the call of method 'doFinal()' if the wrong key was given (or if the
given encrypted data is invalid). Please note that 'doFinal' might, in
rare occasions, not throw an exception and return garbled data for
unmatched keys, but it depends on the algorithm and padding used. If
you stumble into this situation you'll probably notice it anyway since
you won't be able to interpret the decrypted information.
Regards,
Tommy Gr=E4ndefors
www.pheox.com
solid wrote:
> By "fail" what do you mean? Exception?
> And, is it using Java cryptography API?
|
|
0
|
|
|
|
Reply
|
iso
|
10/29/2005 7:05:09 PM
|
|
solid wrote:
> By "fail" what do you mean? Exception?
> And, is it using Java cryptography API?
You need to know what padding method you used to encrypt "some text
with the public key". I don't know if you're using OAEP, or another good
padding method (e.g. SAEP+), or not. If you used no padding, then you do
not have secure encryption. If you used a good padding method, and you
supply an incorrect private key, you may get an Exception or a null
object, but if you get back some text, it will be your original text.
The OAEP paper is at http://www-cse.ucsd.edu/users/mihir/papers/oae.pdf.
--Mike Amling
|
|
0
|
|
|
|
Reply
|
Mike
|
10/31/2005 6:18:34 PM
|
|
|
4 Replies
261 Views
(page loaded in 1.147 seconds)
Similiar Articles: public and private key pair in Java - comp.lang.java.security ...Hi, I have the following question: If I encrypted some text with the public key K, and tried to decrypt it with a wrong key (i.e. a key which is NOT t... XML Public/Private Keys - comp.lang.java.securitypublic and private key pair in Java - comp.lang.java.security ... XML Public/Private Keys - comp.lang.java.security I need to create a very simple application whick ... key pair created with DSA, want CSR in RSA - comp.lang.java ...Hi, I generated a public/private keypair using keytool (j2sdk1.4.2_04 on Windows NT): keytool -genkey -alias -keypass -keystore .keystore As I've... Verification of digital signature, generated on .NET platform ...I have applied the base64 decoding to the public & private keys. As a result I succeed to create & verify the signature in my Java application using the keys pair ... Xml signature and pkcs#7 - comp.lang.java.securitypublic and private key pair in Java - comp.lang.java.security ... XML Public/Private Keys - comp.lang.java.security ... As a result I succeed to create & verify the ... Why a invalid keystore format exception? - comp.lang.java.security ...public and private key pair in Java - comp.lang.java.security ..... the corresponding private key), will I get an exception ... key was given (or if the given encrypted ... Convert pgp public key to java object - comp.lang.java.security ...Generate Public and Private Keys (The Java ... the Encoded Public Key Bytes ... (Its corresponding public key will be needed ... The first step is to get a key-pair ... How Java work with PKCS12? - comp.lang.java.securityHi, I'm a beginner of Java security. Is it possible to get Public Key and Private Key from a PKCS12 certificate by Java program? How can I do it? Is t... Extracting RSA Private Key - comp.lang.java.securityXML Public/Private Keys - comp.lang.java.security Extracting RSA Private Key - comp.lang.java.security XML Public/Private Keys - comp.lang.java.security Getting rsa key ... Importing private key from PKCS#8 file format - comp.lang.java ...hi, for the client authentication process, i have generated my own private key and public key using openssl. i have also converted the private key t... public and private key pair in Java - comp.lang.java.security ...Hi, I have the following question: If I encrypted some text with the public key K, and tried to decrypt it with a wrong key (i.e. a key which is NOT t... Generate Public and Private Keys (The Java™ Tutorials > Security ...Trail: Security Features in Java SE Lesson: Generating and ... In some cases the key pair (private key and corresponding public key) are already available in files. 7/23/2012 7:13:27 PM
|