Microsoft Information Protection (MIP) SDK for C++: Reference 1.15
Doxygen-generated documentation for MIP SDK written in C++
Loading...
Searching...
No Matches
protection_common_types.h
Go to the documentation of this file.
1/*
2 *
3 * Copyright (c) Microsoft Corporation.
4 * All rights reserved.
5 *
6 * This code is licensed under the MIT License.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files(the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions :
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 *
26 */
27/**
28 * @brief A file containing the common types used by the protection module.
29 *
30 * @file protection_common_types.h
31 */
32
33#ifndef API_MIP_PROTECTION_PROTECTION_COMMON_TYPES_H_
34#define API_MIP_PROTECTION_PROTECTION_COMMON_TYPES_H_
35
36#define DYNAMIC_WATERMARK_CAPABILITY "dynamicwatermark"
37
38#include <chrono>
39#include <map>
40#include <string>
41#include <vector>
42
43#include "mip/mip_namespace.h"
47
48MIP_NAMESPACE_BEGIN
49
50/**
51 * @brief Holds the details of a Publishing License used to create a protection handler
52 */
54public:
56 const std::vector<uint8_t>& serializedPublishingLicense)
57 : mSerializedPublishingLicense(serializedPublishingLicense),
58 mIsParsed(false),
59 mIssuedTime(std::chrono::system_clock::from_time_t(0)),
60 mLabelInfo("","") {}
61
63 const std::vector<uint8_t>& serializedPreLicense,
64 const std::vector<uint8_t>& serializedPublishingLicense)
65 : mPreLicense(serializedPreLicense),
66 mSerializedPublishingLicense(serializedPublishingLicense),
67 mIsParsed(false),
68 mIssuedTime(std::chrono::system_clock::from_time_t(0)),
69 mLabelInfo("","") {}
70
71 void SetParsedData(std::shared_ptr<ParsedPublishingLicense> parsedPublishingLicense) {
72 mIsParsed = true;
73 mDomains = parsedPublishingLicense->GetDomains();
74 mServerPublicCert = parsedPublishingLicense->GetServerPublicCert();
75 mContentId = parsedPublishingLicense->GetContentId();
76 mIssuerId = parsedPublishingLicense->GetIssuerId();
77 mDoubleKeyAlgorithm = parsedPublishingLicense->GetDoubleKeyAlgorithm();
78 mOwner = parsedPublishingLicense->GetOwner();
79 mConnectionInfo = parsedPublishingLicense->GetConnectionInfo();
80 mDescriptor = parsedPublishingLicense->GetDescriptor();
81 mReferralInfoUrl = parsedPublishingLicense->GetReferralInfoUrl();
82 mSignedApplicationData = parsedPublishingLicense->GetSignedApplicationData();
83 mIssuedTime = parsedPublishingLicense->GetIssuedTime();
84 mLabelInfo = parsedPublishingLicense->GetLabelInfo();
85 mEncryptedRightsData = parsedPublishingLicense->GetEncryptedRightsData();
86 }
87
88#if !defined(SWIG) && !defined(SWIG_DIRECTORS)
89 [[deprecated("This version of SetParsedData is deprecated, use the version that accepts a ParsedPublishingLicense")]]
90#endif
92 const std::vector<std::string>& domains,
93 const std::string& serverPublicCert,
94 const std::string& contentId,
95 const std::string& issuerId) {
96 mDomains = domains;
97 mServerPublicCert = serverPublicCert;
98 mContentId = contentId;
99 mIssuerId = issuerId;
100 mIsParsed = true;
101 }
102
103 const std::vector<uint8_t>& GetSerializedPublishingLicense() const { return mSerializedPublishingLicense; }
104 const std::vector<uint8_t>& GetPreLicense() const { return mPreLicense; }
105
106 const std::vector<std::string>& GetDomains() const { return mDomains; }
107 const std::string& GetServerPublicCertificate() const { return mServerPublicCert; }
108 const std::string& GetIssuerId() const { return mIssuerId; }
109 const std::string& GetContentId() const { return mContentId; }
110 bool IsLicenseParsed() const { return mIsParsed; }
111 bool HasPreLicense() const { return !mPreLicense.empty(); }
112 bool GetIsDoubleKeyLicense() const { return !mDoubleKeyAlgorithm.empty(); }
113 const std::string& GetDoubleKeyAlgorithm() const { return mDoubleKeyAlgorithm; }
114 const std::string& GetOwner() const { return mOwner; }
115 std::shared_ptr<LicenseConnectionInfo> GetConnectionInfo() const { return mConnectionInfo; }
116 std::shared_ptr<LicenseDescriptor> GetDescriptor() const { return mDescriptor; }
117 const std::string& GetReferralInfoUrl() const { return mReferralInfoUrl; }
118 const std::vector<std::shared_ptr<LicenseApplicationData>>& GetSignedApplicationData() const { return mSignedApplicationData; }
119 const std::chrono::time_point<std::chrono::system_clock>& GetIssuedTime() const { return mIssuedTime; }
120 const mip::LabelInfo GetLabelInfo() const { return mLabelInfo; }
121 const std::vector<uint8_t>& GetEncryptedRightsData() const { return mEncryptedRightsData; }
122
123private:
124 std::vector<uint8_t> mPreLicense;
125 std::vector<uint8_t> mSerializedPublishingLicense;
126
127 std::vector<std::string> mDomains;
128 std::string mServerPublicCert;
129 std::string mContentId;
130 std::string mIssuerId;
131 bool mIsParsed;
132 std::string mDoubleKeyAlgorithm;
133 std::string mOwner;
134 std::shared_ptr<LicenseConnectionInfo> mConnectionInfo;
135 std::shared_ptr<LicenseDescriptor> mDescriptor;
136 std::string mReferralInfoUrl;
137 std::vector<std::shared_ptr<LicenseApplicationData>> mSignedApplicationData;
138 std::chrono::time_point<std::chrono::system_clock> mIssuedTime;
139 LabelInfo mLabelInfo;
140 std::vector<uint8_t> mEncryptedRightsData;
141};
142
143/**
144 * @brief Cipher mode identifier
145 */
146enum class CipherMode {
147 CIPHER_MODE_CBC4K = 0, /**< CBC 4K mode with internal padding */
148 CIPHER_MODE_ECB = 1, /**< ECB mode */
149 CIPHER_MODE_CBC512NOPADDING = 2, /**< CBC 512 mode with external (client) padding */
150 CIPHER_MODE_CBC4KNOPADDING = 3 /**< CBC 4K mode with external (client) padding */
151};
152
153MIP_NAMESPACE_END
154
155#endif // API_MIP_PROTECTION_PROTECTION_COMMON_TYPES_H_
Holds the details of a Publishing License used to create a protection handler.
PublishingLicenseInfo(const std::vector< uint8_t > &serializedPreLicense, const std::vector< uint8_t > &serializedPublishingLicense)
const std::vector< uint8_t > & GetPreLicense() const
const std::vector< uint8_t > & GetSerializedPublishingLicense() const
const std::string & GetDoubleKeyAlgorithm() const
const std::chrono::time_point< std::chrono::system_clock > & GetIssuedTime() const
const std::string & GetServerPublicCertificate() const
const std::string & GetReferralInfoUrl() const
const mip::LabelInfo GetLabelInfo() const
std::shared_ptr< LicenseDescriptor > GetDescriptor() const
const std::vector< std::string > & GetDomains() const
const std::string & GetContentId() const
std::shared_ptr< LicenseConnectionInfo > GetConnectionInfo() const
const std::string & GetIssuerId() const
void SetParsedData(std::shared_ptr< ParsedPublishingLicense > parsedPublishingLicense)
const std::vector< std::shared_ptr< LicenseApplicationData > > & GetSignedApplicationData() const
const std::vector< uint8_t > & GetEncryptedRightsData() const
void SetParsedData(const std::vector< std::string > &domains, const std::string &serverPublicCert, const std::string &contentId, const std::string &issuerId)
const std::string & GetOwner() const
PublishingLicenseInfo(const std::vector< uint8_t > &serializedPublishingLicense)
Defines LicenseConnectionInfo interface.
Defines LicenseDescriptor interface.
MIP namespace macros.
Contains details of a parsed publishing license.
CipherMode
Cipher mode identifier.
@ CIPHER_MODE_ECB
ECB mode.
@ CIPHER_MODE_CBC4KNOPADDING
CBC 4K mode with external (client) padding.
@ CIPHER_MODE_CBC512NOPADDING
CBC 512 mode with external (client) padding.
@ CIPHER_MODE_CBC4K
CBC 4K mode with internal padding.
Label information for a template or ad-hoc (custom) protection.