diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2014-05-15 14:06:14 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2014-05-15 14:06:14 +0000 |
commit | c0474f05f116683f7f4acb7b6e0f9a463c7b6927 (patch) | |
tree | 10aa0a8ca04bd299b3647c8e01d62a1d57467c8b /lib | |
parent | 02fdd4b682149f08dedb63744bc0ea6452758618 (diff) |
KNF.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libssl/src/crypto/evp/e_aes.c | 21 | ||||
-rw-r--r-- | lib/libssl/src/crypto/evp/evp_aead.c | 128 |
2 files changed, 75 insertions, 74 deletions
diff --git a/lib/libssl/src/crypto/evp/e_aes.c b/lib/libssl/src/crypto/evp/e_aes.c index e4d9457c96d..4da61b8f626 100644 --- a/lib/libssl/src/crypto/evp/e_aes.c +++ b/lib/libssl/src/crypto/evp/e_aes.c @@ -658,7 +658,8 @@ aes_gcm_cleanup(EVP_CIPHER_CTX *c) /* increment counter (64-bit int) by 1 */ static void -ctr64_inc(unsigned char *counter) { +ctr64_inc(unsigned char *counter) +{ int n = 8; unsigned char c; @@ -991,11 +992,11 @@ aes_gcm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | EVP_CIPH_CUSTOM_IV | EVP_CIPH_FLAG_CUSTOM_CIPHER \ | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CTRL_INIT) -BLOCK_CIPHER_custom(NID_aes, 128, 1,12, gcm, GCM, +BLOCK_CIPHER_custom(NID_aes, 128, 1, 12, gcm, GCM, EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_AEAD_CIPHER|CUSTOM_FLAGS) -BLOCK_CIPHER_custom(NID_aes, 192, 1,12, gcm, GCM, +BLOCK_CIPHER_custom(NID_aes, 192, 1, 12, gcm, GCM, EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_AEAD_CIPHER|CUSTOM_FLAGS) -BLOCK_CIPHER_custom(NID_aes, 256, 1,12, gcm, GCM, +BLOCK_CIPHER_custom(NID_aes, 256, 1, 12, gcm, GCM, EVP_CIPH_FLAG_FIPS|EVP_CIPH_FLAG_AEAD_CIPHER|CUSTOM_FLAGS) static int @@ -1104,8 +1105,8 @@ aes_xts_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, #define XTS_FLAGS (EVP_CIPH_FLAG_DEFAULT_ASN1 | EVP_CIPH_CUSTOM_IV \ | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CTRL_INIT) -BLOCK_CIPHER_custom(NID_aes, 128, 1,16, xts, XTS, EVP_CIPH_FLAG_FIPS|XTS_FLAGS) -BLOCK_CIPHER_custom(NID_aes, 256, 1,16, xts, XTS, EVP_CIPH_FLAG_FIPS|XTS_FLAGS) +BLOCK_CIPHER_custom(NID_aes, 128, 1, 16, xts, XTS, EVP_CIPH_FLAG_FIPS|XTS_FLAGS) +BLOCK_CIPHER_custom(NID_aes, 256, 1, 16, xts, XTS, EVP_CIPH_FLAG_FIPS|XTS_FLAGS) static int aes_ccm_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr) @@ -1254,11 +1255,11 @@ aes_ccm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, #define aes_ccm_cleanup NULL -BLOCK_CIPHER_custom(NID_aes, 128, 1,12, ccm, CCM, +BLOCK_CIPHER_custom(NID_aes, 128, 1, 12, ccm, CCM, EVP_CIPH_FLAG_FIPS|CUSTOM_FLAGS) -BLOCK_CIPHER_custom(NID_aes, 192, 1,12, ccm, CCM, +BLOCK_CIPHER_custom(NID_aes, 192, 1, 12, ccm, CCM, EVP_CIPH_FLAG_FIPS|CUSTOM_FLAGS) -BLOCK_CIPHER_custom(NID_aes, 256, 1,12, ccm, CCM, +BLOCK_CIPHER_custom(NID_aes, 256, 1, 12, ccm, CCM, EVP_CIPH_FLAG_FIPS|CUSTOM_FLAGS) #define EVP_AEAD_AES_GCM_TAG_LEN 16 @@ -1390,7 +1391,7 @@ aead_aes_gcm_open(const EVP_AEAD_CTX *ctx, unsigned char *out, if (gcm_ctx->ctr) { if (CRYPTO_gcm128_decrypt_ctr32(&gcm, in + bulk, out + bulk, - in_len-bulk-gcm_ctx->tag_len, gcm_ctx->ctr)) + in_len - bulk - gcm_ctx->tag_len, gcm_ctx->ctr)) return -1; } else { if (CRYPTO_gcm128_decrypt(&gcm, in + bulk, out + bulk, diff --git a/lib/libssl/src/crypto/evp/evp_aead.c b/lib/libssl/src/crypto/evp/evp_aead.c index 137e3dd05bf..c8ba1df54a2 100644 --- a/lib/libssl/src/crypto/evp/evp_aead.c +++ b/lib/libssl/src/crypto/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; - } +} |