Skip to content

Commit 1eb5789

Browse files
committed
Fix GNU TLS support for JWT signatures (Issue #68)
1 parent a6997e7 commit 1eb5789

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

cups/jwt.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,13 +1171,19 @@ cupsJWTSign(cups_jwt_t *jwt, // I - JWT object
11711171

11721172
// Create new signature...
11731173
if (!make_signature(jwt, alg, jwk, signature, &sigsize, &sigkid))
1174+
{
1175+
DEBUG_puts("2cupsJWTSign: Unable to create signature.");
11741176
return (false);
1177+
}
11751178

11761179
if (sigkid)
11771180
jwt->sigkid = strdup(sigkid);
11781181

11791182
if ((jwt->signature = malloc(sigsize)) == NULL)
1183+
{
1184+
DEBUG_printf("2cupsJWTSign: Unable to allocate %d bytes for signature.", (int)sigsize);
11801185
return (false);
1186+
}
11811187

11821188
memcpy(jwt->signature, signature, sigsize);
11831189
jwt->sigalg = alg;
@@ -1627,7 +1633,7 @@ make_signature(cups_jwt_t *jwt, // I - JWT
16271633
gnutls_privkey_t key; // Private key
16281634
gnutls_datum_t text_datum, // Text datum
16291635
sig_datum; // Signature datum
1630-
static int algs[] = { GNUTLS_DIG_SHA256, GNUTLS_DIG_SHA384, GNUTLS_DIG_SHA512, GNUTLS_SIGN_ECDSA_SHA256, GNUTLS_SIGN_ECDSA_SHA384, GNUTLS_SIGN_ECDSA_SHA512 };
1636+
static int algs[] = { GNUTLS_DIG_SHA256, GNUTLS_DIG_SHA384, GNUTLS_DIG_SHA512, GNUTLS_DIG_SHA256, GNUTLS_DIG_SHA384, GNUTLS_DIG_SHA512 };
16311637
// Hash algorithms
16321638
#endif // HAVE_OPENSSL
16331639

@@ -1809,7 +1815,10 @@ make_signature(cups_jwt_t *jwt, // I - JWT
18091815
gnutls_free(r.data);
18101816
gnutls_free(s.data);
18111817
}
1812-
1818+
else
1819+
{
1820+
DEBUG_printf("4make_signature: EC signing failed, sig_datum=%d bytes.", (int)sig_datum.size);
1821+
}
18131822
gnutls_free(sig_datum.data);
18141823
gnutls_privkey_deinit(key);
18151824
}

0 commit comments

Comments
 (0)