refactor obj2txt to be a separate method
diff --git a/src/cryptography/hazmat/backends/openssl/x509.py b/src/cryptography/hazmat/backends/openssl/x509.py
index c69e914..b712f1f 100644
--- a/src/cryptography/hazmat/backends/openssl/x509.py
+++ b/src/cryptography/hazmat/backends/openssl/x509.py
@@ -122,14 +122,7 @@
                 buf, lambda buf: self._backend._lib.OPENSSL_free(buf[0])
             )
             value = self._backend._ffi.buffer(buf[0], res)[:].decode('utf8')
-            # Set to 80 on the recommendation of
-            # https://www.openssl.org/docs/crypto/OBJ_nid2ln.html
-            buf_len = 80
-            buf = self._backend._ffi.new("char[]", buf_len)
-            res = self._backend._lib.OBJ_obj2txt(buf, buf_len, obj, 1)
-            assert res > 0
-            oid = self._backend._ffi.buffer(buf, res)[:].decode()
-
+            oid = self._obj2txt(obj)
             attributes.append(
                 x509.NameAttribute(
                     x509.ObjectIdentifier(oid), value
@@ -138,15 +131,18 @@
 
         return x509.Name(attributes)
 
+    def _obj2txt(self, obj):
+        # Set to 80 on the recommendation of
+        # https://www.openssl.org/docs/crypto/OBJ_nid2ln.html#return_values
+        buf_len = 80
+        buf = self._backend._ffi.new("char[]", buf_len)
+        res = self._backend._lib.OBJ_obj2txt(buf, buf_len, obj, 1)
+        assert res > 0
+        return self._backend._ffi.buffer(buf, res)[:].decode()
+
     @property
     def signature_hash_algorithm(self):
-        buf_len = 50
-        buf = self._backend._ffi.new("char[]", buf_len)
-        res = self._backend._lib.OBJ_obj2txt(
-            buf, buf_len, self._x509.sig_alg.algorithm, 1
-        )
-        assert res <= 50 and res > 0
-        oid = self._backend._ffi.buffer(buf, res)[:].decode()
+        oid = self._obj2txt(self._x509.sig_alg.algorithm)
         try:
             return x509._SIG_OIDS_TO_HASH[oid]
         except KeyError: