diff --git a/lib/capi/c_cipher_segment.cc b/lib/capi/c_cipher_segment.cc index d0db9ae9..a70da63a 100644 --- a/lib/capi/c_cipher_segment.cc +++ b/lib/capi/c_cipher_segment.cc @@ -65,6 +65,9 @@ alcp_cipher_segment_request(const alc_cipher_mode_t mode, const Uint64 keyLen, alc_cipher_handle_p pCipherHandle) { +#ifdef ALCP_ENABLE_DEBUG_LOGGING + ALCP_DEBUG_LOG(LOG_DBG, "KeyLen %6ld", keyLen); +#endif alc_error_t err = ALC_ERROR_NONE; ALCP_BAD_PTR_ERR_RET(pCipherHandle, err); @@ -96,6 +99,9 @@ alcp_cipher_segment_init(const alc_cipher_handle_p pCipherHandle, const Uint8* pIv, Uint64 ivLen) { +#ifdef ALCP_ENABLE_DEBUG_LOGGING + ALCP_DEBUG_LOG(LOG_DBG, "KeyLen %6ld,IVLen %6ld", keyLen, ivLen); +#endif alc_error_t err = ALC_ERROR_NONE; ALCP_BAD_PTR_ERR_RET(pCipherHandle, err); @@ -125,6 +131,12 @@ alcp_cipher_segment_encrypt_xts(const alc_cipher_handle_p pCipherHandle, Uint64 currPlainTextLen, Uint64 startBlockNum) { +#ifdef ALCP_ENABLE_DEBUG_LOGGING + ALCP_DEBUG_LOG(LOG_DBG, + "CurrentPTLen %6ld,BlkNo %6ld", + currPlainTextLen, + startBlockNum); +#endif alc_error_t err = ALC_ERROR_NONE; ALCP_BAD_PTR_ERR_RET(pCipherHandle, err); @@ -151,6 +163,12 @@ alcp_cipher_segment_decrypt_xts(const alc_cipher_handle_p pCipherHandle, Uint64 currCipherTextLen, Uint64 startBlockNum) { +#ifdef ALCP_ENABLE_DEBUG_LOGGING + ALCP_DEBUG_LOG(LOG_DBG, + "CurrentPTLen %6ld,BlkNo %6ld", + currPlainTextLen, + startBlockNum); +#endif alc_error_t err = ALC_ERROR_NONE; ALCP_BAD_PTR_ERR_RET(pCipherHandle, err); @@ -173,6 +191,9 @@ alcp_cipher_segment_decrypt_xts(const alc_cipher_handle_p pCipherHandle, void alcp_cipher_segment_finish(const alc_cipher_handle_p pCipherHandle) { +#ifdef ALCP_ENABLE_DEBUG_LOGGING + ALCP_DEBUG_LOG(LOG_INFO); +#endif if (pCipherHandle == nullptr || pCipherHandle->ch_context == nullptr) return; diff --git a/lib/capi/c_drbg.cc b/lib/capi/c_drbg.cc index 6f677cb5..041a73dc 100644 --- a/lib/capi/c_drbg.cc +++ b/lib/capi/c_drbg.cc @@ -44,12 +44,18 @@ Uint64 alcp_drbg_context_size(const alc_drbg_info_p pDrbgInfo) { Uint64 size = sizeof(Context) + DrbgBuilder::getSize(*pDrbgInfo); +#ifdef ALCP_ENABLE_DEBUG_LOGGING + ALCP_DEBUG_LOG(LOG_DBG, "CtxSize %6ld", size); +#endif return size; } alc_error_t alcp_drbg_supported(const alc_drbg_info_p pcDrbgInfo) { +#ifdef ALCP_ENABLE_DEBUG_LOGGING + ALCP_DEBUG_LOG(LOG_INFO); +#endif alc_error_t err = ALC_ERROR_NONE; ALCP_BAD_PTR_ERR_RET(pcDrbgInfo, err); // FIXME: Implement Digest Support check @@ -62,6 +68,9 @@ alc_error_t alcp_drbg_request(alc_drbg_handle_p pDrbgHandle, const alc_drbg_info_p pDrbgInfo) { +#ifdef ALCP_ENABLE_DEBUG_LOGGING + ALCP_DEBUG_LOG(LOG_INFO); +#endif alc_error_t err = ALC_ERROR_NONE; ALCP_BAD_PTR_ERR_RET(pDrbgHandle, err); @@ -81,6 +90,11 @@ alcp_drbg_initialize(alc_drbg_handle_p pDrbgHandle, Uint8* personalization_string, Uint64 personalization_string_length) { +#ifdef ALCP_ENABLE_DEBUG_LOGGING + ALCP_DEBUG_LOG(LOG_DBG, + "personalization_string_length %6ld", + personalization_string_length); +#endif alc_error_t err = ALC_ERROR_NONE; ALCP_BAD_PTR_ERR_RET(pDrbgHandle, err); ALCP_BAD_PTR_ERR_RET(pDrbgHandle->ch_context, err); @@ -105,6 +119,14 @@ alcp_drbg_randomize(alc_drbg_handle_p pDrbgHandle, const Uint8 cAdditionalInput[], const size_t cAdditionalInputLength) { +#ifdef ALCP_ENABLE_DEBUG_LOGGING + ALCP_DEBUG_LOG(LOG_DBG, + "OutputLength %6ld, cSecurityStrength %6ld, " + "cAdditionalInputLength %6ld", + cOutputLength, + cSecurityStrength, + cAdditionalInputLength); +#endif alc_error_t err = ALC_ERROR_NONE; ALCP_BAD_PTR_ERR_RET(pDrbgHandle, err); ALCP_BAD_PTR_ERR_RET(pDrbgHandle->ch_context, err); @@ -126,6 +148,9 @@ alcp_drbg_randomize(alc_drbg_handle_p pDrbgHandle, alc_error_t alcp_drbg_finish(alc_drbg_handle_p pDrbgHandle) { +#ifdef ALCP_ENABLE_DEBUG_LOGGING + ALCP_DEBUG_LOG(LOG_INFO); +#endif alc_error_t err = ALC_ERROR_NONE; ALCP_BAD_PTR_ERR_RET(pDrbgHandle, err); ALCP_BAD_PTR_ERR_RET(pDrbgHandle->ch_context, err); diff --git a/lib/capi/c_error.cc b/lib/capi/c_error.cc index 62720e19..b3c211b1 100644 --- a/lib/capi/c_error.cc +++ b/lib/capi/c_error.cc @@ -41,6 +41,9 @@ using namespace alcp::base; Uint8 alcp_is_error(alc_error_t err) { +#ifdef ALCP_ENABLE_DEBUG_LOGGING + ALCP_DEBUG_LOG(LOG_INFO); +#endif return err != 0; } diff --git a/lib/capi/c_rng.cc b/lib/capi/c_rng.cc index 93350f35..2841410b 100644 --- a/lib/capi/c_rng.cc +++ b/lib/capi/c_rng.cc @@ -48,12 +48,18 @@ alcp_rng_context_size(const alc_rng_info_p pRngInfo) } Uint64 size = sizeof(alcp::rng::Context) + RngBuilder::getSize(*pRngInfo); +#ifdef ALCP_ENABLE_DEBUG_LOGGING + ALCP_DEBUG_LOG(LOG_DBG, "CtxSize %6ld", size); +#endif return size; } alc_error_t alcp_rng_supported(const alc_rng_info_p pRngInfo) { +#ifdef ALCP_ENABLE_DEBUG_LOGGING + ALCP_DEBUG_LOG(LOG_INFO); +#endif ALCP_BAD_PTR_ERR_RET(pRngInfo, error); alc_error_t error = ALC_ERROR_NONE; @@ -92,6 +98,9 @@ alcp_rng_supported(const alc_rng_info_p pRngInfo) alc_error_t alcp_rng_request(const alc_rng_info_p pRngInfo, alc_rng_handle_p pHandle) { +#ifdef ALCP_ENABLE_DEBUG_LOGGING + ALCP_DEBUG_LOG(LOG_INFO); +#endif alc_error_t error = ALC_ERROR_NOT_SUPPORTED; auto ctx = static_cast(pHandle->rh_context); @@ -130,6 +139,9 @@ alcp_rng_gen_random(alc_rng_handle_p pRngHandle, Uint64 size /* output buffer size */ ) { +#ifdef ALCP_ENABLE_DEBUG_LOGGING + ALCP_DEBUG_LOG(LOG_DBG, "OutputBuff size %6ld", size); +#endif ALCP_BAD_PTR_ERR_RET(pRngHandle, error); ALCP_BAD_PTR_ERR_RET(pRngHandle->rh_context, error); @@ -150,6 +162,9 @@ alcp_rng_gen_random(alc_rng_handle_p pRngHandle, alc_error_t alcp_rng_reseed(alc_rng_handle_p pRngHandle) { +#ifdef ALCP_ENABLE_DEBUG_LOGGING + ALCP_DEBUG_LOG(LOG_INFO); +#endif ALCP_BAD_PTR_ERR_RET(pRngHandle, error); ALCP_BAD_PTR_ERR_RET(pRngHandle->rh_context, error); alcp::rng::Context* ctx = (alcp::rng::Context*)pRngHandle->rh_context; @@ -161,6 +176,9 @@ alcp_rng_reseed(alc_rng_handle_p pRngHandle) alc_error_t alcp_rng_finish(alc_rng_handle_p pRngHandle) { +#ifdef ALCP_ENABLE_DEBUG_LOGGING + ALCP_DEBUG_LOG(LOG_INFO); +#endif ALCP_BAD_PTR_ERR_RET(pRngHandle, error); ALCP_BAD_PTR_ERR_RET(pRngHandle->rh_context, error); alcp::rng::Context* ctx = (alcp::rng::Context*)pRngHandle->rh_context;