+ FILE* f = fopen_boost (p, "r");
+ if (!f) {
+ throw FileError ("could not open file", p, errno);
+ }
+
+ char* c = new char[len];
+ /* This may read less than `len' if we are on Windows and we have CRLF in the file */
+ int const N = fread (c, 1, len, f);
+ fclose (f);
+
+ string s (c, N);
+ delete[] c;
+
+ return s;
+}
+
+/** @param key RSA private key in PEM format (optionally with -----BEGIN... / -----END...)
+ * @return SHA1 fingerprint of key
+ */
+string
+dcp::private_key_fingerprint (string key)
+{
+ boost::replace_all (key, "-----BEGIN RSA PRIVATE KEY-----\n", "");
+ boost::replace_all (key, "\n-----END RSA PRIVATE KEY-----\n", "");
+
+ unsigned char buffer[4096];
+ int const N = base64_decode (key, buffer, sizeof (buffer));
+
+ SHA_CTX sha;
+ SHA1_Init (&sha);
+ SHA1_Update (&sha, buffer, N);
+ uint8_t digest[20];
+ SHA1_Final (digest, &sha);
+
+ char digest_base64[64];
+ return Kumu::base64encode (digest, 20, digest_base64, 64);
+}
+
+xmlpp::Node *
+dcp::find_child (xmlpp::Node const * node, string name)
+{
+ xmlpp::Node::NodeList c = node->get_children ();
+ xmlpp::Node::NodeList::iterator i = c.begin();
+ while (i != c.end() && (*i)->get_name() != name) {
+ ++i;
+ }
+
+ DCP_ASSERT (i != c.end ());
+ return *i;
+}
+
+string
+dcp::remove_urn_uuid (string raw)
+{
+ DCP_ASSERT (raw.substr(0, 9) == "urn:uuid:");
+ return raw.substr (9);
+}
+
+string
+dcp::openjpeg_version ()
+{
+ return opj_version ();