Skip to content

Commit 9756dff

Browse files
author
Pan
committed
Added pki_priv and updated pki definitions.
1 parent 3f729a8 commit 9756dff

File tree

3 files changed

+146
-1
lines changed

3 files changed

+146
-1
lines changed

ssh/c_pki.pxd

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@
1414
# License along with this library; if not, write to the Free Software
1515
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
1616

17-
from c_ssh cimport ssh_session, ssh_buffer, uint32_t, uint8_t, ssh_keytypes_e
17+
from c_ssh cimport ssh_session, ssh_buffer, uint32_t, uint8_t, ssh_keytypes_e, \
18+
ssh_string, ssh_buffer_struct
1819
from c_wrapper cimport ssh_hmac_e
1920
from c_callbacks cimport ssh_packet_callbacks
2021
from c_ed25519 cimport ed25519_pubkey, ed25519_privkey
22+
from c_priv cimport ssh_key
23+
from c_legacy cimport ssh_private_key, ssh_public_key
2124

2225
cdef extern from "libssh/include/pki.h" nogil:
2326
enum:
@@ -35,3 +38,44 @@ cdef extern from "libssh/include/pki.h" nogil:
3538
ed25519_privkey *ed25519_privkey
3639
void *cert
3740
ssh_keytypes_e cert_type
41+
struct ssh_signature_struct:
42+
ssh_keytypes_e _type "type"
43+
const char *type_c
44+
ctypedef ssh_signature_struct *ssh_signature
45+
ssh_key ssh_key_dup(const ssh_key key)
46+
void ssh_key_clean (ssh_key key)
47+
48+
ssh_signature ssh_signature_new()
49+
void ssh_signature_free(ssh_signature sign)
50+
51+
int ssh_pki_export_signature_blob(const ssh_signature sign,
52+
ssh_string *sign_blob)
53+
int ssh_pki_import_signature_blob(const ssh_string sig_blob,
54+
const ssh_key pubkey,
55+
ssh_signature *psig)
56+
int ssh_pki_signature_verify_blob(ssh_session session,
57+
ssh_string sig_blob,
58+
const ssh_key key,
59+
unsigned char *digest,
60+
size_t dlen)
61+
int ssh_pki_export_pubkey_blob(const ssh_key key,
62+
ssh_string *pblob)
63+
int ssh_pki_import_pubkey_blob(const ssh_string key_blob,
64+
ssh_key *pkey)
65+
int ssh_pki_export_pubkey_rsa1(const ssh_key key,
66+
const char *host,
67+
char *rsa1,
68+
size_t rsa1_len)
69+
70+
int ssh_pki_import_cert_blob(const ssh_string cert_blob,
71+
ssh_key *pkey)
72+
73+
ssh_string ssh_pki_do_sign(ssh_session session, ssh_buffer sigbuf,
74+
const ssh_key privatekey)
75+
ssh_string ssh_pki_do_sign_agent(ssh_session session,
76+
ssh_buffer_struct *buf,
77+
const ssh_key pubkey)
78+
ssh_string ssh_srv_pki_do_sign_sessionid(ssh_session session,
79+
const ssh_key privkey)
80+
ssh_public_key ssh_pki_convert_key_to_publickey(const ssh_key key)
81+
ssh_private_key ssh_pki_convert_key_to_privatekey(const ssh_key key)

ssh/c_pki_priv.pxd

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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, ssh_keytypes_e, ssh_string, ssh_auth_callback, \
18+
ssh_buffer, ssh_keycmp_e, ssh_session
19+
from c_pki cimport ssh_key_struct, ssh_signature
20+
21+
cdef extern from "libssh/include/pki_priv.h" nogil:
22+
ctypedef ssh_key_struct *ssh_key
23+
int bcrypt_pbkdf(const char *,
24+
size_t passlen,
25+
const uint8_t *salt,
26+
size_t saltlen,
27+
uint8_t *key,
28+
size_t keylen,
29+
unsigned int rounds)
30+
31+
int pki_key_ecdsa_nid_from_name(const char *name)
32+
const char *pki_key_ecdsa_nid_to_name(int nid)
33+
ssh_key pki_key_dup(const ssh_key key, int demote);
34+
int pki_key_generate_rsa(ssh_key key, int parameter);
35+
int pki_key_generate_dss(ssh_key key, int parameter);
36+
int pki_key_generate_ecdsa(ssh_key key, int parameter);
37+
int pki_key_generate_ed25519(ssh_key key);
38+
39+
int pki_key_compare(const ssh_key k1,
40+
const ssh_key k2,
41+
ssh_keycmp_e what)
42+
43+
ssh_keytypes_e pki_privatekey_type_from_string(const char *privkey);
44+
ssh_key pki_private_key_from_base64(const char *b64_key,
45+
const char *passphrase,
46+
ssh_auth_callback auth_fn,
47+
void *auth_data)
48+
ssh_string pki_private_key_to_pem(const ssh_key key,
49+
const char *passphrase,
50+
ssh_auth_callback auth_fn,
51+
void *auth_data)
52+
53+
int pki_pubkey_build_dss(ssh_key key,
54+
ssh_string p,
55+
ssh_string q,
56+
ssh_string g,
57+
ssh_string pubkey)
58+
int pki_pubkey_build_rsa(ssh_key key,
59+
ssh_string e,
60+
ssh_string n)
61+
int pki_pubkey_build_ecdsa(ssh_key key, int nid, ssh_string e)
62+
ssh_string pki_publickey_to_blob(const ssh_key key)
63+
int pki_export_pubkey_rsa1(const ssh_key key,
64+
const char *host,
65+
char *rsa1,
66+
size_t rsa1_len)
67+
68+
ssh_string pki_signature_to_blob(const ssh_signature sign);
69+
ssh_signature pki_signature_from_blob(const ssh_key pubkey,
70+
const ssh_string sig_blob,
71+
ssh_keytypes_e);
72+
int pki_signature_verify(ssh_session session,
73+
const ssh_signature sig,
74+
const ssh_key key,
75+
const unsigned char *hash,
76+
size_t hlen)
77+
78+
ssh_signature pki_do_sign(const ssh_key privkey,
79+
const unsigned char *hash,
80+
size_t hlen)
81+
ssh_signature pki_do_sign_sessionid(const ssh_key key,
82+
const unsigned char *hash,
83+
size_t hlen)
84+
int pki_ed25519_sign(const ssh_key privkey, ssh_signature sig,
85+
const unsigned char *hash, size_t hlen)
86+
int pki_ed25519_verify(const ssh_key pubkey, ssh_signature sig,
87+
const unsigned char *hash, size_t hlen)
88+
int pki_ed25519_key_cmp(const ssh_key k1,
89+
const ssh_key k2,
90+
ssh_keycmp_e what)
91+
int pki_ed25519_key_dup(ssh_key, const ssh_key key)
92+
int pki_ed25519_public_key_to_blob(ssh_buffer buffer, ssh_key key)
93+
ssh_string pki_ed25519_sig_to_blob(ssh_signature sig)
94+
int pki_ed25519_sig_from_blob(ssh_signature sig, ssh_string sig_blob)
95+
ssh_key ssh_pki_openssh_privkey_import(
96+
const char *text_key,
97+
const char *passphrase, ssh_auth_callback auth_fn, void *auth_data)
98+
ssh_string ssh_pki_openssh_privkey_export(
99+
const ssh_key privkey,
100+
const char *passphrase, ssh_auth_callback auth_fn, void *auth_data)

ssh/ssh.pyx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ cimport c_gssapi
3737
cimport c_socket
3838
cimport c_priv
3939
cimport c_session
40+
cimport c_pki_priv

0 commit comments

Comments
 (0)