sl@0: // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32\common\secure.cpp sl@0: // sl@0: // sl@0: sl@0: #define __INCLUDE_ALL_SUPPORTED_CAPABILITIES__ sl@0: #include "common.h" sl@0: #ifdef __KERNEL_MODE__ sl@0: #include sl@0: #include sl@0: #endif sl@0: sl@0: // Check that the layout of TSecurityInfo and SSecurityInfo are the same sl@0: // because we use this assumption in the TSecurityInfo::Set methods sl@0: __ASSERT_COMPILE(_FOFF(TSecurityInfo,iSecureId)==_FOFF(SSecurityInfo,iSecureId)); sl@0: __ASSERT_COMPILE(_FOFF(TSecurityInfo,iVendorId)==_FOFF(SSecurityInfo,iVendorId)); sl@0: __ASSERT_COMPILE(_FOFF(TSecurityInfo,iCaps)==_FOFF(SSecurityInfo,iCaps)); sl@0: sl@0: sl@0: #ifdef __KERNEL_MODE__ sl@0: sl@0: sl@0: /** sl@0: Construct a TSecurityInfo setting it to the security attributes of aProcess. sl@0: @param aProcess A process. sl@0: */ sl@0: EXPORT_C TSecurityInfo::TSecurityInfo(DProcess* aProcess) sl@0: { sl@0: memcpy(this, &aProcess->iS, sizeof(SSecurityInfo)); sl@0: } sl@0: sl@0: /** sl@0: Construct a TSecurityInfo setting it to the security attributes to those of the process sl@0: owning the specified thread. sl@0: @param aThread A thread. sl@0: */ sl@0: EXPORT_C TSecurityInfo::TSecurityInfo(DThread* aThread) sl@0: { sl@0: memcpy(this, &aThread->iOwningProcess->iS, sizeof(SSecurityInfo)); sl@0: } sl@0: sl@0: #else sl@0: sl@0: /** sl@0: Construct a TSecurityInfo setting it to the security attributes of aProcess. sl@0: @param aProcess A process. sl@0: */ sl@0: EXPORT_C TSecurityInfo::TSecurityInfo(RProcess aProcess) sl@0: { sl@0: Exec::ProcessSecurityInfo(aProcess.Handle(),*(SSecurityInfo*)this); sl@0: } sl@0: sl@0: /** sl@0: Construct a TSecurityInfo setting it to the security attributes to those of the process sl@0: owning the specified thread. sl@0: @param aThread A thread. sl@0: */ sl@0: EXPORT_C TSecurityInfo::TSecurityInfo(RThread aThread) sl@0: { sl@0: Exec::ThreadSecurityInfo(aThread.Handle(),*(SSecurityInfo*)this); sl@0: } sl@0: sl@0: /** sl@0: Construct a TSecurityInfo setting it to the security attributes of the process sl@0: which sent the message aMsgPtr sl@0: @param aMsgPtr a message sl@0: */ sl@0: EXPORT_C TSecurityInfo::TSecurityInfo(RMessagePtr2 aMsgPtr) sl@0: { sl@0: Exec::MessageSecurityInfo(aMsgPtr.Handle(),*(SSecurityInfo*)this); sl@0: } sl@0: sl@0: TInt TSecurityInfo::Set(RSessionBase aSession) sl@0: { sl@0: return Exec::SessionSecurityInfo(aSession.Handle(),*(SSecurityInfo*)this); sl@0: } sl@0: sl@0: /** sl@0: Sets this TSecurityInfo to the security attributes of this process' creator. sl@0: */ sl@0: EXPORT_C void TSecurityInfo::SetToCreatorInfo() sl@0: { sl@0: Exec::CreatorSecurityInfo(*(SSecurityInfo*)this); sl@0: } sl@0: sl@0: #endif //__KERNEL_MODE__ sl@0: sl@0: /** sl@0: Construct a set consisting of two capabilities. sl@0: @param aCapability1 The first capability. sl@0: @param aCapability2 The second capability. sl@0: */ sl@0: EXPORT_C TCapabilitySet::TCapabilitySet(TCapability aCapability1, TCapability aCapability2) sl@0: { sl@0: SetEmpty(); sl@0: AddCapability(aCapability1); sl@0: AddCapability(aCapability2); sl@0: } sl@0: sl@0: /** sl@0: Make this set empty. I.e. Containing no capabilities. sl@0: */ sl@0: EXPORT_C void TCapabilitySet::SetEmpty() sl@0: { sl@0: memset(iCaps,0,sizeof(iCaps)); sl@0: } sl@0: sl@0: sl@0: /** sl@0: Make this set consist of all capabilities supported by this OS version. sl@0: */ sl@0: EXPORT_C void TCapabilitySet::SetAllSupported() sl@0: { sl@0: *(SCapabilitySet*)&iCaps=AllSupportedCapabilities; sl@0: } sl@0: sl@0: #ifndef __KERNEL_MODE__ sl@0: // Documented in header file sl@0: EXPORT_C void TCapabilitySet::SetDisabled() sl@0: { sl@0: Exec::DisabledCapabilities(*(SCapabilitySet*)this); sl@0: } sl@0: #endif // __KERNEL_MODE__ sl@0: sl@0: /** sl@0: Add a single capability to the set. sl@0: If the capability is not supported by this OS version then it is not added and sl@0: the set is left unchanged. sl@0: @see TCapabilitySet::SetAllSupported() sl@0: @param aCapability Capability to add. sl@0: */ sl@0: EXPORT_C void TCapabilitySet::AddCapability(TCapability aCapability) sl@0: { sl@0: if((TUint32)aCapability<(TUint32)ECapability_Limit) sl@0: { sl@0: TInt index = aCapability>>3; sl@0: TUint8 mask = (TUint8)(1<<(aCapability&7)); sl@0: mask &= ((TUint8*)&AllSupportedCapabilities)[index]; sl@0: ((TUint8*)iCaps)[index] |= mask; sl@0: } sl@0: } sl@0: sl@0: /** sl@0: Remove a single capability from the set, if it is present. sl@0: @param aCapability Capability to remove. sl@0: */ sl@0: EXPORT_C void TCapabilitySet::RemoveCapability(TCapability aCapability) sl@0: { sl@0: if((TUint32)aCapability<(TUint32)ECapability_Limit) sl@0: { sl@0: TInt index = aCapability>>3; sl@0: TUint8 mask = (TUint8)(1<<(aCapability&7)); sl@0: ((TUint8*)iCaps)[index] &= ~mask; sl@0: } sl@0: } sl@0: sl@0: /** sl@0: Perform a union of this capability set with another. sl@0: The result replaces the content of 'this'. sl@0: @param aCapabilities A cpability set sl@0: */ sl@0: EXPORT_C void TCapabilitySet::Union(const TCapabilitySet& aCapabilities) sl@0: { sl@0: for(TInt n = (ECapability_Limit-1)>>5; n>=0; n--) sl@0: iCaps[n] |= aCapabilities.iCaps[n]; sl@0: } sl@0: sl@0: /** sl@0: Perform an intersection of this capability set with another. sl@0: The result replaces the content of 'this'. sl@0: @param aCapabilities A capability set sl@0: */ sl@0: EXPORT_C void TCapabilitySet::Intersection(const TCapabilitySet& aCapabilities) sl@0: { sl@0: for(TInt n = (ECapability_Limit-1)>>5; n>=0; n--) sl@0: iCaps[n] &= aCapabilities.iCaps[n]; sl@0: } sl@0: sl@0: /** sl@0: Remove a set of capabilities from this set. sl@0: @param aCapabilities The set of capabilities to remove sl@0: */ sl@0: EXPORT_C void TCapabilitySet::Remove(const TCapabilitySet& aCapabilities) sl@0: { sl@0: for(TInt n = (ECapability_Limit-1)>>5; n>=0; n--) sl@0: iCaps[n] &= ~aCapabilities.iCaps[n]; sl@0: } sl@0: sl@0: /** sl@0: Test if a single capability is present in the set. sl@0: The capability ECapability_None is always treated as being present. sl@0: @param aCapability The capability to test sl@0: @return 1 if the capability is present, 0 if it is not. sl@0: */ sl@0: EXPORT_C TBool TCapabilitySet::HasCapability(TCapability aCapability) const sl@0: { sl@0: if((TUint32)aCapability<(TUint32)ECapability_Limit) sl@0: return (((TUint8*)iCaps)[aCapability>>3]>>(aCapability&7))&1; sl@0: // coverity[dead_error_condition] sl@0: if(aCapability==ECapability_None) sl@0: return ETrue; sl@0: return EFalse; // Handles illegal argument and ECapability_Denied sl@0: } sl@0: sl@0: /** sl@0: Test if all the capabilities in a given set are present in this set sl@0: @param aCapabilities The capability set to test sl@0: @return A non-zero value if all the capabilities are present, zero otherwise. sl@0: */ sl@0: EXPORT_C TBool TCapabilitySet::HasCapabilities(const TCapabilitySet& aCapabilities) const sl@0: { sl@0: TUint32 checkFail=0; sl@0: for(TInt n = (ECapability_Limit-1)>>5; n>=0; n--) sl@0: checkFail |= aCapabilities.iCaps[n]&~iCaps[n]; sl@0: return checkFail?0:1; sl@0: } sl@0: sl@0: // Documented in header file sl@0: TBool TCapabilitySet::NotEmpty() const sl@0: { sl@0: TUint32 notEmpty=0; sl@0: for(TInt n = (ECapability_Limit-1)>>5; n>=0; n--) sl@0: notEmpty |= iCaps[n]; sl@0: return notEmpty; sl@0: } sl@0: sl@0: //ECapability_None is assumed to be -1 in the internals of TSecurityPolicy sl@0: __ASSERT_COMPILE(ECapability_None == -1); sl@0: sl@0: /** Constructs a TSecurityPolicy to either always pass or always fail checks made sl@0: against it, depending on the value of aType. sl@0: @param aType Must be one of EAlwaysPass or EAlwaysFail sl@0: @panic USER 191 if aType is not a valid value sl@0: */ sl@0: EXPORT_C TSecurityPolicy::TSecurityPolicy(TSecPolicyType aType) sl@0: : iType((TUint8)aType), iSecureId(TUint32(ECapability_None)) sl@0: { sl@0: //This constructor uses TSecPolicyType as public alias for the internal sl@0: //TType. Thus EAlwaysFail must have the same value as ETypeFail (same with the sl@0: //pass case too). sl@0: __ASSERT_COMPILE(EAlwaysFail == (TSecPolicyType)ETypeFail); sl@0: __ASSERT_COMPILE(EAlwaysPass == (TSecPolicyType)ETypePass); sl@0: sl@0: __ASSERT_ALWAYS(aType == EAlwaysFail || aType == EAlwaysPass, Panic(ETSecPolicyTypeInvalid)); sl@0: iCaps[0] = (TUint8)ECapability_None; sl@0: iCaps[1] = (TUint8)ECapability_None; sl@0: iCaps[2] = (TUint8)ECapability_None; sl@0: } sl@0: sl@0: /** Construct a TSecurityPolicy object to check up to 3 capabilties. sl@0: @param aCap1 The first capability to add to this policy sl@0: @param aCap2 An optional second capability to add to this policy sl@0: @param aCap3 An optional third capability to add to this policy sl@0: @panic USER 189 If any of the supplied capabilities are not valid. sl@0: */ sl@0: EXPORT_C TSecurityPolicy::TSecurityPolicy(TCapability aCap1, TCapability aCap2, TCapability aCap3) sl@0: //iSecureId=0xFFFFFFFF sets iExtraCaps[0-3] each to ECapability_None (==0xFF) sl@0: : iType(ETypeC3), iSecureId(TUint32(ECapability_None)) sl@0: { sl@0: ConstructAndCheck3(aCap1, aCap2, aCap3); sl@0: } sl@0: sl@0: /** Construct a TSecurityPolicy object to check up to 7 capabilties. sl@0: @param aCap1 The first capability to add to this policy sl@0: @param aCap2 The second capability to add to this policy sl@0: @param aCap3 The third capability to add to this policy sl@0: @param aCap4 The fourth capability to add to this policy sl@0: @param aCap5 An optional fifth capability to add to this policy sl@0: @param aCap6 An optional sixth capability to add to this policy sl@0: @param aCap7 An optional seventh capability to add to this policy sl@0: @panic USER 189 If any of the supplied capabilities are not valid. sl@0: */ sl@0: EXPORT_C TSecurityPolicy::TSecurityPolicy(TCapability aCap1, TCapability aCap2, sl@0: TCapability aCap3, TCapability aCap4, TCapability aCap5, TCapability aCap6, TCapability aCap7) sl@0: : iType(ETypeC7) sl@0: { sl@0: ConstructAndCheck3(aCap1, aCap2, aCap3); sl@0: __ASSERT_COMPILE(ECapability_None==-1); // Our argument check below assumes this sl@0: __ASSERT_ALWAYS( (TUint)(aCap4+1)<=(TUint)ECapability_Limit sl@0: &&(TUint)(aCap5+1)<=(TUint)ECapability_Limit sl@0: &&(TUint)(aCap6+1)<=(TUint)ECapability_Limit sl@0: &&(TUint)(aCap7+1)<=(TUint)ECapability_Limit sl@0: ,Panic(ECapabilityInvalid)); sl@0: iExtraCaps[0] = (TUint8)aCap4; sl@0: iExtraCaps[1] = (TUint8)aCap5; sl@0: iExtraCaps[2] = (TUint8)aCap6; sl@0: iExtraCaps[3] = (TUint8)aCap7; sl@0: } sl@0: sl@0: /** Construct a TSecurityPolicy object to check a secure id and up to 3 capabilties. sl@0: @param aSecureId The secure id to add to this policy sl@0: @param aCap1 The first capability to add to this policy sl@0: @param aCap2 The second capability to add to this policy sl@0: @param aCap3 The third capability to add to this policy sl@0: @panic USER 189 If any of the supplied capabilities are not valid. sl@0: */ sl@0: EXPORT_C TSecurityPolicy::TSecurityPolicy(TSecureId aSecureId, sl@0: TCapability aCap1, TCapability aCap2, TCapability aCap3) sl@0: : iType(ETypeS3), iSecureId(aSecureId) sl@0: { sl@0: ConstructAndCheck3(aCap1, aCap2, aCap3); sl@0: } sl@0: sl@0: /** Construct a TSecurityPolicy object to check a vendor id and up to 3 capabilties. sl@0: @param aVendorId The vendor id to add to this policy sl@0: @param aCap1 The first capability to add to this policy sl@0: @param aCap2 The second capability to add to this policy sl@0: @param aCap3 The third capability to add to this policy sl@0: @panic USER 189 If any of the supplied capabilities are not valid. sl@0: */ sl@0: EXPORT_C TSecurityPolicy::TSecurityPolicy(TVendorId aVendorId, sl@0: TCapability aCap1, TCapability aCap2, TCapability aCap3) sl@0: : iType(ETypeV3), iVendorId(aVendorId) sl@0: { sl@0: ConstructAndCheck3(aCap1, aCap2, aCap3); sl@0: } sl@0: sl@0: /** Sets up iCaps[0-2] with supplied values and checks for their validity. sl@0: @panic USER 189 If any of the supplied capabilities are invalid. sl@0: */ sl@0: void TSecurityPolicy::ConstructAndCheck3(TCapability aCap1, TCapability aCap2, TCapability aCap3) sl@0: { sl@0: __ASSERT_COMPILE(ECapability_None==-1); // Our argument check below assumes this sl@0: __ASSERT_ALWAYS( (TUint)(aCap1+1)<=(TUint)ECapability_Limit sl@0: &&(TUint)(aCap2+1)<=(TUint)ECapability_Limit sl@0: &&(TUint)(aCap3+1)<=(TUint)ECapability_Limit sl@0: ,Panic(ECapabilityInvalid)); sl@0: iCaps[0] = (TUint8)aCap1; sl@0: iCaps[1] = (TUint8)aCap2; sl@0: iCaps[2] = (TUint8)aCap3; sl@0: } sl@0: sl@0: /** sl@0: Checks that this object is in a valid state sl@0: @return A non-zero value if this object is valid, zero otherwise. sl@0: @internalComponent sl@0: */ sl@0: TBool TSecurityPolicy::Validate() const sl@0: { sl@0: switch(iType) sl@0: { sl@0: case ETypeFail: sl@0: case ETypePass: sl@0: if(iSecureId!=TUint32(ECapability_None)) sl@0: return EFalse; sl@0: __ASSERT_COMPILE(TUint8(ECapability_None)==0xffu); // Test below assumes this... sl@0: if((iCaps[0]&iCaps[1]&iCaps[2])!=TUint8(ECapability_None)) // check caps 0 to 2 are each == ECapability_None sl@0: return EFalse; sl@0: return ETrue; sl@0: sl@0: case ETypeC7: sl@0: return ETrue; sl@0: sl@0: case ETypeC3: sl@0: if(iSecureId!=TUint32(ECapability_None)) sl@0: return EFalse; sl@0: return ETrue; sl@0: sl@0: case ETypeS3: sl@0: case ETypeV3: sl@0: return ETrue; sl@0: sl@0: default: sl@0: return EFalse; sl@0: } sl@0: } sl@0: sl@0: /** Sets this TSecurityPolicy to a copy of the policy described by the sl@0: supplied descriptor. Such a descriptor can be obtained from sl@0: TSecurityPolicy::Package(). sl@0: @see TSecurityPolicy::Package() sl@0: @param aDes A descriptor representing the state of another TSecurityPolicy. sl@0: @return KErrNone, if successful, otherwise one of the other system-wide error sl@0: codes. sl@0: */ sl@0: EXPORT_C TInt TSecurityPolicy::Set(const TDesC8& aDes) sl@0: { sl@0: if(aDes.Size() == sizeof(TSecurityPolicy)) sl@0: { sl@0: *this = *(TSecurityPolicy*)aDes.Ptr(); sl@0: if(Validate()) sl@0: return KErrNone; sl@0: } sl@0: // Set failed so set up the policy as an EAlwaysFail case. sl@0: iType = EAlwaysFail; sl@0: iCaps[0] = TUint8(ECapability_None); sl@0: iCaps[1] = TUint8(ECapability_None); sl@0: iCaps[2] = TUint8(ECapability_None); sl@0: iSecureId = TUint32(ECapability_None); sl@0: return KErrArgument; sl@0: } sl@0: sl@0: /** sl@0: Constructs a TPtrC8 wrapping the platform security attributes of this sl@0: TSecurityPolicy. Such a descriptor is suitable for passing across the sl@0: client server boundary. sl@0: sl@0: The format of the descriptor is determined by the first byte which specifies sl@0: the type of this TSecurityPolicy. The first byte is one of the constants sl@0: specified in the enum TSecurityPolicy::TType. sl@0: sl@0: For TSecurityPolicy objects of types ETypeC3, ETypeS3, ETypePass or ETypeFail sl@0: the descriptor will contain the following data in the order listed: sl@0: @code sl@0: TUint8 iType; // set to ETypeC3, ETypeS3, ETypePass or ETypeFail sl@0: TUint8 iCaps[3]; sl@0: TUint32 iSecureId; sl@0: @endcode sl@0: ETypeC3 descriptors will contain capabilities in iCaps but have iSecureId set sl@0: to ECapability_None. ETypeS3 are similar to ETypeC3 descriptors but will have sl@0: iSecureId set to the secure ID value of the TSecurityPolicy object. sl@0: ETypePass and ETypeFail objects will have values of all of the elements of iCaps sl@0: and iSecureId set to ECapability_None. sl@0: sl@0: For TSecurityPolicy objects of type ETypeV3 the descriptor will contain the sl@0: following data in the order listed: sl@0: @code sl@0: TUint8 iType; // set to ETypeV3 sl@0: TUint8 iCaps[3]; // set to the values of 3 capabilities sl@0: TUint32 iVendorId; // set to the value of the vendor ID of the TSecurityPolicy sl@0: @endcode sl@0: sl@0: For TSecurityPolicy objects of type ETypeC7 the descriptor will contain the sl@0: following data in the order listed: sl@0: @code sl@0: TUint8 iType; // set to ETypeC7 sl@0: TUint8 iCaps[3]; // set to the values of 3 of the objects capabilities sl@0: TUint8 iExtraCaps[4]; // set to the values of 4 of the objects capabilities sl@0: @endcode sl@0: @see TSecurityPolicy::TType sl@0: @see TSecurityPolicy::Set() sl@0: @return A TPtrC8 wrapping the platform security attributes of this TSecurityPolicy. sl@0: */ sl@0: EXPORT_C TPtrC8 TSecurityPolicy::Package() const sl@0: { sl@0: return TPtrC8((TUint8*)(this), sizeof(TSecurityPolicy)); sl@0: } sl@0: sl@0: /** Checks this policy against the supplied SSecurityInfo. sl@0: @param aSecInfo The SSecurityInfo object to check against this TSecurityPolicy. sl@0: @param aMissing A SSecurityInfo object which this method fills with any capabilities or IDs sl@0: it finds to be missing. This is designed to help generating diagnostic messages. sl@0: @return ETrue if all the requirements of this TSecurityPolicy are met, EFalse sl@0: @panic USER 190 if aSecInfo is an invalid SSecurityInfo object sl@0: otherwise. sl@0: */ sl@0: TBool TSecurityPolicy::CheckPolicy(const SSecurityInfo& aSecInfo, SSecurityInfo& aMissing) const sl@0: { sl@0: TBool result = EFalse; sl@0: //It is thought to be by far the most common case to have 3 or less sl@0: //capabilities in a policy. Hence we'll set this for all of them even sl@0: //though ETypePass doesn't need it. sl@0: aMissing.iSecureId = 0; sl@0: aMissing.iVendorId = 0; sl@0: __ASSERT_COMPILE(SCapabilitySet::ENCapW == 2); sl@0: aMissing.iCaps[0] = 0; sl@0: aMissing.iCaps[1] = 0; sl@0: aMissing.iCaps.AddCapability((TCapability)(iCaps[0])); sl@0: aMissing.iCaps.AddCapability((TCapability)(iCaps[1])); sl@0: aMissing.iCaps.AddCapability((TCapability)(iCaps[2])); sl@0: aMissing.iCaps.Remove(aSecInfo.iCaps); sl@0: switch(iType) sl@0: { sl@0: case ETypeFail: sl@0: //result already False; sl@0: break; sl@0: case ETypePass: sl@0: result = ETrue; sl@0: break; sl@0: case ETypeC7: sl@0: aMissing.iCaps.AddCapability((TCapability)(iExtraCaps[0])); sl@0: aMissing.iCaps.AddCapability((TCapability)(iExtraCaps[1])); sl@0: aMissing.iCaps.AddCapability((TCapability)(iExtraCaps[2])); sl@0: aMissing.iCaps.AddCapability((TCapability)(iExtraCaps[3])); sl@0: aMissing.iCaps.Remove(aSecInfo.iCaps); sl@0: //It is intentional that there is no break statement here sl@0: case ETypeC3: sl@0: if(!aMissing.iCaps.NotEmpty()) sl@0: { sl@0: result = ETrue; sl@0: } sl@0: break; sl@0: case ETypeS3: sl@0: if(!aMissing.iCaps.NotEmpty() && iSecureId == aSecInfo.iSecureId) sl@0: { sl@0: result = ETrue; sl@0: } sl@0: //This else if required to set the aMissing.iCaps secure id for diagnostics. sl@0: //Doesn't affect pass case. sl@0: else if(iSecureId != aSecInfo.iSecureId) sl@0: { sl@0: aMissing.iSecureId = iSecureId; sl@0: } sl@0: break; sl@0: case ETypeV3: sl@0: if(!aMissing.iCaps.NotEmpty() && iVendorId == aSecInfo.iVendorId) sl@0: { sl@0: result = ETrue; sl@0: } sl@0: else if(iVendorId != aSecInfo.iVendorId) sl@0: { sl@0: aMissing.iVendorId = iVendorId; sl@0: } sl@0: break; sl@0: default: sl@0: Panic(ESecurityPolicyCorrupt); sl@0: break; sl@0: } sl@0: return result; sl@0: } sl@0: sl@0: #ifndef __KERNEL_MODE__ sl@0: sl@0: /** Checks this policy against the platform security attributes of aProcess. sl@0: sl@0: When a check fails the action taken is determined by the system wide Platform Security sl@0: configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. sl@0: If PlatSecEnforcement is OFF, then this function will return ETrue even though the sl@0: check failed. sl@0: sl@0: @param aProcess The RProcess object to check against this TSecurityPolicy. sl@0: @param aDiagnostic A string that will be emitted along with any diagnostic message sl@0: that may be issued if the policy check fails. sl@0: This string must be enclosed in the __PLATSEC_DIAGNOSTIC_STRING macro sl@0: which enables it to be easily removed from the system. sl@0: @return ETrue if all the requirements of this TSecurityPolicy are met by the sl@0: platform security attributes of aProcess, EFalse otherwise. sl@0: @panic USER 190 if 'this' is an invalid SSecurityInfo object sl@0: */ sl@0: #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: EXPORT_C TBool TSecurityPolicy::DoCheckPolicy(RProcess aProcess, const char* aDiagnostic) const sl@0: { sl@0: SSecurityInfo missing; sl@0: TSecurityInfo secInfo(aProcess); sl@0: TBool pass = CheckPolicy(*((SSecurityInfo*)&secInfo), missing); sl@0: if(!pass) sl@0: pass = PlatSec::PolicyCheckFail(aProcess.Handle(),missing,aDiagnostic)==KErrNone; sl@0: return pass; sl@0: } sl@0: #else // !__REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: EXPORT_C TBool TSecurityPolicy::DoCheckPolicy(RProcess aProcess, const char* /*aDiagnostic*/) const sl@0: { sl@0: return DoCheckPolicy(aProcess); sl@0: } sl@0: #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: sl@0: /** Checks this policy against the platform security attributes of aProcess. sl@0: sl@0: When a check fails the action taken is determined by the system wide Platform Security sl@0: configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. sl@0: If PlatSecEnforcement is OFF, then this function will return ETrue even though the sl@0: check failed. sl@0: sl@0: @param aProcess The RProcess object to check against this TSecurityPolicy. sl@0: @return ETrue if all the requirements of this TSecurityPolicy are met by the sl@0: platform security attributes of aProcess, EFalse otherwise. sl@0: @panic USER 190 if 'this' is an invalid SSecurityInfo object sl@0: */ sl@0: EXPORT_C TBool TSecurityPolicy::DoCheckPolicy(RProcess aProcess) const sl@0: { sl@0: #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: return DoCheckPolicy(aProcess, NULL); sl@0: #else //__REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: SSecurityInfo missing; sl@0: TSecurityInfo secInfo(aProcess); sl@0: TBool pass = CheckPolicy(*((SSecurityInfo*)&secInfo), missing); sl@0: if(!pass) sl@0: pass = (PlatSec::EmitDiagnostic() == KErrNone); sl@0: return pass; sl@0: #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: } sl@0: sl@0: /** Checks this policy against the platform security attributes of the process sl@0: owning aThread. sl@0: sl@0: When a check fails the action taken is determined by the system wide Platform Security sl@0: configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. sl@0: If PlatSecEnforcement is OFF, then this function will return ETrue even though the sl@0: check failed. sl@0: sl@0: @param aThread The thread whose owning process' platform security attributes sl@0: are to be checked against this TSecurityPolicy. sl@0: @param aDiagnostic A string that will be emitted along with any diagnostic message sl@0: that may be issued if the policy check fails. sl@0: This string must be enclosed in the __PLATSEC_DIAGNOSTIC_STRING macro sl@0: which enables it to be easily removed from the system. sl@0: @return ETrue if all the requirements of this TSecurityPolicy are met by the sl@0: platform security parameters of the owning process of aThread, EFalse otherwise. sl@0: @panic USER 190 if 'this' is an invalid SSecurityInfo object sl@0: */ sl@0: #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: EXPORT_C TBool TSecurityPolicy::DoCheckPolicy(RThread aThread, const char* aDiagnostic) const sl@0: { sl@0: SSecurityInfo missing; sl@0: TSecurityInfo secInfo(aThread); sl@0: TBool pass = CheckPolicy(*((SSecurityInfo*)&secInfo), missing); sl@0: if(!pass) sl@0: pass = PlatSec::PolicyCheckFail(aThread.Handle(),missing,aDiagnostic)==KErrNone; sl@0: return pass; sl@0: } sl@0: #else //__REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: EXPORT_C TBool TSecurityPolicy::DoCheckPolicy(RThread aThread, const char* /*aDiagnostic*/) const sl@0: { sl@0: return DoCheckPolicy(aThread); sl@0: } sl@0: #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: sl@0: /** Checks this policy against the platform security attributes of the process sl@0: owning aThread. sl@0: sl@0: When a check fails the action taken is determined by the system wide Platform Security sl@0: configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. sl@0: If PlatSecEnforcement is OFF, then this function will return ETrue even though the sl@0: check failed. sl@0: sl@0: @param aThread The thread whose owning process' platform security attributes sl@0: are to be checked against this TSecurityPolicy. sl@0: @return ETrue if all the requirements of this TSecurityPolicy are met by the sl@0: platform security parameters of the owning process of aThread, EFalse otherwise. sl@0: @panic USER 190 if 'this' is an invalid SSecurityInfo object sl@0: */ sl@0: EXPORT_C TBool TSecurityPolicy::DoCheckPolicy(RThread aThread) const sl@0: { sl@0: #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: return DoCheckPolicy(aThread, NULL); sl@0: #else //__REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: SSecurityInfo missing; sl@0: TSecurityInfo secInfo(aThread); sl@0: TBool pass = CheckPolicy(*((SSecurityInfo*)&secInfo), missing); sl@0: if(!pass) sl@0: pass = (PlatSec::EmitDiagnostic() == KErrNone); sl@0: return pass; sl@0: #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: } sl@0: sl@0: TInt TSecurityPolicy::CheckPolicy(RSessionBase aSession) const sl@0: { sl@0: SSecurityInfo missing; sl@0: TSecurityInfo secInfo; sl@0: TInt r = secInfo.Set(aSession); sl@0: if (r!=KErrNone) sl@0: return r; sl@0: TBool pass = CheckPolicy(*((SSecurityInfo*)&secInfo), missing); sl@0: if(!pass) sl@0: { sl@0: #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: r = PlatSec::PolicyCheckFail(aSession.Handle(),missing,NULL); sl@0: #else sl@0: r = PlatSec::EmitDiagnostic(); sl@0: #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: } sl@0: return r; sl@0: } sl@0: sl@0: /** Checks this policy against the platform security attributes of the process which sent sl@0: the given message. sl@0: sl@0: When a check fails the action taken is determined by the system wide Platform Security sl@0: configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. sl@0: If PlatSecEnforcement is OFF, then this function will return ETrue even though the sl@0: check failed. sl@0: sl@0: @param aMsgPtr The RMessagePtr2 object to check against this TSecurityPolicy. sl@0: @param aDiagnostic A string that will be emitted along with any diagnostic message sl@0: that may be issued if the policy check fails. sl@0: This string must be enclosed in the __PLATSEC_DIAGNOSTIC_STRING macro sl@0: which enables it to be easily removed from the system. sl@0: @return ETrue if all the requirements of this TSecurityPolicy are met by the sl@0: platform security attributes of aMsg, EFalse otherwise. sl@0: @panic USER 190 if 'this' is an invalid SSecurityInfo object sl@0: */ sl@0: #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: EXPORT_C TBool TSecurityPolicy::DoCheckPolicy(RMessagePtr2 aMsgPtr, const char* aDiagnostic) const sl@0: { sl@0: SSecurityInfo missing; sl@0: TSecurityInfo secInfo(aMsgPtr); sl@0: TBool pass = CheckPolicy(*((SSecurityInfo*)&secInfo), missing); sl@0: if(!pass) sl@0: pass = PlatSec::PolicyCheckFail(aMsgPtr,missing,aDiagnostic)==KErrNone; sl@0: return pass; sl@0: } sl@0: #else //__REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: EXPORT_C TBool TSecurityPolicy::DoCheckPolicy(RMessagePtr2 aMsgPtr, const char* /*aDiagnostic*/) const sl@0: { sl@0: return DoCheckPolicy(aMsgPtr); sl@0: } sl@0: #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: sl@0: /** Checks this policy against the platform security attributes of the process which sent sl@0: the given message. sl@0: sl@0: When a check fails the action taken is determined by the system wide Platform Security sl@0: configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. sl@0: If PlatSecEnforcement is OFF, then this function will return ETrue even though the sl@0: check failed. sl@0: sl@0: @param aMsgPtr The RMessagePtr2 object to check against this TSecurityPolicy. sl@0: @return ETrue if all the requirements of this TSecurityPolicy are met by the sl@0: platform security attributes of aMsg, EFalse otherwise. sl@0: @panic USER 190 if 'this' is an invalid SSecurityInfo object sl@0: */ sl@0: EXPORT_C TBool TSecurityPolicy::DoCheckPolicy(RMessagePtr2 aMsgPtr) const sl@0: { sl@0: #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: return DoCheckPolicy(aMsgPtr, NULL); sl@0: #else //__REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: SSecurityInfo missing; sl@0: TSecurityInfo secInfo(aMsgPtr); sl@0: TBool pass = CheckPolicy(*((SSecurityInfo*)&secInfo), missing); sl@0: if(!pass) sl@0: pass = (PlatSec::EmitDiagnostic() == KErrNone); sl@0: return pass; sl@0: #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: } sl@0: sl@0: /** Checks this policy against the platform security attributes of the process which sent sl@0: the given message. sl@0: sl@0: When a check fails the action taken is determined by the system wide Platform Security sl@0: configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. sl@0: If PlatSecEnforcement is OFF, then this function will return ETrue even though the sl@0: check failed. sl@0: sl@0: @param aMsgPtr The RMessagePtr2 object to check against this TSecurityPolicy. sl@0: @param aMissing A TSecurityInfo object which this method fills with any capabilities or IDs sl@0: it finds to be missing. sl@0: @param aDiagnostic A string that will be emitted along with any diagnostic message sl@0: that may be issued if the policy check fails. sl@0: This string must be enclosed in the __PLATSEC_DIAGNOSTIC_STRING macro sl@0: which enables it to be easily removed from the system. sl@0: @return ETrue if all the requirements of this TSecurityPolicy are met by the sl@0: platform security attributes of aMsg, EFalse otherwise. sl@0: @panic USER 190 if 'this' is an invalid SSecurityInfo object sl@0: */ sl@0: #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: TBool TSecurityPolicy::DoCheckPolicy(RMessagePtr2 aMsgPtr, TSecurityInfo& aMissing, const char* aDiagnostic) const sl@0: { sl@0: TSecurityInfo secInfo(aMsgPtr); sl@0: TBool pass = CheckPolicy(*((SSecurityInfo*)&secInfo), *((SSecurityInfo*)&aMissing)); sl@0: if(!pass) sl@0: pass = PlatSec::PolicyCheckFail(aMsgPtr,*((SSecurityInfo*)&aMissing),aDiagnostic)==KErrNone; sl@0: return pass; sl@0: } sl@0: #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: sl@0: /** Checks this policy against the platform security attributes of the process which sent sl@0: the given message. sl@0: sl@0: When a check fails the action taken is determined by the system wide Platform Security sl@0: configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. sl@0: If PlatSecEnforcement is OFF, then this function will return ETrue even though the sl@0: check failed. sl@0: sl@0: @param aMsgPtr The RMessagePtr2 object to check against this TSecurityPolicy. sl@0: @param aMissing A TSecurityInfo object which this method fills with any capabilities or IDs sl@0: it finds to be missing. sl@0: @return ETrue if all the requirements of this TSecurityPolicy are met by the sl@0: platform security attributes of aMsg, EFalse otherwise. sl@0: @panic USER 190 if 'this' is an invalid SSecurityInfo object sl@0: */ sl@0: TBool TSecurityPolicy::DoCheckPolicy(RMessagePtr2 aMsgPtr, TSecurityInfo& aMissing) const sl@0: { sl@0: #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: return DoCheckPolicy(aMsgPtr, aMissing, NULL); sl@0: #else //__REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: TSecurityInfo secInfo(aMsgPtr); sl@0: TBool pass = CheckPolicy(*((SSecurityInfo*)&secInfo), *((SSecurityInfo*)&aMissing)); sl@0: if(!pass) sl@0: pass = (PlatSec::EmitDiagnostic() == KErrNone); sl@0: return pass; sl@0: #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: } sl@0: sl@0: /** Checks this policy against the platform security attributes of this process' creator. sl@0: sl@0: When a check fails the action taken is determined by the system wide Platform Security sl@0: configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. sl@0: If PlatSecEnforcement is OFF, then this function will return ETrue even though the sl@0: check failed. sl@0: sl@0: @param aProcess The RProcess object to check against this TSecurityPolicy. sl@0: @param aDiagnostic A string that will be emitted along with any diagnostic message sl@0: that may be issued if the policy check fails. sl@0: This string must be enclosed in the __PLATSEC_DIAGNOSTIC_STRING macro sl@0: which enables it to be easily removed from the system. sl@0: @return ETrue if all the requirements of this TSecurityPolicy are met by the sl@0: platform security attributes of this process' creator, EFalse otherwise. sl@0: @panic USER 190 if 'this' is an invalid SSecurityInfo object sl@0: */ sl@0: #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: EXPORT_C TBool TSecurityPolicy::DoCheckPolicyCreator(const char* aDiagnostic) const sl@0: { sl@0: SSecurityInfo missing; sl@0: TSecurityInfo secInfo; sl@0: secInfo.SetToCreatorInfo(); sl@0: TBool pass = CheckPolicy(*((SSecurityInfo*)&secInfo), missing); sl@0: if(!pass) sl@0: pass = PlatSec::CreatorPolicyCheckFail(missing,aDiagnostic)==KErrNone; sl@0: return pass; sl@0: } sl@0: #else // !__REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: EXPORT_C TBool TSecurityPolicy::DoCheckPolicyCreator(const char* /*aDiagnostic*/) const sl@0: { sl@0: return DoCheckPolicyCreator(); sl@0: } sl@0: #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: sl@0: /** Checks this policy against the platform security attributes of this process' creator. sl@0: sl@0: When a check fails the action taken is determined by the system wide Platform Security sl@0: configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. sl@0: If PlatSecEnforcement is OFF, then this function will return ETrue even though the sl@0: check failed. sl@0: sl@0: @param aProcess The RProcess object to check against this TSecurityPolicy. sl@0: @return ETrue if all the requirements of this TSecurityPolicy are met by the sl@0: platform security attributes of this process' creator, EFalse otherwise. sl@0: @panic USER 190 if 'this' is an invalid SSecurityInfo object sl@0: */ sl@0: EXPORT_C TBool TSecurityPolicy::DoCheckPolicyCreator() const sl@0: { sl@0: #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: return DoCheckPolicyCreator(NULL); sl@0: #else //__REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: SSecurityInfo missing; sl@0: TSecurityInfo secInfo; sl@0: secInfo.SetToCreatorInfo(); sl@0: TBool pass = CheckPolicy(*((SSecurityInfo*)&secInfo), missing); sl@0: if(!pass) sl@0: pass = (PlatSec::EmitDiagnostic() == KErrNone); sl@0: return pass; sl@0: #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: } sl@0: sl@0: #else //__KERNEL_MODE__ sl@0: sl@0: /** Checks this policy against the platform security attributes of aProcess. sl@0: sl@0: When a check fails the action taken is determined by the system wide Platform Security sl@0: configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. sl@0: If PlatSecEnforcement is OFF, then this function will return ETrue even though the sl@0: check failed. sl@0: sl@0: @param aProcess The DProcess object to check against this TSecurityPolicy. sl@0: @param aDiagnostic A string that will be emitted along with any diagnostic message sl@0: that may be issued if the policy check fails. sl@0: This string must be enclosed in the __PLATSEC_DIAGNOSTIC_STRING macro sl@0: which enables it to be easily removed from the system. sl@0: @return ETrue if all the requirements of this TSecurityPolicy are met by the sl@0: platform security attributes of aProcess, EFalse otherwise. sl@0: @panic KERN-COMMON 190 if 'this' is an invalid SSecurityInfo object sl@0: */ sl@0: #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: EXPORT_C TBool TSecurityPolicy::DoCheckPolicy(DProcess* aProcess, const char* aDiagnostic) const sl@0: { sl@0: SSecurityInfo missing; sl@0: TBool pass = CheckPolicy(aProcess->iS, missing); sl@0: if(!pass) sl@0: pass = PlatSec::PolicyCheckFail(aProcess,missing,aDiagnostic)==KErrNone; sl@0: return pass; sl@0: } sl@0: #else //__REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: EXPORT_C TBool TSecurityPolicy::DoCheckPolicy(DProcess* aProcess, const char* /*aDiagnostic*/) const sl@0: { sl@0: return DoCheckPolicy(aProcess); sl@0: } sl@0: #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: sl@0: /** Checks this policy against the platform security attributes of aProcess. sl@0: sl@0: When a check fails the action taken is determined by the system wide Platform Security sl@0: configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. sl@0: If PlatSecEnforcement is OFF, then this function will return ETrue even though the sl@0: check failed. sl@0: sl@0: @param aProcess The DProcess object to check against this TSecurityPolicy. sl@0: @return ETrue if all the requirements of this TSecurityPolicy are met by the sl@0: platform security attributes of aProcess, EFalse otherwise. sl@0: @panic KERN-COMMON 190 if 'this' is an invalid SSecurityInfo object sl@0: */ sl@0: EXPORT_C TBool TSecurityPolicy::DoCheckPolicy(DProcess* aProcess) const sl@0: { sl@0: #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: return DoCheckPolicy(aProcess, NULL); sl@0: #else //__REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: SSecurityInfo missing; sl@0: TBool pass = CheckPolicy(aProcess->iS, missing); sl@0: if(!pass) sl@0: pass = (PlatSec::EmitDiagnostic() == KErrNone); sl@0: return pass; sl@0: #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: } sl@0: sl@0: /** Checks this policy against the platform security attributes of the process sl@0: owning aThread. sl@0: sl@0: When a check fails the action taken is determined by the system wide Platform Security sl@0: configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. sl@0: If PlatSecEnforcement is OFF, then this function will return ETrue even though the sl@0: check failed. sl@0: sl@0: @param aThread The thread whose owning process' platform security attributes sl@0: are to be checked against this TSecurityPolicy. sl@0: @param aDiagnostic A string that will be emitted along with any diagnostic message sl@0: that may be issued if the policy check fails. sl@0: This string must be enclosed in the __PLATSEC_DIAGNOSTIC_STRING macro sl@0: which enables it to be easily removed from the system. sl@0: @return ETrue if all the requirements of this TSecurityPolicy are met by the sl@0: platform security parameters of the owning process of aThread, EFalse otherwise. sl@0: @panic KERN-COMMON 190 if 'this' is an invalid SSecurityInfo object sl@0: */ sl@0: #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: EXPORT_C TBool TSecurityPolicy::DoCheckPolicy(DThread* aThread, const char* aDiagnostic) const sl@0: { sl@0: SSecurityInfo missing; sl@0: TBool pass = CheckPolicy(aThread->iOwningProcess->iS, missing); sl@0: if(!pass) sl@0: pass = PlatSec::PolicyCheckFail(aThread,missing,aDiagnostic)==KErrNone; sl@0: return pass; sl@0: } sl@0: #else //__REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: EXPORT_C TBool TSecurityPolicy::DoCheckPolicy(DThread* aThread, const char* /*aDiagnostic*/) const sl@0: { sl@0: return DoCheckPolicy(aThread); sl@0: } sl@0: #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: sl@0: /** Checks this policy against the platform security attributes of the process sl@0: owning aThread. sl@0: sl@0: When a check fails the action taken is determined by the system wide Platform Security sl@0: configuration. If PlatSecDiagnostics is ON, then a diagnostic message is emitted. sl@0: If PlatSecEnforcement is OFF, then this function will return ETrue even though the sl@0: check failed. sl@0: sl@0: @param aThread The thread whose owning process' platform security attributes sl@0: are to be checked against this TSecurityPolicy. sl@0: @return ETrue if all the requirements of this TSecurityPolicy are met by the sl@0: platform security parameters of the owning process of aThread, EFalse otherwise. sl@0: @panic KERN-COMMON 190 if 'this' is an invalid SSecurityInfo object sl@0: */ sl@0: EXPORT_C TBool TSecurityPolicy::DoCheckPolicy(DThread* aThread) const sl@0: { sl@0: #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: return DoCheckPolicy(aThread, NULL); sl@0: #else //__REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: SSecurityInfo missing; sl@0: TBool pass = CheckPolicy(aThread->iOwningProcess->iS, missing); sl@0: if(!pass) sl@0: pass = (PlatSec::EmitDiagnostic() == KErrNone); sl@0: return pass; sl@0: #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: } sl@0: sl@0: #endif // !__KERNEL_MODE__ sl@0: sl@0: sl@0: #ifndef __KERNEL_MODE__ sl@0: sl@0: EXPORT_C TInt PlatSec::ConfigSetting(TConfigSetting aSetting) sl@0: { sl@0: TUint32 flags = Exec::KernelConfigFlags(); sl@0: switch(aSetting) sl@0: { sl@0: case EPlatSecEnforcement: sl@0: flags &= EKernelConfigPlatSecEnforcement; sl@0: break; sl@0: case EPlatSecDiagnotics: sl@0: #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: flags &= EKernelConfigPlatSecDiagnostics; sl@0: #else //__REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: flags=0; sl@0: #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__ sl@0: break; sl@0: case EPlatSecProcessIsolation: sl@0: flags &= EKernelConfigPlatSecProcessIsolation; sl@0: break; sl@0: case EPlatSecEnforceSysBin: sl@0: flags &= EKernelConfigPlatSecEnforceSysBin; sl@0: break; sl@0: case EPlatSecLocked: sl@0: flags &= EKernelConfigPlatSecLocked; sl@0: break; sl@0: default: sl@0: flags = 0; sl@0: break; sl@0: } sl@0: if(flags) sl@0: flags = 1; sl@0: return flags; sl@0: } sl@0: sl@0: EXPORT_C TBool PlatSec::IsCapabilityEnforced(TCapability aCapability) sl@0: { sl@0: if(!((TCapabilitySet&)AllSupportedCapabilities).HasCapability(aCapability)) sl@0: return EFalse; sl@0: sl@0: SCapabilitySet disabled; sl@0: Exec::DisabledCapabilities(disabled); sl@0: if(((TCapabilitySet&)disabled).HasCapability(aCapability)) sl@0: return EFalse; sl@0: sl@0: return PlatSec::ConfigSetting(EPlatSecEnforcement); sl@0: } sl@0: sl@0: #endif // Not __KERNEL_MODE__