Example #1
0
        internal static int DRMCreateEnablingBitsEncryptor(
            SafeRightsManagementHandle boundLicenseHandle,
            string right,
            uint auxLibrary,
            string auxPlugin,
            out SafeRightsManagementHandle encryptorHandle)
        {
            SecurityHelper.DemandRightsManagementPermission();
            int res = UnsafeNativeMethods.DRMCreateEnablingBitsEncryptor(
                boundLicenseHandle,
                right,
                auxLibrary,
                auxPlugin,
                out encryptorHandle);

            // 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 ((encryptorHandle != null) && encryptorHandle.IsInvalid)
            {
                encryptorHandle.Dispose();
                encryptorHandle = null;
            }
            return(res);
        }
Example #2
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);
        }
Example #3
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);
        }
Example #4
0
        internal static int DRMGetBoundLicenseObject(
            SafeRightsManagementHandle queryRootHandle,
            string subObjectType,
            uint index,
            out SafeRightsManagementHandle subQueryHandle)
        {
            int res = UnsafeNativeMethods.DRMGetBoundLicenseObject(
                queryRootHandle,
                subObjectType,
                index,
                out subQueryHandle);

            // 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 ((subQueryHandle != null) && subQueryHandle.IsInvalid)
            {
                subQueryHandle.Dispose();
                subQueryHandle = null;
            }
            return(res);
        }
 internal static int DRMCreateEnablingBitsEncryptor(
                          SafeRightsManagementHandle boundLicenseHandle,
                          string right,
                          uint auxLibrary, 
                          string auxPlugin,
                          out SafeRightsManagementHandle encryptorHandle) 
 { 
     SecurityHelper.DemandRightsManagementPermission();
     int res = UnsafeNativeMethods.DRMCreateEnablingBitsEncryptor( 
                         boundLicenseHandle,
                         right,
                         auxLibrary,
                         auxPlugin, 
                         out encryptorHandle);
     // 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 ((encryptorHandle != null) && encryptorHandle.IsInvalid) 
     {
         encryptorHandle.Dispose();
         encryptorHandle = null;
     } 
     return res;
 } 
        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 DRMGetBoundLicenseObject(
                                 SafeRightsManagementHandle queryRootHandle,
                                 string subObjectType, 
                                 uint index,
                                 out SafeRightsManagementHandle subQueryHandle) 
        { 
            SecurityHelper.DemandRightsManagementPermission();
            int res = UnsafeNativeMethods.DRMGetBoundLicenseObject( 
                                queryRootHandle,
                                subObjectType,
                                index,
                                out subQueryHandle); 

            // 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 ((subQueryHandle != null) && subQueryHandle.IsInvalid) 
            {
                subQueryHandle.Dispose();
                subQueryHandle = 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;
        }