//
-// Open Service Platform
// Copyright (c) 2013 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the License);
ASN1_TYPE* pParam = null;
std::unique_ptr< Pkcs05PbKdf2Parameters > pKdf2Parameters;
-
- SysAssertf(__keyDerivationFunction.GetAlgorithmObjectId().GetLength() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class. ");
- SysAssertf(__messageAuthScheme.GetAlgorithmObjectId().GetLength() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class. ");
-
pBuffer = encodedData.GetPointer();
SysTryReturnResult(NID_SEC_CRYPTO, pBuffer != null, E_INVALID_ARG, "The specified input parameter is invalid.");
r = GetLastResult();
SysTryCatch(NID_SEC_CRYPTO, r != E_UNSUPPORTED_ALGORITHM, r = E_UNSUPPORTED_ALGORITHM, E_UNSUPPORTED_ALGORITHM, "[E_UNSUPPORTED_ALGORITHM] The input algorithm is not supported.");
- __messageAuthScheme.Construct(macOid, null);
+ r = __messageAuthScheme.Construct(macOid, null);
SysTryCatch(NID_SEC_CRYPTO, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
- CATCH:
+CATCH:
PBE2PARAM_free(pMacObj);
return r;
{
result r = E_SUCCESS;
- SysAssertf(__keyDerivationFunction.GetAlgorithmObjectId().GetLength() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class. ");
- SysAssertf(__messageAuthScheme.GetAlgorithmObjectId().GetLength() <= 0, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class. ");
+ std::unique_ptr< IAlgorithmParameters > pParam(keyDerivationFunction.GetParametersN());
+ SysTryReturn(NID_SEC_CRYPTO, pParam != null, r, r, "[%s] Failed to get the parameters.", GetErrorMessage(r));
- r = __keyDerivationFunction.Construct(keyDerivationFunction.GetAlgorithmObjectId(), keyDerivationFunction.GetParametersN());
+ r = __keyDerivationFunction.Construct(keyDerivationFunction.GetAlgorithmObjectId(), pParam.get());
SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Failed to construct the algorithm identifier.", GetErrorMessage(r));
- r = __messageAuthScheme.Construct(messageAuthScheme.GetAlgorithmObjectId(), messageAuthScheme.GetParametersN());
+ std::unique_ptr< IAlgorithmParameters > pAuthParam(messageAuthScheme.GetParametersN());
+ SysTryReturn(NID_SEC_CRYPTO, pParam != null, r, r, "[%s] Failed to get the parameters.", GetErrorMessage(r));
+
+ r = __messageAuthScheme.Construct(messageAuthScheme.GetAlgorithmObjectId(), pAuthParam.get());
SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Failed to construct the algorithm identifier.", GetErrorMessage(r));
return r;
pEncMacParam->Flip();
- CATCH:
+CATCH:
+ if (IsFailed(r))
+ {
+ pEncMacParam.reset(null);
+ }
PBE2PARAM_free(pMacObj);
OPENSSL_free(pTemp);
SetLastResult(r);
_Pkcs05PbMacParametersImpl::GetKeyDerivationAlgorithm(void) const
{
ClearLastResult();
+
+ SysAssertf(__keyDerivationFunction.GetAlgorithmObjectId().GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+ SysAssertf(__messageAuthScheme.GetAlgorithmObjectId().GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+
return __keyDerivationFunction;
}
_Pkcs05PbMacParametersImpl::GetMacAlgorithm(void) const
{
ClearLastResult();
+
+ SysAssertf(__keyDerivationFunction.GetAlgorithmObjectId().GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+ SysAssertf(__messageAuthScheme.GetAlgorithmObjectId().GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+
return __messageAuthScheme;
}
{
bool value = false;
+ SysAssertf(__keyDerivationFunction.GetAlgorithmObjectId().GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+ SysAssertf(__messageAuthScheme.GetAlgorithmObjectId().GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+
const _Pkcs05PbMacParametersImpl* pOther = dynamic_cast< const _Pkcs05PbMacParametersImpl* >(&obj);
SysTryReturn(NID_SEC_CRYPTO, pOther != null, false, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
SysAssertf(__keyDerivationFunction.GetAlgorithmObjectId().GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
SysAssertf(__messageAuthScheme.GetAlgorithmObjectId().GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
-
return __keyDerivationFunction.GetHashCode() + __messageAuthScheme.GetHashCode();
}