# You should have received a copy of the GNU Lesser General Public
# License along with this program. If not, see
# <http://www.gnu.org/licenses/>.
-"""CRL related schemes, just to test the performance with them
+"""CRL related schemas, just to test the performance with them
"""
+from os.path import exists
+from time import time
+from unittest import skipIf
+from unittest import TestCase
+
from pyderasn import BitString
+from pyderasn import encode_cer
from pyderasn import Sequence
from pyderasn import SequenceOf
from pyderasn import tag_ctxc
("signatureAlgorithm", AlgorithmIdentifier()),
("signatureValue", BitString()),
)
+
+@skipIf(not exists("revoke.crl"), "CACert's revoke.crl not found")
+class TestCACert(TestCase):
+ def test_cer(self):
+ with open("revoke.crl", "rb") as fd:
+ raw = fd.read()
+ print("DER read")
+ start = time()
+ crl1 = CertificateList().decod(raw)
+ print("DER decoded", time() - start)
+ start = time()
+ cer_raw = encode_cer(crl1)
+ print("CER encoded", time() - start)
+ start = time()
+ crl2 = CertificateList().decod(cer_raw, ctx={"bered": True})
+ print("CER decoded", time() - start)
+ self.assertEqual(crl2, crl1)
+ start = time()
+ der_raw = crl2.encode()
+ print("DER encoded", time() - start)
+ self.assertSequenceEqual(der_raw, raw)