CipherMethod.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace Aws\Crypto\Cipher;
  3. interface CipherMethod
  4. {
  5. /**
  6. * Returns an identifier recognizable by `openssl_*` functions, such as
  7. * `aes-256-cbc` or `aes-128-ctr`.
  8. *
  9. * @return string
  10. */
  11. public function getOpenSslName();
  12. /**
  13. * Returns an AES recognizable name, such as 'AES/GCM/NoPadding'.
  14. *
  15. * @return string
  16. */
  17. public function getAesName();
  18. /**
  19. * Returns the IV that should be used to initialize the next block in
  20. * encrypt or decrypt.
  21. *
  22. * @return string
  23. */
  24. public function getCurrentIv();
  25. /**
  26. * Indicates whether the cipher method used with this IV requires padding
  27. * the final block to make sure the plaintext is evenly divisible by the
  28. * block size.
  29. *
  30. * @return boolean
  31. */
  32. public function requiresPadding();
  33. /**
  34. * Adjust the return of this::getCurrentIv to reflect a seek performed on
  35. * the encryption stream using this IV object.
  36. *
  37. * @param int $offset
  38. * @param int $whence
  39. *
  40. * @throws LogicException Thrown if the requested seek is not supported by
  41. * this IV implementation. For example, a CBC IV
  42. * only supports a full rewind ($offset === 0 &&
  43. * $whence === SEEK_SET)
  44. */
  45. public function seek($offset, $whence = SEEK_SET);
  46. /**
  47. * Take account of the last cipher text block to adjust the return of
  48. * this::getCurrentIv
  49. *
  50. * @param string $cipherTextBlock
  51. */
  52. public function update($cipherTextBlock);
  53. }