devencdiskutils/DevEncCommonUtils/src/DevEncKeyUtils.cpp
branchRCL_3
changeset 9 a005fc61b02a
parent 0 164170e6151a
child 11 9971b621ef6c
equal deleted inserted replaced
8:ece4bbb094df 9:a005fc61b02a
    22 #include "DevEncDef.h"
    22 #include "DevEncDef.h"
    23 #include "DevEncKeyUtils.h"
    23 #include "DevEncKeyUtils.h"
    24 #include "DevEncLog.h"
    24 #include "DevEncLog.h"
    25 #include "DevEncUids.hrh"
    25 #include "DevEncUids.hrh"
    26 
    26 
       
    27 
    27 #include <pbe.h>
    28 #include <pbe.h>
    28 #include <pbedata.h>
    29 #include <pbedata.h>
    29 //#include <PathInfo.h> // for system path literals
    30 //#include <PathInfo.h> // for system path literals
    30 #include <pkcs5kdf.h>
    31 #include <pkcs5kdf.h>
    31 #include <s32file.h>
    32 #include <s32file.h>
    32 #include <s32mem.h>
    33 #include <s32mem.h>
    33 #include <imcvcodc.h>
    34 #include <tconvbase64.h>
    34 
    35 
    35 #include <DevEncEngineConstants.h>
    36 #include <DevEncEngineConstants.h>
    36 #include <DevEncEngineBase.h>
    37 #include <DevEncEngineBase.h>
    37 
    38 
    38 // --------------------------------------------------------------------------
    39 // --------------------------------------------------------------------------
   271     
   272     
   272     // Encode key to base64 before returning it
   273     // Encode key to base64 before returning it
   273     aResult = HBufC8::NewL( resultPtr.Length()*4/3+3 );
   274     aResult = HBufC8::NewL( resultPtr.Length()*4/3+3 );
   274     TPtr8 returnPtr = aResult->Des();
   275     TPtr8 returnPtr = aResult->Des();
   275     returnPtr.SetLength( 0 );
   276     returnPtr.SetLength( 0 );
   276     TImCodecB64 b64codec;
   277     TBase64 b64codec;
   277     b64codec.Initialise();
       
   278     b64codec.Encode( *result, returnPtr );
   278     b64codec.Encode( *result, returnPtr );
   279     
   279     
   280     // Destroy the evidence
   280     // Destroy the evidence
   281     CleanupStack::PopAndDestroy( result );
   281     CleanupStack::PopAndDestroy( result );
   282     CleanupStack::PopAndDestroy( ciphertextTemp );
   282     CleanupStack::PopAndDestroy( ciphertextTemp );
   318     {
   318     {
   319     // Decode the base64 encoded key
   319     // Decode the base64 encoded key
   320     HBufC8* decodedKey = HBufC8::NewLC( aPkcs5Key.Length()*3/4 );
   320     HBufC8* decodedKey = HBufC8::NewLC( aPkcs5Key.Length()*3/4 );
   321     TPtr8 keyPtr = decodedKey->Des();
   321     TPtr8 keyPtr = decodedKey->Des();
   322     keyPtr.SetLength( 0 );
   322     keyPtr.SetLength( 0 );
   323     TImCodecB64 b64codec;
   323     TBase64 b64codec;
   324     b64codec.Initialise();
       
   325     b64codec.Decode( aPkcs5Key, keyPtr );
   324     b64codec.Decode( aPkcs5Key, keyPtr );
   326 
   325 
   327     // Read the parameters and ciphertext from the input
   326     // Read the parameters and ciphertext from the input
   328     CPBEncryptElement* encryption( NULL );
   327     CPBEncryptElement* encryption( NULL );
   329     HBufC8* ciphertext( NULL );
   328     HBufC8* ciphertext( NULL );