Debug function is exported but the header is kept private.
Change-Id: I399bc52688c126a061dc29d66029bfe66d993c47
#endif
/**
- * @defgroup Error Yet another Crypto API - error enums and debug functions.
+ * @defgroup Error Yet another Crypto API - error enums.
*
* @{
*/
YACA_ERROR_TOO_BIG_ARGUMENT = -4,
YACA_ERROR_OUT_OF_MEMORY = -5,
YACA_ERROR_SIGNATURE_INVALID = -6,
- YACA_ERROR_PASSWORD_INVALID = -7,
+ YACA_ERROR_PASSWORD_INVALID = -7
};
-// TODO disable debug function in release?
-
-/**
- * @brief Debug callback type.
- */
-typedef void (*yaca_debug_func)(const char*);
-
-/**
- * @brief Sets a current thread debug callback that will be called each time an
- * internal error occurs. A NULL terminated string with location and
- * description of the error will be passed as an argument.
- *
- * @param[in] fn Function to set as internal error callback.
- */
-void yaca_error_set_debug_func(yaca_debug_func fn);
-
/**@}*/
#ifdef __cplusplus
#include <yaca/error.h>
#include "lorem.h"
#include "misc.h"
+#include "../src/debug.h"
void digest_simple(void)
{
int main()
{
- yaca_error_set_debug_func(debug_func);
+ yaca_debug_set_error_cb(debug_func);
int ret = yaca_init();
if (ret < 0)
#include <yaca/error.h>
#include "lorem.h"
#include "misc.h"
+#include "../src/debug.h"
void encrypt_simple(const yaca_enc_algo_e algo,
const yaca_block_cipher_mode_e bcm,
int main()
{
- yaca_error_set_debug_func(debug_func);
+ yaca_debug_set_error_cb(debug_func);
int ret = yaca_init();
if (ret < 0)
#include "lorem.h"
#include "misc.h"
+#include "../src/debug.h"
// Symmetric aes gcm encryption using advanced API
void encrypt_decrypt_aes_gcm(void)
int main()
{
- yaca_error_set_debug_func(debug_func);
+ yaca_debug_set_error_cb(debug_func);
int ret = yaca_init();
if (ret < 0)
#include <yaca/types.h>
#include <yaca/error.h>
#include "misc.h"
+#include "../src/debug.h"
void key_exchange_dh(void)
{
int main()
{
- yaca_error_set_debug_func(debug_func);
+ yaca_debug_set_error_cb(debug_func);
int ret = yaca_init();
if (ret < 0)
#include <stdio.h>
#include "misc.h"
+#include "../src/debug.h"
#include <yaca/crypto.h>
#include <yaca/encrypt.h>
if (ret != 0)
return ret;
- yaca_error_set_debug_func(debug_func);
+ yaca_debug_set_error_cb(debug_func);
ret = yaca_key_gen(&sym, YACA_KEY_TYPE_SYMMETRIC, YACA_KEY_1024BIT);
if (ret != 0)
#include <yaca/error.h>
#include "lorem.h"
#include "misc.h"
+#include "../src/debug.h"
void encrypt_seal(void)
{
int main()
{
- yaca_error_set_debug_func(debug_func);
+ yaca_debug_set_error_cb(debug_func);
int ret = yaca_init();
if (ret < 0)
#include "lorem.h"
#include "misc.h"
+#include "../src/debug.h"
// Signature creation and verification using advanced API
void sign_verify_asym(yaca_key_type_e type, const char *algo)
int main()
{
- yaca_error_set_debug_func(debug_func);
+ yaca_debug_set_error_cb(debug_func);
int ret = yaca_init();
if (ret < 0)
#include <yaca/types.h>
#include <yaca/error.h>
#include "misc.h"
+#include "../src/debug.h"
/** Simple test for development of library (before API is ready) */
int main(int argc, char* argv[])
{
- yaca_error_set_debug_func(debug_func);
+ yaca_debug_set_error_cb(debug_func);
yaca_key_h key;
char *k;
* limitations under the License
*/
/*
- * @file error.c
+ * @file debug.c
* @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
*/
#include <yaca/error.h>
#include "internal.h"
+#include "debug.h"
// TODO any better idea than to use __thread?
-static __thread yaca_debug_func debug_fn = NULL;
+static __thread yaca_error_cb error_cb = NULL;
static bool error_strings_loaded = false;
-API void yaca_error_set_debug_func(yaca_debug_func fn)
+API void yaca_debug_set_error_cb(yaca_error_cb fn)
{
- debug_fn = fn;
+ error_cb = fn;
}
// TODO use peeking function to intercept common errors
void error_dump(const char *file, int line, const char *function, int code)
{
- if (debug_fn == NULL)
+ if (error_cb == NULL)
return;
static const size_t BUF_SIZE = 512;
}
buf[written] = '\0';
- (*debug_fn)(buf);
+ (*error_cb)(buf);
}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Krzysztof Jackiewicz <k.jackiewicz@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+/**
+ * @file debug.h
+ * @brief
+ */
+
+#ifndef YACA_DEBUG_H
+#define YACA_DEBUG_H
+
+typedef void (*yaca_error_cb)(const char*);
+
+void yaca_debug_set_error_cb(yaca_error_cb cb);
+
+
+#endif /* YACA_DEBUG_H */
In other words check whether the user won't cause a buffer overflow.
- Importing/exporting encrypted (passphrased) RSA keys
- Support for OCB mode was added in OpenSSL 1.1.0
+- Remove debug function from examples