if (retCode == CKM_API_SUCCESS)
key = m_decider.getStore(row).getKey(row);
return retCode;
- } catch (const KeyProvider::Exception::Base &e) {
- LogError("KeyProvider failed with error: " << e.GetMessage());
- return CKM_API_ERROR_SERVER_ERROR;
} catch (const DB::Crypto::Exception::Base &e) {
LogError("DB::Crypto failed with message: " << e.GetMessage());
return CKM_API_ERROR_DB_ERROR;
return;
}
- // TODO encrypt/decrypt
- LogError("Encryption/decryption not yet supported");
- m_service.RespondToClient(req, CKM_API_ERROR_SERVER_ERROR);
+ // encrypt/decrypt
+ try {
+ RawBuffer output;
+ if (req.command == EncryptionCommand::ENCRYPT)
+ output = response.key->encrypt(req.cas, req.input);
+ else
+ output = response.key->decrypt(req.cas, req.input);
+ m_service.RespondToClient(req, CKM_API_SUCCESS, output);
+ } catch (const Exc::Exception& ex) {
+ m_service.RespondToClient(req, ex.error());
+ } catch (...) {
+ LogError("Uncaught exception from encrypt/decrypt.");
+ m_service.RespondToClient(req, CKM_API_ERROR_SERVER_ERROR);
+ }
}
} /* namespace CKM */