1247 {
1249 try
1250 {
1252 {
1254 throw hRForLastWin32Error.ToCryptographicException();
1255 }
1256 int dwDataLen = 0;
1257 if (!global::Interop.Advapi32.CryptExportKey(hKey, phKey, 1, 0, null, ref dwDataLen))
1258 {
1260 throw hRForLastWin32Error2.ToCryptographicException();
1261 }
1262 byte[]
array =
new byte[dwDataLen];
1263 if (!global::Interop.Advapi32.CryptExportKey(hKey, phKey, 1, 0,
array, ref dwDataLen))
1264 {
1266 throw hRForLastWin32Error3.ToCryptographicException();
1267 }
1268 int num = 8;
1269 int num2 = num + 4;
1270 int num3 = checked(dwDataLen - num - 4 - 2);
1271 while (num3 > 0 &&
array[num3 + num2] != 0)
1272 {
1273 num3--;
1274 }
1275 key_out = new byte[num3];
1278 cb_out = num3;
1279 }
1280 finally
1281 {
1282 phKey?.Dispose();
1283 }
1284 }
static ReadOnlySpan< byte > RgbPubKey
static unsafe bool CryptImportKey(SafeProvHandle hProv, ReadOnlySpan< byte > pbData, SafeKeyHandle hPubKey, int dwFlags, out SafeKeyHandle phKey)
static void Reverse(Array array)
static void BlockCopy(Array src, int srcOffset, Array dst, int dstOffset, int count)
static int GetHRForLastWin32Error()
static SafeKeyHandle InvalidHandle