This discussion is archived
1 2 Previous Next 20 Replies Latest reply: Sep 18, 2012 7:11 PM by EJP Go to original post RSS
  • 15. Re: How to decrypt entered value if Cipher outputsize is different.
    EJP Guru
    Currently Being Moderated
    That suggests that either the ciphertext iis incorrect, or the base64-encoding isn't correct, or it isn't arriving intact, or your Base64-decoding process is manging it. You can verify each of those separately and locally without using the network.

    And I am still waiting to hear why SSL isn't a better solution for you.
  • 16. Re: How to decrypt entered value if Cipher outputsize is different.
    sabre150 Expert
    Currently Being Moderated
    Ajay Sharma wrote:
    Hi..

    No it is not throwing an exception and Its not showing any results.

    When I put SOP statements after every method call in my decrypt method, as follow
    System.out.println("Decrypting Final");
    cipherText = cipher.doFinal(cipherText);
    System.out.println("Sending Cipher Text to Decrypt Method");
    Its printing "Decrypting Final " on server console. But not the statement after cipher.doFinal method.

    I think it getting stuck at doFinal method. but I am not getting the reason behind it.
    This suggests to me that the doFinal() method is throwing an exception. In this situation the most common exception I have seen is a BadPaddingException caused by a corruption of the ciphertext. This corruption is frequently caused by using a String to hold the ciphertext.

    P.S. It is just lazy to re-use 'cipherText' to hold the cleartext.
  • 17. Re: How to decrypt entered value if Cipher outputsize is different.
    Ajay Sharma Newbie
    Currently Being Moderated
    Hi..
    Sabre Wrote:
    
    This suggests to me that the doFinal() method is throwing an exception. 
    In this situation the most common exception I have seen is a BadPaddingException caused by a corruption of the ciphertext. 
    This corruption is frequently caused by using a String to hold the ciphertext.
    The decryption is not happening only in the case when I am passing a large encrypted value to decrypt method as string that too in web service.
    In other cases its working fine. The same code is working perfectly in class with main method for large encrypted values.



    Regards,
    Ajay

    Edited by: Ajay Sharma on Sep 18, 2012 2:53 PM
  • 18. Re: How to decrypt entered value if Cipher outputsize is different.
    EJP Guru
    Currently Being Moderated
    You keep evading the issue. It strongly appears that doFinal() is throwing an exception that you are not aware of. Investigate that.

    Investigate running the entire thing in a single program in a single JVM with the large data that is failing.

    Investigate whether you are enciphering correctly.

    Investigate whether you encoding correctly.

    Investigate whether you are transmitting correctly. I note that you haven't ever posted this code.

    Investigate whether you are receiving correctly. I note that you haven't ever posted this code.

    Investigate whether you are decoding correctly.

    Investigate whether you are decrypting correctly.

    You've been told all this before.
  • 19. Re: How to decrypt entered value if Cipher outputsize is different.
    Ajay Sharma Newbie
    Currently Being Moderated
    Hi EJP,

    You Wrote
    You keep evading the issue. It strongly appears that doFinal() is throwing an exception that you are not aware of. Investigate that.
    
    Investigate running the entire thing in a single program in a single JVM with the large data that is failing.
    
    Investigate whether you are enciphering correctly.
    
    Investigate whether you encoding correctly.
    
    Investigate whether you are transmitting correctly. I note that you haven't ever posted this code.
    
    Investigate whether you are receiving correctly. I note that you haven't ever posted this code.
    
    Investigate whether you are decoding correctly.
    
    Investigate whether you are decrypting correctly.
    
    You've been told all this before.
    I already told you that I tested this code in normal java class which contains
    public static void main() //metod
    Here is my that class's main method code.
      public static void main(String[] args) throws Exception{
        
            
            AESEncrption128 aESEncrption128 = new AESEncrption128();
            String actualString = "Here i am passing a string that not decrypting in Web Service";
                        
            String encyptedString = aESEncrption128.encrypt(actualString, "testingKey");
            
            System.out.println("Encrypted String in MAin method = "+encyptedString);
            System.out.println("Encrypted string length = "+ encyptedString.length());
            System.out.println("Length remaining = "+ ((encyptedString.length()%16)));
            
            /*String decryptedString = aESEncrption128.decrypt("VOkHipDi4IORU20Nw3k9soCuhr0WPrGSWckbDVJw6oK0GZuESMwgHaHnxwO1XmVFPV34cQNHOsRN0ah4DRu1FDUgy3cNtai3rNfGnq+WjcLXAC19TG6dVqXr4eV3BPkpTnzzMYb0cyMjdDPSR0QpDg==", "testingKey");*/
    
             String decryptedString = aESEncrption128.decrypt(encyptedString, "testapp.onwardinfosys.com");
            
            System.out.println("Decrypted String in MAin method = "+decryptedString);
     
        }
    for AES Encryption Decryption i used following variables
        private final String characterEncoding = "UTF-8";
        private final String cipherTransformation = "AES/CBC/PKCS5Padding";
        private final String aesEncryptionAlgorithm = "AES";
    The code for encrypt and decrypt method is same as i posted earlier in this thread . It's working fine. No Error no Exception.

    Even if instead of passing variable encyptedString to decrypt method if i passed value of this string as :-
    String decryptedString = aESEncrption128.decrypt("VOkHipDi4IORU20Nw3k9soCuhr0WPrGSWckbDVJw6oK0GZuESMwgHaHnxwO1XmVFPV34cQNHOsRN0ah4DRu1FDUgy3cNtai3rNfGnq+WjcLXAC19TG6dVqXr4eV3BPkpTnzzMYb0cyMjdDPSR0QpDg==", "testingKey");
    its working.

    Now, you tell EJP (The Guru) is there any thing else I need to test or change.
    and please try to understand that Its an error which is not getting solved by me (a new java programmer ), so I am posting here..
    So please do not block the thread. Its a strange problem.


    Thanks and Regards,
    Ajay Sharma

    Edited by: Ajay Sharma on Sep 18, 2012 5:09 PM
  • 20. Re: How to decrypt entered value if Cipher outputsize is different.
    EJP Guru
    Currently Being Moderated
    I may or may not be a Guru but even the goddess Kali cannot reach her ten arms through the Internet to the keyboard of your computer and investigate for you the seven things I suggested you investigate. You have to do it yourself. Posting your code over and over again is not investigation, and repeatedly evading questions like how is the data transmitted and why aren't you using SSL doesn't get us anywhere either.

    I will give you one hint. This statement:
    It's working fine. No Error no Exception.
    is definitely untrue, for reasons which you were given last week.
1 2 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points