_PkcsUtility::IsParameterSupported(Tizen::Base::String algorithm)
{
if (algorithm == OID_PBKDF2 || algorithm == OID_PBES2 || algorithm == OID_PBMAC1 || algorithm == OID_DES_CBC || algorithm == OID_DES_CBC_EDE3
- || algorithm == OID_AES_128_CBC || algorithm == OID_AES_192_CBC || algorithm == OID_AES_256_CBC || algorithm == OID_RC2_CBC)
+ || algorithm == OID_AES_128_CBC || algorithm == OID_AES_192_CBC || algorithm == OID_AES_256_CBC || algorithm == OID_RC2_CBC)
{
return true;
}
}
}
- return pOutBuffer.release();
+ return pOutBuffer.release();
case _OID_TYPE_RSA_ENCRYPTION:
{
}
}
- return pOutBuffer.release();
+ return pOutBuffer.release();
default:
r = E_UNSUPPORTED_ALGORITHM;
memset(pOut.get(), 0, tempLen);
+ if (dataLen % pCipherAlgorithm->block_size != 0)
+ {
+ // set padding
+ ret = EVP_CIPHER_CTX_set_padding(&cipherCtx, static_cast< int >(true));
+ SysTryCatch(NID_SEC_CRYPTO, ret == 1, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+ }
+
//cipher update operation
ret = EVP_CipherUpdate(&cipherCtx, pOut.get(), static_cast< int* >(&outLen), pData, dataLen);
SysTryCatch(NID_SEC_CRYPTO, ret == 1, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
pOutBuffer->Flip();
-CATCH:
+ CATCH:
+ if (IsFailed(r))
+ {
+ pOutBuffer.reset(null);
+ }
EVP_CIPHER_CTX_cleanup(&cipherCtx);
SetLastResult(r);
PBKDF2PARAM_free(pKdf);
return pKeyfunc;
-CATCH:
+ CATCH:
PBKDF2PARAM_free(pKdf);
X509_ALGOR_free(pKeyfunc);
switch (oidValue)
{
case _OID_TYPE_DES_CBC:
- // fall through
+ // fall through
case _OID_TYPE_DES_CBC_EDE3:
- // fall through
+ // fall through
case _OID_TYPE_AES_128_CBC:
- // fall through
+ // fall through
case _OID_TYPE_AES_192_CBC:
- // fall through
+ // fall through
case _OID_TYPE_AES_256_CBC:
{
X509_ALGOR_get0(&pAlgoObj->algorithm, &pType, &pVal, pAlgoObj);
break;
case _OID_TYPE_HMAC_SHA1:
- // fall through
+ // fall through
case _OID_TYPE_HMAC_SHA2_224:
- // fall through
+ // fall through
case _OID_TYPE_HMAC_SHA2_256:
- // fall through
+ // fall through
case _OID_TYPE_HMAC_SHA2_384:
- // fall through
+ // fall through
case _OID_TYPE_HMAC_SHA2_512:
- // fall through
+ // fall through
case _OID_TYPE_RSA_ENCRYPTION:
{
pAlgoParams = null;
switch (oidValue)
{
case _OID_TYPE_DES_CBC:
- // fall through
+ // fall through
case _OID_TYPE_DES_CBC_EDE3:
- // fall through
+ // fall through
case _OID_TYPE_AES_128_CBC:
- // fall through
+ // fall through
case _OID_TYPE_AES_192_CBC:
- // fall through
+ // fall through
case _OID_TYPE_AES_256_CBC:
{
SysTryReturn(NID_SEC_CRYPTO, pAlgoParam != null, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
break;
case _OID_TYPE_HMAC_SHA1:
- // fall through
+ // fall through
case _OID_TYPE_HMAC_SHA2_224:
- // fall through
+ // fall through
case _OID_TYPE_HMAC_SHA2_256:
- // fall through
+ // fall through
case _OID_TYPE_HMAC_SHA2_384:
- // fall through
+ // fall through
case _OID_TYPE_RSA_ENCRYPTION:
- // fall through
+ // fall through
case _OID_TYPE_HMAC_SHA2_512:
{
ret = X509_ALGOR_set0(pAlgoObj, OBJ_nid2obj(algoNid), V_ASN1_NULL, NULL);