Fix missing version string when Popen communicate returns byte strings.
[libdcp.git] / src / decrypted_kdm.cc
index 72070fe723936bf657cad832ffae398c48a0fd41..0fa95f9a714399acd27927586a64d782faa82326 100644 (file)
@@ -101,7 +101,11 @@ string
 DecryptedKDM::get_uuid (unsigned char ** p)
 {
        char buffer[37];
+#ifdef LIBDCP_WINDOWS
+       __mingw_snprintf (
+#else
        snprintf (
+#endif
                buffer, sizeof(buffer), "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx",
                (*p)[0], (*p)[1], (*p)[2], (*p)[3], (*p)[4], (*p)[5], (*p)[6], (*p)[7],
                (*p)[8], (*p)[9], (*p)[10], (*p)[11], (*p)[12], (*p)[13], (*p)[14], (*p)[15]
@@ -149,7 +153,11 @@ DecryptedKDM::DecryptedKDM (EncryptedKDM const & kdm, string private_key)
                int const decrypted_len = RSA_private_decrypt (cipher_value_len, cipher_value, decrypted, rsa, RSA_PKCS1_OAEP_PADDING);
                if (decrypted_len == -1) {
                        delete[] decrypted;
-                       throw KDMDecryptionError (ERR_error_string (ERR_get_error(), 0));
+#if OPENSSL_VERSION_NUMBER > 0x10100000L
+                       throw KDMDecryptionError (ERR_error_string (ERR_get_error(), 0), cipher_value_len, RSA_bits(rsa));
+#else
+                       throw KDMDecryptionError (ERR_error_string (ERR_get_error(), 0), cipher_value_len, rsa->n->dmax);
+#endif
                }
 
                unsigned char* p = decrypted;
@@ -295,9 +303,16 @@ DecryptedKDM::add_key (DecryptedKDMKey key)
 
 EncryptedKDM
 DecryptedKDM::encrypt (
-       shared_ptr<const CertificateChain> signer, Certificate recipient, vector<Certificate> trusted_devices, Formulation formulation
+       shared_ptr<const CertificateChain> signer,
+       Certificate recipient,
+       vector<Certificate> trusted_devices,
+       Formulation formulation,
+       bool disable_forensic_marking_picture,
+       optional<int> disable_forensic_marking_audio
        ) const
 {
+       DCP_ASSERT (!_keys.empty ());
+
        list<pair<string, string> > key_ids;
        list<string> keys;
        BOOST_FOREACH (DecryptedKDMKey const & i, _keys) {
@@ -359,6 +374,8 @@ DecryptedKDM::encrypt (
                _not_valid_before,
                _not_valid_after,
                formulation,
+               disable_forensic_marking_picture,
+               disable_forensic_marking_audio,
                key_ids,
                keys
                );