From b115738274236129c97a787d577da5cbff4c828e Mon Sep 17 00:00:00 2001 From: jsing <> Date: Thu, 15 May 2014 14:14:56 +0000 Subject: KNF. --- src/lib/libcrypto/evp/evp_aead.c | 128 +++++++++++++++++++-------------------- 1 file changed, 64 insertions(+), 64 deletions(-) (limited to 'src/lib/libcrypto/evp/evp_aead.c') diff --git a/src/lib/libcrypto/evp/evp_aead.c b/src/lib/libcrypto/evp/evp_aead.c index 137e3dd05b..c8ba1df54a 100644 --- a/src/lib/libcrypto/evp/evp_aead.c +++ b/src/lib/libcrypto/evp/evp_aead.c @@ -4,21 +4,21 @@ * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. - * + * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * + * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -33,10 +33,10 @@ * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from + * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * + * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -48,7 +48,7 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * + * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence @@ -63,46 +63,50 @@ #include "evp_locl.h" -size_t EVP_AEAD_key_length(const EVP_AEAD *aead) - { +size_t +EVP_AEAD_key_length(const EVP_AEAD *aead) +{ return aead->key_len; - } +} -size_t EVP_AEAD_nonce_length(const EVP_AEAD *aead) - { +size_t +EVP_AEAD_nonce_length(const EVP_AEAD *aead) +{ return aead->nonce_len; - } +} -size_t EVP_AEAD_max_overhead(const EVP_AEAD *aead) - { +size_t +EVP_AEAD_max_overhead(const EVP_AEAD *aead) +{ return aead->overhead; - } +} -size_t EVP_AEAD_max_tag_len(const EVP_AEAD *aead) - { +size_t +EVP_AEAD_max_tag_len(const EVP_AEAD *aead) +{ return aead->max_tag_len; - } +} -int EVP_AEAD_CTX_init(EVP_AEAD_CTX *ctx, const EVP_AEAD *aead, - const unsigned char *key, size_t key_len, - size_t tag_len, ENGINE *impl) - { +int +EVP_AEAD_CTX_init(EVP_AEAD_CTX *ctx, const EVP_AEAD *aead, + const unsigned char *key, size_t key_len, size_t tag_len, ENGINE *impl) +{ ctx->aead = aead; - if (key_len != aead->key_len) - { - EVPerr(EVP_F_EVP_AEAD_CTX_INIT,EVP_R_UNSUPPORTED_KEY_SIZE); + if (key_len != aead->key_len) { + EVPerr(EVP_F_EVP_AEAD_CTX_INIT, EVP_R_UNSUPPORTED_KEY_SIZE); return 0; - } - return aead->init(ctx, key, key_len, tag_len); } + return aead->init(ctx, key, key_len, tag_len); +} -void EVP_AEAD_CTX_cleanup(EVP_AEAD_CTX *ctx) - { +void +EVP_AEAD_CTX_cleanup(EVP_AEAD_CTX *ctx) +{ if (ctx->aead == NULL) return; ctx->aead->cleanup(ctx); ctx->aead = NULL; - } +} /* check_alias returns 0 if out points within the buffer determined by in * and in_len and 1 otherwise. @@ -112,41 +116,39 @@ void EVP_AEAD_CTX_cleanup(EVP_AEAD_CTX *ctx) * stomp input that hasn't been read yet. * * This function checks for that case. */ -static int check_alias(const unsigned char *in, size_t in_len, - const unsigned char *out) - { +static int +check_alias(const unsigned char *in, size_t in_len, const unsigned char *out) +{ if (out <= in) return 1; if (in + in_len <= out) return 1; return 0; - } - -ssize_t EVP_AEAD_CTX_seal(const EVP_AEAD_CTX *ctx, - unsigned char *out, size_t max_out_len, - const unsigned char *nonce, size_t nonce_len, - const unsigned char *in, size_t in_len, - const unsigned char *ad, size_t ad_len) - { +} + +ssize_t +EVP_AEAD_CTX_seal(const EVP_AEAD_CTX *ctx, unsigned char *out, + size_t max_out_len, const unsigned char *nonce, size_t nonce_len, + const unsigned char *in, size_t in_len, const unsigned char *ad, + size_t ad_len) +{ size_t possible_out_len = in_len + ctx->aead->overhead; ssize_t r; if (possible_out_len < in_len /* overflow */ || possible_out_len > SSIZE_MAX /* return value cannot be - represented */) - { + represented */) { EVPerr(EVP_F_EVP_AEAD_CTX_SEAL, EVP_R_TOO_LARGE); goto error; - } + } - if (!check_alias(in, in_len, out)) - { + if (!check_alias(in, in_len, out)) { EVPerr(EVP_F_EVP_AEAD_CTX_SEAL, EVP_R_OUTPUT_ALIASES_INPUT); goto error; - } + } r = ctx->aead->seal(ctx, out, max_out_len, nonce, nonce_len, - in, in_len, ad, ad_len); + in, in_len, ad, ad_len); if (r >= 0) return r; @@ -155,30 +157,28 @@ error: * that doesn't check the return value doesn't send raw data. */ memset(out, 0, max_out_len); return -1; - } - -ssize_t EVP_AEAD_CTX_open(const EVP_AEAD_CTX *ctx, - unsigned char *out, size_t max_out_len, - const unsigned char *nonce, size_t nonce_len, - const unsigned char *in, size_t in_len, - const unsigned char *ad, size_t ad_len) - { +} + +ssize_t +EVP_AEAD_CTX_open(const EVP_AEAD_CTX *ctx, unsigned char *out, + size_t max_out_len, const unsigned char *nonce, size_t nonce_len, + const unsigned char *in, size_t in_len, const unsigned char *ad, + size_t ad_len) +{ ssize_t r; - if (in_len > SSIZE_MAX) - { + if (in_len > SSIZE_MAX) { EVPerr(EVP_F_EVP_AEAD_CTX_OPEN, EVP_R_TOO_LARGE); goto error; /* may not be able to represent return value. */ - } + } - if (!check_alias(in, in_len, out)) - { + if (!check_alias(in, in_len, out)) { EVPerr(EVP_F_EVP_AEAD_CTX_OPEN, EVP_R_OUTPUT_ALIASES_INPUT); goto error; - } + } r = ctx->aead->open(ctx, out, max_out_len, nonce, nonce_len, - in, in_len, ad, ad_len); + in, in_len, ad, ad_len); if (r >= 0) return r; @@ -189,4 +189,4 @@ error: * data. */ memset(out, 0, max_out_len); return -1; - } +} -- cgit v1.2.3-55-g6feb