Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ UIPolicy

unsafe CngUIPolicy System.Security.Cryptography.CngKey.UIPolicy
get

Definition at line 151 of file CngKey.cs.

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 {
180 errorCode = global::Interop.NCrypt.NCryptGetProperty(_keyHandle, "UI Policy", ptr, array.Length, out pcbResult, CngPropertyOptions.None);
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;
187 friendlyName = Marshal.PtrToStringUni(ptr2->pszFriendlyName);
188 description = Marshal.PtrToStringUni(ptr2->pszDescription);
189 creationTitle = Marshal.PtrToStringUni(ptr2->pszCreationTitle);
190 }
191 }
192 string propertyAsString = _keyHandle.GetPropertyAsString("Use Context", CngPropertyOptions.None);
193 return new CngUIPolicy(protectionLevel, friendlyName, description, propertyAsString, creationTitle);
194 }
195 }
static unsafe? string PtrToStringUni(IntPtr ptr)
Definition Marshal.cs:652
readonly SafeNCryptKeyHandle _keyHandle
Definition CngKey.cs:11