Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
11b6452a
Commit
11b6452a
authored
Sep 26, 2014
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extend SHA1 service. cleanup of sha1 wrappers
parent
93b50e64
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
102 additions
and
65 deletions
+102
-65
include/mysql/plugin_audit.h.pp
include/mysql/plugin_audit.h.pp
+8
-0
include/mysql/plugin_auth.h.pp
include/mysql/plugin_auth.h.pp
+8
-0
include/mysql/plugin_ftparser.h.pp
include/mysql/plugin_ftparser.h.pp
+8
-0
include/mysql/service_sha1.h
include/mysql/service_sha1.h
+13
-1
include/service_versions.h
include/service_versions.h
+1
-1
mysys_ssl/my_sha1.cc
mysys_ssl/my_sha1.cc
+58
-61
sql/sql_plugin_services.h
sql/sql_plugin_services.h
+6
-2
No files found.
include/mysql/plugin_audit.h.pp
View file @
11b6452a
...
...
@@ -112,9 +112,17 @@ void thd_gmt_sec_to_TIME(void* thd, MYSQL_TIME *ltime, my_time_t t);
extern
struct
my_sha1_service_st
{
void
(
*
my_sha1_type
)(
unsigned
char
*
,
const
char
*
,
size_t
);
void
(
*
my_sha1_multi_type
)(
unsigned
char
*
,
...
);
size_t
(
*
my_sha1_context_size_type
)();
void
(
*
my_sha1_init_type
)(
void
*
);
void
(
*
my_sha1_input_type
)(
void
*
,
const
unsigned
char
*
,
size_t
);
void
(
*
my_sha1_result_type
)(
void
*
,
unsigned
char
*
);
}
*
my_sha1_service
;
void
my_sha1
(
unsigned
char
*
,
const
char
*
,
size_t
);
void
my_sha1_multi
(
unsigned
char
*
,
...
);
size_t
my_sha1_context_size
();
void
my_sha1_init
(
void
*
context
);
void
my_sha1_input
(
void
*
context
,
const
unsigned
char
*
buf
,
size_t
len
);
void
my_sha1_result
(
void
*
context
,
unsigned
char
*
digest
);
#include <mysql/service_logger.h>
typedef
struct
logger_handle_st
LOGGER_HANDLE
;
extern
struct
logger_service_st
{
...
...
include/mysql/plugin_auth.h.pp
View file @
11b6452a
...
...
@@ -112,9 +112,17 @@ void thd_gmt_sec_to_TIME(void* thd, MYSQL_TIME *ltime, my_time_t t);
extern
struct
my_sha1_service_st
{
void
(
*
my_sha1_type
)(
unsigned
char
*
,
const
char
*
,
size_t
);
void
(
*
my_sha1_multi_type
)(
unsigned
char
*
,
...
);
size_t
(
*
my_sha1_context_size_type
)();
void
(
*
my_sha1_init_type
)(
void
*
);
void
(
*
my_sha1_input_type
)(
void
*
,
const
unsigned
char
*
,
size_t
);
void
(
*
my_sha1_result_type
)(
void
*
,
unsigned
char
*
);
}
*
my_sha1_service
;
void
my_sha1
(
unsigned
char
*
,
const
char
*
,
size_t
);
void
my_sha1_multi
(
unsigned
char
*
,
...
);
size_t
my_sha1_context_size
();
void
my_sha1_init
(
void
*
context
);
void
my_sha1_input
(
void
*
context
,
const
unsigned
char
*
buf
,
size_t
len
);
void
my_sha1_result
(
void
*
context
,
unsigned
char
*
digest
);
#include <mysql/service_logger.h>
typedef
struct
logger_handle_st
LOGGER_HANDLE
;
extern
struct
logger_service_st
{
...
...
include/mysql/plugin_ftparser.h.pp
View file @
11b6452a
...
...
@@ -112,9 +112,17 @@ void thd_gmt_sec_to_TIME(void* thd, MYSQL_TIME *ltime, my_time_t t);
extern
struct
my_sha1_service_st
{
void
(
*
my_sha1_type
)(
unsigned
char
*
,
const
char
*
,
size_t
);
void
(
*
my_sha1_multi_type
)(
unsigned
char
*
,
...
);
size_t
(
*
my_sha1_context_size_type
)();
void
(
*
my_sha1_init_type
)(
void
*
);
void
(
*
my_sha1_input_type
)(
void
*
,
const
unsigned
char
*
,
size_t
);
void
(
*
my_sha1_result_type
)(
void
*
,
unsigned
char
*
);
}
*
my_sha1_service
;
void
my_sha1
(
unsigned
char
*
,
const
char
*
,
size_t
);
void
my_sha1_multi
(
unsigned
char
*
,
...
);
size_t
my_sha1_context_size
();
void
my_sha1_init
(
void
*
context
);
void
my_sha1_input
(
void
*
context
,
const
unsigned
char
*
buf
,
size_t
len
);
void
my_sha1_result
(
void
*
context
,
unsigned
char
*
digest
);
#include <mysql/service_logger.h>
typedef
struct
logger_handle_st
LOGGER_HANDLE
;
extern
struct
logger_service_st
{
...
...
include/mysql/service_sha1.h
View file @
11b6452a
#ifndef MYSQL_SERVICE_SHA1_INCLUDED
/* Copyright (c) 2013, Monty Program Ab
/* Copyright (c) 2013,
2014,
Monty Program Ab
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
...
...
@@ -34,17 +34,29 @@ extern "C" {
extern
struct
my_sha1_service_st
{
void
(
*
my_sha1_type
)(
unsigned
char
*
,
const
char
*
,
size_t
);
void
(
*
my_sha1_multi_type
)(
unsigned
char
*
,
...);
size_t
(
*
my_sha1_context_size_type
)();
void
(
*
my_sha1_init_type
)(
void
*
);
void
(
*
my_sha1_input_type
)(
void
*
,
const
unsigned
char
*
,
size_t
);
void
(
*
my_sha1_result_type
)(
void
*
,
unsigned
char
*
);
}
*
my_sha1_service
;
#ifdef MYSQL_DYNAMIC_PLUGIN
#define my_sha1(A,B,C) my_sha1_service->my_sha1_type(A,B,C)
#define my_sha1_multi my_sha1_service->my_sha1_multi_type
#define my_sha1_context_size_type() my_sha1_service->my_sha1_context_size_type()
#define my_sha1_init_type(A) my_sha1_service->my_sha1_init_type(A)
#define my_sha1_input_type(A,B,C) my_sha1_service->my_sha1_input_type(A,B,C)
#define my_sha1_result_type(A,B) my_sha1_service->my_sha1_result_type(A,B)
#else
void
my_sha1
(
unsigned
char
*
,
const
char
*
,
size_t
);
void
my_sha1_multi
(
unsigned
char
*
,
...);
size_t
my_sha1_context_size
();
void
my_sha1_init
(
void
*
context
);
void
my_sha1_input
(
void
*
context
,
const
unsigned
char
*
buf
,
size_t
len
);
void
my_sha1_result
(
void
*
context
,
unsigned
char
*
digest
);
#endif
...
...
include/service_versions.h
View file @
11b6452a
...
...
@@ -28,7 +28,7 @@
#define VERSION_thd_wait 0x0100
#define VERSION_progress_report 0x0100
#define VERSION_thd_timezone 0x0100
#define VERSION_my_sha1 0x010
0
#define VERSION_my_sha1 0x010
1
#define VERSION_logger 0x0100
#define VERSION_thd_autoinc 0x0100
#define VERSION_thd_error_context 0x0100
mysys_ssl/my_sha1.cc
View file @
11b6452a
/* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2012, Oracle and/or its affiliates.
Copyright (c) 2014, SkySQL Ab.
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
...
...
@@ -29,66 +30,52 @@
#if defined(HAVE_YASSL)
#include "sha.hpp"
/**
Compute SHA1 message digest using YaSSL.
typedef
TaoCrypt
::
SHA
SHA_CTX
;
@param digest [out] Computed SHA1 digest
@param buf [in] Message to be computed
@param len [in] Length of the message
static
void
sha1_init
(
SHA_CTX
*
context
)
{
context
->
Init
();
}
@return void
/*
this is a variant of sha1_init to be used in this file only.
does nothing for yassl, because the context's constructor was called automatically.
*/
void
mysql_sha1_yassl
(
uint8
*
digest
,
const
char
*
buf
,
int
len
)
static
void
sha1_init_fast
(
SHA_CTX
*
context
)
{
TaoCrypt
::
SHA
hasher
;
hasher
.
Update
((
const
TaoCrypt
::
byte
*
)
buf
,
len
);
hasher
.
Final
((
TaoCrypt
::
byte
*
)
digest
);
}
/**
Compute SHA1 message digest for two messages in order to
emulate sha1(msg1, msg2) using YaSSL.
@param digest [out] Computed SHA1 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
static
void
sha1_input
(
SHA_CTX
*
context
,
const
uchar
*
buf
,
unsigned
len
)
{
context
->
Update
((
const
TaoCrypt
::
byte
*
)
buf
,
len
);
}
@return void
*/
void
mysql_sha1_multi_yassl
(
uint8
*
digest
,
va_list
args
)
static
void
sha1_result
(
SHA_CTX
*
context
,
uchar
digest
[
SHA1_HASH_SIZE
])
{
const
char
*
str
;
TaoCrypt
::
SHA
hasher
;
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
);
context
->
Final
((
TaoCrypt
::
byte
*
)
digest
);
}
#elif defined(HAVE_OPENSSL)
#include <openssl/sha.h>
int
mysql_sha1_rese
t
(
SHA_CTX
*
context
)
static
void
sha1_ini
t
(
SHA_CTX
*
context
)
{
return
SHA1_Init
(
context
);
SHA1_Init
(
context
);
}
int
mysql_sha1_input
(
SHA_CTX
*
context
,
const
uint8
*
message_array
,
unsigned
length
)
static
void
sha1_init_fast
(
SHA_CTX
*
context
)
{
return
SHA1_Update
(
context
,
message_array
,
length
);
sha1_init
(
context
);
}
static
void
sha1_input
(
SHA_CTX
*
context
,
const
uchar
*
buf
,
unsigned
len
)
{
SHA1_Update
(
context
,
buf
,
len
);
}
int
mysql_sha1_result
(
SHA_CTX
*
context
,
uint8
Message_Digest
[
SHA1_HASH_SIZE
])
static
void
sha1_result
(
SHA_CTX
*
context
,
uchar
digest
[
SHA1_HASH_SIZE
])
{
return
SHA1_Final
(
Message_D
igest
,
context
);
SHA1_Final
(
d
igest
,
context
);
}
#endif
/* HAVE_YASSL */
...
...
@@ -102,17 +89,13 @@ int mysql_sha1_result(SHA_CTX *context,
@return void
*/
void
my_sha1
(
u
int8
*
digest
,
const
char
*
buf
,
size_t
len
)
void
my_sha1
(
u
char
*
digest
,
const
char
*
buf
,
size_t
len
)
{
#if defined(HAVE_YASSL)
mysql_sha1_yassl
(
digest
,
buf
,
len
);
#elif defined(HAVE_OPENSSL)
SHA_CTX
sha1_context
;
mysql_sha1_reset
(
&
sha1_context
);
mysql_sha1_input
(
&
sha1_context
,
(
const
uint8
*
)
buf
,
len
);
mysql_sha1_result
(
&
sha1_context
,
digest
);
#endif
/* HAVE_YASSL */
sha1_init_fast
(
&
sha1_context
);
sha1_input
(
&
sha1_context
,
(
const
uchar
*
)
buf
,
len
);
sha1_result
(
&
sha1_context
,
digest
);
}
...
...
@@ -128,24 +111,38 @@ void my_sha1(uint8 *digest, const char *buf, size_t len)
@return void
*/
void
my_sha1_multi
(
u
int8
*
digest
,
...)
void
my_sha1_multi
(
u
char
*
digest
,
...)
{
va_list
args
;
va_start
(
args
,
digest
);
#if defined(HAVE_YASSL)
mysql_sha1_multi_yassl
(
digest
,
args
);
#elif defined(HAVE_OPENSSL)
SHA_CTX
sha1_context
;
const
char
*
str
;
mysql_sha1_reset
(
&
sha1_context
);
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 */
const
uchar
*
str
;
sha1_init_fast
(
&
sha1_context
);
for
(
str
=
va_arg
(
args
,
const
uchar
*
);
str
;
str
=
va_arg
(
args
,
const
uchar
*
))
sha1_input
(
&
sha1_context
,
str
,
va_arg
(
args
,
size_t
));
sha1_result
(
&
sha1_context
,
digest
);
va_end
(
args
);
}
size_t
my_sha1_context_size
()
{
return
sizeof
(
SHA_CTX
);
}
void
my_sha1_init
(
void
*
context
)
{
sha1_init
((
SHA_CTX
*
)
context
);
}
void
my_sha1_input
(
void
*
context
,
const
uchar
*
buf
,
size_t
len
)
{
sha1_input
((
SHA_CTX
*
)
context
,
buf
,
len
);
}
void
my_sha1_result
(
void
*
context
,
uchar
*
digest
)
{
sha1_result
((
SHA_CTX
*
)
context
,
digest
);
}
sql/sql_plugin_services.h
View file @
11b6452a
/* Copyright (c) 2009, 2010, Oracle and/or its affiliates.
Copyright (c) 2012, 201
3
, Monty Program Ab
Copyright (c) 2012, 201
4
, Monty Program Ab
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
...
...
@@ -61,7 +61,11 @@ static struct thd_timezone_service_st thd_timezone_handler= {
static
struct
my_sha1_service_st
my_sha1_handler
=
{
my_sha1
,
my_sha1_multi
my_sha1_multi
,
my_sha1_context_size
,
my_sha1_init
,
my_sha1_input
,
my_sha1_result
};
static
struct
logger_service_st
logger_service_handler
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment