16 #include "my_global.h"
18 #include "des_key_file.h"
24 struct st_des_keyschedule des_keyschedule[10];
27 #define des_cs &my_charset_latin1
41 load_des_key_file(
const char *file_name)
46 DBUG_ENTER(
"load_des_key_file");
47 DBUG_PRINT(
"enter",(
"name: %s",file_name));
51 O_RDONLY | O_BINARY, MYF(MY_WME))) < 0 ||
52 init_io_cache(&io, file, IO_SIZE*2, READ_CACHE, 0, 0, MYF(MY_WME)))
55 memset(des_keyschedule, 0,
sizeof(
struct st_des_keyschedule) * 10);
61 st_des_keyblock keyblock;
64 if (!(length=my_b_gets(&io,buf,
sizeof(buf)-1)))
67 if (offset >=
'0' && offset <=
'9')
69 offset=(char) (offset -
'0');
71 for (start=buf+1 ; my_isspace(des_cs, *start) ; start++) ;
73 for (end=strend(buf) ;
74 end > start && !my_isgraph(des_cs, end[-1]) ; end--) ;
79 memset(&ivec, 0,
sizeof(ivec));
81 EVP_BytesToKey(EVP_des_ede3_cbc(),EVP_md5(),NULL,
82 (uchar *) start, (
int) (end-start),1,
85 DES_set_key_unchecked(&keyblock.key1,&(des_keyschedule[(
int)offset].ks1));
86 DES_set_key_unchecked(&keyblock.key2,&(des_keyschedule[(
int)offset].ks2));
87 DES_set_key_unchecked(&keyblock.key3,&(des_keyschedule[(
int)offset].ks3));
88 if (des_default_key == 15)
89 des_default_key= (uint) offset;
92 else if (offset !=
'#')
93 sql_print_error(
"load_des_file: Found wrong key_number: %c",offset);