Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
libatsha204
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Turris
libatsha204
Commits
b1c1c8b8
Verified
Commit
b1c1c8b8
authored
Oct 31, 2018
by
Štěpán Henek
🐻
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
migrate to python3
parent
9f183596
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
8 deletions
+50
-8
src/python/atsha204.c
src/python/atsha204.c
+49
-7
src/python/setup.py
src/python/setup.py
+1
-1
No files found.
src/python/atsha204.c
View file @
b1c1c8b8
...
...
@@ -32,7 +32,7 @@ static PyObject *atsha_emulate_hmac(PyObject *self, PyObject *args) {
int
size_serial
,
size_key
,
size_challenge
;
unsigned
char
slot_id
;
const
uint8_t
*
serial
,
*
key
,
*
challenge
;
if
(
!
PyArg_ParseTuple
(
args
,
"b
s#s#s
#"
,
&
slot_id
,
&
serial
,
&
size_serial
,
&
key
,
&
size_key
,
&
challenge
,
&
size_challenge
))
{
if
(
!
PyArg_ParseTuple
(
args
,
"b
y#y#y
#"
,
&
slot_id
,
&
serial
,
&
size_serial
,
&
key
,
&
size_key
,
&
challenge
,
&
size_challenge
))
{
return
NULL
;
}
...
...
@@ -60,14 +60,14 @@ static PyObject *atsha_emulate_hmac(PyObject *self, PyObject *args) {
return
NULL
;
}
atsha_close
(
crypto
);
return
Py_BuildValue
(
"
s
#"
,
response_s
.
data
,
(
int
)
response_s
.
bytes
);
return
Py_BuildValue
(
"
y
#"
,
response_s
.
data
,
(
int
)
response_s
.
bytes
);
}
static
PyObject
*
atsha_do_hmac
(
PyObject
*
self
,
PyObject
*
args
)
{
(
void
)
self
;
int
size_challenge
;
const
uint8_t
*
challenge
;
if
(
!
PyArg_ParseTuple
(
args
,
"
s
#"
,
&
challenge
,
&
size_challenge
))
{
if
(
!
PyArg_ParseTuple
(
args
,
"
y
#"
,
&
challenge
,
&
size_challenge
))
{
return
NULL
;
}
...
...
@@ -91,7 +91,7 @@ static PyObject *atsha_do_hmac(PyObject *self, PyObject *args) {
return
NULL
;
}
atsha_close
(
crypto
);
return
Py_BuildValue
(
"
s
#"
,
response_s
.
data
,
(
int
)
response_s
.
bytes
);
return
Py_BuildValue
(
"
y
#"
,
response_s
.
data
,
(
int
)
response_s
.
bytes
);
}
static
PyObject
*
get_serial
(
PyObject
*
self
,
PyObject
*
args
)
{
...
...
@@ -119,7 +119,7 @@ static PyObject *get_serial(PyObject *self, PyObject *args) {
return
NULL
;
}
atsha_close
(
crypto
);
return
Py_BuildValue
(
"
s
#"
,
abi_serial
.
data
,
(
int
)
abi_serial
.
bytes
);
return
Py_BuildValue
(
"
y
#"
,
abi_serial
.
data
,
(
int
)
abi_serial
.
bytes
);
}
static
PyMethodDef
atsha_methods
[]
=
{
...
...
@@ -148,6 +148,48 @@ static PyMethodDef atsha_methods[] = {
{
NULL
}
};
PyMODINIT_FUNC
initatsha204
(
void
)
{
Py_InitModule
(
"atsha204"
,
atsha_methods
);
struct
module_state
{
PyObject
*
error
;
};
#define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
static
int
atsha_traverse
(
PyObject
*
m
,
visitproc
visit
,
void
*
arg
)
{
Py_VISIT
(
GETSTATE
(
m
)
->
error
);
return
0
;
}
static
int
atsha_clear
(
PyObject
*
m
)
{
Py_CLEAR
(
GETSTATE
(
m
)
->
error
);
return
0
;
}
static
struct
PyModuleDef
moduledef
=
{
PyModuleDef_HEAD_INIT
,
"atsha204"
,
NULL
,
sizeof
(
struct
module_state
),
atsha_methods
,
NULL
,
atsha_traverse
,
atsha_clear
,
NULL
};
PyMODINIT_FUNC
PyInit_atsha204
(
void
)
{
PyObject
*
module
=
PyModule_Create
(
&
moduledef
);
if
(
module
==
NULL
)
{
return
NULL
;
}
struct
module_state
*
st
=
GETSTATE
(
module
);
st
->
error
=
PyErr_NewException
(
"atsha204.Error"
,
NULL
,
NULL
);
if
(
st
->
error
==
NULL
)
{
Py_DECREF
(
module
);
return
NULL
;
}
return
module
;
}
src/python/setup.py
View file @
b1c1c8b8
...
...
@@ -18,4 +18,4 @@
from
distutils.core
import
setup
,
Extension
extension
=
Extension
(
'atsha204'
,
[
'atsha204.c'
],
libraries
=
[
'atsha204'
],
library_dirs
=
[
'../../lib'
])
setup
(
name
=
'atsha204'
,
version
=
'0.
1
'
,
ext_modules
=
[
extension
],
provides
=
[
'atsha204'
])
setup
(
name
=
'atsha204'
,
version
=
'0.
2
'
,
ext_modules
=
[
extension
],
provides
=
[
'atsha204'
])
Daniel Kahn Gillmor
@dkg
mentioned in issue
#2 (closed)
·
Mar 14, 2019
mentioned in issue
#2 (closed)
mentioned in issue #2
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment