Skip to content

Commit a52ea1b

Browse files
committed
Remove unused functions
1 parent 0863371 commit a52ea1b

1 file changed

Lines changed: 0 additions & 86 deletions

File tree

  • network/cloud_sync

network/cloud_sync/s3.c

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -441,45 +441,6 @@ static char* s3_url_encode(const char *input)
441441
return output;
442442
}
443443

444-
/* Trim whitespace from string */
445-
static char* s3_trim_string(const char *input)
446-
{
447-
size_t len;
448-
size_t start = 0;
449-
size_t end;
450-
size_t trimmed_len = 0;
451-
char *trimmed = NULL;
452-
453-
/* NULL-check input BEFORE calling strlen. Same dead-code bug
454-
* as s3_url_encode: the 'if (!input)' check sat after the
455-
* strlen call, so NULL input segfaulted before the guard
456-
* could fire. */
457-
if (!input)
458-
return NULL;
459-
460-
len = strlen(input);
461-
end = len;
462-
463-
/* Find start of non-whitespace */
464-
while (start < len && (input[start] == ' ' || input[start] == '\t'))
465-
start++;
466-
467-
/* Find end of non-whitespace */
468-
while (end > start && (input[end-1] == ' ' || input[end-1] == '\t'))
469-
end--;
470-
471-
/* Create trimmed string */
472-
trimmed_len = end - start;
473-
trimmed = malloc(trimmed_len + 1);
474-
if (!trimmed)
475-
return NULL;
476-
477-
memcpy(trimmed, input + start, trimmed_len);
478-
trimmed[trimmed_len] = '\0';
479-
480-
return trimmed;
481-
}
482-
483444
/* Canonicalize query string parameters */
484445
static char* s3_canonicalize_query_string(const char *query_string)
485446
{
@@ -602,53 +563,6 @@ static uint8_t* s3_hmac_sha256_bin(const uint8_t *key, size_t key_len, const cha
602563
return output;
603564
}
604565

605-
/* Calculate HMAC-SHA256 (legacy function for compatibility) */
606-
static char* s3_hmac_sha256(const char *key, const char *data, char *output)
607-
{
608-
unsigned i;
609-
char *hmac_hex = malloc(65);
610-
uint8_t binary_key[64];
611-
size_t key_len;
612-
uint8_t result[32];
613-
614-
if (!hmac_hex)
615-
return NULL;
616-
617-
key_len = strlen(key);
618-
619-
/* Convert key to binary */
620-
if (key_len <= 64)
621-
{
622-
memset(binary_key, 0, 64);
623-
memcpy(binary_key, key, key_len);
624-
}
625-
else
626-
{
627-
/* Hash the key if it's longer than 64 bytes */
628-
char temp_hash[65];
629-
sha256_hash(temp_hash, (const uint8_t*)key, key_len);
630-
for (i = 0; i < 32; i++)
631-
{
632-
char hex_byte[3] = {temp_hash[i*2], temp_hash[i*2+1], 0};
633-
binary_key[i] = (uint8_t)strtol(hex_byte, NULL, 16);
634-
}
635-
key_len = 32;
636-
}
637-
638-
if (!s3_hmac_sha256_bin(binary_key, key_len, data, result))
639-
{
640-
free(hmac_hex);
641-
return NULL;
642-
}
643-
644-
/* Convert binary result to hex */
645-
for (i = 0; i < 32; i++)
646-
snprintf(hmac_hex + 2 * i, 3, "%02x", (unsigned)result[i]);
647-
648-
hmac_hex[64] = '\0';
649-
return hmac_hex;
650-
}
651-
652566
/* Calculate AWS Signature Version 4 signature with proper key derivation */
653567
static char* s3_calculate_aws4_signature(const char *secret_key, const char *date,
654568
const char *region, const char *service,

0 commit comments

Comments
 (0)