Пример #1
0
        internal static int DRMCreateBoundLicense(
            SafeRightsManagementEnvironmentHandle environmentHandle,
            BoundLicenseParams boundLicenseParams,
            string licenseChain,
            out SafeRightsManagementHandle boundLicenseHandle,
            out uint errorLogHandle)
        {
            SecurityHelper.DemandRightsManagementPermission();
            int res = UnsafeNativeMethods.DRMCreateBoundLicense(
                environmentHandle,
                boundLicenseParams,
                licenseChain,
                out boundLicenseHandle,
                out errorLogHandle);

            // on some platforms in the failure cases the out parameter is being created with the value 0
            // in order to simplify error handling and Disposing of those handles we will just close them as
            // soon as we detect such case
            if ((boundLicenseHandle != null) && boundLicenseHandle.IsInvalid)
            {
                boundLicenseHandle.Dispose();
                boundLicenseHandle = null;
            }
            return(res);
        }
Пример #2
0
 internal static extern int DRMCreateLicenseStorageSession(
     [In] SafeRightsManagementEnvironmentHandle envHandle,
     [In] SafeRightsManagementHandle hDefLib,
     [In] SafeRightsManagementSessionHandle hClientSession,
     [In, MarshalAs(UnmanagedType.U4)] uint uFlags,
     [In, MarshalAs(UnmanagedType.LPWStr)] string IssuanceLicense,
     [Out] out SafeRightsManagementSessionHandle phLicenseStorageSession);
Пример #3
0
        internal static int DRMCreateLicenseStorageSession(
            SafeRightsManagementEnvironmentHandle hEnv,
            SafeRightsManagementHandle hDefLib,
            SafeRightsManagementSessionHandle hClientSession,
            uint uFlags,
            string IssuanceLicense,
            out SafeRightsManagementSessionHandle phLicenseStorageSession)
        {
            SecurityHelper.DemandRightsManagementPermission();
            int res = UnsafeNativeMethods.DRMCreateLicenseStorageSession(
                hEnv,
                hDefLib,
                hClientSession,
                uFlags,
                IssuanceLicense,
                out phLicenseStorageSession);

            // on some platforms in the failure cases the out parameter is being created with the value 0
            // in order to simplify error handling and Disposing of those handles we will just close them as
            // soon as we detect such case
            if ((phLicenseStorageSession != null) && phLicenseStorageSession.IsInvalid)
            {
                phLicenseStorageSession.Dispose();
                phLicenseStorageSession = null;
            }
            return(res);
        }
Пример #4
0
 internal static int DRMGetSignedIssuanceLicense(
     SafeRightsManagementEnvironmentHandle environmentHandle,
     SafeRightsManagementPubHandle issuanceLicenseHandle,
     uint flags,
     byte[] symmetricKey,
     uint symmetricKeyByteCount,
     string symmetricKeyType,
     string clientLicensorCertificate,
     CallbackDelegate pfnCallback,
     string Url,
     uint context)
 {
     SecurityHelper.DemandRightsManagementPermission();
     return(UnsafeNativeMethods.DRMGetSignedIssuanceLicense(
                environmentHandle,
                issuanceLicenseHandle,
                flags,
                symmetricKey,
                symmetricKeyByteCount,
                symmetricKeyType,
                clientLicensorCertificate,
                pfnCallback,
                Url,
                context));
 }
Пример #5
0
        internal static int DRMInitEnvironment(
            uint eSecurityProviderType,
            uint eSpecification,
            string securityProvider,
            string manifestCredentials,
            string machineCredentials,
            out SafeRightsManagementEnvironmentHandle environmentHandle,
            out SafeRightsManagementHandle defaultLibrary)
        {
            SecurityHelper.DemandRightsManagementPermission();
            int res = UnsafeNativeMethods.DRMInitEnvironment(
                eSecurityProviderType,
                eSpecification,
                securityProvider,
                manifestCredentials,
                machineCredentials,
                out environmentHandle,
                out defaultLibrary);

            // on some platforms in the failure cases the out parameter is being created with the value 0
            // in order to simplify error handling and Disposing of those handles we will just close them as
            // soon as we detect such case
            if ((environmentHandle != null) && environmentHandle.IsInvalid)
            {
                environmentHandle.Dispose();
                environmentHandle = null;
            }
            if ((defaultLibrary != null) && defaultLibrary.IsInvalid)
            {
                defaultLibrary.Dispose();
                defaultLibrary = null;
            }

            return(res);
        }
Пример #6
0
 internal static extern int DRMInitEnvironment(
     [In, MarshalAs(UnmanagedType.U4)] uint eSecurityProviderType,
     [In, MarshalAs(UnmanagedType.U4)] uint eSpecification,
     [In, MarshalAs(UnmanagedType.LPWStr)] string securityProvider,
     [In, MarshalAs(UnmanagedType.LPWStr)] string manifestCredentials,
     [In, MarshalAs(UnmanagedType.LPWStr)] string machineCredentials,
     [Out] out SafeRightsManagementEnvironmentHandle environmentHandle,
     [Out] out SafeRightsManagementHandle defaultLibrary);
Пример #7
0
 internal static extern int DRMGetSignedIssuanceLicense(
     [In] SafeRightsManagementEnvironmentHandle environmentHandle,
     [In] SafeRightsManagementPubHandle issuanceLicenseHandle,
     [In, MarshalAs(UnmanagedType.U4)] uint flags,
     [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] byte[] symmetricKey,
     [In, MarshalAs(UnmanagedType.U4)] uint symmetricKeyByteCount,
     [In, MarshalAs(UnmanagedType.LPWStr)] string symmetricKeyType,
     [In, MarshalAs(UnmanagedType.LPWStr)] string clientLicensorCertificate,
     [In, MarshalAs(UnmanagedType.FunctionPtr)] CallbackDelegate pfnCallback,
     [In, MarshalAs(UnmanagedType.LPWStr)] string url,
     [In, MarshalAs(UnmanagedType.U4)] uint context);
Пример #8
0
 internal static extern int DRMCreateBoundLicense(
     [In] SafeRightsManagementEnvironmentHandle environmentHandle,
     [In, MarshalAs(UnmanagedType.LPStruct)] BoundLicenseParams boundLicenseParams,
     [In, MarshalAs(UnmanagedType.LPWStr)] string licenseChain,
     [Out] out SafeRightsManagementHandle boundLicenseHandle,
     [Out, MarshalAs(UnmanagedType.U4)] out uint errorLogHandle);
        internal static int DRMCreateBoundLicense( 
                                 SafeRightsManagementEnvironmentHandle environmentHandle,
                                 BoundLicenseParams boundLicenseParams, 
                                 string licenseChain, 
                                 out SafeRightsManagementHandle boundLicenseHandle,
                                 out uint errorLogHandle) 
        {
            SecurityHelper.DemandRightsManagementPermission();
            int res = UnsafeNativeMethods.DRMCreateBoundLicense(
                                environmentHandle, 
                                boundLicenseParams,
                                licenseChain, 
                                out boundLicenseHandle, 
                                out errorLogHandle);
            // on some platforms in the failure cases the out parameter is being created with the value 0 
            // in order to simplify error handling and Disposing of those handles we will just close them as
            // soon as we detect such case
            if ((boundLicenseHandle != null) && boundLicenseHandle.IsInvalid)
            { 
                boundLicenseHandle.Dispose();
                boundLicenseHandle = null; 
            } 
            return res;
 
        }
 internal static int DRMGetSignedIssuanceLicense(
                          SafeRightsManagementEnvironmentHandle environmentHandle,
                          SafeRightsManagementPubHandle issuanceLicenseHandle, 
                          uint flags,
                          byte[] symmetricKey, 
                          uint symmetricKeyByteCount, 
                          string symmetricKeyType,
                          string clientLicensorCertificate, 
                          CallbackDelegate pfnCallback,
                          string Url,
                          uint context)
 { 
     SecurityHelper.DemandRightsManagementPermission();
     return UnsafeNativeMethods.DRMGetSignedIssuanceLicense( 
                         environmentHandle, 
                         issuanceLicenseHandle,
                         flags, 
                         symmetricKey,
                         symmetricKeyByteCount,
                         symmetricKeyType,
                         clientLicensorCertificate, 
                         pfnCallback,
                         Url, 
                         context); 
 }
        internal static int DRMCreateLicenseStorageSession( 
                                SafeRightsManagementEnvironmentHandle hEnv,
                                SafeRightsManagementHandle hDefLib, 
                                SafeRightsManagementSessionHandle hClientSession,
                                uint uFlags,
                                string IssuanceLicense,
                                out SafeRightsManagementSessionHandle phLicenseStorageSession) 
        {
            SecurityHelper.DemandRightsManagementPermission(); 
            int res = UnsafeNativeMethods.DRMCreateLicenseStorageSession( 
                                hEnv,
                                hDefLib, 
                                hClientSession,
                                uFlags,
                                IssuanceLicense,
                                out phLicenseStorageSession); 

            // on some platforms in the failure cases the out parameter is being created with the value 0 
            // in order to simplify error handling and Disposing of those handles we will just close them as 
            // soon as we detect such case
            if ((phLicenseStorageSession != null) && phLicenseStorageSession.IsInvalid) 
            {
                phLicenseStorageSession.Dispose();
                phLicenseStorageSession = null;
            } 
            return res;
        } 
        internal static int DRMInitEnvironment( 
                                 uint eSecurityProviderType,
                                 uint eSpecification, 
                                 string securityProvider, 
                                 string manifestCredentials,
                                 string machineCredentials, 
                                 out SafeRightsManagementEnvironmentHandle environmentHandle,
                                 out SafeRightsManagementHandle defaultLibrary)
        {
            SecurityHelper.DemandRightsManagementPermission(); 
            int res = UnsafeNativeMethods.DRMInitEnvironment(
                                eSecurityProviderType, 
                                eSpecification, 
                                securityProvider,
                                manifestCredentials, 
                                machineCredentials,
                                out environmentHandle,
                                out defaultLibrary);
 
            // on some platforms in the failure cases the out parameter is being created with the value 0
            // in order to simplify error handling and Disposing of those handles we will just close them as 
            // soon as we detect such case 
            if ((environmentHandle != null) && environmentHandle.IsInvalid)
            { 
                environmentHandle.Dispose();
                environmentHandle = null;
            }
            if ((defaultLibrary != null) && defaultLibrary.IsInvalid) 
            {
                defaultLibrary.Dispose(); 
                defaultLibrary = null; 
            }
 
            return res;
        }