pki: Use a consistent naming scheme.
Этот коммит содержится в:
родитель
3e56ac650c
Коммит
c575de17a8
@ -457,10 +457,10 @@ LIBSSH_API int ssh_pki_import_pubkey_base64(const char *b64_key,
|
|||||||
ssh_key *pkey);
|
ssh_key *pkey);
|
||||||
LIBSSH_API int ssh_pki_import_pubkey_file(const char *filename,
|
LIBSSH_API int ssh_pki_import_pubkey_file(const char *filename,
|
||||||
ssh_key *pkey);
|
ssh_key *pkey);
|
||||||
LIBSSH_API int ssh_pki_export_publickey_base64(const ssh_key key,
|
LIBSSH_API int ssh_pki_export_pubkey_base64(const ssh_key key,
|
||||||
char **b64_key);
|
char **b64_key);
|
||||||
LIBSSH_API int ssh_pki_export_publickey_file(const ssh_key key,
|
LIBSSH_API int ssh_pki_export_pubkey_file(const ssh_key key,
|
||||||
const char *filename);
|
const char *filename);
|
||||||
|
|
||||||
LIBSSH_API int ssh_userauth_pki_pubkey(ssh_session session, const char *username,
|
LIBSSH_API int ssh_userauth_pki_pubkey(ssh_session session, const char *username,
|
||||||
ssh_string publickey, ssh_key privatekey);
|
ssh_string publickey, ssh_key privatekey);
|
||||||
|
@ -60,7 +60,7 @@ int pki_pubkey_build_dss(ssh_key key,
|
|||||||
int pki_pubkey_build_rsa(ssh_key key,
|
int pki_pubkey_build_rsa(ssh_key key,
|
||||||
ssh_string e,
|
ssh_string e,
|
||||||
ssh_string n);
|
ssh_string n);
|
||||||
ssh_string pki_publickey_to_string(const ssh_key key);
|
ssh_string pki_publickey_to_blob(const ssh_key key);
|
||||||
|
|
||||||
|
|
||||||
/* half public ssh pki functions */
|
/* half public ssh pki functions */
|
||||||
@ -72,7 +72,7 @@ ssh_key ssh_pki_publickey_from_privatekey(const ssh_key privkey);
|
|||||||
int ssh_pki_import_pubkey_blob(const ssh_string key_blob,
|
int ssh_pki_import_pubkey_blob(const ssh_string key_blob,
|
||||||
ssh_key *pkey);
|
ssh_key *pkey);
|
||||||
|
|
||||||
ssh_string ssh_pki_publickey_to_blob(const ssh_key key);
|
ssh_string ssh_pki_export_pubkey_blob(const ssh_key key);
|
||||||
|
|
||||||
ssh_string ssh_pki_do_sign(ssh_session session, ssh_buffer sigbuf,
|
ssh_string ssh_pki_do_sign(ssh_session session, ssh_buffer sigbuf,
|
||||||
ssh_key privatekey);
|
ssh_key privatekey);
|
||||||
|
@ -355,7 +355,7 @@ ssh_string publickey_from_file(ssh_session session, const char *filename,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
key_str = ssh_pki_publickey_to_blob(key);
|
key_str = ssh_pki_export_pubkey_blob(key);
|
||||||
if (key_str == NULL) {
|
if (key_str == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -420,7 +420,7 @@ ssh_string publickey_to_string(ssh_public_key pubkey) {
|
|||||||
key->dsa = pubkey->dsa_pub;
|
key->dsa = pubkey->dsa_pub;
|
||||||
key->rsa = pubkey->rsa_pub;
|
key->rsa = pubkey->rsa_pub;
|
||||||
|
|
||||||
key_blob = ssh_pki_publickey_to_blob(key);
|
key_blob = ssh_pki_export_pubkey_blob(key);
|
||||||
|
|
||||||
key->dsa = NULL;
|
key->dsa = NULL;
|
||||||
key->rsa = NULL;
|
key->rsa = NULL;
|
||||||
|
16
src/pki.c
16
src/pki.c
@ -710,13 +710,13 @@ ssh_key ssh_pki_publickey_from_privatekey(const ssh_key privkey) {
|
|||||||
*
|
*
|
||||||
* @return The key_blob or NULL on error.
|
* @return The key_blob or NULL on error.
|
||||||
*/
|
*/
|
||||||
ssh_string ssh_pki_publickey_to_blob(const ssh_key key)
|
ssh_string ssh_pki_export_pubkey_blob(const ssh_key key)
|
||||||
{
|
{
|
||||||
if (key == NULL) {
|
if (key == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return pki_publickey_to_string(key);
|
return pki_publickey_to_blob(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -730,8 +730,8 @@ ssh_string ssh_pki_publickey_to_blob(const ssh_key key)
|
|||||||
*
|
*
|
||||||
* @see ssh_string_free_char()
|
* @see ssh_string_free_char()
|
||||||
*/
|
*/
|
||||||
int ssh_pki_export_publickey_base64(const ssh_key key,
|
int ssh_pki_export_pubkey_base64(const ssh_key key,
|
||||||
char **b64_key)
|
char **b64_key)
|
||||||
{
|
{
|
||||||
ssh_string key_blob;
|
ssh_string key_blob;
|
||||||
unsigned char *b64;
|
unsigned char *b64;
|
||||||
@ -740,7 +740,7 @@ int ssh_pki_export_publickey_base64(const ssh_key key,
|
|||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
key_blob = pki_publickey_to_string(key);
|
key_blob = pki_publickey_to_blob(key);
|
||||||
if (key_blob == NULL) {
|
if (key_blob == NULL) {
|
||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
@ -756,8 +756,8 @@ int ssh_pki_export_publickey_base64(const ssh_key key,
|
|||||||
return SSH_OK;
|
return SSH_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ssh_pki_export_publickey_file(const ssh_key key,
|
int ssh_pki_export_pubkey_file(const ssh_key key,
|
||||||
const char *filename)
|
const char *filename)
|
||||||
{
|
{
|
||||||
char key_buf[4096];
|
char key_buf[4096];
|
||||||
char host[256];
|
char host[256];
|
||||||
@ -781,7 +781,7 @@ int ssh_pki_export_publickey_file(const ssh_key key,
|
|||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ssh_pki_export_publickey_base64(key, &b64_key);
|
rc = ssh_pki_export_pubkey_base64(key, &b64_key);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
free(user);
|
free(user);
|
||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
|
@ -350,7 +350,7 @@ int pki_pubkey_build_rsa(ssh_key key,
|
|||||||
return SSH_OK;
|
return SSH_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssh_string pki_publickey_to_string(const ssh_key key)
|
ssh_string pki_publickey_to_blob(const ssh_key key)
|
||||||
{
|
{
|
||||||
ssh_buffer buffer;
|
ssh_buffer buffer;
|
||||||
ssh_string type_s;
|
ssh_string type_s;
|
||||||
|
@ -985,7 +985,7 @@ fail:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssh_string pki_publickey_to_string(const ssh_key key)
|
ssh_string pki_publickey_to_blob(const ssh_key key)
|
||||||
{
|
{
|
||||||
ssh_buffer buffer;
|
ssh_buffer buffer;
|
||||||
ssh_string type_s;
|
ssh_string type_s;
|
||||||
|
@ -316,7 +316,7 @@ static void torture_pki_publickey_dsa_base64(void **state)
|
|||||||
rc = ssh_pki_import_pubkey_base64(q, type, &key);
|
rc = ssh_pki_import_pubkey_base64(q, type, &key);
|
||||||
assert_true(rc == 0);
|
assert_true(rc == 0);
|
||||||
|
|
||||||
rc = ssh_pki_export_publickey_base64(key, &b64_key);
|
rc = ssh_pki_export_pubkey_base64(key, &b64_key);
|
||||||
assert_true(rc == 0);
|
assert_true(rc == 0);
|
||||||
|
|
||||||
assert_string_equal(q, b64_key);
|
assert_string_equal(q, b64_key);
|
||||||
@ -354,7 +354,7 @@ static void torture_pki_publickey_rsa_base64(void **state)
|
|||||||
rc = ssh_pki_import_pubkey_base64(q, type, &key);
|
rc = ssh_pki_import_pubkey_base64(q, type, &key);
|
||||||
assert_true(rc == 0);
|
assert_true(rc == 0);
|
||||||
|
|
||||||
rc = ssh_pki_export_publickey_base64(key, &b64_key);
|
rc = ssh_pki_export_pubkey_base64(key, &b64_key);
|
||||||
assert_true(rc == 0);
|
assert_true(rc == 0);
|
||||||
|
|
||||||
assert_string_equal(q, b64_key);
|
assert_string_equal(q, b64_key);
|
||||||
@ -391,7 +391,7 @@ static void torture_generate_pubkey_from_privkey(void **state) {
|
|||||||
pubkey = ssh_pki_publickey_from_privatekey(privkey);
|
pubkey = ssh_pki_publickey_from_privatekey(privkey);
|
||||||
assert_true(pubkey != NULL);
|
assert_true(pubkey != NULL);
|
||||||
|
|
||||||
rc = ssh_pki_export_publickey_file(pubkey, LIBSSH_DSA_TESTKEY ".pub");
|
rc = ssh_pki_export_pubkey_file(pubkey, LIBSSH_DSA_TESTKEY ".pub");
|
||||||
assert_true(rc == 0);
|
assert_true(rc == 0);
|
||||||
|
|
||||||
rc = torture_read_one_line(LIBSSH_DSA_TESTKEY ".pub",
|
rc = torture_read_one_line(LIBSSH_DSA_TESTKEY ".pub",
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user