diff options
author | Iru Cai <mytbk920423@gmail.com> | 2018-05-17 11:15:24 +0800 |
---|---|---|
committer | Iru Cai <mytbk920423@gmail.com> | 2018-05-21 09:18:16 +0800 |
commit | 144bb1128909b953be7c76e2d022cc86d9fe1062 (patch) | |
tree | 82dfd86b40709162693e5f602fd55f5f2709f77d /src/protocol/internal/ssh_evp_cipher.c | |
parent | aa6575788302729a321c9a14816dd267fbcb0899 (diff) | |
download | fqterm-144bb1128909b953be7c76e2d022cc86d9fe1062.tar.xz |
replace is_{en,de}crypt_ things with cipher->started
Diffstat (limited to 'src/protocol/internal/ssh_evp_cipher.c')
-rw-r--r-- | src/protocol/internal/ssh_evp_cipher.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/protocol/internal/ssh_evp_cipher.c b/src/protocol/internal/ssh_evp_cipher.c index 29f8434..ebef3e9 100644 --- a/src/protocol/internal/ssh_evp_cipher.c +++ b/src/protocol/internal/ssh_evp_cipher.c @@ -8,12 +8,13 @@ struct evp_priv }; static int -cipher_init(SSH_CIPHER* my) +cipher_init(SSH_CIPHER* my, const uint8_t *key, const uint8_t *IV) { struct evp_priv *priv = (struct evp_priv*)my->priv; + my->started = true; priv->ctx = EVP_CIPHER_CTX_new(); EVP_CIPHER_CTX_init(priv->ctx); - return EVP_CipherInit(priv->ctx, priv->evp(), my->key, my->IV, priv->enc); + return EVP_CipherInit(priv->ctx, priv->evp(), key, IV, priv->enc); } static int @@ -25,12 +26,6 @@ do_crypt(SSH_CIPHER* my, const uint8_t* in, uint8_t* out, size_t l) static void cleanup(SSH_CIPHER* my) { - if (my->IV!=NULL) - free(my->IV); - - if (my->key!=NULL) - free(my->key); - if (my->priv!=NULL) { struct evp_priv *priv = my->priv; if (priv->ctx!=NULL) @@ -54,10 +49,9 @@ new_ssh_cipher_evp(SSH_EVP evp, size_t ks, size_t is, size_t bs, int enc) cipher->blkSize = bs; cipher->keySize = ks; cipher->IVSize = is; - cipher->key = (unsigned char*)malloc(ks); - cipher->IV = (unsigned char*)malloc(is); cipher->init = cipher_init; cipher->crypt = do_crypt; cipher->cleanup = cleanup; + cipher->started = false; return cipher; } |