1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-08-08 19:02:06 +03:00

pki: Add ssh_pki_export_signature_blob().

This commit is contained in:
Andreas Schneider
2011-08-21 10:11:05 +02:00
parent ab0354dbb6
commit 4f19a304d1
4 changed files with 170 additions and 0 deletions

View File

@@ -857,6 +857,62 @@ int ssh_pki_export_pubkey_file(const ssh_key key,
return SSH_OK;
}
int ssh_pki_export_signature_blob(const ssh_signature sig,
ssh_string *sig_blob)
{
ssh_buffer buf = NULL;
ssh_string str;
int rc;
if (sig == NULL || sig_blob == NULL) {
return SSH_ERROR;
}
buf = ssh_buffer_new();
if (buf == NULL) {
return SSH_ERROR;
}
str = ssh_string_from_char(ssh_key_type_to_char(sig->type));
if (str == NULL) {
ssh_buffer_free(buf);
return SSH_ERROR;
}
rc = buffer_add_ssh_string(buf, str);
ssh_string_free(str);
if (rc < 0) {
ssh_buffer_free(buf);
return SSH_ERROR;
}
str = pki_signature_to_blob(sig);
if (str == NULL) {
ssh_buffer_free(buf);
return SSH_ERROR;
}
rc = buffer_add_ssh_string(buf, str);
ssh_string_free(str);
if (rc < 0) {
ssh_buffer_free(buf);
return SSH_ERROR;
}
str = ssh_string_new(buffer_get_rest_len(buf));
if (str == NULL) {
ssh_buffer_free(buf);
return SSH_ERROR;
}
ssh_string_fill(str, buffer_get_rest(buf), buffer_get_rest_len(buf));
ssh_buffer_free(buf);
*sig_blob = str;
return SSH_OK;
}
/*
* This function signs the session id (known as H) as a string then
* the content of sigbuf */