]> git.ipfire.org Git - pakfire.git/commitdiff
keys: Give signing functions better names
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 1 Feb 2025 15:53:56 +0000 (15:53 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 1 Feb 2025 15:53:56 +0000 (15:53 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/key.c
src/pakfire/key.h
src/pakfire/repo.c
src/python/key.c
tests/libpakfire/key.c

index dd55556038c15e4a695f155951be8707970758ac..ac1c90c49572c8b8fb730f3537ddfcca0df19a28 100644 (file)
@@ -830,10 +830,10 @@ ERROR:
        return r;
 }
 
-int pakfire_key_sign(struct pakfire_key* key,
+int pakfire_key_sign_string(struct pakfire_key* key,
                FILE* f, const void* data, const size_t length, const char* comment) {
        struct pakfire_key_signature signature = { 0 };
-       char* s = NULL;
+       char* buffer = NULL;
        int r;
 
        // Create a signature
@@ -852,12 +852,12 @@ int pakfire_key_sign(struct pakfire_key* key,
        }
 
        // Encode the signature to base64
-       r = pakfire_b64encode(key->ctx, &s, &signature, sizeof(signature));
+       r = pakfire_b64encode(key->ctx, &buffer, &signature, sizeof(signature));
        if (r < 0)
                goto ERROR;
 
        // Write the signature
-       r = fprintf(f, "%s\n", s);
+       r = fprintf(f, "%s\n", buffer);
        if (r < 0) {
                ERROR(key->ctx, "Could not write the signature: %m\n");
                r = -errno;
@@ -871,13 +871,13 @@ int pakfire_key_sign(struct pakfire_key* key,
        r = 0;
 
 ERROR:
-       if (s)
-               free(s);
+       if (buffer)
+               free(buffer);
 
        return r;
 }
 
-int pakfire_key_signf(struct pakfire_key* key, FILE* s, FILE* f, const char* comment) {
+int pakfire_key_sign(struct pakfire_key* key, FILE* s, FILE* f, const char* comment) {
        char* buffer = NULL;
        size_t length = 0;
        int r;
@@ -888,7 +888,7 @@ int pakfire_key_signf(struct pakfire_key* key, FILE* s, FILE* f, const char* com
                goto ERROR;
 
        // Sign!
-       r = pakfire_key_sign(key, s, buffer, length, comment);
+       r = pakfire_key_sign_string(key, s, buffer, length, comment);
 
 ERROR:
        if (buffer)
index f97923e55ca0dc8f95d7bd6b21aebe834f853ceb..959f155b84cf232a10dccdbbb18043c1cfaf5a96 100644 (file)
@@ -55,14 +55,13 @@ int pakfire_key_import(struct pakfire_key** key, struct pakfire_ctx* ctx, FILE*
 char* pakfire_key_dump(struct pakfire_key* key, size_t* length);
 
 // Sign
-int pakfire_key_sign(struct pakfire_key* key,
-       FILE* f, const void* data, const size_t length, const char* comment);
+int pakfire_key_sign(struct pakfire_key* key, FILE* s, FILE* f, const char* comment);
+int pakfire_key_sign_string(struct pakfire_key* key,
+       FILE* s, const void* data, const size_t length, const char* comment);
 int pakfire_key_verify(struct pakfire_key* key,
        FILE* f, const void* data, const size_t length);
 
 int pakfire_key_import_from_string(struct pakfire_key** key,
        struct pakfire_ctx* ctx, const char* data, const size_t length);
 
-int pakfire_key_signf(struct pakfire_key* key, FILE* s, FILE* f, const char* comment);
-
 #endif /* PAKFIRE_KEY_H */
index ab3bccd7fdebc7632751cf6e079dc6642f59f3bc..aa19f84c94ee6145dc3a148b118e6892ae5940da 100644 (file)
@@ -1993,7 +1993,7 @@ static int pakfire_repo_sign_database(struct pakfire_repo* repo, struct pakfire_
        }
 
        // Create the signature
-       r = pakfire_key_signf(key, s, f, "Database Signature");
+       r = pakfire_key_sign(key, s, f, "Database Signature");
        if (r) {
                ERROR(repo->ctx, "Could not sign the database: %m\n");
                goto ERROR;
index 03645c453aafd7d19c9e0e697bc814786e13dbb8..24bafd1f9b7723dd00cf4ca9dad3600bda76cbdc 100644 (file)
@@ -177,7 +177,7 @@ static PyObject* Key_sign(KeyObject* self, PyObject* args, PyObject* kwargs) {
        }
 
        // Create the signature
-       r = pakfire_key_sign(self->key, f, data, data_length, comment);
+       r = pakfire_key_sign_string(self->key, f, data, data_length, comment);
        if (r) {
                PyErr_SetFromErrno(PyExc_OSError);
                goto ERROR;
index 32d626a4bcf76f3ac2bf6cc900ae2555a6d1a18d..5ca1cb62bc310725a135e58cbf3b805349b74737 100644 (file)
@@ -75,7 +75,7 @@ static int test_sign_and_verify(const struct test* t) {
        ASSERT_SUCCESS(pakfire_key_export(key, stdout, PAKFIRE_KEY_EXPORT_MODE_PRIVATE));
 
        // Sign!
-       ASSERT_SUCCESS(pakfire_key_sign(key, f, DATA, DATA_LENGTH, "UNTRUSTED COMMENT"));
+       ASSERT_SUCCESS(pakfire_key_sign_string(key, f, DATA, DATA_LENGTH, "UNTRUSTED COMMENT"));
 
        // Rewind the file
        rewind(f);