Extract KDM standard.
authorCarl Hetherington <cth@carlh.net>
Tue, 14 Feb 2017 16:43:59 +0000 (16:43 +0000)
committerCarl Hetherington <cth@carlh.net>
Tue, 14 Feb 2017 16:43:59 +0000 (16:43 +0000)
src/decrypted_kdm.cc
src/decrypted_kdm.h
src/decrypted_kdm_key.cc
src/decrypted_kdm_key.h
tools/dcpkdm.cc

index 7113afb8ab512b3ff3d0a6e359abd29f333e7de6..72070fe723936bf657cad832ffae398c48a0fd41 100644 (file)
@@ -170,7 +170,7 @@ DecryptedKDM::DecryptedKDM (EncryptedKDM const & kdm, string private_key)
                        /* 93 is not-valid-after (a string) [25 bytes] */
                        p += 25;
                        /* 118 is the key [ASDCP::KeyLen bytes] */
-                       add_key (optional<string>(), key_id, Key (p), cpl_id);
+                       add_key (optional<string>(), key_id, Key (p), cpl_id, INTEROP);
                        break;
                }
                case 138:
@@ -192,7 +192,7 @@ DecryptedKDM::DecryptedKDM (EncryptedKDM const & kdm, string private_key)
                        /* 97 is not-valid-after (a string) [25 bytes] */
                        p += 25;
                        /* 112 is the key [ASDCP::KeyLen bytes] */
-                       add_key (key_type, key_id, Key (p), cpl_id);
+                       add_key (key_type, key_id, Key (p), cpl_id, SMPTE);
                        break;
                }
                default:
@@ -242,7 +242,7 @@ DecryptedKDM::DecryptedKDM (
        , _issue_date (issue_date)
 {
        for (map<shared_ptr<const ReelMXF>, Key>::const_iterator i = keys.begin(); i != keys.end(); ++i) {
-               add_key (i->first->key_type(), i->first->key_id().get(), i->second, cpl_id);
+               add_key (i->first->key_type(), i->first->key_id().get(), i->second, cpl_id, SMPTE);
        }
 }
 
@@ -266,7 +266,7 @@ DecryptedKDM::DecryptedKDM (
        BOOST_FOREACH(shared_ptr<const ReelAsset> i, cpl->reel_assets ()) {
                shared_ptr<const ReelMXF> mxf = boost::dynamic_pointer_cast<const ReelMXF> (i);
                if (mxf && mxf->key_id ()) {
-                       add_key (mxf->key_type(), mxf->key_id().get(), key, cpl->id ());
+                       add_key (mxf->key_type(), mxf->key_id().get(), key, cpl->id(), SMPTE);
                        did_one = true;
                }
        }
@@ -282,9 +282,9 @@ DecryptedKDM::DecryptedKDM (
  *  @param cpl_id ID of CPL that the key is for.
  */
 void
-DecryptedKDM::add_key (optional<string> type, string key_id, Key key, string cpl_id)
+DecryptedKDM::add_key (optional<string> type, string key_id, Key key, string cpl_id, Standard standard)
 {
-       _keys.push_back (DecryptedKDMKey (type, key_id, key, cpl_id));
+       _keys.push_back (DecryptedKDMKey (type, key_id, key, cpl_id, standard));
 }
 
 void
@@ -294,7 +294,9 @@ DecryptedKDM::add_key (DecryptedKDMKey key)
 }
 
 EncryptedKDM
-DecryptedKDM::encrypt (shared_ptr<const CertificateChain> signer, Certificate recipient, vector<Certificate> trusted_devices, Formulation formulation) const
+DecryptedKDM::encrypt (
+       shared_ptr<const CertificateChain> signer, Certificate recipient, vector<Certificate> trusted_devices, Formulation formulation
+       ) const
 {
        list<pair<string, string> > key_ids;
        list<string> keys;
index 585cc615759dd5959e196173a20b38ba8065c646..56529b5df563709c34c33cd70dac1417561d4ed4 100644 (file)
@@ -133,7 +133,7 @@ public:
                Formulation formulation
                ) const;
 
-       void add_key (boost::optional<std::string> type, std::string key_id, Key key, std::string cpl_id);
+       void add_key (boost::optional<std::string> type, std::string key_id, Key key, std::string cpl_id, Standard standard);
        void add_key (DecryptedKDMKey key);
 
        /** @return This KDM's (decrypted) keys, which could be used to decrypt assets. */
index 02042d4e7208bd0f979aa83eaca5326d020e6d8f..40ac73e92f71c4013487ac5f7a671ea0df687e8f 100644 (file)
@@ -38,5 +38,10 @@ using namespace dcp;
 bool
 dcp::operator== (dcp::DecryptedKDMKey const & a, dcp::DecryptedKDMKey const & b)
 {
-       return a.type() == b.type() && a.id() == b.id() && a.key() == b.key() && a.cpl_id() == b.cpl_id();
+       return a.type() == b.type()
+               && a.id() == b.id()
+               && a.key() == b.key()
+               && a.cpl_id() == b.cpl_id()
+               && a.standard() == b.standard()
+               && a.signer_thumbprint() == b.signer_thumbprint();
 }
index 1e03ee0a15118a15ab21f1df213ef50b605960ad..b98f1b2b3eae2fca8a037e21aceec84a9f041013 100644 (file)
@@ -39,6 +39,7 @@
 #define LIBDCP_DECRYPTED_KDM_KEY_H
 
 #include "key.h"
+#include "types.h"
 #include <boost/optional.hpp>
 
 namespace dcp {
@@ -49,11 +50,13 @@ namespace dcp {
 class DecryptedKDMKey
 {
 public:
-       DecryptedKDMKey (boost::optional<std::string> type, std::string id, Key key, std::string cpl_id)
+       DecryptedKDMKey (boost::optional<std::string> type, std::string id, Key key, std::string cpl_id, Standard standard, std::string signer_thumbprint)
                : _type (type)
                , _id (id)
                , _key (key)
                , _cpl_id (cpl_id)
+               , _standard (standard)
+               , _signer_thumbprint (signer_thumbprint)
        {}
 
        boost::optional<std::string> type () const {
@@ -72,11 +75,21 @@ public:
                return _cpl_id;
        }
 
+       Standard standard () const {
+               return _standard;
+       }
+
+       std::string signer_thumbprint () const {
+               return _signer_thumbprint;
+       }
+
 private:
        boost::optional<std::string> _type;
        std::string _id;
        Key _key;
        std::string _cpl_id;
+       Standard _standard;
+       std::string _signer_thumbprint;
 };
 
 bool operator== (DecryptedKDMKey const &, DecryptedKDMKey const &);
index 197397cb980a593902ba7d2ef78324e37777dc51..1e35803f4edabe0bd375362c09e5c15dc914d6f0 100644 (file)
@@ -102,11 +102,12 @@ main (int argc, char* argv[])
                        cout << "\nKeys";
                        BOOST_FOREACH (dcp::DecryptedKDMKey i, dec_kdm.keys ()) {
                                cout << "\n";
-                               cout << "\tID:   " << i.id() << "\n";
+                               cout << "\tID:       " << i.id() << "\n";
+                               cout << "\tStandard: " << (i.standard() == dcp::SMPTE ? "SMPTE" : "Interop") << "\n";
                                if (i.type()) {
-                                       cout << "\tType: " << i.type().get() << "\n";
+                                       cout << "\tType:     " << i.type().get() << "\n";
                                }
-                               cout << "\tKey:  " << i.key().hex() << "\n";
+                               cout << "\tKey:      " << i.key().hex() << "\n";
                        }
                } catch (dcp::KDMDecryptionError& e) {
                        cerr << e.what() << "\n";