From bd0551b22076b82a6d49e9f7a2b2e0c90a1b2326 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Fri, 05 Feb 2016 07:25:27 -0500
Subject: [PATCH] Secure also downloads of addressbook exports, managesieve script exports and Enigma keys exports

---
 plugins/enigma/lib/enigma_key.php |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/plugins/enigma/lib/enigma_key.php b/plugins/enigma/lib/enigma_key.php
index 734cbb8..976cb45 100644
--- a/plugins/enigma/lib/enigma_key.php
+++ b/plugins/enigma/lib/enigma_key.php
@@ -26,8 +26,11 @@
     const TYPE_KEYPAIR = 1;
     const TYPE_PUBLIC  = 2;
 
-    const CAN_SIGN    = 1;
-    const CAN_ENCRYPT = 2;
+    const CAN_ENCRYPT      = 1;
+    const CAN_SIGN         = 2;
+    const CAN_CERTIFY      = 4;
+    const CAN_AUTHENTICATE = 8;
+
 
     /**
      * Keys list sorting callback for usort()
@@ -99,9 +102,7 @@
             if ($user->email === $email && $user->valid && !$user->revoked) {
                 foreach ($this->subkeys as $subkey) {
                     if (!$subkey->revoked && (!$subkey->expires || $subkey->expires > $now)) {
-                        if (($mode == self::CAN_ENCRYPT && $subkey->can_encrypt)
-                            || ($mode == self::CAN_SIGN && $subkey->has_private)
-                        ) {
+                        if ($subkey->usage & $mode) {
                             return $subkey;
                         }
                     }
@@ -147,5 +148,4 @@
 
         return $result;
     }
-
 }

--
Gitblit v1.9.1