Skip to content

Commit

Permalink
Provide EVP_CIPHER_CTX_reset().
Browse files Browse the repository at this point in the history
Rides previous minor bump.
  • Loading branch information
jsing committed Feb 17, 2018
1 parent 60ecfa2 commit 2443cc9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/lib/libcrypto/Symbols.list
Expand Up @@ -1216,6 +1216,7 @@ EVP_CIPHER_CTX_key_length
EVP_CIPHER_CTX_new
EVP_CIPHER_CTX_nid
EVP_CIPHER_CTX_rand_key
EVP_CIPHER_CTX_reset
EVP_CIPHER_CTX_set_app_data
EVP_CIPHER_CTX_set_flags
EVP_CIPHER_CTX_set_key_length
Expand Down
3 changes: 2 additions & 1 deletion src/lib/libcrypto/evp/evp.h
@@ -1,4 +1,4 @@
/* $OpenBSD: evp.h,v 1.56 2018/02/17 14:55:31 jsing Exp $ */
/* $OpenBSD: evp.h,v 1.57 2018/02/17 16:54:08 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
Expand Down Expand Up @@ -644,6 +644,7 @@ void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a);
int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a);
EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void);
void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *a);
int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *a);
int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);
int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *c, int pad);
int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);
Expand Down
42 changes: 25 additions & 17 deletions src/lib/libcrypto/evp/evp_enc.c
@@ -1,4 +1,4 @@
/* $OpenBSD: evp_enc.c,v 1.37 2017/11/28 06:55:49 tb Exp $ */
/* $OpenBSD: evp_enc.c,v 1.38 2018/02/17 16:54:08 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
Expand Down Expand Up @@ -75,18 +75,6 @@

#define M_do_cipher(ctx, out, in, inl) ctx->cipher->do_cipher(ctx, out, in, inl)

void
EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *ctx)
{
memset(ctx, 0, sizeof(EVP_CIPHER_CTX));
}

EVP_CIPHER_CTX *
EVP_CIPHER_CTX_new(void)
{
return calloc(1, sizeof(EVP_CIPHER_CTX));
}

int
EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
const unsigned char *key, const unsigned char *iv, int enc)
Expand Down Expand Up @@ -548,13 +536,33 @@ EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
return (1);
}

EVP_CIPHER_CTX *
EVP_CIPHER_CTX_new(void)
{
return calloc(1, sizeof(EVP_CIPHER_CTX));
}

void
EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx)
{
if (ctx) {
EVP_CIPHER_CTX_cleanup(ctx);
free(ctx);
}
if (ctx == NULL)
return;

EVP_CIPHER_CTX_cleanup(ctx);

free(ctx);
}

void
EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *ctx)
{
memset(ctx, 0, sizeof(EVP_CIPHER_CTX));
}

int
EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *a)
{
return EVP_CIPHER_CTX_cleanup(a);
}

int
Expand Down

0 comments on commit 2443cc9

Please sign in to comment.