]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-dcrypt: Add key id and usage fields to dcrypt keys
authorAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 23 Aug 2019 08:51:21 +0000 (11:51 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Mon, 23 Sep 2019 05:47:49 +0000 (08:47 +0300)
Simplifies next change

src/lib-dcrypt/dcrypt-openssl.c
src/lib-dcrypt/dcrypt.h

index c420d68592860258ff953a0d87e9b95a73d1571d..70a6bfa8133ea34a32a3f1881ac003e4c046b552 100644 (file)
@@ -131,11 +131,15 @@ struct dcrypt_context_hmac {
 struct dcrypt_public_key {
        EVP_PKEY *key;
        unsigned int ref;
+       enum dcrypt_key_usage usage;
+       char *key_id;
 };
 
 struct dcrypt_private_key {
        EVP_PKEY *key;
        unsigned int ref;
+       enum dcrypt_key_usage usage;
+       char *key_id;
 };
 
 static bool
@@ -1476,7 +1480,9 @@ dcrypt_openssl_load_public_key_dovecot_v1(struct dcrypt_public_key **key_r,
                EC_KEY_free(eckey);
                /* make sure digest matches */
                buffer_t *dgst = t_buffer_create(32);
-               struct dcrypt_public_key tmp = { key, 0 };
+               struct dcrypt_public_key tmp;
+               i_zero(&tmp);
+               tmp.key = key;
                dcrypt_openssl_public_key_id_old(&tmp, dgst, NULL);
                if (strcmp(binary_to_hex(dgst->data, dgst->used),
                           input[len-1]) != 0) {
@@ -1517,7 +1523,9 @@ dcrypt_openssl_load_public_key_dovecot_v2(struct dcrypt_public_key **key_r,
 
        /* make sure digest matches */
        buffer_t *dgst = t_buffer_create(32);
-       struct dcrypt_public_key tmpkey = {pkey, 0};
+       struct dcrypt_public_key tmpkey;
+       i_zero(&tmpkey);
+       tmpkey.key = pkey;
        dcrypt_openssl_public_key_id(&tmpkey, "sha256", dgst, NULL);
        if (strcmp(binary_to_hex(dgst->data, dgst->used), input[len-1]) != 0) {
                if (error_r != NULL)
index 539c0e797826dd618f797c31f49d8e3dde708160..79a334f665536fcd7d0d7652db7e947cfc3fbb4a 100644 (file)
@@ -50,6 +50,12 @@ enum dcrypt_key_kind {
        DCRYPT_KEY_KIND_PRIVATE
 };
 
+enum dcrypt_key_usage {
+       DCRYPT_KEY_USAGE_NONE,
+       DCRYPT_KEY_USAGE_ENCRYPT,
+       DCRYPT_KEY_USAGE_SIGN,
+};
+
 struct dcrypt_settings {
        /* OpenSSL engine to use */
        const char *crypto_device;