summaryrefslogtreecommitdiffstats
path: root/src/pki.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pki.c')
-rw-r--r--src/pki.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/pki.c b/src/pki.c
index effeb70..f776938 100644
--- a/src/pki.c
+++ b/src/pki.c
@@ -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 */