summaryrefslogtreecommitdiff
path: root/mysys_ssl
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2013-07-13 17:48:06 +0200
committerSergei Golubchik <sergii@pisem.net>2013-07-13 17:48:06 +0200
commit3e9446a7426d13c8cc53937b0dc9a8ce17127ae3 (patch)
treeecca01e0ae52afde99aa9393a22a57f319fc208f /mysys_ssl
parent36519b8a830204f45ec4693c89b6bdb8c9c6b79b (diff)
downloadmariadb-git-3e9446a7426d13c8cc53937b0dc9a8ce17127ae3.tar.gz
SHA1 service
(because mysql_ssl library is built with -fvisibility=hidden)
Diffstat (limited to 'mysys_ssl')
-rw-r--r--mysys_ssl/my_sha1.cc30
1 files changed, 20 insertions, 10 deletions
diff --git a/mysys_ssl/my_sha1.cc b/mysys_ssl/my_sha1.cc
index 1c4bf7c9747..fc8f88856bb 100644
--- a/mysys_ssl/my_sha1.cc
+++ b/mysys_ssl/my_sha1.cc
@@ -24,6 +24,7 @@
#include <my_global.h>
#include <sha1.h>
+#include <stdarg.h>
#if defined(HAVE_YASSL)
#include "sha.hpp"
@@ -56,12 +57,15 @@ void mysql_sha1_yassl(uint8 *digest, const char *buf, int len)
@return void
*/
-void mysql_sha1_multi_yassl(uint8 *digest, const char *buf1, int len1,
- const char *buf2, int len2)
+void mysql_sha1_multi_yassl(uint8 *digest, va_list args)
{
+ const char *str;
TaoCrypt::SHA hasher;
- hasher.Update((const TaoCrypt::byte *) buf1, len1);
- hasher.Update((const TaoCrypt::byte *) buf2, len2);
+
+ for (str= va_arg(args, const char*); str; str= va_arg(args, const char*))
+ {
+ hasher.Update((const TaoCrypt::byte *) str, va_arg(args, size_t));
+ }
hasher.Final((TaoCrypt::byte *) digest);
}
@@ -98,7 +102,7 @@ int mysql_sha1_result(SHA_CTX *context,
@return void
*/
-void compute_sha1_hash(uint8 *digest, const char *buf, int len)
+void my_sha1(uint8 *digest, const char *buf, size_t len)
{
#if defined(HAVE_YASSL)
mysql_sha1_yassl(digest, buf, len);
@@ -124,18 +128,24 @@ void compute_sha1_hash(uint8 *digest, const char *buf, int len)
@return void
*/
-void compute_sha1_hash_multi(uint8 *digest, const char *buf1, int len1,
- const char *buf2, int len2)
+void my_sha1_multi(uint8 *digest, ...)
{
+ va_list args;
+ va_start(args, digest);
+
#if defined(HAVE_YASSL)
- mysql_sha1_multi_yassl(digest, buf1, len1, buf2, len2);
+ mysql_sha1_multi_yassl(digest, args);
#elif defined(HAVE_OPENSSL)
SHA_CTX sha1_context;
+ const char *str;
mysql_sha1_reset(&sha1_context);
- mysql_sha1_input(&sha1_context, (const uint8 *) buf1, len1);
- mysql_sha1_input(&sha1_context, (const uint8 *) buf2, len2);
+ for (str= va_arg(args, const char*); str; str= va_arg(args, const char*))
+ {
+ mysql_sha1_input(&sha1_context, (const uint8 *) str, va_arg(args, size_t));
+ }
mysql_sha1_result(&sha1_context, digest);
#endif /* HAVE_YASSL */
+ va_end(args);
}