Bump the minimum PyPy/cffi version and simplify as a result (#3585)

* Bump the minimum PyPy/cffi version and simplify as a result

* unused imports

* grumble, fix
diff --git a/.travis.yml b/.travis.yml
index 21a4d7a..87e4304 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -23,8 +23,7 @@
           env: TOXENV=py35
         - python: 3.6
           env: TOXENV=py36
-        - env: TOXENV=pypy-nocoverage PYPY_VERSION=2.6.1
-        - env: TOXENV=pypy PYPY_VERSION=4.0.1
+        - env: TOXENV=pypy PYPY_VERSION=5.3
         - env: TOXENV=pypy PYPY_VERSION=5.7.1
         - python: 2.7
           env: TOXENV=py27 OPENSSL=1.1.0e
@@ -65,7 +64,7 @@
         - language: generic
           os: osx
           osx_image: xcode8.3
-          env: TOXENV=pypy-nocoverage CRYPTOGRAPHY_OSX_NO_LINK_FLAGS=1 PYPY_VERSION=5.7.1
+          env: TOXENV=pypy CRYPTOGRAPHY_OSX_NO_LINK_FLAGS=1 PYPY_VERSION=5.7.1
         - language: generic
           os: osx
           osx_image: xcode8.3
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 822a8c8..0e7619e 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -13,6 +13,7 @@
   has always been to check whether or not
   :class:`~cryptography.exceptions.InvalidSignature` was raised.
 * **BACKWARDS INCOMPATIBLE:** Dropped support for macOS 10.7 and 10.8.
+* **BACKWARDS INCOMPATIBLE:** The minimum supported PyPy version is now 5.3.
 * Python 3.3 support has been deprecated, and will be removed in the
   ``cryptography`` release.
 * Add support for providing ``tag`` during
diff --git a/setup.py b/setup.py
index 33b3b54..b134e0a 100644
--- a/setup.py
+++ b/setup.py
@@ -47,14 +47,14 @@
     requirements.append("ipaddress")
 
 if platform.python_implementation() == "PyPy":
-    if sys.pypy_version_info < (2, 6):
+    if sys.pypy_version_info < (5, 3):
         raise RuntimeError(
-            "cryptography 1.0 is not compatible with PyPy < 2.6. Please "
+            "cryptography 1.9 is not compatible with PyPy < 5.3. Please "
             "upgrade PyPy to use this library."
         )
 else:
-    requirements.append("cffi>=1.4.1")
-    setup_requirements.append("cffi>=1.4.1")
+    requirements.append("cffi>=1.7")
+    setup_requirements.append("cffi>=1.7")
 
 test_requirements = [
     "pytest>=2.9.0",
diff --git a/src/cryptography/hazmat/primitives/ciphers/base.py b/src/cryptography/hazmat/primitives/ciphers/base.py
index 826e23e..f857041 100644
--- a/src/cryptography/hazmat/primitives/ciphers/base.py
+++ b/src/cryptography/hazmat/primitives/ciphers/base.py
@@ -6,8 +6,6 @@
 
 import abc
 
-import cffi
-
 import six
 
 from cryptography import utils
@@ -150,19 +148,10 @@
             raise AlreadyFinalized("Context was already finalized.")
         return self._ctx.update(data)
 
-    # cffi 1.7 supports from_buffer on bytearray, which is required. We can
-    # remove this check in the future when we raise our minimum PyPy version.
-    if cffi.__version_info__ >= (1, 7):
-        def update_into(self, data, buf):
-            if self._ctx is None:
-                raise AlreadyFinalized("Context was already finalized.")
-            return self._ctx.update_into(data, buf)
-    else:
-        def update_into(self, data, buf):
-            raise NotImplementedError(
-                "update_into requires cffi 1.7+. To use this method please "
-                "update cffi."
-            )
+    def update_into(self, data, buf):
+        if self._ctx is None:
+            raise AlreadyFinalized("Context was already finalized.")
+        return self._ctx.update_into(data, buf)
 
     def finalize(self):
         if self._ctx is None:
@@ -199,18 +188,9 @@
         self._check_limit(len(data))
         return self._ctx.update(data)
 
-    # cffi 1.7 supports from_buffer on bytearray, which is required. We can
-    # remove this check in the future when we raise our minimum PyPy version.
-    if cffi.__version_info__ >= (1, 7):
-        def update_into(self, data, buf):
-            self._check_limit(len(data))
-            return self._ctx.update_into(data, buf)
-    else:
-        def update_into(self, data, buf):
-            raise NotImplementedError(
-                "update_into requires cffi 1.7+. To use this method please "
-                "update cffi."
-            )
+    def update_into(self, data, buf):
+        self._check_limit(len(data))
+        return self._ctx.update_into(data, buf)
 
     def finalize(self):
         if self._ctx is None:
diff --git a/tests/hazmat/primitives/test_block.py b/tests/hazmat/primitives/test_block.py
index 4c6ad18..c053fea 100644
--- a/tests/hazmat/primitives/test_block.py
+++ b/tests/hazmat/primitives/test_block.py
@@ -6,8 +6,6 @@
 
 import binascii
 
-import cffi
-
 import pytest
 
 from cryptography.exceptions import (
@@ -72,10 +70,6 @@
         with pytest.raises(AlreadyFinalized):
             decryptor.finalize()
 
-    @pytest.mark.skipif(
-        cffi.__version_info__ < (1, 7),
-        reason="cffi version too old"
-    )
     def test_use_update_into_after_finalize(self, backend):
         cipher = Cipher(
             algorithms.AES(binascii.unhexlify(b"0" * 32)),
diff --git a/tests/hazmat/primitives/test_ciphers.py b/tests/hazmat/primitives/test_ciphers.py
index 60faa0c..f1718c0 100644
--- a/tests/hazmat/primitives/test_ciphers.py
+++ b/tests/hazmat/primitives/test_ciphers.py
@@ -7,8 +7,6 @@
 import binascii
 import os
 
-import cffi
-
 import pytest
 
 from cryptography.exceptions import AlreadyFinalized, _Reasons
@@ -141,10 +139,6 @@
         ciphers.Cipher(AES(b"AAAAAAAAAAAAAAAA"), modes.ECB, pretend_backend)
 
 
-@pytest.mark.skipif(
-    cffi.__version_info__ < (1, 7),
-    reason="cffi version too old"
-)
 @pytest.mark.supported(
     only_if=lambda backend: backend.cipher_supported(
         AES(b"\x00" * 16), modes.ECB()
@@ -259,45 +253,3 @@
         buf = bytearray(5)
         with pytest.raises(ValueError):
             encryptor.update_into(b"testing", buf)
-
-
-@pytest.mark.skipif(
-    cffi.__version_info__ >= (1, 7),
-    reason="cffi version too new"
-)
-@pytest.mark.requires_backend_interface(interface=CipherBackend)
-class TestCipherUpdateIntoUnsupported(object):
-    def _too_old(self, mode, backend):
-        key = b"\x00" * 16
-        c = ciphers.Cipher(AES(key), mode, backend)
-        encryptor = c.encryptor()
-        buf = bytearray(32)
-        with pytest.raises(NotImplementedError):
-            encryptor.update_into(b"\x00" * 16, buf)
-
-    @pytest.mark.supported(
-        only_if=lambda backend: backend.cipher_supported(
-            AES(b"\x00" * 16), modes.ECB()
-        ),
-        skip_message="Does not support AES ECB",
-    )
-    def test_cffi_too_old_ecb(self, backend):
-        self._too_old(modes.ECB(), backend)
-
-    @pytest.mark.supported(
-        only_if=lambda backend: backend.cipher_supported(
-            AES(b"\x00" * 16), modes.CTR(b"0" * 16)
-        ),
-        skip_message="Does not support AES CTR",
-    )
-    def test_cffi_too_old_ctr(self, backend):
-        self._too_old(modes.CTR(b"0" * 16), backend)
-
-    @pytest.mark.supported(
-        only_if=lambda backend: backend.cipher_supported(
-            AES(b"\x00" * 16), modes.GCM(b"0" * 16)
-        ),
-        skip_message="Does not support AES GCM",
-    )
-    def test_cffi_too_old_gcm(self, backend):
-        self._too_old(modes.GCM(b"0" * 16), backend)
diff --git a/tox.ini b/tox.ini
index 136b4cc..525ffe2 100644
--- a/tox.ini
+++ b/tox.ini
@@ -38,14 +38,6 @@
 commands =
     sphinx-build -W -b linkcheck docs docs/_build/html
 
-# This target disables coverage on pypy because of performance problems with
-# coverage.py on pypy.
-[testenv:pypy-nocoverage]
-basepython = pypy
-commands =
-    pip list
-    py.test --capture=no --strict {posargs}
-
 [testenv:pep8]
 extras =
     pep8test