]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-dcrypt: Add API for dcrypt_ecdh_derive_secret
authorAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 29 Aug 2019 13:52:51 +0000 (16:52 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Mon, 23 Sep 2019 05:47:55 +0000 (08:47 +0300)
src/lib-dcrypt/dcrypt-private.h
src/lib-dcrypt/dcrypt.c
src/lib-dcrypt/dcrypt.h

index 96fa8d3c961ec564e7db512638962cb87e4004a7..834ed7fab2f05317b056b8e642da572a0a5997dc 100644 (file)
@@ -191,6 +191,9 @@ struct dcrypt_vfs {
                       const unsigned char *signature, size_t signature_len,
                       bool *valid_r, enum dcrypt_padding padding,
                       const char **error_r);
+       bool (*ecdh_derive_secret)(struct dcrypt_private_key *priv_key,
+                                  struct dcrypt_public_key *pub_key,
+                                  buffer_t *shared_secret, const char **error_r);
 };
 
 void dcrypt_set_vfs(struct dcrypt_vfs *vfs);
index 6b2abc9b0c3c58be0a729c4965c3e69285a4148f..ef55c69e4df8ccce0b34f2b854737d39175566dd 100644 (file)
@@ -242,6 +242,20 @@ bool dcrypt_ctx_hmac_final(struct dcrypt_context_hmac *ctx, buffer_t *result,
        return dcrypt_vfs->ctx_hmac_final(ctx, result, error_r);
 }
 
+bool dcrypt_ecdh_derive_secret(struct dcrypt_private_key *local_key,
+                              struct dcrypt_public_key *pub_key,
+                              buffer_t *shared_secret,
+                              const char **error_r)
+{
+       i_assert(dcrypt_vfs != NULL);
+       if (dcrypt_vfs->ecdh_derive_secret == NULL) {
+               *error_r = "Not implemented";
+               return FALSE;
+       }
+       return dcrypt_vfs->ecdh_derive_secret(local_key, pub_key, shared_secret,
+                                             error_r);
+}
+
 bool dcrypt_ecdh_derive_secret_local(struct dcrypt_private_key *local_key,
                                     buffer_t *R, buffer_t *S,
                                     const char **error_r)
index ab22d9b4f3351d0629a525be51bc7811dac0d066..62fa1949dbbdbc5d7d3dd2a834bff09019a8badf 100644 (file)
@@ -212,6 +212,12 @@ bool dcrypt_ctx_hmac_final(struct dcrypt_context_hmac *ctx, buffer_t *result,
 
 /**
  * Elliptic Curve based Diffie-Heffman shared secret derivation */
+bool dcrypt_ecdh_derive_secret(struct dcrypt_private_key *priv_key,
+                              struct dcrypt_public_key *pub_key,
+                              buffer_t *shared_secret,
+                              const char **error_r);
+/**
+ * Helpers for DCRYPT file format */
 bool dcrypt_ecdh_derive_secret_local(struct dcrypt_private_key *local_key,
                                     buffer_t *R, buffer_t *S,
                                     const char **error_r);