X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/51e9d3c00a3471f284e89ec1f59f38ca25f10c5f..HEAD:/sshaes.c diff --git a/sshaes.c b/sshaes.c index 5664f775..97935b7f 100644 --- a/sshaes.c +++ b/sshaes.c @@ -1097,35 +1097,35 @@ static void aes_sdctr(unsigned char *blk, int len, AESContext *ctx) memcpy(ctx->iv, iv, sizeof(iv)); } -static void *aes_make_context(void) +void *aes_make_context(void) { return snew(AESContext); } -static void aes_free_context(void *handle) +void aes_free_context(void *handle) { sfree(handle); } -static void aes128_key(void *handle, unsigned char *key) +void aes128_key(void *handle, unsigned char *key) { AESContext *ctx = (AESContext *)handle; aes_setup(ctx, 16, key, 16); } -static void aes192_key(void *handle, unsigned char *key) +void aes192_key(void *handle, unsigned char *key) { AESContext *ctx = (AESContext *)handle; aes_setup(ctx, 16, key, 24); } -static void aes256_key(void *handle, unsigned char *key) +void aes256_key(void *handle, unsigned char *key) { AESContext *ctx = (AESContext *)handle; aes_setup(ctx, 16, key, 32); } -static void aes_iv(void *handle, unsigned char *iv) +void aes_iv(void *handle, unsigned char *iv) { AESContext *ctx = (AESContext *)handle; int i; @@ -1133,13 +1133,13 @@ static void aes_iv(void *handle, unsigned char *iv) ctx->iv[i] = GET_32BIT_MSB_FIRST(iv + 4 * i); } -static void aes_ssh2_encrypt_blk(void *handle, unsigned char *blk, int len) +void aes_ssh2_encrypt_blk(void *handle, unsigned char *blk, int len) { AESContext *ctx = (AESContext *)handle; aes_encrypt_cbc(blk, len, ctx); } -static void aes_ssh2_decrypt_blk(void *handle, unsigned char *blk, int len) +void aes_ssh2_decrypt_blk(void *handle, unsigned char *blk, int len) { AESContext *ctx = (AESContext *)handle; aes_decrypt_cbc(blk, len, ctx); @@ -1157,7 +1157,7 @@ void aes256_encrypt_pubkey(unsigned char *key, unsigned char *blk, int len) aes_setup(&ctx, 16, key, 32); memset(ctx.iv, 0, sizeof(ctx.iv)); aes_encrypt_cbc(blk, len, &ctx); - memset(&ctx, 0, sizeof(ctx)); + smemclr(&ctx, sizeof(ctx)); } void aes256_decrypt_pubkey(unsigned char *key, unsigned char *blk, int len) @@ -1166,56 +1166,56 @@ void aes256_decrypt_pubkey(unsigned char *key, unsigned char *blk, int len) aes_setup(&ctx, 16, key, 32); memset(ctx.iv, 0, sizeof(ctx.iv)); aes_decrypt_cbc(blk, len, &ctx); - memset(&ctx, 0, sizeof(ctx)); + smemclr(&ctx, sizeof(ctx)); } static const struct ssh2_cipher ssh_aes128_ctr = { aes_make_context, aes_free_context, aes_iv, aes128_key, aes_ssh2_sdctr, aes_ssh2_sdctr, "aes128-ctr", - 16, 128, "AES-128 SDCTR" + 16, 128, 0, "AES-128 SDCTR" }; static const struct ssh2_cipher ssh_aes192_ctr = { aes_make_context, aes_free_context, aes_iv, aes192_key, aes_ssh2_sdctr, aes_ssh2_sdctr, "aes192-ctr", - 16, 192, "AES-192 SDCTR" + 16, 192, 0, "AES-192 SDCTR" }; static const struct ssh2_cipher ssh_aes256_ctr = { aes_make_context, aes_free_context, aes_iv, aes256_key, aes_ssh2_sdctr, aes_ssh2_sdctr, "aes256-ctr", - 16, 256, "AES-256 SDCTR" + 16, 256, 0, "AES-256 SDCTR" }; static const struct ssh2_cipher ssh_aes128 = { aes_make_context, aes_free_context, aes_iv, aes128_key, aes_ssh2_encrypt_blk, aes_ssh2_decrypt_blk, "aes128-cbc", - 16, 128, "AES-128 CBC" + 16, 128, SSH_CIPHER_IS_CBC, "AES-128 CBC" }; static const struct ssh2_cipher ssh_aes192 = { aes_make_context, aes_free_context, aes_iv, aes192_key, aes_ssh2_encrypt_blk, aes_ssh2_decrypt_blk, "aes192-cbc", - 16, 192, "AES-192 CBC" + 16, 192, SSH_CIPHER_IS_CBC, "AES-192 CBC" }; static const struct ssh2_cipher ssh_aes256 = { aes_make_context, aes_free_context, aes_iv, aes256_key, aes_ssh2_encrypt_blk, aes_ssh2_decrypt_blk, "aes256-cbc", - 16, 256, "AES-256 CBC" + 16, 256, SSH_CIPHER_IS_CBC, "AES-256 CBC" }; static const struct ssh2_cipher ssh_rijndael_lysator = { aes_make_context, aes_free_context, aes_iv, aes256_key, aes_ssh2_encrypt_blk, aes_ssh2_decrypt_blk, "rijndael-cbc@lysator.liu.se", - 16, 256, "AES-256 CBC" + 16, 256, SSH_CIPHER_IS_CBC, "AES-256 CBC" }; static const struct ssh2_cipher *const aes_list[] = {