1
1

wrapper: Reformat crypt_set_algorithms2()

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Этот коммит содержится в:
Andreas Schneider 2018-09-26 10:44:46 +02:00
родитель 60a3796041
Коммит 39b08af2e8

Просмотреть файл

@ -224,11 +224,12 @@ void crypto_free(struct ssh_crypto_struct *crypto)
SAFE_FREE(crypto);
}
static int crypt_set_algorithms2(ssh_session session){
const char *wanted;
int i = 0;
static int crypt_set_algorithms2(ssh_session session)
{
const char *wanted = NULL;
struct ssh_cipher_struct *ssh_ciphertab=ssh_get_ciphertab();
struct ssh_hmac_struct *ssh_hmactab=ssh_get_hmactab();
size_t i = 0;
int cmp;
/*
@ -238,8 +239,11 @@ static int crypt_set_algorithms2(ssh_session session){
/* out */
wanted = session->next_crypto->kex_methods[SSH_CRYPT_C_S];
while (ssh_ciphertab[i].name && strcmp(wanted, ssh_ciphertab[i].name)) {
i++;
for (i = 0; i < 64 && ssh_ciphertab[i].name != NULL; ++i) {
cmp = strcmp(wanted, ssh_ciphertab[i].name);
if (cmp == 0) {
break;
}
}
if (ssh_ciphertab[i].name == NULL) {
@ -255,7 +259,6 @@ static int crypt_set_algorithms2(ssh_session session){
ssh_set_error_oom(session);
return SSH_ERROR;
}
i = 0;
if (session->next_crypto->out_cipher->aead_encrypt != NULL) {
/* this cipher has integrated MAC */
@ -343,19 +346,22 @@ static int crypt_set_algorithms2(ssh_session session){
SSH_LOG(SSH_LOG_PACKET, "Set HMAC input algorithm to %s", wanted);
session->next_crypto->in_hmac = ssh_hmactab[i].hmac_type;
i = 0;
/* compression */
if (strcmp(session->next_crypto->kex_methods[SSH_COMP_C_S], "zlib") == 0) {
cmp = strcmp(session->next_crypto->kex_methods[SSH_COMP_C_S], "zlib");
if (cmp == 0) {
session->next_crypto->do_compress_out = 1;
}
if (strcmp(session->next_crypto->kex_methods[SSH_COMP_S_C], "zlib") == 0) {
cmp = strcmp(session->next_crypto->kex_methods[SSH_COMP_S_C], "zlib");
if (cmp == 0) {
session->next_crypto->do_compress_in = 1;
}
if (strcmp(session->next_crypto->kex_methods[SSH_COMP_C_S], "zlib@openssh.com") == 0) {
cmp = strcmp(session->next_crypto->kex_methods[SSH_COMP_C_S], "zlib@openssh.com");
if (cmp == 0) {
session->next_crypto->delayed_compress_out = 1;
}
if (strcmp(session->next_crypto->kex_methods[SSH_COMP_S_C], "zlib@openssh.com") == 0) {
cmp = strcmp(session->next_crypto->kex_methods[SSH_COMP_S_C], "zlib@openssh.com");
if (cmp == 0) {
session->next_crypto->delayed_compress_in = 1;
}