Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
python-cellframe
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cellframe
python-cellframe
Commits
9f2ad11a
Commit
9f2ad11a
authored
5 years ago
by
alexey.stratulat
Browse files
Options
Downloads
Patches
Plain Diff
[*] Adding and adapting the library to work with the libdap-crypto-python submodule
parent
5706120a
No related branches found
No related tags found
1 merge request
!1
Features 2466
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/python-cellframe.h
+3
-1
3 additions, 1 deletion
include/python-cellframe.h
src/python-cellframe.c
+6
-1
6 additions, 1 deletion
src/python-cellframe.c
test/main_test.py
+77
-2
77 additions, 2 deletions
test/main_test.py
with
86 additions
and
4 deletions
include/python-cellframe.h
+
3
−
1
View file @
9f2ad11a
...
@@ -2,7 +2,9 @@
...
@@ -2,7 +2,9 @@
#include
"Python.h"
#include
"Python.h"
#include
"libdap-python.h"
#include
"libdap-python.h"
#include
"libdap-crypto-python.h"
#include
"libdap-crypto-python.h"
#include
"libdap-server-core-python.h"
#include
"libdap_server_core_python.h"
#include
"libdap_crypto_key_type_python.h"
#include
"libdap_crypto_data_type.h"
#include
"dap_common.h"
#include
"dap_common.h"
...
...
This diff is collapsed.
Click to expand it.
src/python-cellframe.c
+
6
−
1
View file @
9f2ad11a
...
@@ -5,7 +5,9 @@ PyMODINIT_FUNC PyInit_libCellFrame(void){
...
@@ -5,7 +5,9 @@ PyMODINIT_FUNC PyInit_libCellFrame(void){
if
(
PyType_Ready
(
&
DapObject_DapObjectType
)
<
0
||
PyType_Ready
(
&
dapCrypto_dapCryptoType
)
<
0
||
if
(
PyType_Ready
(
&
DapObject_DapObjectType
)
<
0
||
PyType_Ready
(
&
dapCrypto_dapCryptoType
)
<
0
||
PyType_Ready
(
&
ServerCore_ServerCoreType
)
<
0
||
PyType_Ready
(
&
dapEvents_dapEventsType
)
<
0
||
PyType_Ready
(
&
ServerCore_ServerCoreType
)
<
0
||
PyType_Ready
(
&
dapEvents_dapEventsType
)
<
0
||
PyType_Ready
(
&
dapEventsSocket_dapEventsSocketType
)
<
0
)
PyType_Ready
(
&
dapEventsSocket_dapEventsSocketType
)
<
0
||
PyType_Ready
(
&
CryptoKeyTypeObjecy_CryptoKeyTypeObjecyType
)
<
0
||
PyType_Ready
(
&
CryptoDataTypeObjecy_CryptoDataTypeObjecyType
)
<
0
)
return
NULL
;
return
NULL
;
PyObject
*
module
=
PyModule_Create
(
&
CellFramePythonModule
);
PyObject
*
module
=
PyModule_Create
(
&
CellFramePythonModule
);
...
@@ -28,6 +30,9 @@ PyMODINIT_FUNC PyInit_libCellFrame(void){
...
@@ -28,6 +30,9 @@ PyMODINIT_FUNC PyInit_libCellFrame(void){
PyModule_AddObject
(
module
,
"Events"
,
(
PyObject
*
)
&
dapEvents_dapEventsType
);
PyModule_AddObject
(
module
,
"Events"
,
(
PyObject
*
)
&
dapEvents_dapEventsType
);
PyModule_AddObject
(
module
,
"EventsSocket"
,
(
PyObject
*
)
&
dapEventsSocket_dapEventsSocketType
);
PyModule_AddObject
(
module
,
"EventsSocket"
,
(
PyObject
*
)
&
dapEventsSocket_dapEventsSocketType
);
PyModule_AddObject
(
module
,
"CryptoKeyType"
,
(
PyObject
*
)
&
CryptoKeyTypeObjecy_CryptoKeyTypeObjecyType
);
PyModule_AddObject
(
module
,
"CryptoDataType"
,
(
PyObject
*
)
&
CryptoDataTypeObjecy_CryptoDataTypeObjecyType
);
//PyModule_AddObject(module, "Dap", (PyObject*)&DapObject_DapObjectType);
//PyModule_AddObject(module, "Dap", (PyObject*)&DapObject_DapObjectType);
return
module
;
return
module
;
...
...
This diff is collapsed.
Click to expand it.
test/main_test.py
+
77
−
2
View file @
9f2ad11a
from
libCellFrame
import
*
from
libCellFrame
import
*
import
pickle
import
os
import
os
import
sys
import
sys
...
@@ -12,9 +13,8 @@ app_name = "testAPP"
...
@@ -12,9 +13,8 @@ app_name = "testAPP"
print
(
"
Create config file
"
)
print
(
"
Create config file
"
)
create_config_file
(
app_name
)
create_config_file
(
app_name
)
json_string
=
"""
{
json_string
=
"""
{
"
modules
"
:
""
,
"
modules
"
:
[
"
crypto
"
]
,
"
DAP
"
: {
"
DAP
"
: {
"
config_dir
"
:
\"
"""
+
os
.
getcwd
()
+
"""
\"
,
"
config_dir
"
:
\"
"""
+
os
.
getcwd
()
+
"""
\"
,
"
log_level
"
:
"
L_DEBUG
"
,
"
log_level
"
:
"
L_DEBUG
"
,
...
@@ -23,6 +23,8 @@ json_string = """{
...
@@ -23,6 +23,8 @@ json_string = """{
}
}
}
"""
}
"""
print
(
"
init start
"
)
init
(
json_string
)
init
(
json_string
)
logItInfo
(
"
Initialization of the DAP done
"
)
logItInfo
(
"
Initialization of the DAP done
"
)
setLogLevel
(
DEBUG
)
setLogLevel
(
DEBUG
)
...
@@ -34,6 +36,79 @@ logItInfo("Output [server] 'listen_address' = "+res1+"\n")
...
@@ -34,6 +36,79 @@ logItInfo("Output [server] 'listen_address' = "+res1+"\n")
res2
=
configGetItemDefault
(
"
server1
"
,
"
listen_address
"
,
"
8.8.8.8
"
)
res2
=
configGetItemDefault
(
"
server1
"
,
"
listen_address
"
,
"
8.8.8.8
"
)
logItInfo
(
"
Output default value
'
8.8.8.8
'
[server1]
'
listen_address
'
=
"
+
res2
+
"
\n
"
)
logItInfo
(
"
Output default value
'
8.8.8.8
'
[server1]
'
listen_address
'
=
"
+
res2
+
"
\n
"
)
logItInfo
(
"
TEST. Get default config done
"
)
logItInfo
(
"
TEST. Get default config done
"
)
logItInfo
(
"
Create KEY
"
)
key
=
Crypto
.
newKey
(
CryptoKeyType
.
DAP_ENC_KEY_TYPE_IAES
())
del
key
logItInfo
(
"
Create KEY TWO
"
)
key2
=
Crypto
.
newKey
(
CryptoKeyType
.
DAP_ENC_KEY_TYPE_OAES
())
logItInfo
(
"
Dellete key
"
)
del
key2
logItInfo
(
"
TEST BASE58. START...
"
)
s
=
"""
Test! I will crush Base58!
"""
base_in
=
pickle
.
dumps
(
s
)
crypt
=
Crypto
.
encodeBase58
(
base_in
)
decrypt
=
Crypto
.
decodeBase58
(
crypt
)
out_data
=
pickle
.
loads
(
decrypt
)
if
s
==
out_data
:
logItInfo
(
"
TEST 1. Encode/Decode base58 done
"
)
else
:
logItInfo
(
"
TEST 1. Encode/Decode base58 faild
"
)
sys
.
exit
(
1
)
logItInfo
(
"
TEST. BASE64 START...
"
)
s
=
"
Test! I will crush Base64!
"
crypt
=
Crypto
.
encodeBase64
(
bytes
(
s
,
"
utf-8
"
),
CryptoDataType
.
DAP_ENC_DATA_TYPE_B64
())
decrypt
=
Crypto
.
decodeBase64
(
crypt
,
CryptoDataType
.
DAP_ENC_DATA_TYPE_B64
())
if
bytes
(
s
,
"
utf-8
"
)
==
decrypt
:
logItInfo
(
"
TEST 1. Encode/Decode base64 done
"
)
else
:
logItInfo
(
"
TEST 1. Encode/Decode base64 faild
"
)
sys
.
exit
(
1
)
logItInfo
(
"
TEST.BASE64 URLSAFE START...
"
)
u
=
"
http://kelvin.foundation/
"
crypt_u
=
Crypto
.
encodeBase64
(
bytes
(
u
,
"
utf-8
"
),
CryptoDataType
.
DAP_ENC_DATA_TYPE_B64_URLSAFE
())
decrypt_u
=
Crypto
.
decodeBase64
(
crypt_u
,
CryptoDataType
.
DAP_ENC_DATA_TYPE_B64_URLSAFE
())
if
bytes
(
u
,
"
utf-8
"
)
==
decrypt_u
:
logItInfo
(
"
TEST 2. Encode/Decode base64 urlsafe done
"
)
else
:
logItInfo
(
"
TEST 2. Encode/Decode base64 urlsafe faild
"
)
sys
.
exit
(
2
)
logItInfo
(
"
TEST. IAES256 CBC START...
"
)
s
=
"
Test! I will crush iaes256!
"
kex_buff
=
bytes
(
"
123
"
,
"
utf-8
"
)
size_kex_buff
=
len
(
kex_buff
)
seed
=
bytes
(
112771128
)
seed_size
=
len
(
seed
)
key_n
=
Crypto
.
generateNewKey
(
CryptoKeyType
.
DAP_ENC_KEY_TYPE_IAES
(),
kex_buff
,
size_kex_buff
,
seed
,
seed_size
,
0
)
source
=
bytes
(
s
,
"
utf-8
"
)
enc
=
Crypto
.
encryptIAES256CBCFast
(
key_n
,
source
,
len
(
source
),
2048
)
decrypt
=
Crypto
.
decryptIAES256CBCFast
(
key_n
,
enc
,
len
(
enc
),
2048
)
if
bytes
(
s
,
"
utf-8
"
)
==
decrypt
:
logItInfo
(
"
TEST 1. Encode/Decode IAES256 CBC FAST done
"
)
else
:
logItInfo
(
"
TEST 1. Encode/Decode IAES256 CBC FAST faild
"
)
sys
.
exit
(
1
)
logItInfo
(
"
TEST. OAES START...
"
)
s
=
"
Test! I will crush OAES!
"
kex_buff
=
bytes
(
"
114151400014314485131FGXVGHcJFIH
"
,
"
utf-8
"
)
size_kex_buff
=
len
(
kex_buff
)
seed
=
bytes
(
112771128
)
seed_size
=
len
(
seed
)
key_id
=
Crypto
.
generateNewKey
(
CryptoKeyType
.
DAP_ENC_KEY_TYPE_OAES
(),
kex_buff
,
size_kex_buff
,
seed
,
seed_size
,
32
)
source
=
bytes
(
s
,
"
utf-8
"
)
enc
=
Crypto
.
encryptOAESFast
(
key_id
,
source
,
len
(
source
),
2048
)
decrypt
=
Crypto
.
decryptOAESFast
(
key_id
,
enc
,
len
(
enc
),
2048
)
if
bytes
(
s
,
"
utf-8
"
)
==
decrypt
:
logItInfo
(
"
TEST 1. Encode/Decode OAES FAST done
"
)
else
:
logItInfo
(
"
TEST 1. Encode/Decode OAES CBC FAST faild
"
)
sys
.
exit
(
1
)
deinit
()
deinit
()
logItInfo
(
"
Deinitialization done
"
)
logItInfo
(
"
Deinitialization done
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment