152 {
153 get
154 {
155 global::Interop.NCrypt.ErrorCode errorCode = global::Interop.NCrypt.NCryptGetProperty(
_keyHandle,
"UI Policy",
null, 0, out var pcbResult,
CngPropertyOptions.None);
156 if (errorCode != 0 && errorCode != global::Interop.NCrypt.ErrorCode.NTE_NOT_FOUND)
157 {
158 throw errorCode.ToCryptographicException();
159 }
160 CngUIProtectionLevels protectionLevel;
161 string friendlyName;
162 string description;
163 string creationTitle;
164 if (errorCode != 0 || pcbResult == 0)
165 {
166 protectionLevel = CngUIProtectionLevels.None;
167 friendlyName = null;
168 description = null;
169 creationTitle = null;
170 }
171 else
172 {
173 if (pcbResult < sizeof(global::Interop.NCrypt.NCRYPT_UI_POLICY))
174 {
175 throw global::Interop.NCrypt.ErrorCode.E_FAIL.ToCryptographicException();
176 }
177 byte[]
array =
new byte[pcbResult];
178 fixed (
byte* ptr = &
array[0])
179 {
181 if (errorCode != 0)
182 {
183 throw errorCode.ToCryptographicException();
184 }
185 global::Interop.NCrypt.NCRYPT_UI_POLICY* ptr2 = (global::Interop.NCrypt.NCRYPT_UI_POLICY*)ptr;
186 protectionLevel = ptr2->dwFlags;
190 }
191 }
193 return new CngUIPolicy(protectionLevel, friendlyName, description, propertyAsString, creationTitle);
194 }
195 }
static unsafe? string PtrToStringUni(IntPtr ptr)
readonly SafeNCryptKeyHandle _keyHandle