1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-06-30 19:12:48 -05:00

Add 'next_message' methods to cipher and MAC vtables.

This provides a convenient hook to be called between SSH messages, for
the crypto components to do any per-message processing like
incrementing a sequence number.
This commit is contained in:
Simon Tatham
2022-08-16 18:27:06 +01:00
parent 9160c41e7b
commit 840043f06e
12 changed files with 66 additions and 0 deletions

View File

@ -52,6 +52,7 @@ static inline bool check_availability(const struct aes_extra *extra)
.setkey = aes ## impl_c ## _setkey, \
.encrypt = aes ## bits ## impl_c ## _cbc_encrypt, \
.decrypt = aes ## bits ## impl_c ## _cbc_decrypt, \
.next_message = nullcipher_next_message, \
.ssh2_id = "aes" #bits "-cbc", \
.blksize = 16, \
.real_keybits = bits, \
@ -69,6 +70,7 @@ static inline bool check_availability(const struct aes_extra *extra)
.setkey = aes ## impl_c ## _setkey, \
.encrypt = aes ## bits ## impl_c ## _sdctr, \
.decrypt = aes ## bits ## impl_c ## _sdctr, \
.next_message = nullcipher_next_message, \
.ssh2_id = "aes" #bits "-ctr", \
.blksize = 16, \
.real_keybits = bits, \

View File

@ -110,6 +110,7 @@ const ssh_cipheralg ssh_arcfour128_ssh2 = {
.setkey = arcfour_ssh2_setkey,
.encrypt = arcfour_ssh2_block,
.decrypt = arcfour_ssh2_block,
.next_message = nullcipher_next_message,
.ssh2_id = "arcfour128",
.blksize = 1,
.real_keybits = 128,
@ -125,6 +126,7 @@ const ssh_cipheralg ssh_arcfour256_ssh2 = {
.setkey = arcfour_ssh2_setkey,
.encrypt = arcfour_ssh2_block,
.decrypt = arcfour_ssh2_block,
.next_message = nullcipher_next_message,
.ssh2_id = "arcfour256",
.blksize = 1,
.real_keybits = 256,

View File

@ -654,6 +654,7 @@ const ssh_cipheralg ssh_blowfish_ssh1 = {
.setkey = blowfish_ssh_setkey,
.encrypt = blowfish_ssh1_encrypt_blk,
.decrypt = blowfish_ssh1_decrypt_blk,
.next_message = nullcipher_next_message,
.blksize = 8,
.real_keybits = 128,
.padded_keybytes = SSH1_SESSION_KEY_LENGTH,
@ -668,6 +669,7 @@ const ssh_cipheralg ssh_blowfish_ssh2 = {
.setkey = blowfish_ssh_setkey,
.encrypt = blowfish_ssh2_encrypt_blk,
.decrypt = blowfish_ssh2_decrypt_blk,
.next_message = nullcipher_next_message,
.ssh2_id = "blowfish-cbc",
.blksize = 8,
.real_keybits = 128,
@ -683,6 +685,7 @@ const ssh_cipheralg ssh_blowfish_ssh2_ctr = {
.setkey = blowfish_ssh_setkey,
.encrypt = blowfish_ssh2_sdctr,
.decrypt = blowfish_ssh2_sdctr,
.next_message = nullcipher_next_message,
.ssh2_id = "blowfish-ctr",
.blksize = 8,
.real_keybits = 256,

View File

@ -964,6 +964,7 @@ const ssh2_macalg ssh2_poly1305 = {
.setkey = poly_setkey,
.start = poly_start,
.genresult = poly_genresult,
.next_message = nullmac_next_message,
.text_name = poly_text_name,
.name = "",
.etm_name = "", /* Not selectable individually, just part of
@ -1061,6 +1062,7 @@ const ssh_cipheralg ssh2_chacha20_poly1305 = {
.decrypt = ccp_decrypt,
.encrypt_length = ccp_encrypt_length,
.decrypt_length = ccp_decrypt_length,
.next_message = nullcipher_next_message, // FIXME: can we use this?
.ssh2_id = "chacha20-poly1305@openssh.com",
.blksize = 1,
.real_keybits = 512,

View File

@ -689,6 +689,7 @@ const ssh_cipheralg ssh_des = {
.setkey = des_cbc_setkey,
.encrypt = des_cbc_encrypt,
.decrypt = des_cbc_decrypt,
.next_message = nullcipher_next_message,
.ssh2_id = "des-cbc",
.blksize = 8,
.real_keybits = 56,
@ -705,6 +706,7 @@ const ssh_cipheralg ssh_des_sshcom_ssh2 = {
.setkey = des_cbc_setkey,
.encrypt = des_cbc_encrypt,
.decrypt = des_cbc_decrypt,
.next_message = nullcipher_next_message,
.ssh2_id = "des-cbc@ssh.com",
.blksize = 8,
.real_keybits = 56,
@ -808,6 +810,7 @@ const ssh_cipheralg ssh_3des_ssh2 = {
.setkey = des3_cbc1_setkey,
.encrypt = des3_cbc1_cbc_encrypt,
.decrypt = des3_cbc1_cbc_decrypt,
.next_message = nullcipher_next_message,
.ssh2_id = "3des-cbc",
.blksize = 8,
.real_keybits = 168,
@ -905,6 +908,7 @@ const ssh_cipheralg ssh_3des_ssh2_ctr = {
.setkey = des3_sdctr_setkey,
.encrypt = des3_sdctr_encrypt_decrypt,
.decrypt = des3_sdctr_encrypt_decrypt,
.next_message = nullcipher_next_message,
.ssh2_id = "3des-ctr",
.blksize = 8,
.real_keybits = 168,
@ -1040,6 +1044,7 @@ const ssh_cipheralg ssh_3des_ssh1 = {
.setkey = des3_cbc3_setkey,
.encrypt = des3_cbc3_cbc_encrypt,
.decrypt = des3_cbc3_cbc_decrypt,
.next_message = nullcipher_next_message,
.blksize = 8,
.real_keybits = 168,
.padded_keybytes = 24,

View File

@ -167,6 +167,7 @@ const ssh2_macalg ssh_hmac_sha256 = {
.setkey = hmac_key,
.start = hmac_start,
.genresult = hmac_genresult,
.next_message = nullmac_next_message,
.text_name = hmac_text_name,
.name = "hmac-sha2-256",
.etm_name = "hmac-sha2-256-etm@openssh.com",
@ -182,6 +183,7 @@ const ssh2_macalg ssh_hmac_md5 = {
.setkey = hmac_key,
.start = hmac_start,
.genresult = hmac_genresult,
.next_message = nullmac_next_message,
.text_name = hmac_text_name,
.name = "hmac-md5",
.etm_name = "hmac-md5-etm@openssh.com",
@ -198,6 +200,7 @@ const ssh2_macalg ssh_hmac_sha1 = {
.setkey = hmac_key,
.start = hmac_start,
.genresult = hmac_genresult,
.next_message = nullmac_next_message,
.text_name = hmac_text_name,
.name = "hmac-sha1",
.etm_name = "hmac-sha1-etm@openssh.com",
@ -214,6 +217,7 @@ const ssh2_macalg ssh_hmac_sha1_96 = {
.setkey = hmac_key,
.start = hmac_start,
.genresult = hmac_genresult,
.next_message = nullmac_next_message,
.text_name = hmac_text_name,
.name = "hmac-sha1-96",
.etm_name = "hmac-sha1-96-etm@openssh.com",
@ -232,6 +236,7 @@ const ssh2_macalg ssh_hmac_sha1_buggy = {
.setkey = hmac_key,
.start = hmac_start,
.genresult = hmac_genresult,
.next_message = nullmac_next_message,
.text_name = hmac_text_name,
.name = "hmac-sha1",
.len = 20,
@ -249,6 +254,7 @@ const ssh2_macalg ssh_hmac_sha1_96_buggy = {
.setkey = hmac_key,
.start = hmac_start,
.genresult = hmac_genresult,
.next_message = nullmac_next_message,
.text_name = hmac_text_name,
.name = "hmac-sha1-96",
.len = 12,