×

Discussion Board

Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 42

Thread: System error !!

  1. #16
    Registered User
    Join Date
    Sep 2011
    Posts
    203

    Re: System error !!

    Hi pavarang.
    yes i can use PKCS7/PKCS5 instead but in server side AES, ISO10126d2Padding implementation is there so i have to use this kind of padding
    in my application to decrypt data which is Encrypted in JAVA.
    these are the padding options availble in JAVA
    Paddings available (http://www.bouncycastle.org/docs/doc...Padding.html):
    * - ISO10126d2Padding
    * - ISO7816d4Padding
    * - PKCS7Padding
    * - TBCPadding
    * - X923Padding
    * - ZeroBytePadding
    and in symbian Cryptolib i found out these padding options. anybody tel me other options which i left?
    CPaddingNone
    CPaddingPKCS1Signature
    CPaddingPKCS1Encryption
    CPaddingSSLv3
    CPaddingPKCS7
    is there any other method i can follow to decrypt?

  2. #17
    Registered User
    Join Date
    Jan 2005
    Location
    Italy
    Posts
    639

    Re: System error !!

    Hi,
    assuming the problem is only in padding, i've read ISO 10126 padding resume from:
    http://en.wikipedia.org/wiki/Padding_%28cryptography%29
    (it's reported as withdrawn, but if your server is happy with it....)
    maybe you could try to set CPaddingNone in Symbian, decrypt, then read the last byte and discard the number of bytes at the end matching the value in the last byte

  3. #18
    Registered User
    Join Date
    Sep 2011
    Posts
    203

    Re: System error !!

    I tried with CPaddingNone but after decrypting this
    f118404f2b7d98a744d2fa24c0d21167
    got this vaue
    \x02¬rð+i¾üo]IÇÒþ¯\x1D
    which part i have to discard?

  4. #19
    Registered User
    Join Date
    Jan 2005
    Location
    Italy
    Posts
    639

    Re: System error !!

    i think padding is just a way to add data to obtain fixed size (blocks) of data on which to apply the crypt algorithm; if you are sure you are using the same crypt algorithm for encryption and decryption, just consider the decryption result as an array of bytes, look at the last byte, it contains a value, that value is the number of bytes you have to discard at the end of the byte array, or, at least, this is ISO 10126 as described here:
    http://en.wikipedia.org/wiki/Padding_%28cryptography%29
    but feel free to use/search other info about it, of course :-)

  5. #20
    Registered User
    Join Date
    Sep 2011
    Posts
    203

    Re: System error !!

    Thanks Pavarang.Now I am able to decrypt with CPaddingNone option which is encrpted in ISO 10126
    but if i try to decrypt long string then only starting 16bytes is decrypted after that got like this
    the padding shou\x04íÒ\x7FjZ߀ˆÍ}f±ºi\x1D·Ê\x1AøÍ&ï¢Hßù۝sæl\f
    \x18\x10ýÃmZû“\x15ÂþýX\t$>ž ...
    i tried but dint able to find out where i am doing mistake
    Code:
    _LIT8(aA,"6889f21d0f7abbefe6a85d079aacf7d9df4978d9ae3a97ab069bca29e9ff95baee07c60e60777396e31a338ffb35b09f933c66491efc394a03699ea466c9f8ca1cb12af932caae1b72ea45f1f3424ed7");
                HBufC8* str = HexToBufLC(aA);
                TPtr8 str1(str->Des());
                TInt strlen = str1.Size();
                
                //CPaddingNone* encryptPadding1 = CPaddingNone::NewL(16);   
                CPaddingNone* encryptPadding1 = CPaddingNone::NewL(strlen);   
                CAESEncryptor* aesEncryptor1 = CAESEncryptor::NewL(Key);	
                CBufferedEncryptor* bufEncryptor1  = CBufferedEncryptor::NewL(aesEncryptor1, encryptPadding1);        
                HBufC8* encryptData1 = HBufC8::NewLC(bufEncryptor1->MaxFinalOutputLength(strlen));			 
                TPtr8 encryptDataPtr1 = encryptData1->Des();
                encryptDataPtr1.Copy(str1);
                
                //Initializing the encrytor and padding objects
                CPaddingNone* decryptPadding = CPaddingNone::NewL(strlen);                      //WRONG VALUE     
                //CPaddingNone* decryptPadding = CPaddingNone::NewL(16);                      //WRONG VALUE                
                //CPaddingSSLv3* decryptPadding = CPaddingSSLv3::NewL(strlen);                 //INVALID PADDING    
                //CPaddingPKCS1Signature* decryptPadding = CPaddingPKCS1Signature::NewL(16);    //WRONG VALUE     
                //CPaddingPKCS1Encryption* decryptPadding = CPaddingPKCS1Encryption::NewL(16);  //INVALID PADDING 
                //CPaddingPKCS7* decryptPadding = CPaddingPKCS7::NewL(16);                      //INVALID PADDING 
    
                CAESDecryptor* aesDecryptor = CAESDecryptor::NewL(Key);	                
                CBufferedDecryptor* bufDecryptor = CBufferedDecryptor::NewL(aesDecryptor, decryptPadding);
                TInt decrypterlen= encryptDataPtr1.Size();
                HBufC8* decryptedText = HBufC8::NewLC(bufDecryptor->MaxFinalOutputLength(decrypterlen));			 
                //HBufC8* decryptedText = HBufC8::NewLC(bufDecryptor->MaxFinalOutputLength(256));			 
                TPtr8 decryptedTextPtr = decryptedText->Des();
                TInt Err=KErrNone;
                TRAP(Err,bufDecryptor->ProcessFinalL(encryptDataPtr1,decryptedTextPtr));
    Last edited by please_help; 2012-04-04 at 12:30.

  6. #21
    Registered User
    Join Date
    Jan 2005
    Location
    Italy
    Posts
    639

    Re: System error !!

    hmmm... have no idea either :-)
    you could try to extract some ideas/info from this old post:
    http://www.developer.nokia.com/Commu...pahy-libraries
    and maybe you could also try to encrypt in Symbian the same string that is encrypted by server and see if and where they differ....

  7. #22
    Registered User
    Join Date
    Sep 2011
    Posts
    203

    Re: System error !!

    6889f21d0f7abbefe6a85d079aacf7d9df4978d9ae3a97ab069bca29e9ff95baee07c60e60777396e31a338ffb35b09f933c66491efc394a03699ea466c9f8ca1cb12af932caae1b72ea45f1f3424ed7
    it is not possible to decrypt this entire value?
    anybody have idea on this. please reply.

  8. #23
    Registered User
    Join Date
    Sep 2011
    Posts
    203

    Re: System error !!

    Quote Originally Posted by pavarang View Post
    you could also try to encrypt in Symbian the same string that is encrypted by server and see if and where they differ....
    i tried in symbian with the same string i can encrypt and decrypt it completely.
    but the server encrypted data i am able to decrypt in symbian only 16bytes.

  9. #24
    Registered User
    Join Date
    Jan 2005
    Location
    Italy
    Posts
    639

    Re: System error !!

    Quote Originally Posted by please_help View Post
    i tried in symbian with the same string i can encrypt and decrypt it completely.
    but the server encrypted data i am able to decrypt in symbian only 16bytes.
    and have you also compared the two encrypted buffers (the Symbian one and the server one) ? do they differ (i suppose yes)? and where? maybe this could give a hint...
    regards
    pg

  10. #25
    Registered User
    Join Date
    Sep 2011
    Posts
    203

    Re: System error !!

    Quote Originally Posted by pavarang View Post
    and have you also compared the two encrypted buffers (the Symbian one and the server one) ? do they differ (i suppose yes)? and where? maybe this could give a hint...
    Encrypted values
    symbian SSLV3 : h‰ò\x1D\x0Fz»ïæ¨]\aš¬÷ÙçÖH ¼‰sBï¼x,ã¬Y~ß=쮟\x11Gö<1\x13ê*\'M‚+Œ&N
    \"Æeñºl_´ÜªáAŽh¯€\x19–\x1 ...
    JAVA : h‰ò\x1D\x0Fz»ïæ¨]\aš¬÷ÙßIxÙ®:—«\x06›Ê)éÿ•ºî\aÆ\x0E`ws–ã\x1A\x33û5°Ÿ“<fI\x1Eü9J\x03iž¤fÉøÊ\x1C
    ±*ù ...
    Symbian decry :the padding shou\x04íÒ\x7FjZ߀ˆÍ}f±ºi\x1D·Ê\x1AøÍ&ï¢Hßù۝sæl\f
    \x18\x10ýÃmZû“\x15ÂþýX\t$>ž ...
    yes you are right, only starting 16bytes is same after that it differs so from there getting wrong value.
    when encrypted value only is not same so obviously when i decrypt i wont get exact value so the mode which
    is used in JAVA and symbian is different means again padding problem right?

  11. #26
    Registered User
    Join Date
    Jan 2005
    Location
    Italy
    Posts
    639

    Re: System error !!

    I don't think it's a padding problem, most probably is about encryption algorithm.
    You could try with CBC decryption:

    Code:
    CBlockTransformation* aesDecr = CAESDecryptor::NewL(keyPtr);
    CModeCBCDecryptor* cbcMode = CModeCBCDecryptor::NewL(aesDecr, iv);
    CPadding* padding = CPaddingNone::NewL(aesDecr->BlockSize());
    CBufferedDecryptor* bufDecryptor = CBufferedDecryptor::NewLC(cbcMode, padding);
    HBufC8* plain = HBufC8::NewLC(bufDecryptor->MaxFinalOutputLength(encryptedData.Length()));
    TPtr8 plainPtr = plain->Des();
    bufDecryptor->ProcessFinalL(encryptedData, plainPtr);
    you should try to understand what value is best for iv, usually is zeroed 16 bytes array

    at the moment, i don't have any other suggestion,
    regards
    pg

  12. #27
    Registered User
    Join Date
    Sep 2011
    Posts
    203

    Re: System error !!

    yes i tried this method also from this link which you suggested me yesterday but same result

    anybody else have suggestions to solve this problem?

  13. #28
    Registered User
    Join Date
    Sep 2011
    Posts
    203

    Re: crypto.dll 1 panic with AES CModeCBCDecryptor

    Quote Originally Posted by pavarang View Post
    I don't think it's a padding problem, most probably is about encryption algorithm.
    You could try with CBC decryption:

    Code:
    CBlockTransformation* aesDecr = CAESDecryptor::NewL(keyPtr);
    CModeCBCDecryptor* cbcMode = CModeCBCDecryptor::NewL(aesDecr, iv);
    CPadding* padding = CPaddingNone::NewL(aesDecr->BlockSize());
    CBufferedDecryptor* bufDecryptor = CBufferedDecryptor::NewLC(cbcMode, padding);
    HBufC8* plain = HBufC8::NewLC(bufDecryptor->MaxFinalOutputLength(encryptedData.Length()));
    TPtr8 plainPtr = plain->Des();
    bufDecryptor->ProcessFinalL(encryptedData, plainPtr);
    still I am not able to solve this problem. I was wrong i am not able to use CModeCBCDecryptor mode, getting crypto.dll 1 panic.without CModeCBCDecryptor it works with CAESDecryptor but same result only starting 16bytes is correct.


    Code:
          
                _LIT8(aA,"6889f21d0f7abbefe6a85d079aacf7d9df4978d9ae3a97ab069bca29e9ff95baee07c60e60777396e31a338ffb35b09f933c66491efc394a03699ea466c9f8ca1cb12af932caae1b72ea45f1f3424ed7");
                HBufC8* str = HexToBufLC(aA);
                TPtr8 str1(str->Des());
                TInt strlen = str1.Size();
                encryptDataPtr.Copy(str1); 
      
               HBufC8* CBCencryptData = HBufC8::NewLC(bufEncryptor->MaxFinalOutputLength(strlen));			 
                TPtr8 CBCencryptDataPtr = CBCencryptData->Des();
                //CBCencryptDataPtr.Copy(encryptDataPtr);
                CBCencryptDataPtr.Copy(str1);
    
                //CBlockTransformation* aesDecr = CAESDecryptor::NewL(Key);
                CAESDecryptor* aesDecr = CAESDecryptor::NewL(Key);                    //method
                _LIT8(aIv,"16");
                TInt iv = aesDecr->BlockSize();
                CModeCBCDecryptor* cbcMode = CModeCBCDecryptor::NewL(aesDecr, aIv);   //mode
                CPadding* padding = CPaddingNone::NewL(aesDecr->BlockSize());         //padding
                //CPaddingPKCS7* padding = CPaddingPKCS7::NewL(aesDecr->BlockSize());
    
                //CBufferedDecryptor* bufDecryptor = CBufferedDecryptor::NewLC(cbcMode, padding);
                CBufferedDecryptor* bufDecryptor = CBufferedDecryptor::NewLC(aesDecr, padding);
    
                HBufC8* CBCPlain = HBufC8::NewLC(bufDecryptor->MaxFinalOutputLength(CBCencryptDataPtr.Length()));
                //HBufC8* CBCPlain = HBufC8::NewLC(bufEncryptor->MaxFinalOutputLength(255));			 
                TPtr8 CBCPlainPtr = CBCPlain->Des();
                
                TInt Err = KErrNone;
                TRAP(Err,bufDecryptor->ProcessFinalL(CBCencryptDataPtr, CBCPlainPtr));  <--crypto.dll 1 panic
                
                AESplainText.Copy(CBCPlainPtr);
                AEStext.Format(_L("Decrypted text:\n%S"), &AESplainText);
                iAppView->LogPrintL(AEStext);
    
    HBufC8 * CExampleStubAppUi::HexToBufLC(const TDesC8 &aDes)
    {
        HBufC8* buf = HBufC8::NewLC(aDes.Length()/2);
        for(TInt i=0; i < aDes.Length();i = i+2)
        {
            TLex8 lex(aDes.Mid(i,2));
            TUint8 val;
            lex.Val(val,EHex);
            buf->Des().Append(val);
        }
        return buf;
    }
    i found out thiswith the same.

    anybody help me to solve this... thank you.

  14. #29
    Registered User
    Join Date
    Jan 2005
    Location
    Italy
    Posts
    639

    Re: crypto.dll 1 panic with AES CModeCBCDecryptor

    Hello,
    one of the possible reasons for a panic in ProcessFinalL is that the length of data is not a multiple of BlockSize().

    That said, I've retrieved from my old code two samples using CBC, they were working fine but don't take them as Bible :-) You can adapt the padding to your needs.

    Code snippet n.1:

    Code:
    HBufC8* AES::EncryptPkcs5L(const TDesC8& plainData, const TDesC8& iv, const TDesC8& key)
    	{
    	// takes in consideration only the first 16bytes of the key
    	TPtrC8 keyPtr = key.Left(key.Length());
    	if (key.Length() > 16)
    		keyPtr.Set( key.Left(16) );
    	CBlockTransformation* aesEncr = CAESEncryptor::NewL(keyPtr);
    	CModeCBCEncryptor* cbcMode = CModeCBCEncryptor::NewL(aesEncr, iv);
    	CPadding* padding = CPaddingNone::NewL(aesEncr->BlockSize());
    	CBufferedEncryptor* bufEncryptor = CBufferedEncryptor::NewLC(cbcMode, padding);
    
    	// Data Length must be multiple of BlockSize() or the ProcessFinalL() will raise a Panic()
    	// Add Padding PKCS5
    	TInt8 paddedLen = 16 - (plainData.Length() % 16);
    	RBuf8 paddedPlainData;
    	paddedPlainData.CleanupClosePushL();
    	TInt err = paddedPlainData.Create(paddedLen + plainData.Length());
    	if(err == KErrNoMemory)  
    		{
    		CleanupStack::PopAndDestroy(&paddedPlainData);
    		CleanupStack::PopAndDestroy(bufEncryptor);
    		HBufC8* emptyBuf = HBufC8::NewL(0);
    		return emptyBuf;
    		}
    	paddedPlainData.Copy(plainData);
    	paddedPlainData.AppendFill(paddedLen,paddedLen);
    
    	TInt maxOutputSize = bufEncryptor->MaxFinalOutputLength(paddedPlainData.Size());
    	HBufC8* encryptedData=NULL;
    	TRAPD(error, (encryptedData = HBufC8::NewL(maxOutputSize)));
    	if(error == KErrNoMemory)
    		{
    		CleanupStack::PopAndDestroy(&paddedPlainData);
    		CleanupStack::PopAndDestroy(bufEncryptor);
    		HBufC8* emptyBuf = HBufC8::NewL(0);
    		return emptyBuf;
    		}
    	CleanupStack::PushL(encryptedData);
    	TPtr8 encryptedPtr = encryptedData->Des();
    	bufEncryptor->ProcessFinalL(paddedPlainData, encryptedPtr);
    	CleanupStack::Pop(encryptedData);
    	CleanupStack::PopAndDestroy(&paddedPlainData);
    	CleanupStack::PopAndDestroy(bufEncryptor);
    
    	return encryptedData;
    	}

    code snippet n. 2

    Code:
    HBufC8* AES::DecryptPkcs5L(const TDesC8& encryptedData, const TDesC8& iv, const TDesC8& key)
    	{
    		if(encryptedData.Size() == 0)
    			return HBufC8::NewL(0);
    		// takes in consideration only the first 16bytes of the key
    		TPtrC8 keyPtr = key.Left(key.Length());
    		if (key.Length() > 16)
    			keyPtr.Set( key.Left(16) );
    		CBlockTransformation* aesDecr = CAESDecryptor::NewL(keyPtr);
    		CModeCBCDecryptor* cbcMode = CModeCBCDecryptor::NewL(aesDecr, iv);
    		CPadding* padding = CPaddingNone::NewL(aesDecr->BlockSize());
    		CBufferedDecryptor* bufDecryptor = CBufferedDecryptor::NewLC(cbcMode, padding);
    		
    		// Data Length must be multiple of BlockSize() or the ProcessFinalL() will raise a Panic()
    		ASSERT( encryptedData.Length() % aesDecr->BlockSize() == 0);
    		if (encryptedData.Length() % aesDecr->BlockSize() != 0)
    			{
    			CleanupStack::PopAndDestroy(bufDecryptor);
    			return HBufC8::NewL(0);
    			}
    
    		HBufC8* plain = HBufC8::NewLC(bufDecryptor->MaxFinalOutputLength(encryptedData.Length()));
    		TPtr8 plainPtr = plain->Des();
    		bufDecryptor->ProcessFinalL(encryptedData, plainPtr);
    		
    		// remove PKCS5 padding
    		TUint8 paddedLen;
    		Mem::Copy(&paddedLen,plain->Right(1).Ptr(),1);
    		plain->Des().SetLength(plain->Size()-paddedLen);
    		
    		CleanupStack::Pop(plain);
    		CleanupStack::PopAndDestroy(bufDecryptor);
    		return plain;
    	}
    Some things you could try:
    1. try to understand the exact encryption algorithm used by your server, not only the padding
    2. try to reproduce it using encryption method (code snippet n.1 ) until you obtain the same byte array given by your server
    3. if you succeed with previous item, you should be able to modify code snippet n.2 to decrypt

    hope it helps somehow
    good luck!
    pg

    ps: as a last try: if you have a Symbian3 device or sdk try to use its encryption library, if it works, then take a look at symbian sources available on SourceForge site
    Last edited by pavarang; 2012-04-24 at 13:15. Reason: adding info

  15. #30
    Registered User
    Join Date
    Sep 2011
    Posts
    203

    Re: crypto.dll 1 panic with AES CModeCBCDecryptor

    Quote Originally Posted by pavarang View Post
    one of the possible reasons for a panic in ProcessFinalL is that the length of data is not a multiple of BlockSize().
    but i tried the code which you posted, there also getting crypto.dll:1 panic at the same line(ProcessFinalL). You have told that code is working fine then i think some thing is wrong from my side only bcs i tried in different ways but every where getting crypto.dll:1 panic at the same line .

    method 1:
    Code:
    _LIT8(KAESKey,"2020a7db17ca8071de72ef439405b570");
    HBufC8* KKey = HexToBufLC(KAESKey);
    TPtr8 Key(KKey->Des())
    _LIT8(i,"the padding");
    //_LIT8(i,"the padding should be done at the end of that last block with random bytes");
    AESEncryptL(Key,i);
    
    HBufC8* CExampleStubAppUi::AESEncryptL(const TDesC8& aKey, const TDesC8& aPlainText)
    {
    _LIT8(aIv,"16");
    
    CAESEncryptor* method = CAESEncryptor::NewL(aKey);
    
    TInt blocklen = method->BlockSize();
    TInt Keylen = method->KeySize();
    
    CModeCBCEncryptor* mode = CModeCBCEncryptor::NewL(method, aIv);
    CPadding* padding = CPaddingPKCS7::NewL(method->BlockSize());
    
    CBufferedEncryptor* bufEncryptor = CBufferedEncryptor::NewL(mode, padding);
    HBufC8* cipherText = HBufC8::NewL(bufEncryptor->MaxFinalOutputLength(aPlainText.Size()));
    //HBufC8* cipherText = HBufC8::NewL(bufEncryptor->MaxFinalOutputLength(255));
    
    TPtr8 cipherTextPtr = cipherText->Des();
    
    TRAPD(Err,bufEncryptor->ProcessFinalL(aPlainText,cipherTextPtr));
    
    if(Err)
    	{
    	
    	}
    
    return cipherText;
    }
    method2:
    #post 28

    In paul-todds-forum it's mentoned that
    the generic error "Panic crypto.dll 1" is a generic catchall panic code that is entirely useless as it is used in multiple places in the crypto library (Note to the Symbian Cryptogrpahy writers:
    We have numbered panic codes, please use them!).
    but i am not able to TRAP that also....
    if possible can anybody try to execute code and tel me where i am doing wrong?

Similar Threads

  1. Fatal: IO Error:SymbainOS error = -34 : General: System error
    By dharmeshkhatri in forum Mobile Java Networking & Messaging & Security
    Replies: 9
    Last Post: 2010-04-12, 15:17
  2. Replies: 3
    Last Post: 2009-05-18, 09:38
  3. running easydgm on simulator occur error:system error(-1)
    By mandysss in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2008-10-31, 05:46
  4. java.io.IOEXCEPTION: SymbianOS error = -33 : System error
    By hari_scjp in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2006-02-27, 13:38
  5. java.io.IOException: SymbianOS error = -28 : System error
    By raghuraman in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2004-10-21, 09:33

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×