From 47e18af906f41c3b15796b8d4e6da9b744491b91 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Thu, 13 Jan 2022 17:27:28 +0100 Subject: MDEV-27494 Rename .ic files to .inl --- mysys_ssl/my_sha.ic | 188 ------------------------------------------------- mysys_ssl/my_sha.inl | 188 +++++++++++++++++++++++++++++++++++++++++++++++++ mysys_ssl/my_sha1.cc | 2 +- mysys_ssl/my_sha224.cc | 2 +- mysys_ssl/my_sha256.cc | 2 +- mysys_ssl/my_sha384.cc | 2 +- mysys_ssl/my_sha512.cc | 2 +- 7 files changed, 193 insertions(+), 193 deletions(-) delete mode 100644 mysys_ssl/my_sha.ic create mode 100644 mysys_ssl/my_sha.inl (limited to 'mysys_ssl') diff --git a/mysys_ssl/my_sha.ic b/mysys_ssl/my_sha.ic deleted file mode 100644 index 97344dc0415..00000000000 --- a/mysys_ssl/my_sha.ic +++ /dev/null @@ -1,188 +0,0 @@ -/* Copyright (c) 2012, Oracle and/or its affiliates. - Copyright (c) 2014, 2017, MariaDB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ - - -/** - @file - - @brief - Wrapper functions for OpenSSL, YaSSL implementations. Also provides a - Compatibility layer to make available YaSSL's SHAn implementation. -*/ - -#include -#include - -#define HASH_SIZE (NUM > 1 ? NUM/8 : 20) - -#if defined(HAVE_YASSL) -#include "sha.hpp" - -#define xCONTEXT(x) TaoCrypt::SHA ## x -#define yCONTEXT(y) xCONTEXT(y) -#define CONTEXT yCONTEXT(NUM) -#define SHA1 SHA - -static void sha_init(CONTEXT *context) -{ - context->Init(); -} - -/* - this is a variant of sha_init to be used in this file only. - does nothing for yassl, because the context's constructor was called automatically. -*/ -static void sha_init_fast(CONTEXT *context) -{ -} - -static void sha_input(CONTEXT *context, const uchar *buf, unsigned len) -{ - context->Update((const TaoCrypt::byte *) buf, len); -} - -static void sha_result(CONTEXT *context, uchar digest[HASH_SIZE]) -{ - context->Final((TaoCrypt::byte *) digest); -} - -#elif defined(HAVE_OPENSSL) -#include - -#define xCONTEXT(x) SHA ## x ## _CTX -#define yCONTEXT(y) xCONTEXT(y) -#define CONTEXT yCONTEXT(NUM) -#define SHA1_CTX SHA_CTX -#define SHA224_CTX SHA256_CTX -#define SHA384_CTX SHA512_CTX - -#define xSHA_Init(x) SHA ## x ## _Init -#define xSHA_Update(x) SHA ## x ## _Update -#define xSHA_Final(x) SHA ## x ## _Final -#define ySHA_Init(y) xSHA_Init(y) -#define ySHA_Update(y) xSHA_Update(y) -#define ySHA_Final(y) xSHA_Final(y) -#define SHA_Init ySHA_Init(NUM) -#define SHA_Update ySHA_Update(NUM) -#define SHA_Final ySHA_Final(NUM) - -static void sha_init(CONTEXT *context) -{ - SHA_Init(context); -} - -static void sha_init_fast(CONTEXT *context) -{ - sha_init(context); -} - -static void sha_input(CONTEXT *context, const uchar *buf, unsigned len) -{ - SHA_Update(context, buf, len); -} - -static void sha_result(CONTEXT *context, uchar digest[HASH_SIZE]) -{ - SHA_Final(digest, context); -} - -#endif /* HAVE_YASSL */ - -#define xmy_sha_multi(x) my_sha ## x ## _multi -#define xmy_sha_context_size(x) my_sha ## x ## _context_size -#define xmy_sha_init(x) my_sha ## x ## _init -#define xmy_sha_input(x) my_sha ## x ## _input -#define xmy_sha_result(x) my_sha ## x ## _result -#define xmy_sha(x) my_sha ## x -#define ymy_sha_multi(y) xmy_sha_multi(y) -#define ymy_sha_context_size(y) xmy_sha_context_size(y) -#define ymy_sha_init(y) xmy_sha_init(y) -#define ymy_sha_input(y) xmy_sha_input(y) -#define ymy_sha_result(y) xmy_sha_result(y) -#define ymy_sha(y) xmy_sha(y) -#define my_sha_multi ymy_sha_multi(NUM) -#define my_sha_context_size ymy_sha_context_size(NUM) -#define my_sha_init ymy_sha_init(NUM) -#define my_sha_input ymy_sha_input(NUM) -#define my_sha_result ymy_sha_result(NUM) -#define my_sha ymy_sha(NUM) - -/** - Wrapper function to compute SHAn message digest. - - @param digest [out] Computed SHAn digest - @param buf [in] Message to be computed - @param len [in] Length of the message - - @return void -*/ -void my_sha(uchar *digest, const char *buf, size_t len) -{ - CONTEXT context; - - sha_init_fast(&context); - sha_input(&context, (const uchar *)buf, (unsigned int)len); - sha_result(&context, digest); -} - - -/** - Wrapper function to compute SHAn message digest for - two messages in order to emulate shaN(msg1, msg2). - - @param digest [out] Computed SHAn digest - @param buf1 [in] First message - @param len1 [in] Length of first message - @param buf2 [in] Second message - @param len2 [in] Length of second message - - @return void -*/ -void my_sha_multi(uchar *digest, ...) -{ - va_list args; - va_start(args, digest); - - CONTEXT context; - const uchar *str; - - sha_init_fast(&context); - for (str= va_arg(args, const uchar*); str; str= va_arg(args, const uchar*)) - sha_input(&context, str, (uint) va_arg(args, size_t)); - - sha_result(&context, digest); - va_end(args); -} - -size_t my_sha_context_size() -{ - return sizeof(CONTEXT); -} - -void my_sha_init(void *context) -{ - sha_init((CONTEXT *)context); -} - -void my_sha_input(void *context, const uchar *buf, size_t len) -{ - sha_input((CONTEXT *)context, buf, (uint) len); -} - -void my_sha_result(void *context, uchar *digest) -{ - sha_result((CONTEXT *)context, digest); -} diff --git a/mysys_ssl/my_sha.inl b/mysys_ssl/my_sha.inl new file mode 100644 index 00000000000..97344dc0415 --- /dev/null +++ b/mysys_ssl/my_sha.inl @@ -0,0 +1,188 @@ +/* Copyright (c) 2012, Oracle and/or its affiliates. + Copyright (c) 2014, 2017, MariaDB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ + + +/** + @file + + @brief + Wrapper functions for OpenSSL, YaSSL implementations. Also provides a + Compatibility layer to make available YaSSL's SHAn implementation. +*/ + +#include +#include + +#define HASH_SIZE (NUM > 1 ? NUM/8 : 20) + +#if defined(HAVE_YASSL) +#include "sha.hpp" + +#define xCONTEXT(x) TaoCrypt::SHA ## x +#define yCONTEXT(y) xCONTEXT(y) +#define CONTEXT yCONTEXT(NUM) +#define SHA1 SHA + +static void sha_init(CONTEXT *context) +{ + context->Init(); +} + +/* + this is a variant of sha_init to be used in this file only. + does nothing for yassl, because the context's constructor was called automatically. +*/ +static void sha_init_fast(CONTEXT *context) +{ +} + +static void sha_input(CONTEXT *context, const uchar *buf, unsigned len) +{ + context->Update((const TaoCrypt::byte *) buf, len); +} + +static void sha_result(CONTEXT *context, uchar digest[HASH_SIZE]) +{ + context->Final((TaoCrypt::byte *) digest); +} + +#elif defined(HAVE_OPENSSL) +#include + +#define xCONTEXT(x) SHA ## x ## _CTX +#define yCONTEXT(y) xCONTEXT(y) +#define CONTEXT yCONTEXT(NUM) +#define SHA1_CTX SHA_CTX +#define SHA224_CTX SHA256_CTX +#define SHA384_CTX SHA512_CTX + +#define xSHA_Init(x) SHA ## x ## _Init +#define xSHA_Update(x) SHA ## x ## _Update +#define xSHA_Final(x) SHA ## x ## _Final +#define ySHA_Init(y) xSHA_Init(y) +#define ySHA_Update(y) xSHA_Update(y) +#define ySHA_Final(y) xSHA_Final(y) +#define SHA_Init ySHA_Init(NUM) +#define SHA_Update ySHA_Update(NUM) +#define SHA_Final ySHA_Final(NUM) + +static void sha_init(CONTEXT *context) +{ + SHA_Init(context); +} + +static void sha_init_fast(CONTEXT *context) +{ + sha_init(context); +} + +static void sha_input(CONTEXT *context, const uchar *buf, unsigned len) +{ + SHA_Update(context, buf, len); +} + +static void sha_result(CONTEXT *context, uchar digest[HASH_SIZE]) +{ + SHA_Final(digest, context); +} + +#endif /* HAVE_YASSL */ + +#define xmy_sha_multi(x) my_sha ## x ## _multi +#define xmy_sha_context_size(x) my_sha ## x ## _context_size +#define xmy_sha_init(x) my_sha ## x ## _init +#define xmy_sha_input(x) my_sha ## x ## _input +#define xmy_sha_result(x) my_sha ## x ## _result +#define xmy_sha(x) my_sha ## x +#define ymy_sha_multi(y) xmy_sha_multi(y) +#define ymy_sha_context_size(y) xmy_sha_context_size(y) +#define ymy_sha_init(y) xmy_sha_init(y) +#define ymy_sha_input(y) xmy_sha_input(y) +#define ymy_sha_result(y) xmy_sha_result(y) +#define ymy_sha(y) xmy_sha(y) +#define my_sha_multi ymy_sha_multi(NUM) +#define my_sha_context_size ymy_sha_context_size(NUM) +#define my_sha_init ymy_sha_init(NUM) +#define my_sha_input ymy_sha_input(NUM) +#define my_sha_result ymy_sha_result(NUM) +#define my_sha ymy_sha(NUM) + +/** + Wrapper function to compute SHAn message digest. + + @param digest [out] Computed SHAn digest + @param buf [in] Message to be computed + @param len [in] Length of the message + + @return void +*/ +void my_sha(uchar *digest, const char *buf, size_t len) +{ + CONTEXT context; + + sha_init_fast(&context); + sha_input(&context, (const uchar *)buf, (unsigned int)len); + sha_result(&context, digest); +} + + +/** + Wrapper function to compute SHAn message digest for + two messages in order to emulate shaN(msg1, msg2). + + @param digest [out] Computed SHAn digest + @param buf1 [in] First message + @param len1 [in] Length of first message + @param buf2 [in] Second message + @param len2 [in] Length of second message + + @return void +*/ +void my_sha_multi(uchar *digest, ...) +{ + va_list args; + va_start(args, digest); + + CONTEXT context; + const uchar *str; + + sha_init_fast(&context); + for (str= va_arg(args, const uchar*); str; str= va_arg(args, const uchar*)) + sha_input(&context, str, (uint) va_arg(args, size_t)); + + sha_result(&context, digest); + va_end(args); +} + +size_t my_sha_context_size() +{ + return sizeof(CONTEXT); +} + +void my_sha_init(void *context) +{ + sha_init((CONTEXT *)context); +} + +void my_sha_input(void *context, const uchar *buf, size_t len) +{ + sha_input((CONTEXT *)context, buf, (uint) len); +} + +void my_sha_result(void *context, uchar *digest) +{ + sha_result((CONTEXT *)context, digest); +} diff --git a/mysys_ssl/my_sha1.cc b/mysys_ssl/my_sha1.cc index b53e214468d..29563742e6b 100644 --- a/mysys_ssl/my_sha1.cc +++ b/mysys_ssl/my_sha1.cc @@ -15,4 +15,4 @@ #define NUM 1 -#include "my_sha.ic" +#include "my_sha.inl" diff --git a/mysys_ssl/my_sha224.cc b/mysys_ssl/my_sha224.cc index 200b6ed161c..5fffdce7794 100644 --- a/mysys_ssl/my_sha224.cc +++ b/mysys_ssl/my_sha224.cc @@ -15,4 +15,4 @@ #define NUM 224 -#include "my_sha.ic" +#include "my_sha.inl" diff --git a/mysys_ssl/my_sha256.cc b/mysys_ssl/my_sha256.cc index 1562809f91a..59e871de121 100644 --- a/mysys_ssl/my_sha256.cc +++ b/mysys_ssl/my_sha256.cc @@ -15,4 +15,4 @@ #define NUM 256 -#include "my_sha.ic" +#include "my_sha.inl" diff --git a/mysys_ssl/my_sha384.cc b/mysys_ssl/my_sha384.cc index 6bb64470105..40707de0a8d 100644 --- a/mysys_ssl/my_sha384.cc +++ b/mysys_ssl/my_sha384.cc @@ -15,4 +15,4 @@ #define NUM 384 -#include "my_sha.ic" +#include "my_sha.inl" diff --git a/mysys_ssl/my_sha512.cc b/mysys_ssl/my_sha512.cc index 1047d0dbe46..6a5a04d72f0 100644 --- a/mysys_ssl/my_sha512.cc +++ b/mysys_ssl/my_sha512.cc @@ -15,4 +15,4 @@ #define NUM 512 -#include "my_sha.ic" +#include "my_sha.inl" -- cgit v1.2.1