pkiutilities/PKCS12/CrPkcs12/Src/crpkcs12.cpp
branchRCL_3
changeset 5 3b17fc5c9564
parent 0 164170e6151a
equal deleted inserted replaced
1:d5423fbb4f29 5:3b17fc5c9564
     1 /*
     1 /*
     2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2004, 2010 Nokia Corporation and/or its subsidiary(-ies). 
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
  1128                 {
  1128                 {
  1129                 stop = ETrue;
  1129                 stop = ETrue;
  1130                 }
  1130                 }
  1131             }
  1131             }
  1132         }
  1132         }
       
  1133 
       
  1134     if( !pkcs7EncryptedDataBuf )
       
  1135         {
       
  1136         CleanupStack::PopAndDestroy(numberOfItemsInCStack); // set
       
  1137         numberOfItemsInCStack = 0;
       
  1138         return EFalse;
       
  1139         }
       
  1140 
  1133     // OK, now we have buffer to be decrypted, used algorithm, salt and
  1141     // OK, now we have buffer to be decrypted, used algorithm, salt and
  1134     // an iteration count. Next we decrypt buffer and append it to iBags.
  1142     // an iteration count. Next we decrypt buffer and append it to iBags.
  1135 	
  1143 	DecryptPkcs7EncryptedDataL( pkcs7EncryptedDataBuf, salt, iter, algorithm );
  1136 	DecryptPkcs7EncryptedDataL( pkcs7EncryptedDataBuf,salt,iter,algorithm );
       
  1137 
  1144 
  1138     CleanupStack::PopAndDestroy(numberOfItemsInCStack);
  1145     CleanupStack::PopAndDestroy(numberOfItemsInCStack);
  1139     numberOfItemsInCStack = 0;
  1146     numberOfItemsInCStack = 0;
  1140 
  1147 
  1141     return ETrue;
  1148     return ETrue;
  1307 // -----------------------------------------------------------------------------
  1314 // -----------------------------------------------------------------------------
  1308 void CCrPKCS12::DecryptShroudedKeybagL( CCrData& aSafeBag )
  1315 void CCrPKCS12::DecryptShroudedKeybagL( CCrData& aSafeBag )
  1309     {
  1316     {
  1310     TInt numberOfItemsinCStack = 0;
  1317     TInt numberOfItemsinCStack = 0;
  1311     CCrBerSet* set = NULL;
  1318     CCrBerSet* set = NULL;
  1312     TInt errData = KErrNone;
       
  1313 
  1319 
  1314     set = CCrBerSet::NewLC( 1 );
  1320     set = CCrBerSet::NewLC( 1 );
  1315     ++numberOfItemsinCStack;
  1321     ++numberOfItemsinCStack;
  1316     
  1322     
  1317     CCrBer* object = NULL;
  1323     CCrBer* object = NULL;
  1401     // EncryptedData
  1407     // EncryptedData
  1402     HBufC8* encryptedPrivateKeyInfo = object->GetOctetStringL();
  1408     HBufC8* encryptedPrivateKeyInfo = object->GetOctetStringL();
  1403     CleanupStack::PushL(encryptedPrivateKeyInfo);
  1409     CleanupStack::PushL(encryptedPrivateKeyInfo);
  1404     ++numberOfItemsinCStack;
  1410     ++numberOfItemsinCStack;
  1405     
  1411     
  1406     if ( errData < KErrNone )
       
  1407         {
       
  1408         User::Leave(KErrArgument);
       
  1409         }
       
  1410 
       
  1411     // Decrypt
  1412     // Decrypt
  1412     if ( !DecryptPrivateKeyL( encryptedPrivateKeyInfo,
  1413     if ( !DecryptPrivateKeyL( encryptedPrivateKeyInfo,
  1413                                                  salt,
  1414                                                  salt,
  1414                                                  iter,
  1415                                                  iter,
  1415                                                  algorithm ) )
  1416                                                  algorithm ) )