|
| 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 |
| 18 | +from c_crypto cimport ssh_cipher_struct, ssh_crypto_struct |
| 19 | + |
| 20 | +cdef extern from "libssh/include/wrapper.h" nogil: |
| 21 | + enum ssh_mac_e: |
| 22 | + SSH_MAC_SHA1, |
| 23 | + SSH_MAC_SHA256, |
| 24 | + SSH_MAC_SHA384, |
| 25 | + SSH_MAC_SHA512 |
| 26 | + |
| 27 | + enum ssh_hmac_e: |
| 28 | + SSH_HMAC_SHA1, |
| 29 | + SSH_HMAC_SHA256, |
| 30 | + SSH_HMAC_SHA384, |
| 31 | + SSH_HMAC_SHA512, |
| 32 | + SSH_HMAC_MD5 |
| 33 | + |
| 34 | + enum ssh_des_e: |
| 35 | + SSH_3DES, |
| 36 | + SSH_DES |
| 37 | + |
| 38 | + struct ssh_hmac_struct: |
| 39 | + const char* name |
| 40 | + ssh_hmac_e hmac_type |
| 41 | + |
| 42 | + # ctypedef ssh_mac_ctx_struct *ssh_mac_ctx |
| 43 | + # MD5CTX md5_init() |
| 44 | + # void md5_update(MD5CTX c, const void *data, unsigned long len) |
| 45 | + # void md5_final(unsigned char *md,MD5CTX c) |
| 46 | + # SHACTX sha1_init() |
| 47 | + # void sha1_update(SHACTX c, const void *data, unsigned long len) |
| 48 | + # void sha1_final(unsigned char *md,SHACTX c) |
| 49 | + void sha1(unsigned char *digest,int len,unsigned char *hash) |
| 50 | + |
| 51 | + # SHA256CTX sha256_init() |
| 52 | + # void sha256_update(SHA256CTX c, const void *data, unsigned long len) |
| 53 | + # void sha256_final(unsigned char *md,SHA256CTX c) |
| 54 | + void sha256(unsigned char *digest, int len, unsigned char *hash) |
| 55 | + |
| 56 | + # SHA384CTX sha384_init(); |
| 57 | + # void sha384_update(SHA384CTX c, const void *data, unsigned long len) |
| 58 | + # void sha384_final(unsigned char *md,SHA384CTX c) |
| 59 | + void sha384(unsigned char *digest, int len, unsigned char *hash) |
| 60 | + |
| 61 | + # SHA512CTX sha512_init(); |
| 62 | + # void sha512_update(SHA512CTX c, const void *data, unsigned long len) |
| 63 | + # void sha512_final(unsigned char *md,SHA512CTX c) |
| 64 | + void sha512(unsigned char *digest, int len, unsigned char *hash) |
| 65 | + |
| 66 | + void evp(int nid, unsigned char *digest, int len, unsigned char *hash, unsigned int *hlen) |
| 67 | + # EVPCTX evp_init(int nid) |
| 68 | + # void evp_update(EVPCTX ctx, const void *data, unsigned long len) |
| 69 | + # void evp_final(EVPCTX ctx, unsigned char *md, unsigned int *mdlen) |
| 70 | + |
| 71 | + # ssh_mac_ctx ssh_mac_ctx_init(ssh_mac_e type) |
| 72 | + # void ssh_mac_update(ssh_mac_ctx ctx, const void *data, unsigned long len) |
| 73 | + # void ssh_mac_final(unsigned char *md, ssh_mac_ctx ctx) |
| 74 | + |
| 75 | + # HMACCTX hmac_init(const void *key,int len, ssh_hmac_e type) |
| 76 | + # void hmac_update(HMACCTX c, const void *data, unsigned long len) |
| 77 | + # void hmac_final(HMACCTX ctx,unsigned char *hashmacbuf,unsigned int *len) |
| 78 | + size_t hmac_digest_len(ssh_hmac_e type) |
| 79 | + |
| 80 | + int crypt_set_algorithms(ssh_session session, ssh_des_e des_type) |
| 81 | + int crypt_set_algorithms_server(ssh_session session) |
| 82 | + ssh_crypto_struct *crypto_new() |
| 83 | + void crypto_free(ssh_crypto_struct *crypto) |
| 84 | + |
| 85 | + void ssh_reseed() |
| 86 | + |
| 87 | + void ssh_cipher_clear(ssh_cipher_struct *cipher) |
| 88 | + ssh_hmac_struct *ssh_get_hmactab() |
| 89 | + const char *ssh_hmac_type_to_string(ssh_hmac_e hmac_type) |
0 commit comments