gcrypt: Drop unnecessary arguments of decode_key().
[paraslash.git] / gcrypt.c
index 694c0adb8454b73dc0e5b67876fc7a03617b61d0..50ddff46df79820c9af24c7a4f96c02ef05f9675 100644 (file)
--- a/gcrypt.c
+++ b/gcrypt.c
@@ -106,8 +106,12 @@ static const char *gcrypt_strerror(gcry_error_t gret)
        return gcry_strerror(gcry_err_code(gret));
 }
 
-static int decode_key(const char *key_file, const char *header_str,
-               const char *footer_str, unsigned char **result)
+/** Private keys start with this header. */
+#define PRIVATE_KEY_HEADER "-----BEGIN RSA PRIVATE KEY-----"
+/** Private keys end with this footer. */
+#define PRIVATE_KEY_FOOTER "-----END RSA PRIVATE KEY-----"
+
+static int decode_key(const char *key_file, unsigned char **result)
 {
        int ret, ret2, i, j;
        void *map;
@@ -119,13 +123,13 @@ static int decode_key(const char *key_file, const char *header_str,
        if (ret < 0)
                goto out;
        ret = -E_KEY_MARKER;
-       if (strncmp(map, header_str, strlen(header_str)))
+       if (strncmp(map, PRIVATE_KEY_HEADER, strlen(PRIVATE_KEY_HEADER)))
                goto unmap;
-       footer = strstr(map, footer_str);
+       footer = strstr(map, PRIVATE_KEY_FOOTER);
        ret = -E_KEY_MARKER;
        if (!footer)
                goto unmap;
-       begin = map + strlen(header_str);
+       begin = map + strlen(PRIVATE_KEY_HEADER);
        /* skip whitespace at the beginning */
        for (; begin < footer; begin++) {
                if (para_isspace(*begin))
@@ -290,11 +294,6 @@ static int find_privkey_bignum_offset(const unsigned char *data, int len)
        return p - data;
 }
 
-/** Private keys start with this header. */
-#define PRIVATE_KEY_HEADER "-----BEGIN RSA PRIVATE KEY-----"
-/** Private keys end with this footer. */
-#define PRIVATE_KEY_FOOTER "-----END RSA PRIVATE KEY-----"
-
 static int get_private_key(const char *key_file, struct asymmetric_key **result)
 {
        gcry_mpi_t n = NULL, e = NULL, d = NULL, p = NULL, q = NULL,
@@ -307,8 +306,7 @@ static int get_private_key(const char *key_file, struct asymmetric_key **result)
        struct asymmetric_key *key;
 
        *result = NULL;
-       ret = decode_key(key_file, PRIVATE_KEY_HEADER, PRIVATE_KEY_FOOTER,
-               &blob);
+       ret = decode_key(key_file, &blob);
        if (ret < 0)
                return ret;
        blob_size = ret;