27#include "libssh/libssh.h"
28#include "libssh/libcrypto.h"
29#include "libssh/libgcrypt.h"
30#include "libssh/libmbedcrypto.h"
48 SSH_HMAC_AEAD_POLY1305,
58struct ssh_hmac_struct {
60 enum ssh_hmac_e hmac_type;
64enum ssh_crypto_direction_e {
66 SSH_DIRECTION_OUT = 2,
67 SSH_DIRECTION_BOTH = 3,
70struct ssh_cipher_struct;
71struct ssh_crypto_struct;
73typedef struct ssh_mac_ctx_struct *ssh_mac_ctx;
75void md5_ctx_free(MD5CTX);
76int md5_update(MD5CTX c,
const void *data,
size_t len);
77int md5_final(
unsigned char *md, MD5CTX c);
79SHACTX sha1_init(
void);
80void sha1_ctx_free(SHACTX);
81int sha1_update(SHACTX c,
const void *data,
size_t len);
82int sha1_final(
unsigned char *md,SHACTX c);
83int sha1(
const unsigned char *digest,
size_t len,
unsigned char *hash);
85SHA256CTX sha256_init(
void);
86void sha256_ctx_free(SHA256CTX);
87int sha256_update(SHA256CTX c,
const void *data,
size_t len);
88int sha256_final(
unsigned char *md,SHA256CTX c);
89int sha256(
const unsigned char *digest,
size_t len,
unsigned char *hash);
91SHA384CTX sha384_init(
void);
92void sha384_ctx_free(SHA384CTX);
93int sha384_update(SHA384CTX c,
const void *data,
size_t len);
94int sha384_final(
unsigned char *md,SHA384CTX c);
95int sha384(
const unsigned char *digest,
size_t len,
unsigned char *hash);
97SHA512CTX sha512_init(
void);
98void sha512_ctx_free(SHA512CTX);
99int sha512_update(SHA512CTX c,
const void *data,
size_t len);
100int sha512_final(
unsigned char *md,SHA512CTX c);
101int sha512(
const unsigned char *digest,
size_t len,
unsigned char *hash);
103HMACCTX hmac_init(
const void *key,
size_t len,
enum ssh_hmac_e type);
104int hmac_update(HMACCTX c,
const void *data,
size_t len);
105int hmac_final(HMACCTX ctx,
unsigned char *hashmacbuf,
size_t *len);
106size_t hmac_digest_len(
enum ssh_hmac_e type);
108int ssh_kdf(
struct ssh_crypto_struct *crypto,
109 unsigned char *key,
size_t key_len,
110 uint8_t key_type,
unsigned char *output,
111 size_t requested_len);
113int crypt_set_algorithms_client(ssh_session session);
114int crypt_set_algorithms_server(ssh_session session);
115struct ssh_crypto_struct *crypto_new(
void);
116void crypto_free(
struct ssh_crypto_struct *crypto);
118void ssh_reseed(
void);
119int ssh_crypto_init(
void);
120void ssh_crypto_finalize(
void);
122void ssh_cipher_clear(
struct ssh_cipher_struct *cipher);
123struct ssh_hmac_struct *ssh_get_hmactab(
void);
124struct ssh_cipher_struct *ssh_get_ciphertab(
void);
125const char *ssh_hmac_type_to_string(
enum ssh_hmac_e hmac_type,
bool etm);
127#if defined(HAVE_LIBCRYPTO) && OPENSSL_VERSION_NUMBER >= 0x30000000L
128int evp_build_pkey(
const char* name, OSSL_PARAM_BLD *param_bld, EVP_PKEY **pkey,
int selection);
129int evp_dup_dsa_pkey(
const ssh_key key, ssh_key new_key,
int demote);
130int evp_dup_rsa_pkey(
const ssh_key key, ssh_key new_key,
int demote);
131int evp_dup_ecdsa_pkey(
const ssh_key key, ssh_key new_key,
int demote);