hi i am using password based encryption mechansim for encrypting some string data i was successfully in encrypting the data by while decrypting the data i am getting the system error
please guide me
i am attaching my sample code below
ByteBuffer password;
String pwdbuff="harish";
const int BUFFER_SIZE = 16;
int length = pwdbuff.GetLength();
int index = 0;
result r = E_SUCCESS;
ByteBuffer *pwd=StringUtil::StringToUtf8N(pwdbuff);
r = password.Construct(BUFFER_SIZE);
r = password.SetArray(( byte*)"harish", index, length);
password.Flip();
Pkcs05Schemes pkcs05Schemes;
r = pkcs05Schemes.Construct(password, length);
Pkcs05PbEs2Parameters pkcs05PbEs2Parameters;
AlgorithmIdentifier keyDerivationFunction;
AlgorithmIdentifier encryptionScheme;
Pkcs05PbKdf2Parameters pkcs05PbKdf2Params;
ByteBuffer saltValue;
InitialVector initialVector;
ByteBuffer initialVectorValue;
int iterationCount = 100;
int derivedKeyLength = 20;
r = saltValue.Construct(16);
r = saltValue.SetArray((byte*) "1234567890123456", 0, 16);
saltValue.Flip();
r = pkcs05PbKdf2Params.Construct(saltValue, iterationCount, derivedKeyLength);
r = keyDerivationFunction.Construct(OID_PBKDF2, &pkcs05PbKdf2Params);
r = initialVectorValue.Construct(BUFFER_SIZE);
r = initialVectorValue.SetArray((const byte*) "12345678", index, length);
initialVectorValue.Flip();
r = initialVector.Construct(initialVectorValue);
r = encryptionScheme.Construct(OID_AES_256_CBC, &initialVector);
r = pkcs05PbEs2Parameters.Construct(keyDerivationFunction, encryptionScheme);
ByteBuffer* pResult = null;
AppLog("after pbes settings");
ByteBuffer *pwdk=StringUtil::StringToUtf8N("harishK");
pResult = pkcs05Schemes.EncryptionScheme2N(pkcs05PbEs2Parameters, *pwdk);
AppLog("pResulr is %s",pResult->GetPointer());
//for decryption
ByteBuffer *pResult1=pkcs05Schemes.DecryptionScheme2N(pkcs05PbEs2Parameters, *pResult);
AppLog("pResult is %s if error is %s",pResult1->GetPointer(),GetLastResult())