mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-29 01:03:57 +03:00
chacha: use a cipher cleanup callback
With this change there is less code specific to the chacha20-poly1305 cipher found in src/wrapper.c. Signed-off-by: Jon Simons <jon@jonsimons.org> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
7a2624dee4
commit
d4a4ce4d44
@@ -187,6 +187,10 @@ static int chacha20_poly1305_aead_decrypt(struct ssh_cipher_struct *cipher,
|
||||
return SSH_OK;
|
||||
}
|
||||
|
||||
static void chacha20_cleanup(struct ssh_cipher_struct *cipher) {
|
||||
SAFE_FREE(cipher->chacha20_schedule);
|
||||
}
|
||||
|
||||
const struct ssh_cipher_struct chacha20poly1305_cipher = {
|
||||
.name = "chacha20-poly1305@openssh.com",
|
||||
.blocksize = 8,
|
||||
@@ -198,5 +202,6 @@ const struct ssh_cipher_struct chacha20poly1305_cipher = {
|
||||
.set_decrypt_key = chacha20_set_encrypt_key,
|
||||
.aead_encrypt = chacha20_poly1305_aead_encrypt,
|
||||
.aead_decrypt_length = chacha20_poly1305_aead_decrypt_length,
|
||||
.aead_decrypt = chacha20_poly1305_aead_decrypt
|
||||
.aead_decrypt = chacha20_poly1305_aead_decrypt,
|
||||
.cleanup = chacha20_cleanup
|
||||
};
|
||||
|
||||
@@ -128,9 +128,6 @@ void ssh_cipher_clear(struct ssh_cipher_struct *cipher){
|
||||
if (cipher->cleanup != NULL) {
|
||||
cipher->cleanup(cipher);
|
||||
}
|
||||
if (cipher->chacha20_schedule != NULL){
|
||||
SAFE_FREE(cipher->chacha20_schedule);
|
||||
}
|
||||
}
|
||||
|
||||
static void cipher_free(struct ssh_cipher_struct *cipher) {
|
||||
|
||||
Reference in New Issue
Block a user