-
-void
-libdcp::add_signer (xmlpp::Element* parent, CertificateChain const & certificates, string const & ns)
-{
- xmlpp::Element* signer = parent->add_child("Signer");
-
- {
- xmlpp::Element* data = signer->add_child("X509Data", ns);
-
- {
- xmlpp::Element* serial_element = data->add_child("X509IssuerSerial", ns);
- serial_element->add_child("X509IssuerName", ns)->add_child_text (certificates.leaf()->issuer());
- serial_element->add_child("X509SerialNumber", ns)->add_child_text (certificates.leaf()->serial());
- }
-
- data->add_child("X509SubjectName", ns)->add_child_text (certificates.leaf()->subject());
- }
-}
-
-/** @param signer_key Filename of private key to sign with */
-void
-libdcp::sign (xmlpp::Element* parent, CertificateChain const & certificates, boost::filesystem::path signer_key, bool interop)
-{
- add_signer (parent, certificates, "dsig");
-
- xmlpp::Element* signature = parent->add_child("Signature", "dsig");
-
- {
- xmlpp::Element* signed_info = signature->add_child ("SignedInfo", "dsig");
- signed_info->add_child("CanonicalizationMethod", "dsig")->set_attribute ("Algorithm", "http://www.w3.org/TR/2001/REC-xml-c14n-20010315");
-
- if (interop) {
- signed_info->add_child("SignatureMethod", "dsig")->set_attribute("Algorithm", "http://www.w3.org/2000/09/xmldsig#rsa-sha1");
- } else {
- signed_info->add_child("SignatureMethod", "dsig")->set_attribute("Algorithm", "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256");
- }
-
- {
- xmlpp::Element* reference = signed_info->add_child("Reference", "dsig");
- reference->set_attribute ("URI", "");
- {
- xmlpp::Element* transforms = reference->add_child("Transforms", "dsig");
- transforms->add_child("Transform", "dsig")->set_attribute (
- "Algorithm", "http://www.w3.org/2000/09/xmldsig#enveloped-signature"
- );
- }
- reference->add_child("DigestMethod", "dsig")->set_attribute("Algorithm", "http://www.w3.org/2000/09/xmldsig#sha1");
- /* This will be filled in by the signing later */
- reference->add_child("DigestValue", "dsig");
- }
- }
-
- add_signature_value (signature, certificates, signer_key, "dsig");
-}
-
-bool libdcp::operator== (libdcp::Size const & a, libdcp::Size const & b)
-{
- return (a.width == b.width && a.height == b.height);
-}
-
-bool libdcp::operator!= (libdcp::Size const & a, libdcp::Size const & b)
-{
- return !(a == b);
-}
-
-/** The base64 decode routine in KM_util.cpp gives different values to both
- * this and the command-line base64 for some inputs. Not sure why.