-
-class TestSignedDataCER(TestCase):
- def runTest(self):
- # openssl ecparam -name prime256v1 -genkey -out key.pem
- # openssl req -x509 -new -key key.pem -outform PEM -out cert.pem
- # -days 365 -nodes -subj "/CN=doesnotmatter"
- with open("cert.cer", "rb") as fd:
+openssl_cms_exists = call("openssl cms -help 2>/dev/null", shell=True) == 0
+
+@skipIf(not openssl_cms_exists, "openssl cms command not found")
+class TestSignedDataCERWithOpenSSL(TestCase):
+ @settings(deadline=None)
+ @given(integers(min_value=1000, max_value=5000))
+ def runTest(self, data_len):
+ def tmpfile():
+ tmp = NamedTemporaryFile(delete=False)
+ tmp.close()
+ tmp = tmp.name
+ self.addCleanup(lambda: remove(tmp))
+ return tmp
+ key_path = tmpfile()
+ self.assertEqual(0, call(
+ "openssl ecparam -name prime256v1 -genkey -out " + key_path,
+ shell=True,
+ ))
+ cert_path = tmpfile()
+ self.assertEqual(0, call(" ".join((
+ "openssl req -x509 -new",
+ ("-key " + key_path),
+ ("-outform PEM -out " + cert_path),
+ "-nodes -subj /CN=pyderasntest",
+ )), shell=True))
+ cert_der_path = tmpfile()
+ self.assertEqual(0, call(" ".join((
+ "openssl x509",
+ "-inform PEM -in " + cert_path,
+ "-outform DER -out " + cert_der_path,
+ )), shell=True))
+ self.assertEqual(0, call("cat %s >> %s" % (key_path, cert_path), shell=True))
+ with open(cert_der_path, "rb") as fd: