Skip to content

Commit d8947d9

Browse files
author
Pan
committed
Added pki and ed25519 definitions. Updated setup.py.
1 parent da3a34c commit d8947d9

File tree

4 files changed

+78
-7
lines changed

4 files changed

+78
-7
lines changed

setup.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,15 @@
2323
ON_WINDOWS = platform.system() == 'Windows'
2424

2525
ext = 'pyx' if USING_CYTHON else 'c'
26-
sources = glob('ssh2/*.%s' % (ext,))
27-
_libs = ['ssh2'] if not ON_WINDOWS else [
28-
'Ws2_32', 'libssh2', 'user32',
26+
sources = glob('ssh/*.%s' % (ext,))
27+
_libs = ['ssh'] if not ON_WINDOWS else [
28+
'Ws2_32', 'libssh', 'user32',
2929
'libeay32MD', 'ssleay32MD',
3030
'zlibstatic',
3131
]
3232

3333
# _comp_args = ["-ggdb"]
3434
_comp_args = ["-O3"] if not ON_WINDOWS else None
35-
_embedded_lib = bool(int(os.environ.get('EMBEDDED_LIB', 1)))
36-
_have_agent_fwd = bool(int(os.environ.get('HAVE_AGENT_FWD', 1)))
3735
cython_directives = {'embedsignature': True,
3836
'boundscheck': False,
3937
'optimize.use_switch': True,
@@ -42,8 +40,7 @@
4240
cython_args = {
4341
'cython_directives': cython_directives,
4442
'cython_compile_time_env': {
45-
'EMBEDDED_LIB': _embedded_lib,
46-
'HAVE_AGENT_FWD': _have_agent_fwd,
43+
'_WIN32': ON_WINDOWS,
4744
}} \
4845
if USING_CYTHON else {}
4946

ssh/c_ed25519.pxd

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# This file is part of ssh-python.
2+
# Copyright (C) 2018 Panos Kittenis
3+
#
4+
# This library is free software; you can redistribute it and/or
5+
# modify it under the terms of the GNU Lesser General Public
6+
# License as published by the Free Software Foundation, version 2.1.
7+
#
8+
# This library is distributed in the hope that it will be useful,
9+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+
# Lesser General Public License for more details.
12+
#
13+
# You should have received a copy of the GNU Lesser General Public
14+
# License along with this library; if not, write to the Free Software
15+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
16+
17+
from c_ssh cimport uint8_t
18+
19+
cdef extern from "libssh/include/ed25519.h" nogil:
20+
enum:
21+
ED25519_PK_LEN
22+
ED25519_SK_LEN
23+
ED25519_SIG_LEN
24+
ctypedef uint8_t ed25519_pubkey[ED25519_PK_LEN]
25+
ctypedef uint8_t ed25519_privkey[ED25519_SK_LEN]
26+
ctypedef uint8_t ed25519_signature[ED25519_SIG_LEN]
27+
int crypto_sign_ed25519_keypair(ed25519_pubkey pk, ed25519_privkey sk)
28+
int crypto_sign_ed25519(
29+
unsigned char *sm,unsigned long long *smlen,
30+
const unsigned char *m,unsigned long long mlen,
31+
const ed25519_privkey sk)
32+
int crypto_sign_ed25519_open(
33+
unsigned char *m,unsigned long long *mlen,
34+
const unsigned char *sm,unsigned long long smlen,
35+
const ed25519_pubkey pk)

ssh/c_pki.pxd

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This file is part of ssh-python.
2+
# Copyright (C) 2018 Panos Kittenis
3+
#
4+
# This library is free software; you can redistribute it and/or
5+
# modify it under the terms of the GNU Lesser General Public
6+
# License as published by the Free Software Foundation, version 2.1.
7+
#
8+
# This library is distributed in the hope that it will be useful,
9+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+
# Lesser General Public License for more details.
12+
#
13+
# You should have received a copy of the GNU Lesser General Public
14+
# License along with this library; if not, write to the Free Software
15+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
16+
17+
from c_ssh cimport ssh_session, ssh_buffer, uint32_t, uint8_t, ssh_keytypes_e
18+
from c_wrapper cimport ssh_hmac_e
19+
from c_callbacks cimport ssh_packet_callbacks
20+
from c_ed25519 cimport ed25519_pubkey, ed25519_privkey
21+
22+
cdef extern from "libssh/include/pki.h" nogil:
23+
enum:
24+
MAX_PUBKEY_SIZE
25+
MAX_PRIVKEY_SIZE
26+
SSH_KEY_FLAG_EMPTY
27+
SSH_KEY_FLAG_PUBLIC
28+
SSH_KEY_FLAG_PRIVATE
29+
struct ssh_key_struct:
30+
ssh_keytypes_e type
31+
int flags
32+
const char *type_c
33+
int ecdsa_nid
34+
ed25519_pubkey *ed25519_pubkey
35+
ed25519_privkey *ed25519_privkey
36+
void *cert
37+
ssh_keytypes_e cert_type

ssh/ssh.pyx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ cimport c_messages
3030
cimport c_options
3131
cimport c_callbacks
3232
cimport c_packet
33+
cimport c_ed25519
34+
cimport c_pki

0 commit comments

Comments
 (0)