/// <summary> /// Attempts to decode the outer layer of a BLOB as a PFX packet /// </summary> /// <param name="rawData">A byte array that the method will attempt to decode as a PFX packet</param> /// <exception cref="ArgumentNullException">If the <strong>rawData</strong> parameter is null.</exception> /// <returns>The function returns <strong>TRUE</strong> if the BLOB can be decoded as a PFX packet. If the outer /// layer of the BLOB cannot be decoded as a PFX packet, the method returns <strong>FALSE.</strong></returns> public static Boolean PfxisPfxBlob(Byte[] rawData) { if (rawData != null) { IntPtr ptr = Marshal.AllocHGlobal(rawData.Length); Marshal.Copy(rawData, 0, ptr, rawData.Length); Wincrypt.CRYPTOAPI_BLOB PPfx = new Wincrypt.CRYPTOAPI_BLOB { cbData = (UInt32)rawData.Length, pbData = ptr }; Boolean result = Crypt32.PFXIsPFXBlob(PPfx); Marshal.FreeHGlobal(ptr); return(result); } throw new ArgumentNullException(nameof(rawData)); }