Skip to content
Snippets Groups Projects
Commit c030c8a2 authored by alexey.stratulat's avatar alexey.stratulat
Browse files

[+] Made a test to check the implementation of base64 wrapping

parent 5f01efc9
No related branches found
No related tags found
1 merge request!26Support 3689
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#ifdef __cplusplus
extern "C" {
#endif
#undef LOG_TAG #undef LOG_TAG
#define LOG_TAG "key-list" #define LOG_TAG "key-list"
...@@ -11,8 +15,12 @@ typedef struct key_list{ ...@@ -11,8 +15,12 @@ typedef struct key_list{
uint8_t lenght; uint8_t lenght;
}key_list_t; }key_list_t;
key_list_t *key_list_init(); key_list_t *key_list_init(void);
void key_list_free(key_list_t* list); void key_list_free(key_list_t* list);
uint8_t key_list_add_element(key_list_t *list, dap_enc_key_t* key); 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); 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); dap_enc_key_t *key_list_get_key(key_list_t *list, uint8_t key);
\ No newline at end of file
#ifdef __cplusplus
}
#endif
...@@ -33,6 +33,8 @@ static PyMethodDef DapCryptoMethods[] = { ...@@ -33,6 +33,8 @@ static PyMethodDef DapCryptoMethods[] = {
{"logItInfo", dap_log_it_info, METH_VARARGS, ""}, {"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."}, {"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, ""}, {"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} {NULL, NULL, 0, NULL}
}; };
...@@ -49,4 +51,4 @@ PyMODINIT_FUNC PyInit_libdap_crypto_python_module(void); ...@@ -49,4 +51,4 @@ PyMODINIT_FUNC PyInit_libdap_crypto_python_module(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
\ No newline at end of file
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
#include "dap_common.h" #include "dap_common.h"
#include "key_list.h" #include "key_list.h"
#ifdef __cplusplus
extern "C" {
#endif
#undef LOG_TAG #undef LOG_TAG
#define LOG_TAG "wrapping-dap-enc-key" #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 ...@@ -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_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_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 PyObject *dap_enc_key_delete_py(PyObject *self, PyObject *args);//dap_enc_key_t * a_key); ->void
\ No newline at end of file
#ifdef __cplusplus
}
#endif
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")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment