From 46909637df94d982e5ee8bfbb27994c02fef0861 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Sun, 23 Sep 2007 19:15:55 +0000 Subject: Checkpoint svn path=/scripts/rpki/cms.py; revision=1009 --- scripts/rpki/cms.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'scripts/rpki/cms.py') diff --git a/scripts/rpki/cms.py b/scripts/rpki/cms.py index 633ab1dc..86a73643 100644 --- a/scripts/rpki/cms.py +++ b/scripts/rpki/cms.py @@ -6,7 +6,7 @@ For the moment these just call the OpenSSL CLI tool, which is slow, requires disk I/O, and likes PEM format. Fix this later. """ -import os, rpki.x509, rpki.exceptions +import os, rpki.x509, rpki.exceptions, lxml.etree # openssl smime -sign -nodetach -outform DER -signer biz-certs/Alice-EE.cer -certfile biz-certs/Alice-CA.cer -inkey biz-certs/Alice-EE.key -in PLAN -out PLAN.der @@ -65,3 +65,11 @@ def decode(cms, ta): return xml else: raise rpki.exceptions.CMSVerificationFailed, "CMS verification failed with status %s" % status + +def xml_decode(elt, ta): + """Composite routine to decode CMS-wrapped XML.""" + return lxml.etree.fromstring(decode(elt, ta)) + +def xml_encode(elt, key, certs): + """Composite routine to encode CMS-wrapped XML.""" + return encode(lxml.etree.tostring(elt, pretty_print=True, encoding="us-ascii", xml_declaration=True), key, certs) -- cgit v1.2.3