Microsoft Information Protection (MIP) SDK for C++: Reference 1.16
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 mSealedKeyType = parsedPublishingLicense->GetSealedKeyType();
78 mDoubleKeyAlgorithm = parsedPublishingLicense->GetDoubleKeyAlgorithm();
79 mOwner = parsedPublishingLicense->GetOwner();
80 mConnectionInfo = parsedPublishingLicense->GetConnectionInfo();
81 mDescriptor = parsedPublishingLicense->GetDescriptor();
82 mReferralInfoUrl = parsedPublishingLicense->GetReferralInfoUrl();
83 mSignedApplicationData = parsedPublishingLicense->GetSignedApplicationData();
84 mIssuedTime = parsedPublishingLicense->GetIssuedTime();
85 mLabelInfo = parsedPublishingLicense->GetLabelInfo();
86 mEncryptedRightsData = parsedPublishingLicense->GetEncryptedRightsData();
87 }
88
89#if !defined(SWIG) && !defined(SWIG_DIRECTORS)
90 [[deprecated("This version of SetParsedData is deprecated, use the version that accepts a ParsedPublishingLicense")]]
91#endif
93 const std::vector<std::string>& domains,
94 const std::string& serverPublicCert,
95 const std::string& contentId,
96 const std::string& issuerId) {
97 mDomains = domains;
98 mServerPublicCert = serverPublicCert;
99 mContentId = contentId;
100 mIssuerId = issuerId;
101 mIsParsed = true;
102 }
103
104 const std::vector<uint8_t>& GetSerializedPublishingLicense() const { return mSerializedPublishingLicense; }
105 const std::vector<uint8_t>& GetPreLicense() const { return mPreLicense; }
106
107 const std::vector<std::string>& GetDomains() const { return mDomains; }
108 const std::string& GetServerPublicCertificate() const { return mServerPublicCert; }
109 const std::string& GetIssuerId() const { return mIssuerId; }
110 const std::string& GetSealedKeyType() const { return mSealedKeyType; }
111 const std::string& GetContentId() const { return mContentId; }
112 bool IsLicenseParsed() const { return mIsParsed; }
113 bool HasPreLicense() const { return !mPreLicense.empty(); }
114 bool GetIsDoubleKeyLicense() const { return !mDoubleKeyAlgorithm.empty(); }
115 const std::string& GetDoubleKeyAlgorithm() const { return mDoubleKeyAlgorithm; }
116 const std::string& GetOwner() const { return mOwner; }
117 std::shared_ptr<LicenseConnectionInfo> GetConnectionInfo() const { return mConnectionInfo; }
118 std::shared_ptr<LicenseDescriptor> GetDescriptor() const { return mDescriptor; }
119 const std::string& GetReferralInfoUrl() const { return mReferralInfoUrl; }
120 const std::vector<std::shared_ptr<LicenseApplicationData>>& GetSignedApplicationData() const { return mSignedApplicationData; }
121 const std::chrono::time_point<std::chrono::system_clock>& GetIssuedTime() const { return mIssuedTime; }
122 const mip::LabelInfo GetLabelInfo() const { return mLabelInfo; }
123 const std::vector<uint8_t>& GetEncryptedRightsData() const { return mEncryptedRightsData; }
124
125private:
126 std::vector<uint8_t> mPreLicense;
127 std::vector<uint8_t> mSerializedPublishingLicense;
128
129 std::vector<std::string> mDomains;
130 std::string mServerPublicCert;
131 std::string mContentId;
132 std::string mIssuerId;
133 std::string mSealedKeyType;
136 std::string mOwner;
137 std::shared_ptr<LicenseConnectionInfo> mConnectionInfo;
138 std::shared_ptr<LicenseDescriptor> mDescriptor;
139 std::string mReferralInfoUrl;
140 std::vector<std::shared_ptr<LicenseApplicationData>> mSignedApplicationData;
141 std::chrono::time_point<std::chrono::system_clock> mIssuedTime;
143 std::vector<uint8_t> mEncryptedRightsData;
144};
145
146/**
147 * @brief Cipher mode identifier
148 */
149enum class CipherMode {
150 CIPHER_MODE_CBC4K = 0, /**< CBC 4K mode with internal padding */
151 CIPHER_MODE_ECB = 1, /**< ECB mode */
152 CIPHER_MODE_CBC512NOPADDING = 2, /**< CBC 512 mode with external (client) padding */
153 CIPHER_MODE_CBC4KNOPADDING = 3 /**< CBC 4K mode with external (client) padding */
154};
155
156MIP_NAMESPACE_END
157
158#endif // API_MIP_PROTECTION_PROTECTION_COMMON_TYPES_H_
Holds the details of a Publishing License used to create a protection handler.
std::vector< uint8_t > mSerializedPublishingLicense
PublishingLicenseInfo(const std::vector< uint8_t > &serializedPreLicense, const std::vector< uint8_t > &serializedPublishingLicense)
const std::vector< uint8_t > & GetPreLicense() const
std::vector< std::shared_ptr< LicenseApplicationData > > mSignedApplicationData
const std::vector< uint8_t > & GetSerializedPublishingLicense() const
const std::string & GetSealedKeyType() const
const std::string & GetDoubleKeyAlgorithm() const
std::shared_ptr< LicenseDescriptor > mDescriptor
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
std::vector< uint8_t > mPreLicense
const std::vector< std::string > & GetDomains() const
std::shared_ptr< LicenseConnectionInfo > mConnectionInfo
const std::string & GetContentId() const
std::vector< uint8_t > mEncryptedRightsData
std::shared_ptr< LicenseConnectionInfo > GetConnectionInfo() const
std::vector< std::string > mDomains
const std::string & GetIssuerId() const
std::chrono::time_point< std::chrono::system_clock > mIssuedTime
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_CBC4KNOPADDING
@ CIPHER_MODE_CBC512NOPADDING
Label information for a template or ad-hoc (custom) protection.