Introduce CryptoAlgorithm in internal socket protocol.
Change-Id: I70000a05e0a47d2b12af9b11324adf67da0f5e22
const Alias& privateKeyAlias,
const Password& password,
const RawBuffer& message,
- const HashAlgorithm hash,
- const RSAPaddingAlgorithm padding)
+ const CryptoAlgorithm &cAlg)
{
observerCheck(observer);
if (privateKeyAlias.empty() || message.empty()) {
helper.getLabel(),
password,
message,
- static_cast<int>(hash),
- static_cast<int>(padding));
+ CryptoAlgorithmSerializable(cAlg));
}, [&observer](int error) {observer->ReceivedError(error);});
}
const Password& password,
const RawBuffer& message,
const RawBuffer& signature,
- const HashAlgorithm hash,
- const RSAPaddingAlgorithm padding)
+ const CryptoAlgorithm &cAlg)
{
observerCheck(observer);
if (publicKeyOrCertAlias.empty() || message.empty() || signature.empty()) {
password,
message,
signature,
- static_cast<int>(hash),
- static_cast<int>(padding));
+ CryptoAlgorithmSerializable(cAlg));
}, [&observer](int error){ observer->ReceivedError(error); } );
}
const Alias& privateKeyAlias,
const Password& password,
const RawBuffer& message,
- const HashAlgorithm hash,
- const RSAPaddingAlgorithm padding);
+ const CryptoAlgorithm& cAlgorithm);
void verifySignature(
const ObserverPtr& observer,
const Alias& publicKeyOrCertAlias,
const Password& password,
const RawBuffer& message,
const RawBuffer& signature,
- const HashAlgorithm hash,
- const RSAPaddingAlgorithm padding);
+ const CryptoAlgorithm& cAlgorithm);
void ocspCheck(
const ObserverPtr& observer,
const HashAlgorithm hash,
const RSAPaddingAlgorithm padding)
{
- m_impl->createSignature(observer, privateKeyAlias, password, message, hash, padding);
+ CryptoAlgorithm cAlg;
+ cAlg.setParam(ParamName::SV_HASH_ALGO, hash);
+ cAlg.setParam(ParamName::SV_RSA_PADDING, padding);
+ m_impl->createSignature(observer, privateKeyAlias, password, message, cAlg);
}
void ManagerAsync::verifySignature(const ObserverPtr& observer,
const HashAlgorithm hash,
const RSAPaddingAlgorithm padding)
{
- m_impl->verifySignature(observer, publicKeyOrCertAlias, password, message, signature, hash, padding);
+ CryptoAlgorithm cAlg;
+ cAlg.setParam(ParamName::SV_HASH_ALGO, hash);
+ cAlg.setParam(ParamName::SV_RSA_PADDING, padding);
+ m_impl->verifySignature(observer, publicKeyOrCertAlias, password, message, signature, cAlg);
}
void ManagerAsync::ocspCheck(const ObserverPtr& observer,
const Alias &privateKeyAlias,
const Password &password, // password for private_key
const RawBuffer &message,
- const HashAlgorithm hash,
- const RSAPaddingAlgorithm padding,
+ const CryptoAlgorithm &cAlgorithm,
RawBuffer &signature)
{
int my_counter = ++m_counter;
helper.getLabel(),
password,
message,
- static_cast<int>(hash),
- static_cast<int>(padding));
+ CryptoAlgorithmSerializable(cAlgorithm));
int retCode = m_storageConnection.processRequest(send.Pop(), recv);
if (CKM_API_SUCCESS != retCode)
const Password &password, // password for public_key (optional)
const RawBuffer &message,
const RawBuffer &signature,
- const HashAlgorithm hash,
- const RSAPaddingAlgorithm padding)
+ const CryptoAlgorithm &cAlg)
{
int my_counter = ++m_counter;
password,
message,
signature,
- static_cast<int>(hash),
- static_cast<int>(padding));
+ CryptoAlgorithmSerializable(cAlg));
int retCode = m_storageConnection.processRequest(send.Pop(), recv);
if (CKM_API_SUCCESS != retCode)
const Alias &privateKeyAlias,
const Password &password, // password for private_key
const RawBuffer &message,
- const HashAlgorithm hash,
- const RSAPaddingAlgorithm padding,
+ const CryptoAlgorithm &cAlgorithm,
RawBuffer &signature);
int verifySignature(
const Password &password, // password for public_key (optional)
const RawBuffer &message,
const RawBuffer &signature,
- const HashAlgorithm hash,
- const RSAPaddingAlgorithm padding);
+ const CryptoAlgorithm &cAlgorithm);
int ocspCheck(const CertificateShPtrVector &certificateChain, int &ocspCheck);
const RSAPaddingAlgorithm padding,
RawBuffer &signature)
{
+ CryptoAlgorithm cAlg;
+ cAlg.setParam(ParamName::SV_HASH_ALGO, hash);
+ cAlg.setParam(ParamName::SV_RSA_PADDING, padding);
return m_impl->createSignature(
privateKeyAlias,
password,
message,
- hash,
- padding,
+ cAlg,
signature);
}
const HashAlgorithm hash,
const RSAPaddingAlgorithm padding)
{
+ CryptoAlgorithm cAlg;
+ cAlg.setParam(ParamName::SV_HASH_ALGO, hash);
+ cAlg.setParam(ParamName::SV_RSA_PADDING, padding);
return m_impl->verifySignature(
publicKeyOrCertAlias,
password,
message,
signature,
- hash,
- padding);
+ cAlg);
}
int Manager::ocspCheck(const CertificateShPtrVector &certificateChainVector, int &ocspStatus) {
const Label & ownerLabel,
const Password &password, // password for private_key
const RawBuffer &message,
- const HashAlgorithm hash,
- const RSAPaddingAlgorithm padding)
+ const CryptoAlgorithm &cryptoAlg)
{
DB::Row row;
RawBuffer signature;
- CryptoAlgorithm cryptoAlg;
- cryptoAlg.setParam(ParamName::SV_HASH_ALGO, hash);
- cryptoAlg.setParam(ParamName::SV_RSA_PADDING, padding);
int retCode = CKM_API_SUCCESS;
const Password &password, // password for public_key (optional)
const RawBuffer &message,
const RawBuffer &signature,
- const HashAlgorithm hash,
- const RSAPaddingAlgorithm padding)
+ const CryptoAlgorithm ¶ms)
{
int retCode = CKM_API_ERROR_VERIFICATION_FAILED;
try {
DB::Row row;
- CryptoAlgorithm params;
- params.setParam(ParamName::SV_HASH_ALGO, hash);
- params.setParam(ParamName::SV_RSA_PADDING, padding);
-
// try certificate first - looking for a public key.
// in case of PKCS, pub key from certificate will be found first
// rather than private key from the same PKCS.
const Label & ownerLabel,
const Password &password, // password for private_key
const RawBuffer &message,
- const HashAlgorithm hash,
- const RSAPaddingAlgorithm padding);
+ const CryptoAlgorithm &cryptoAlgorithm);
RawBuffer verifySignature(
const Credentials &cred,
const Password &password, // password for public_key (optional)
const RawBuffer &message,
const RawBuffer &signature,
- const HashAlgorithm hash,
- const RSAPaddingAlgorithm padding);
+ const CryptoAlgorithm &cryptoAlgorithm);
RawBuffer updateCCMode();
{
Password password; // password for private_key
RawBuffer message;
- int padding = 0, hash = 0;
- buffer.Deserialize(name, label, password, message, hash, padding);
+
+ CryptoAlgorithmSerializable cAlgorithm;
+ buffer.Deserialize(name, label, password, message, cAlgorithm);
+
return m_logic->createSignature(
cred,
msgID,
label,
password, // password for private_key
message,
- static_cast<HashAlgorithm>(hash),
- static_cast<RSAPaddingAlgorithm>(padding));
+ cAlgorithm);
}
case LogicCommand::VERIFY_SIGNATURE:
{
Password password; // password for public_key (optional)
RawBuffer message;
RawBuffer signature;
- //HashAlgorithm hash;
- //RSAPaddingAlgorithm padding;
- int padding = 0, hash = 0;
+ CryptoAlgorithmSerializable cAlg;
+
buffer.Deserialize(name,
label,
password,
message,
signature,
- hash,
- padding);
+ cAlg);
+
return m_logic->verifySignature(
cred,
msgID,
password, // password for public_key (optional)
message,
signature,
- static_cast<const HashAlgorithm>(hash),
- static_cast<const RSAPaddingAlgorithm>(padding));
+ cAlg);
}
case LogicCommand::SET_PERMISSION:
{