Rename SSH-1 cipher constants to start "SSH1_".

They're called things like SSH_CIPHER_3DES in the SSH-1 spec, but I
don't normally let that stop me adding the disambiguating '1' in the
names I give constants inside this code base. These ones are long
overdue for some disambiguation.
This commit is contained in:
Simon Tatham 2019-04-01 20:06:42 +01:00
Родитель 3d8563ec9d
Коммит bf661a7a2c
4 изменённых файлов: 21 добавлений и 20 удалений

9
ssh.h
Просмотреть файл

@ -409,10 +409,11 @@ void ssh_proto_error(Ssh *ssh, const char *fmt, ...);
void ssh_sw_abort(Ssh *ssh, const char *fmt, ...); void ssh_sw_abort(Ssh *ssh, const char *fmt, ...);
void ssh_user_close(Ssh *ssh, const char *fmt, ...); void ssh_user_close(Ssh *ssh, const char *fmt, ...);
#define SSH_CIPHER_IDEA 1 /* Bit positions in the SSH-1 cipher protocol word */
#define SSH_CIPHER_DES 2 #define SSH1_CIPHER_IDEA 1
#define SSH_CIPHER_3DES 3 #define SSH1_CIPHER_DES 2
#define SSH_CIPHER_BLOWFISH 6 #define SSH1_CIPHER_3DES 3
#define SSH1_CIPHER_BLOWFISH 6
struct ssh_key { struct ssh_key {
const ssh_keyalg *vt; const ssh_keyalg *vt;

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

@ -147,9 +147,9 @@ static void ssh1_login_server_process_queue(PacketProtocolLayer *ppl)
s->local_protoflags = SSH1_PROTOFLAGS_SUPPORTED; s->local_protoflags = SSH1_PROTOFLAGS_SUPPORTED;
/* FIXME: ability to configure this to a subset */ /* FIXME: ability to configure this to a subset */
s->supported_ciphers_mask = ((1U << SSH_CIPHER_3DES) | s->supported_ciphers_mask = ((1U << SSH1_CIPHER_3DES) |
(1U << SSH_CIPHER_BLOWFISH) | (1U << SSH1_CIPHER_BLOWFISH) |
(1U << SSH_CIPHER_DES)); (1U << SSH1_CIPHER_DES));
s->supported_auths_mask = 0; s->supported_auths_mask = 0;
s->ap_methods = auth_methods(s->authpolicy); s->ap_methods = auth_methods(s->authpolicy);
if (s->ap_methods & AUTHMETHOD_PASSWORD) if (s->ap_methods & AUTHMETHOD_PASSWORD)
@ -244,8 +244,8 @@ static void ssh1_login_server_process_queue(PacketProtocolLayer *ppl)
{ {
const ssh_cipheralg *cipher = const ssh_cipheralg *cipher =
(s->cipher_type == SSH_CIPHER_BLOWFISH ? &ssh_blowfish_ssh1 : (s->cipher_type == SSH1_CIPHER_BLOWFISH ? &ssh_blowfish_ssh1 :
s->cipher_type == SSH_CIPHER_DES ? &ssh_des : &ssh_3des_ssh1); s->cipher_type == SSH1_CIPHER_DES ? &ssh_des : &ssh_3des_ssh1);
ssh1_bpp_new_cipher(s->ppl.bpp, cipher, s->session_key); ssh1_bpp_new_cipher(s->ppl.bpp, cipher, s->session_key);
} }

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

@ -300,11 +300,11 @@ static void ssh1_login_process_queue(PacketProtocolLayer *ppl)
ppl_logevent("AES not supported in SSH-1, skipping"); ppl_logevent("AES not supported in SSH-1, skipping");
} else { } else {
switch (next_cipher) { switch (next_cipher) {
case CIPHER_3DES: s->cipher_type = SSH_CIPHER_3DES; case CIPHER_3DES: s->cipher_type = SSH1_CIPHER_3DES;
cipher_string = "3DES"; break; cipher_string = "3DES"; break;
case CIPHER_BLOWFISH: s->cipher_type = SSH_CIPHER_BLOWFISH; case CIPHER_BLOWFISH: s->cipher_type = SSH1_CIPHER_BLOWFISH;
cipher_string = "Blowfish"; break; cipher_string = "Blowfish"; break;
case CIPHER_DES: s->cipher_type = SSH_CIPHER_DES; case CIPHER_DES: s->cipher_type = SSH1_CIPHER_DES;
cipher_string = "single-DES"; break; cipher_string = "single-DES"; break;
} }
if (s->supported_ciphers_mask & (1 << s->cipher_type)) if (s->supported_ciphers_mask & (1 << s->cipher_type))
@ -312,7 +312,7 @@ static void ssh1_login_process_queue(PacketProtocolLayer *ppl)
} }
} }
if (!cipher_chosen) { if (!cipher_chosen) {
if ((s->supported_ciphers_mask & (1 << SSH_CIPHER_3DES)) == 0) { if ((s->supported_ciphers_mask & (1 << SSH1_CIPHER_3DES)) == 0) {
ssh_proto_error(s->ppl.ssh, "Server violates SSH-1 protocol " ssh_proto_error(s->ppl.ssh, "Server violates SSH-1 protocol "
"by not supporting 3DES encryption"); "by not supporting 3DES encryption");
} else { } else {
@ -336,13 +336,13 @@ static void ssh1_login_process_queue(PacketProtocolLayer *ppl)
} }
switch (s->cipher_type) { switch (s->cipher_type) {
case SSH_CIPHER_3DES: case SSH1_CIPHER_3DES:
ppl_logevent("Using 3DES encryption"); ppl_logevent("Using 3DES encryption");
break; break;
case SSH_CIPHER_DES: case SSH1_CIPHER_DES:
ppl_logevent("Using single-DES encryption"); ppl_logevent("Using single-DES encryption");
break; break;
case SSH_CIPHER_BLOWFISH: case SSH1_CIPHER_BLOWFISH:
ppl_logevent("Using Blowfish encryption"); ppl_logevent("Using Blowfish encryption");
break; break;
} }
@ -369,8 +369,8 @@ static void ssh1_login_process_queue(PacketProtocolLayer *ppl)
{ {
const ssh_cipheralg *cipher = const ssh_cipheralg *cipher =
(s->cipher_type == SSH_CIPHER_BLOWFISH ? &ssh_blowfish_ssh1 : (s->cipher_type == SSH1_CIPHER_BLOWFISH ? &ssh_blowfish_ssh1 :
s->cipher_type == SSH_CIPHER_DES ? &ssh_des : &ssh_3des_ssh1); s->cipher_type == SSH1_CIPHER_DES ? &ssh_des : &ssh_3des_ssh1);
ssh1_bpp_new_cipher(s->ppl.bpp, cipher, s->session_key); ssh1_bpp_new_cipher(s->ppl.bpp, cipher, s->session_key);
} }

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

@ -71,7 +71,7 @@ static int rsa_ssh1_load_main(FILE * fp, RSAKey *key, bool pub_only,
/* One byte giving encryption type, and one reserved uint32. */ /* One byte giving encryption type, and one reserved uint32. */
ciphertype = get_byte(src); ciphertype = get_byte(src);
if (ciphertype != 0 && ciphertype != SSH_CIPHER_3DES) if (ciphertype != 0 && ciphertype != SSH1_CIPHER_3DES)
goto end; goto end;
if (get_uint32(src) != 0) if (get_uint32(src) != 0)
goto end; /* reserved field nonzero, panic! */ goto end; /* reserved field nonzero, panic! */
@ -330,7 +330,7 @@ bool rsa_ssh1_savekey(const Filename *filename, RSAKey *key,
* The public part of the key. * The public part of the key.
*/ */
put_data(buf, rsa_signature, sizeof(rsa_signature)); put_data(buf, rsa_signature, sizeof(rsa_signature));
put_byte(buf, passphrase ? SSH_CIPHER_3DES : 0); /* encryption type */ put_byte(buf, passphrase ? SSH1_CIPHER_3DES : 0); /* encryption type */
put_uint32(buf, 0); /* reserved */ put_uint32(buf, 0); /* reserved */
rsa_ssh1_public_blob(BinarySink_UPCAST(buf), key, rsa_ssh1_public_blob(BinarySink_UPCAST(buf), key,
RSA_SSH1_MODULUS_FIRST); RSA_SSH1_MODULUS_FIRST);