diff --git a/include/key_list.h b/include/key_list.h index adb0783c1f4569329ad5cd184ad574e0e33af2d0..fffa8638c223df7d5d9032aeaee31cc92a4b7af8 100644 --- a/include/key_list.h +++ b/include/key_list.h @@ -3,6 +3,10 @@ #include <stdint.h> #include <string.h> +#ifdef __cplusplus +extern "C" { +#endif + #undef LOG_TAG #define LOG_TAG "key-list" @@ -11,8 +15,12 @@ typedef struct key_list{ uint8_t lenght; }key_list_t; -key_list_t *key_list_init(); +key_list_t *key_list_init(void); void key_list_free(key_list_t* list); uint8_t key_list_add_element(key_list_t *list, dap_enc_key_t* key); bool key_list_del_element(key_list_t *list, uint8_t key); -dap_enc_key_t *key_list_get_key(key_list_t *list, uint8_t key); \ No newline at end of file +dap_enc_key_t *key_list_get_key(key_list_t *list, uint8_t key); + +#ifdef __cplusplus +} +#endif diff --git a/include/libdap-crypto-python.h b/include/libdap-crypto-python.h index 7a2bf372bed65e9109031df833986f42472aeee8..15c19def3ff56e2437de7b2fe1dffbaf363508fe 100644 --- a/include/libdap-crypto-python.h +++ b/include/libdap-crypto-python.h @@ -33,6 +33,8 @@ static PyMethodDef DapCryptoMethods[] = { {"logItInfo", dap_log_it_info, METH_VARARGS, ""}, {"newKey", dap_enc_key_new_py, METH_VARARGS, "The function creates a new key, and returns it with PyObject."}, {"delKey", dap_enc_key_delete_py, METH_VARARGS, ""}, + {"getEncSizeKey", dap_enc_key_get_enc_size_py, METH_VARARGS, ""}, + {"getDecSizeKey", dap_enc_key_get_dec_size_py, METH_VARARGS, ""}, {NULL, NULL, 0, NULL} }; @@ -49,4 +51,4 @@ PyMODINIT_FUNC PyInit_libdap_crypto_python_module(void); #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/include/wrapping_dap_enc_key.h b/include/wrapping_dap_enc_key.h index 824f99d7a14af77fded5c39149893ff790ee849c..b57bd12c5e902e42a36ae901675d4294494c5edd 100644 --- a/include/wrapping_dap_enc_key.h +++ b/include/wrapping_dap_enc_key.h @@ -3,6 +3,10 @@ #include "dap_common.h" #include "key_list.h" +#ifdef __cplusplus +extern "C" { +#endif + #undef LOG_TAG #define LOG_TAG "wrapping-dap-enc-key" @@ -32,4 +36,8 @@ PyObject *dap_enc_gen_key_public_size_py(PyObject *self, PyObject *args);//dap_e PyObject *dap_enc_gen_key_public_py(PyObject *self, PyObject *args);//dap_enc_key_t *a_key, void * a_output); ->int PyObject *dap_enc_key_signature_delete_py(PyObject *self, PyObject *args);//dap_enc_key_type_t a_key_type, uint8_t *a_sig_buf); ->void -PyObject *dap_enc_key_delete_py(PyObject *self, PyObject *args);//dap_enc_key_t * a_key); ->void \ No newline at end of file +PyObject *dap_enc_key_delete_py(PyObject *self, PyObject *args);//dap_enc_key_t * a_key); ->void + +#ifdef __cplusplus +} +#endif diff --git a/test/test_b64.py b/test/test_b64.py new file mode 100644 index 0000000000000000000000000000000000000000..f03cf9bf129e922f59627279fa20cd5667bd5045 --- /dev/null +++ b/test/test_b64.py @@ -0,0 +1,24 @@ +import libdap_crypto_python_module as crypto + +print ("Start test crypto b64") +s = "Test! I will crush Base64!" +print ("Input data: "+s) +crypt = crypto.encodeBase64(bytes(s, "utf-8"),1) +print ("Encrypted data: \t") +print(crypt) +decrypt = crypto.decodeBase64(crypt, 1) +print ("Decoded data: \t") +print(decrypt) +if bytes(s, "utf-8") == decrypt: + print ("TEST 1. Encode/Decode base64 done") +else: + print ("TEST 1. Encode/Decode base64 faild") + +print ("Test Base64 URLSAFE") +u = "http://kelvin.foundation/" +crypt_u = crypto.encodeBase64(bytes(u, "utf-8"), 2) +decrypt_u = crypto.decodeBase64(crypt_u) +if bytes(u, "utf-8") == decrypt_u: + print ("TEST 2. Encode/Decode base64 urlsafe done") +else: + print ("TEST 2. Encode/Decode base64 urlsafe faild")