YoushouldhavereceivedacopyoftheGNUGeneralPublicLicense alongwiththisprogram;ifnot,writetotheFreeSoftware
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
/******************************************************************//**
@file Parser.cc
A class to parse the key file
How it works...
The location and usage can be configured via the configuration file.
Example
The keys are read from a file.
The filename is set up via the file_key_management_filename
configuration value.
file_key_management_filename is used to configure the absolute
path to this file.
The key file contains AES keys as hex-encoded strings.
Supported are keys of size 128, 192or256 bits.
Example: 1;F5502320F8429037B8DAEF761B189D12 2;770A8A65DA156D24EE2A093277530142770A8A65DA156D24EE2A093277530142
1 is the key identifier which can be used for table creation,
it is followed by a AES key
The key file could be encrypted and the key to decrypt the file can
be given with the optional file_key_management_filekey
parameter.
The file key can also be located if FILE: is prepended to the
key. Then the following part is interpreted as absolute path to the
file containing the file key (which must be a text - not binary - string).
If the key file can not be read at server startup, for example if the
file key is not present, the plugin will not start
access to encrypted tables will not be possible.
Open SSL command line utility can be used to create an encrypted key file.
Example:
openssl enc -aes-256-cbc -md sha1 -k "secret" -in keys.txt -out keys.enc
***********************************************************************/
//If secret starts with FILE: interpret the secret as a filename. if (strncmp(filekey, FILE_PREFIX,sizeof(FILE_PREFIX) -1) == 0)
{ if (read_filekey(filekey + sizeof(FILE_PREFIX) - 1, buf)) return1;
secret= buf;
}
free(buffer); if (keys->size() == 0 || (*keys)[1].id == 0)
{
report_error("System key id 1 is missing", 0); return1;
}
return0;
}
void Parser::report_error(constchar *reason, size_t position)
{
my_printf_error(EE_READ, "%s at %s line %u, column %zu",
ME_ERROR_LOG, reason, filename, line_number, position + 1);
}
/* return0-newkey 1-comment -1-error
*/ int Parser::parse_line(char **line_ptr, keyentry *key)
{ int res= 1; char *p= *line_ptr; while (isspace(*p) && *p != '\n') p++; if (*p != '#' && *p != '\n')
{ if (!isdigit(*p))
{
report_error("Syntax error", p - *line_ptr); return -1;
}
longlong id = 0; while (isdigit(*p))
{
id = id * 10 + *p - '0'; if (id > (longlong) UINT_MAX32)
{
report_error("Invalid key id", p - *line_ptr); return -1;
}
p++;
}
if (id < 1)
{
report_error("Invalid key id", p - *line_ptr); return -1;
}
if (*p != ';')
{
report_error("Syntax error", p - *line_ptr); return -1;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.