1
0

IStorage.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCP\Encryption\Keys;
  8. /**
  9. * Interface IStorage
  10. *
  11. * @since 8.1.0
  12. */
  13. interface IStorage {
  14. /**
  15. * get user specific key
  16. *
  17. * @param string $uid ID if the user for whom we want the key
  18. * @param string $keyId id of the key
  19. * @param string $encryptionModuleId
  20. *
  21. * @return mixed key
  22. * @since 8.1.0
  23. */
  24. public function getUserKey($uid, $keyId, $encryptionModuleId);
  25. /**
  26. * get file specific key
  27. *
  28. * @param string $path path to file
  29. * @param string $keyId id of the key
  30. * @param string $encryptionModuleId
  31. *
  32. * @return mixed key
  33. * @since 8.1.0
  34. */
  35. public function getFileKey($path, $keyId, $encryptionModuleId);
  36. /**
  37. * get system-wide encryption keys not related to a specific user,
  38. * e.g something like a key for public link shares
  39. *
  40. * @param string $keyId id of the key
  41. * @param string $encryptionModuleId
  42. *
  43. * @return mixed key
  44. * @since 8.1.0
  45. */
  46. public function getSystemUserKey($keyId, $encryptionModuleId);
  47. /**
  48. * set user specific key
  49. *
  50. * @param string $uid ID if the user for whom we want the key
  51. * @param string $keyId id of the key
  52. * @param mixed $key
  53. * @param string $encryptionModuleId
  54. * @since 8.1.0
  55. */
  56. public function setUserKey($uid, $keyId, $key, $encryptionModuleId);
  57. /**
  58. * set file specific key
  59. *
  60. * @param string $path path to file
  61. * @param string $keyId id of the key
  62. * @param mixed $key
  63. * @param string $encryptionModuleId
  64. * @since 8.1.0
  65. */
  66. public function setFileKey($path, $keyId, $key, $encryptionModuleId);
  67. /**
  68. * set system-wide encryption keys not related to a specific user,
  69. * e.g something like a key for public link shares
  70. *
  71. * @param string $keyId id of the key
  72. * @param mixed $key
  73. * @param string $encryptionModuleId
  74. *
  75. * @return mixed key
  76. * @since 8.1.0
  77. */
  78. public function setSystemUserKey($keyId, $key, $encryptionModuleId);
  79. /**
  80. * delete user specific key
  81. *
  82. * @param string $uid ID if the user for whom we want to delete the key
  83. * @param string $keyId id of the key
  84. * @param string $encryptionModuleId
  85. *
  86. * @return boolean False when the key could not be deleted
  87. * @since 8.1.0
  88. */
  89. public function deleteUserKey($uid, $keyId, $encryptionModuleId);
  90. /**
  91. * delete file specific key
  92. *
  93. * @param string $path path to file
  94. * @param string $keyId id of the key
  95. * @param string $encryptionModuleId
  96. *
  97. * @return boolean False when the key could not be deleted
  98. * @since 8.1.0
  99. */
  100. public function deleteFileKey($path, $keyId, $encryptionModuleId);
  101. /**
  102. * delete all file keys for a given file
  103. *
  104. * @param string $path to the file
  105. *
  106. * @return boolean False when the keys could not be deleted
  107. * @since 8.1.0
  108. */
  109. public function deleteAllFileKeys($path);
  110. /**
  111. * delete system-wide encryption keys not related to a specific user,
  112. * e.g something like a key for public link shares
  113. *
  114. * @param string $keyId id of the key
  115. * @param string $encryptionModuleId
  116. *
  117. * @return boolean False when the key could not be deleted
  118. * @since 8.1.0
  119. */
  120. public function deleteSystemUserKey($keyId, $encryptionModuleId);
  121. /**
  122. * copy keys if a file was renamed
  123. *
  124. * @param string $source
  125. * @param string $target
  126. * @return boolean
  127. * @since 8.1.0
  128. */
  129. public function renameKeys($source, $target);
  130. /**
  131. * move keys if a file was renamed
  132. *
  133. * @param string $source
  134. * @param string $target
  135. * @return boolean
  136. * @since 8.1.0
  137. */
  138. public function copyKeys($source, $target);
  139. /**
  140. * backup keys of a given encryption module
  141. *
  142. * @param string $encryptionModuleId
  143. * @param string $purpose
  144. * @param string $uid
  145. * @return bool
  146. * @since 12.0.0
  147. */
  148. public function backupUserKeys($encryptionModuleId, $purpose, $uid);
  149. }