提交 0ca8efff 编写于 作者: W WangFengTu 提交者: lifeng68

create aes key file path in aes module

Signed-off-by: NWangFengTu <wangfengtu@huawei.com>
上级 51a09ebd
......@@ -24,11 +24,23 @@
static char *g_aeskey = DEFAULT_AUTH_AESKEY;
void aes_set_key_path(char *key_path)
void aes_set_key_dir(char *key_dir)
{
if (key_path != NULL) {
g_aeskey = util_strdup_s(key_path);
int sret = 0;
char path[PATH_MAX] = {0};
if (key_dir == NULL) {
return;
}
sret = snprintf(path, sizeof(path), "%s/%s", key_dir, AUTH_AESKEY_NAME);
if (sret < 0 || (size_t)sret >= sizeof(path)) {
ERROR("Failed to sprintf auths %s/%s", key_dir, AUTH_AESKEY_NAME);
return;
}
g_aeskey = util_strdup_s(path);
return;
}
......
......@@ -23,7 +23,7 @@ extern "C" {
#define AUTH_AESKEY_NAME "aeskey"
#define DEFAULT_AUTH_AESKEY "/root/.isulad/" AUTH_AESKEY_NAME
void aes_set_key_path(char *key_path);
void aes_set_key_dir(char *key_dir);
// output length is "input_len+AES_256_CFB_IV_LEN"
int aes_encode(unsigned char *input, size_t input_len, unsigned char **output);
// output length is "input_len-AES_256_CFB_IV_LEN"
......
......@@ -52,13 +52,7 @@ void auths_set_dir(char *auth_dir)
g_auth_path = util_strdup_s(path);
sret = snprintf(path, sizeof(path), "%s/%s", auth_dir, AUTH_AESKEY_NAME);
if (sret < 0 || (size_t)sret >= sizeof(path)) {
ERROR("Failed to sprintf auths aeskey, auth dir: %s", auth_dir);
return;
}
aes_set_key_path(path);
aes_set_key_dir(auth_dir);
return;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册