[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Data signing (for Git signing)
[Thread Prev] | [Thread Next]
- Subject: Data signing (for Git signing)
- From: Abdelilah El Aissaoui <aeab13@xxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Fri, 12 Dec 2025 00:45:51 +0100
- To: libssh@xxxxxxxxxx
Hello! I've been using libssh for quite a while now for the usual SSH auth for my Git client and it has been great so far. One feature request I got was to add support signing with SSH keys, as Git CLI does. I've been reading the docs but haven't found anything that could help me to that aside from some methods in "The SSH Public Key Infrastructure" (https://api.libssh.org/stable/group__libssh__pki.html) such as "*ssh_pki_do_sign*" and "*ssh_pki_do_sign_agent*". Given that both methods were not part of the public API, I've done some small changes moving them to "*libssh.h*" and used it like it can be seen here: ``` int result = 0; ssh_init(); ssh_set_log_level(4); ssh_session session = ssh_new(); ssh_options_set(session, SSH_OPTIONS_HOST, "localhost"); result = ssh_connect(session); handleResult(result, session); ssh_buffer buffer = ssh_buffer_new(); char* text = "Hello world"; ssh_buffer_add_data(buffer, text, strlen(text)); ssh_key key = ssh_key_new(); result = ssh_pki_import_privkey_file("/path/to/.ssh/id_rsa", "", NULL, NULL, &key); handleResult(result, session); int hash_type = 2; ssh_string output = ssh_pki_do_sign(session, buffer, key, hash_type); char* text_signed = ssh_string_to_char(output); printf("Output is %s", text_signed); ``` The output always returns empty unfortunately. Given that both methods require a session I assume I'm doing something wrong. It could also be an issue with my C code given that I'm anything but proficient in the language. I was wondering if I'm going in the right direction or perhaps I'm completely off, as I'm not sure it's even possible with what LIBSSH currently offers. I would be grateful for any guidance. Thank you in advance, Abde.
| Re: Data signing (for Git signing) | Aris Adamantiadis <aris@xxxxxxxxxx> |