You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

enigma_driver.php 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?php
  2. /**
  3. +-------------------------------------------------------------------------+
  4. | Abstract driver for the Enigma Plugin |
  5. | |
  6. | Copyright (C) 2010-2015 The Roundcube Dev Team |
  7. | |
  8. | Licensed under the GNU General Public License version 3 or |
  9. | any later version with exceptions for skins & plugins. |
  10. | See the README file for a full license statement. |
  11. | |
  12. +-------------------------------------------------------------------------+
  13. | Author: Aleksander Machniak <alec@alec.pl> |
  14. +-------------------------------------------------------------------------+
  15. */
  16. abstract class enigma_driver
  17. {
  18. /**
  19. * Class constructor.
  20. *
  21. * @param string User name (email address)
  22. */
  23. abstract function __construct($user);
  24. /**
  25. * Driver initialization.
  26. *
  27. * @return mixed NULL on success, enigma_error on failure
  28. */
  29. abstract function init();
  30. /**
  31. * Encryption.
  32. *
  33. * @param string Message body
  34. * @param array List of key-password mapping
  35. *
  36. * @return mixed Encrypted message or enigma_error on failure
  37. */
  38. abstract function encrypt($text, $keys);
  39. /**
  40. * Decryption.
  41. *
  42. * @param string Encrypted message
  43. * @param array List of key-password mapping
  44. */
  45. abstract function decrypt($text, $keys = array());
  46. /**
  47. * Signing.
  48. *
  49. * @param string Message body
  50. * @param string Key ID
  51. * @param string Key password
  52. * @param int Signing mode (enigma_engine::SIGN_*)
  53. *
  54. * @return mixed True on success or enigma_error on failure
  55. */
  56. abstract function sign($text, $key, $passwd, $mode = null);
  57. /**
  58. * Signature verification.
  59. *
  60. * @param string Message body
  61. * @param string Signature, if message is of type PGP/MIME and body doesn't contain it
  62. *
  63. * @return mixed Signature information (enigma_signature) or enigma_error
  64. */
  65. abstract function verify($text, $signature);
  66. /**
  67. * Key/Cert file import.
  68. *
  69. * @param string File name or file content
  70. * @param bollean True if first argument is a filename
  71. *
  72. * @return mixed Import status array or enigma_error
  73. */
  74. abstract function import($content, $isfile = false);
  75. /**
  76. * Key/Cert export.
  77. *
  78. * @param string Key ID
  79. * @param bool Include private key
  80. *
  81. * @return mixed Key content or enigma_error
  82. */
  83. abstract function export($key, $with_private = false);
  84. /**
  85. * Keys listing.
  86. *
  87. * @param string Optional pattern for key ID, user ID or fingerprint
  88. *
  89. * @return mixed Array of enigma_key objects or enigma_error
  90. */
  91. abstract function list_keys($pattern = '');
  92. /**
  93. * Single key information.
  94. *
  95. * @param string Key ID, user ID or fingerprint
  96. *
  97. * @return mixed Key (enigma_key) object or enigma_error
  98. */
  99. abstract function get_key($keyid);
  100. /**
  101. * Key pair generation.
  102. *
  103. * @param array Key/User data (name, email, password, size)
  104. *
  105. * @return mixed Key (enigma_key) object or enigma_error
  106. */
  107. abstract function gen_key($data);
  108. /**
  109. * Key deletion.
  110. *
  111. * @param string Key ID
  112. *
  113. * @return mixed True on success or enigma_error
  114. */
  115. abstract function delete_key($keyid);
  116. }