2 * Copyright (c) 2005 Apple Computer, Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
27 #include <Security/cssmapi.h>
28 #include <Security/cssmapple.h>
33 const CSSM_API_MEMORY_FUNCS gMemFuncs
=
37 (CSSM_REALLOC
)realloc
,
43 cssm_attach(const CSSM_GUID
*guid
, CSSM_HANDLE
*handle
)
47 CSSM_VERSION version
= {2, 0};
48 CSSM_PVC_MODE pvcPolicy
= CSSM_PVC_NONE
;
49 return (ok_status(CSSM_Init(&version
, CSSM_PRIVILEGE_SCOPE_NONE
,
50 &gGuidCssm
, CSSM_KEY_HIERARCHY_NONE
, &pvcPolicy
,
51 NULL
/* reserved */), "CSSM_Init") &&
52 ok_status(CSSM_ModuleLoad(guid
, CSSM_KEY_HIERARCHY_NONE
, NULL
, NULL
),
54 ok_status(CSSM_ModuleAttach(guid
, &version
, &gMemFuncs
,
55 0 /* SubserviceID */, CSSM_SERVICE_DL
, 0 /* CSSM_ATTACH_FLAGS */,
56 CSSM_KEY_HIERARCHY_NONE
, NULL
, 0, NULL
, handle
),
57 "CSSM_ModuleAttach"));
61 cssm_detach(const CSSM_GUID
*guid
, CSSM_HANDLE handle
)
65 return ok_status(CSSM_ModuleDetach(handle
), "CSSM_ModuleDetach") &&
66 ok_status(CSSM_ModuleUnload(guid
, NULL
, NULL
), "CSSM_ModuleUnload") &&
67 ok_status(CSSM_Terminate(), "CSSM_Terminate");