Bump version
[libdcp.git] / src / decrypted_kdm.cc
index 9661281d3aeb882a4f98e2f4680580e820f1b412..949db72bdcc6e763767e7c24fea85d1af3d7ddae 100644 (file)
@@ -25,7 +25,7 @@
 #include "util.h"
 #include "exceptions.h"
 #include "cpl.h"
-#include "signer.h"
+#include "certificate_chain.h"
 #include "dcp_assert.h"
 #include "AS_DCP.h"
 #include "KM_util.h"
@@ -77,7 +77,7 @@ static string
 get_uuid (unsigned char ** p)
 {
        stringstream g;
-       
+
        for (int i = 0; i < 16; ++i) {
                g << setw(2) << setfill('0') << hex << static_cast<int> (**p);
                (*p)++;
@@ -109,7 +109,7 @@ DecryptedKDM::DecryptedKDM (EncryptedKDM const & kdm, string private_key)
        if (!bio) {
                throw MiscError ("could not create memory BIO");
        }
-       
+
        RSA* rsa = PEM_read_bio_RSAPrivateKey (bio, 0, 0, 0);
        if (!rsa) {
                throw FileError ("could not read RSA private key file", private_key, errno);
@@ -174,8 +174,8 @@ DecryptedKDM::DecryptedKDM (EncryptedKDM const & kdm, string private_key)
                }
                default:
                        DCP_ASSERT (false);
-               }               
-               
+               }
+
                delete[] decrypted;
        }
 
@@ -212,7 +212,7 @@ DecryptedKDM::DecryptedKDM (
 }
 
 EncryptedKDM
-DecryptedKDM::encrypt (shared_ptr<const Signer> signer, Certificate recipient, Formulation formulation) const
+DecryptedKDM::encrypt (shared_ptr<const CertificateChain> signer, Certificate recipient, Formulation formulation) const
 {
        list<pair<string, string> > key_ids;
        list<string> keys;
@@ -227,16 +227,16 @@ DecryptedKDM::encrypt (shared_ptr<const Signer> signer, Certificate recipient, F
                uint8_t structure_id[] = { 0xf1, 0xdc, 0x12, 0x44, 0x60, 0x16, 0x9a, 0x0e, 0x85, 0xbc, 0x30, 0x06, 0x42, 0xf8, 0x66, 0xab };
                put (&p, structure_id, 16);
 
-               base64_decode (signer->certificates().leaf().thumbprint (), p, 20);
+               base64_decode (signer->leaf().thumbprint (), p, 20);
                p += 20;
-               
+
                put_uuid (&p, i.cpl_id ());
                put (&p, i.type ());
                put_uuid (&p, i.id ());
                put (&p, _not_valid_before.as_string ());
                put (&p, _not_valid_after.as_string ());
                put (&p, i.key().value(), ASDCP::KeyLen);
-               
+
                /* Encrypt using the projector's public key */
                RSA* rsa = recipient.public_key ();
                unsigned char encrypted[RSA_size(rsa)];
@@ -244,7 +244,7 @@ DecryptedKDM::encrypt (shared_ptr<const Signer> signer, Certificate recipient, F
                if (encrypted_len == -1) {
                        throw MiscError (String::compose ("Could not encrypt KDM (%1)", ERR_error_string (ERR_get_error(), 0)));
                }
-               
+
                /* Lazy overallocation */
                char out[encrypted_len * 2];
                Kumu::base64encode (encrypted, encrypted_len, out, encrypted_len * 2);
@@ -256,11 +256,11 @@ DecryptedKDM::encrypt (shared_ptr<const Signer> signer, Certificate recipient, F
                        }
                        lines << out[i];
                }
-               
+
                keys.push_back (lines.str ());
        }
 
-       string device_list_description = recipient.common_name ();
+       string device_list_description = recipient.subject_common_name ();
        if (device_list_description.find (".") != string::npos) {
                device_list_description = device_list_description.substr (device_list_description.find (".") + 1);
        }