| | |
| | | <?php |
| | | /* |
| | | |
| | | /** |
| | | +-------------------------------------------------------------------------+ |
| | | | Key class for the Enigma Plugin | |
| | | | | |
| | |
| | | |
| | | const CAN_SIGN = 1; |
| | | const CAN_ENCRYPT = 2; |
| | | const CAN_CERTIFY = 4; |
| | | const CAN_AUTH = 8; |
| | | |
| | | |
| | | /** |
| | | * Keys list sorting callback for usort() |
| | |
| | | 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; |
| | | } |
| | | } |
| | |
| | | |
| | | return $result; |
| | | } |
| | | |
| | | } |