//
// JSON Web Token API implementation for CUPS.
//
-// Copyright © 2023-2024 by OpenPrinting.
+// Copyright © 2023-2025 by OpenPrinting.
//
// Licensed under Apache License v2.0. See the file "LICENSE" for more
// information.
#include "cups-private.h"
#include "jwt.h"
#include "json-private.h"
+#include <assert.h>
#ifdef HAVE_OPENSSL
# include <openssl/ecdsa.h>
# include <openssl/evp.h>
#ifdef HAVE_OPENSSL
hash_len = cupsHashData(cups_jwa_algorithms[jwt->sigalg], text, text_len, hash, sizeof(hash));
+ assert(hash_len > 0);
if ((rsa = make_rsa(jwk)) != NULL)
{
#ifdef HAVE_OPENSSL
hash_len = cupsHashData(cups_jwa_algorithms[jwt->sigalg], text, text_len, hash, sizeof(hash));
+ assert(hash_len > 0);
if ((ec = make_ec_key(jwk, true)) != NULL)
{
if ((rsa = make_rsa(jwk)) != NULL)
{
hash_len = cupsHashData(cups_jwa_algorithms[alg], text, text_len, hash, sizeof(hash));
+ assert(hash_len > 0);
+
if (RSA_sign(nids[alg - CUPS_JWA_RS256], hash, hash_len, signature, &siglen, rsa) == 1)
{
*sigsize = siglen;
if ((ec = make_ec_key(jwk, false)) != NULL)
{
hash_len = cupsHashData(cups_jwa_algorithms[alg], text, text_len, hash, sizeof(hash));
+ assert(hash_len > 0);
+
if ((ec_sig = ECDSA_do_sign(hash, hash_len, ec)) != NULL)
{
// Get the raw coordinates...
// Allocate memory for string...
initial_state = httpGetState(http);
- if ((bodylen = (size_t)httpGetLength(http)) == 0 || bodylen > 65536)
+ if ((bytes = httpGetLength(http)) < 0)
+ return (NULL);
+ else if (bytes == 0 || bytes > 65536)
bodylen = 65536; // Accept up to 64k for GETs/POSTs
+ else
+ bodylen = (size_t)bytes;
if ((body = calloc(1, bodylen + 1)) != NULL)
{
//
// (Has the advantage of being easily identified, too...)
//
-// For CUPS 3.0.x:
+// For CUPS 2.5.x:
//
-// 43555053-0300-8010-8011-4F4175746820
+// 43555053-0205-8010-8011-4F4175746820
//
static char * // O - UUID string