Some SlackBuild scripts for Slackware.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.3 KiB

diff --git a/src/agent.c b/src/agent.c
index 9265ca2..b77c879 100644
--- a/src/agent.c
+++ b/src/agent.c
@@ -996,8 +996,9 @@ scute_agent_sign (char *grip, unsigned char *data, int len,
{
char cmd[150];
gpg_error_t err;
-#define MAX_DATA_LEN 36
+#define MAX_DATA_LEN 51
unsigned char pretty_data[2 * MAX_DATA_LEN + 1];
+ char *data_type;
int i;
struct signature sig;
@@ -1016,6 +1017,13 @@ scute_agent_sign (char *grip, unsigned char *data, int len,
if (len > MAX_DATA_LEN)
return gpg_error (GPG_ERR_INV_ARG);
+ if (len == 36) /* TLS <= 1.1, data is a MD5+SHA1 hash */
+ data_type = "tls-md5sha1";
+ else if (len == 35 || len == 51) /* TLS 1.2, data is a DigestInfo object */
+ data_type = "tls-digest";
+ else
+ return gpg_error (GPG_ERR_INV_ARG);
+
if (grip == NULL || sig_result == NULL || *sig_len < SIG_LEN)
return gpg_error (GPG_ERR_INV_ARG);
@@ -1029,7 +1037,7 @@ scute_agent_sign (char *grip, unsigned char *data, int len,
snprintf (&pretty_data[2 * i], 3, "%02X", data[i]);
pretty_data[2 * len] = '\0';
- snprintf (cmd, sizeof (cmd), "SETHASH --hash=tls-md5sha1 %s", pretty_data);
+ snprintf (cmd, sizeof (cmd), "SETHASH --hash=%s %s", data_type, pretty_data);
err = assuan_transact (agent_ctx, cmd, NULL, NULL, default_inq_cb,
NULL, NULL, NULL);
if (err)