×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Nokia Developer Champion
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Encryption problem

    Using TPKCS5KDF:eriveKeyL to convert a password into a key (well, actually an IV, but same difference). Following code:
    Code:
      TPtrC8 inputKey(ctx ->key, ctx ->key_sz);
      TPtr8 resultIv(iv, ctx ->iv_sz);
      TBuf8<16> salt(16);
      for (int i = 0; i < 16; i++) {
    	salt[i] = (pgno * i * 127) % 255;  // No theory -- just seems reasonably random
      }
      TUint iterations = 100;  // 1000 is normal default, but we're not that paranoid
      TPKCS5KDF::DeriveKeyL(resultIv, inputKey, salt, iterations);
    Looking at the values going in, inputKey has a length of 32, resultIv has a length of 16, salt has a length of 16.

    Coming out, resultIv is unchanged. Why?

  2. #2
    Nokia Developer Champion
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Encryption problem

    Duh!! I guess I need that 3rd parm on the TPtr8 constructor, eh?

  3. #3
    Nokia Developer Champion
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Encryption problem

    OK, but now I'm at a loss as to why this gets a crypto.dll 1:
    Code:
    	CAESEncryptor* cipher = CAESEncryptor::NewL(inputKey);
    	CModeCBCEncryptor* ectx = CModeCBCEncryptor::NewL(cipher, resultIv);
    	TBuf8<1024> test(1024);
    	for (int j = 0; j < 1024; j++) {
    	        test[j] = j + 1;
    	}
    	ectx ->Transform(test);
    crypto.dll 1 is, of course, "The supplied descriptor is not large enough to store the output of the cryptographic operation". (Key length is 32, block length 16.)

  4. #4
    Nokia Developer Champion
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Encryption problem

    OK, RTFM -- buffer size must == block size. I guess you're expected to chunk through the buffer yourself, eh? Not entirely clear what function the class is really providing, but I guess it does carry along the IV (though there's nothing to really give you confidence of that).

Similar Threads

  1. Problem with CAknDoubleStyleListBox with a CAknSearchField
    By jjig in forum Symbian User Interface
    Replies: 2
    Last Post: 2009-09-17, 00:58
  2. SyncML link problem
    By samuel_ in forum Symbian
    Replies: 4
    Last Post: 2009-03-27, 08:02
  3. Problem with eglSwapBuffers and heap corruption
    By greatape in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2007-05-24, 03:35
  4. netcards - Problem with opening adapter
    By kernj in forum Symbian Tools & SDKs
    Replies: 5
    Last Post: 2007-01-10, 08:56
  5. Problem: S60 SDK for CW in PC with .NET
    By anttij in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 1
    Last Post: 2005-02-28, 11:36

Posting Permissions

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