From: Jaroslaw Pelczar Date: Tue, 5 Dec 2017 06:18:30 +0000 (+0100) Subject: dcm-client: remove debug level logs, leave only error logs X-Git-Tag: submit/tizen/20171212.022906~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5ff30f836286030b8ee46b848a152fecd6ece6af;p=platform%2Fcore%2Fsecurity%2Fdevice-certificate-manager.git dcm-client: remove debug level logs, leave only error logs Change-Id: I65f9f68274c5407ed6f51df2db81ca8298233d9e Signed-off-by: Jaroslaw Pelczar --- diff --git a/dcm-client/dcm_hw_interface.cpp b/dcm-client/dcm_hw_interface.cpp index 3e2ad58..332141a 100644 --- a/dcm-client/dcm_hw_interface.cpp +++ b/dcm-client/dcm_hw_interface.cpp @@ -43,10 +43,6 @@ static std::map> sEDCSAContex static std::mutex sEDCSAContextsMutex; void* DCM_HWGetKeyContext(const char* service, const char* usage, const char* keytype) { -#ifdef USE_DLOG_LOGGING - LOGD("Create new context for"); -#endif - try { std::unique_ptr context(new dcm_key_context_internal()); @@ -66,11 +62,12 @@ void* DCM_HWGetKeyContext(const char* service, const char* usage, const char* ke return nullptr; } + return context.release(); + } catch(std::exception& ex) { #ifdef USE_DLOG_LOGGING - LOGD("Created context %p", context.get()); + LOGE("Context creation failure: %s", ex.what()); #endif - - return context.release(); + return nullptr; } catch(...) { #ifdef USE_DLOG_LOGGING LOGE("Context creation failure"); @@ -85,10 +82,6 @@ int DCM_HWFreeKeyContext(void* keyContext) return HWIF_ERR_INVALID_PARAM; } -#ifdef USE_DLOG_LOGGING - LOGD("Delete context %p", keyContext); -#endif - delete reinterpret_cast(keyContext); return HWIF_SUCCESS; @@ -104,15 +97,7 @@ int DCM_HWGetOwnCertificateChain(const void* keyContext, return HWIF_ERR_INVALID_PARAM; } -#ifdef USE_DLOG_LOGGING - LOGD("Request certificate chain for session %p", keyContext); -#endif - if(!context->cached_cert_chain.empty()) { -#ifdef USE_DLOG_LOGGING - LOGD("Use cached certificate chain"); -#endif - *cert_chain = &context->cached_cert_chain[0]; *cert_chain_len = context->cached_cert_chain.size(); return HWIF_SUCCESS; @@ -149,6 +134,9 @@ static int pk_rsa_alt_sign_func( void *ctx, } if(mode != MBEDTLS_RSA_PRIVATE) { +#ifdef USE_DLOG_LOGGING + LOGE("Signing mode must be RSA_PRIVATE"); +#endif return MBEDTLS_ERR_PK_BAD_INPUT_DATA; } @@ -305,10 +293,6 @@ int DCM_HWSetupPkContext(mbedtls_pk_context* ctx, void* key_context) return HWIF_ERR_INVALID_PARAM; } -#ifdef USE_DLOG_LOGGING - LOGD("Setup PK context %p with key context %p", ctx, key_context); -#endif - const auto& key_type(context->connection->key_type()); if(key_type == "RSA") { diff --git a/dcm-client/dcmclient.cpp b/dcm-client/dcmclient.cpp index 8f82f03..82acda3 100644 --- a/dcm-client/dcmclient.cpp +++ b/dcm-client/dcmclient.cpp @@ -26,6 +26,7 @@ #include #include #include + #ifdef USE_DLOG_LOGGING #define LOG_TAG "dcm-client" #include @@ -56,16 +57,10 @@ dcm_client_connection_impl::~dcm_client_connection_impl() dcm_client_connection::dcm_client_connection() { -#ifdef USE_DLOG_LOGGING - LOGD("dcm_client_connection: Allocated new client connection at %p", this); -#endif } dcm_client_connection::~dcm_client_connection() { -#ifdef USE_DLOG_LOGGING - LOGD("dcm_client_connection: Deallocated client connection at %p", this); -#endif } std::shared_ptr dcm_client_connection::create() @@ -75,17 +70,8 @@ std::shared_ptr dcm_client_connection::create() void dcm_client_connection_impl::sendReceive(RequestMessage& request, ResponseMessage& response) { -#ifdef USE_DLOG_LOGGING - LOGD("Send request to server in connection %p of type %d", this, request.request_oneof_case()); -#endif - protobuf_sync_message_serialization(*fSocket).encodeMessage(request); - protobuf_sync_message_deserialization(*fSocket).decodeMessage(response); - -#ifdef USE_DLOG_LOGGING - LOGD("Received response from server in connection %p of type %d", this, response.reply_oneof_case()); -#endif } bool dcm_client_connection_impl::create_context(const std::string& serviceName, @@ -103,9 +89,6 @@ bool dcm_client_connection_impl::create_context(const std::string& serviceName, } if(!fSocket) { -#ifdef USE_DLOG_LOGGING - LOGD("%s: Ensure that socket is connected for session %p", __FUNCTION__, this); -#endif try { ensureSocketConnected(); } catch(std::exception& ex) { @@ -121,10 +104,6 @@ bool dcm_client_connection_impl::create_context(const std::string& serviceName, } } -#ifdef USE_DLOG_LOGGING - LOGD("%s: Connection established. Requesting cookie", __FUNCTION__); -#endif - try { RequestMessage request; ResponseMessage response; @@ -156,15 +135,6 @@ bool dcm_client_connection_impl::create_context(const std::string& serviceName, fCookie = assoc_message.context_cookie(); fKeyType = assoc_message.key_type(); fKeyLength = assoc_message.key_length(); - -#ifdef USE_DLOG_LOGGING - LOGD("%s: Received cookie %" PRIx64 " with key type %s and length %zd for session %p", - __FUNCTION__, - fCookie, - this->key_type().c_str(), - fKeyLength, - this); -#endif } catch(std::exception& ex) { #ifdef USE_DLOG_LOGGING LOGE("%s: Caught exception \"%s\" when establishing cookie for session %p", __FUNCTION__, ex.what(), this); @@ -200,10 +170,6 @@ int dcm_client_connection_impl::get_certificate_chain(std::vector& chai return HWIF_ERR_INVALID_PARAM; } -#ifdef USE_DLOG_LOGGING - LOGD("%s: Requesting certificate chain for session %p", __FUNCTION__, this); -#endif - try { RequestMessage request; ResponseMessage response; @@ -248,10 +214,6 @@ int dcm_client_connection_impl::get_certificate_chain(std::vector& chai // Pad with zero chain.push_back(0); } - -#ifdef USE_DLOG_LOGGING - LOGD("%s: Received %zd bytes of certificate for session %p", __FUNCTION__, cert_resp.cert_chain().size(), this); -#endif } catch(std::bad_alloc&) { #ifdef USE_DLOG_LOGGING LOGE("%s: Out of memory when requesting certificate for session %p", __FUNCTION__, this); @@ -292,7 +254,7 @@ int dcm_client_connection_impl::sign_data(mbedtls_md_type_t digestType, const vo if(!fCookie) { #ifdef USE_DLOG_LOGGING - LOGD("%s: Trying to request data signing in object %p but there is no connection", __FUNCTION__); + LOGE("%s: Trying to request data signing in object %p but there is no connection", __FUNCTION__); #endif return MBEDTLS_ERR_PK_BAD_INPUT_DATA; } @@ -303,7 +265,7 @@ int dcm_client_connection_impl::sign_data(mbedtls_md_type_t digestType, const vo if(hash_size == 0) { if(digestType == MBEDTLS_MD_NONE) { #ifdef USE_DLOG_LOGGING - LOGD("%s: Digest type is NONE and hash size is 0", __FUNCTION__); + LOGE("%s: Digest type is NONE and hash size is 0", __FUNCTION__); #endif return MBEDTLS_ERR_PK_BAD_INPUT_DATA; } @@ -312,14 +274,11 @@ int dcm_client_connection_impl::sign_data(mbedtls_md_type_t digestType, const vo if(!md_info) { #ifdef USE_DLOG_LOGGING - LOGD("%s: Can't find hash data for digest type %d", __FUNCTION__, digestType); + LOGE("%s: Can't find hash data for digest type %d", __FUNCTION__, digestType); #endif return MBEDTLS_ERR_PK_BAD_INPUT_DATA; } -#ifdef USE_DLOG_LOGGING - LOGD("%s: Overriding hash size to %zd bytes", __FUNCTION__, hash_size); -#endif hash_size = mbedtls_md_get_size(md_info); } else if(hash_size != 0 && digestType != MBEDTLS_MD_NONE) { /* @@ -329,7 +288,7 @@ int dcm_client_connection_impl::sign_data(mbedtls_md_type_t digestType, const vo if(!md_info) { #ifdef USE_DLOG_LOGGING - LOGD("%s: Can't find hash data for digest type %d", __FUNCTION__, digestType); + LOGE("%s: Can't find hash data for digest type %d", __FUNCTION__, digestType); #endif return MBEDTLS_ERR_PK_BAD_INPUT_DATA; } @@ -356,7 +315,7 @@ int dcm_client_connection_impl::sign_data(mbedtls_md_type_t digestType, const vo if(!response.has_sign_data()) { #ifdef USE_DLOG_LOGGING - LOGD("%s: Response for hash signature has no signature data", __FUNCTION__); + LOGE("%s: Response for hash signature has no signature data", __FUNCTION__); #endif return MBEDTLS_ERR_PK_BAD_INPUT_DATA; } @@ -381,10 +340,6 @@ int dcm_client_connection_impl::sign_data(mbedtls_md_type_t digestType, const vo digest.resize(signature.size()); memcpy(&digest[0], signature.c_str(), signature.size()); - -#ifdef USE_DLOG_LOGGING - LOGD("%s: Received %zd bytes of signed object for session %p", __FUNCTION__, signature.size(), this); -#endif } catch(std::bad_alloc&) { #ifdef USE_DLOG_LOGGING LOGE("%s: Out of memory when processing sign request for session %p", __FUNCTION__, this);