Example #1
0
        static CFArray ItemImport(CFData data, ref SecExternalFormat format, ref SecExternalItemType itemType,
                                  SecItemImportExportFlags flags             = SecItemImportExportFlags.None,
                                  SecItemImportExportKeyParameters?keyParams = null)
        {
            IntPtr keyParamsPtr = IntPtr.Zero;

            if (keyParams != null)
            {
                keyParamsPtr = Marshal.AllocHGlobal(Marshal.SizeOf(keyParams.Value));
                if (keyParamsPtr == IntPtr.Zero)
                {
                    throw new OutOfMemoryException();
                }
                Marshal.StructureToPtr(keyParams.Value, keyParamsPtr, false);
            }

            IntPtr result;
            var    status = SecItemImport(data.Handle, IntPtr.Zero, ref format, ref itemType, flags, keyParamsPtr, IntPtr.Zero, out result);

            if (keyParamsPtr != IntPtr.Zero)
            {
                Marshal.FreeHGlobal(keyParamsPtr);
            }

            if (status != SecStatusCode.Success)
            {
                throw new NotSupportedException(status.ToString());
            }

            return(new CFArray(result, true));
        }
Example #2
0
 extern static SecStatusCode SecItemImport(
     /* CFDataRef */ IntPtr importedData,
     /* CFStringRef */ IntPtr fileNameOrExtension,                   // optional
     /* SecExternalFormat* */ ref SecExternalFormat inputFormat,     // optional, IN/OUT
     /* SecExternalItemType* */ ref SecExternalItemType itemType,    // optional, IN/OUT
     /* SecItemImportExportFlags */ SecItemImportExportFlags flags,
     /* const SecItemImportExportKeyParameters* */ IntPtr keyParams, // optional
     /* SecKeychainRef */ IntPtr importKeychain,                     // optional
     /* CFArrayRef* */ out IntPtr outItems);
Example #3
0
 static extern OSStatus SecItemImport(IntPtr importedData, IntPtr fileName, ref SecExternalFormat format, IntPtr type, SecItemImportExportFlags flags, IntPtr keyParams, IntPtr keychain, ref IntPtr items);
Example #4
0
 static extern OSStatus SecItemExport(IntPtr itemRef, SecExternalFormat format, SecItemImportExportFlags flags, IntPtr keyParams, out IntPtr exportedData);
Example #5
0
 static CFArray ItemImport(CFData data, SecExternalFormat format, SecExternalItemType itemType,
                           SecItemImportExportFlags flags             = SecItemImportExportFlags.None,
                           SecItemImportExportKeyParameters?keyParams = null)
 {
     return(ItemImport(data, ref format, ref itemType, flags, keyParams));
 }
Example #6
0
 static extern OSStatus SecItemExport(IntPtr itemRef, SecExternalFormat format, SecItemImportExportFlags flags, IntPtr keyParams, out IntPtr exportedData);
Example #7
0
 static extern OSStatus SecItemImport(IntPtr importedData, IntPtr fileName, ref SecExternalFormat format, IntPtr type, SecItemImportExportFlags flags, IntPtr keyParams, IntPtr keychain, ref IntPtr items);