PageRenderTime 50ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/Classes/TYPO3/FLOW3/Security/Cryptography/RsaWalletServiceInterface.php

https://github.com/christianjul/FLOW3-Composer
PHP | 120 lines | 15 code | 12 blank | 93 comment | 0 complexity | 22fdbaf7b976ed0ad62092e48368d98e MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-3.0
  1. <?php
  2. namespace TYPO3\FLOW3\Security\Cryptography;
  3. /* *
  4. * This script belongs to the FLOW3 framework. *
  5. * *
  6. * It is free software; you can redistribute it and/or modify it under *
  7. * the terms of the GNU Lesser General Public License, either version 3 *
  8. * of the License, or (at your option) any later version. *
  9. * *
  10. * The TYPO3 project - inspiring people to share! *
  11. * */
  12. /**
  13. * RSA related service functions (e.g. used for the RSA authentication provider)
  14. *
  15. */
  16. interface RsaWalletServiceInterface {
  17. /**
  18. * Generates a new keypair and returns a UUID to refer to it
  19. *
  20. * @param boolean $usedForPasswords TRUE if this keypair should be used to encrypt passwords (then decryption won't be allowed!).
  21. * @return integer An UUID that identifies the generated keypair
  22. */
  23. public function generateNewKeypair($usedForPasswords = FALSE);
  24. /**
  25. * Adds the specified keypair to the local store and returns a UUID to refer to it.
  26. *
  27. * @param string $privateKeyString The private key in its string representation
  28. * @param boolean $usedForPasswords TRUE if this keypair should be used to encrypt passwords (then decryption won't be allowed!).
  29. * @return string The UUID used for storing
  30. */
  31. public function registerKeyPairFromPrivateKeyString($privateKeyString, $usedForPasswords = FALSE);
  32. /**
  33. * Adds the specified public key to the wallet and returns a UUID to refer to it.
  34. * This is helpful if you have not private key and want to use this key only to
  35. * verify incoming data.
  36. *
  37. * @param string $publicKeyString The public key in its string representation
  38. * @return string The UUID used for storing
  39. */
  40. public function registerPublicKeyFromString($publicKeyString);
  41. /**
  42. * Returns the public key for the given UUID
  43. *
  44. * @param string $uuid The UUID
  45. * @return \TYPO3\FLOW3\Security\Cryptography\OpenSslRsaKey The public key
  46. * @throws \TYPO3\FLOW3\Security\Exception\InvalidKeyPairIdException If the given UUID identifies no valid key pair
  47. */
  48. public function getPublicKey($uuid);
  49. /**
  50. * Decrypts the given cypher with the private key identified by the given UUID
  51. * Note: You should never decrypt a password with this function. Use checkRSAEncryptedPassword()
  52. * to check passwords!
  53. *
  54. * @param string $cypher Cypher text to decrypt
  55. * @param string $uuid The uuid to identify to correct private key
  56. * @return string The decrypted text
  57. * @throws \TYPO3\FLOW3\Security\Exception\InvalidKeyPairIdException If the given UUID identifies no valid keypair
  58. * @throws \TYPO3\FLOW3\Security\Exception\DecryptionNotAllowedException If the given UUID identifies a keypair for encrypted passwords
  59. */
  60. public function decrypt($cypher, $uuid);
  61. /**
  62. * Signs the given plaintext with the private key identified by the given UUID
  63. *
  64. * @param string $plaintext The plaintext to sign
  65. * @param string $uuid The uuid to identify to correct private key
  66. * @return string The signature of the given plaintext
  67. * @throws \TYPO3\FLOW3\Security\Exception\InvalidKeyPairIdException If the given UUID identifies no valid keypair
  68. */
  69. public function sign($plaintext, $uuid);
  70. /**
  71. * Checks whether the given signature is valid for the given plaintext
  72. * with the public key identified by the given UUID
  73. *
  74. * @param string $plaintext The plaintext to sign
  75. * @param string $signature The signature that should be verified
  76. * @param string $uuid The uuid to identify to correct public key
  77. * @return boolean TRUE if the signature is correct for the given plaintext and public key
  78. */
  79. public function verifySignature($plaintext, $signature, $uuid);
  80. /**
  81. * Encrypts the given plaintext with the public key identified by the given UUID
  82. *
  83. * @param string $plaintext The plaintext to encrypt
  84. * @param string $uuid The uuid to identify to correct public key
  85. * @return string The ciphertext
  86. */
  87. public function encryptWithPublicKey($plaintext, $uuid);
  88. /**
  89. * Checks if the given encrypted password is correct by
  90. * comparing it's md5 hash. The salt is appended to the decrypted password string before hashing.
  91. *
  92. * @param string $encryptedPassword The received, RSA encrypted password to check
  93. * @param string $passwordHash The md5 hashed password string (md5(md5(password) . salt))
  94. * @param string $salt The salt used in the md5 password hash
  95. * @param string $uuid The uuid to identify to correct private key
  96. * @return boolean TRUE if the password is correct
  97. */
  98. public function checkRSAEncryptedPassword($encryptedPassword, $passwordHash, $salt, $uuid);
  99. /**
  100. * Destroys the keypair identified by the given UUID
  101. *
  102. * @param string $uuid The UUID
  103. * @return void
  104. * @throws \TYPO3\FLOW3\Security\Exception\InvalidKeyPairIdException If the given UUID identifies no valid key pair
  105. */
  106. public function destroyKeypair($uuid);
  107. }
  108. ?>