2 // ucsp.defs - Mach RPC interface between SecurityServer and its clients
4 #include <mach/std_types.defs>
5 #include <mach/mach_types.defs>
8 serverprefix ucsp_server_;
9 userprefix ucsp_client_;
11 import "securityserver.h";
12 import "ucsp_types.h";
18 type Data = array [] of char;
20 type Pointer = unsigned32;
21 type BasePointer = unsigned32;
23 type KeyHandle = unsigned32;
27 type DbHandle = unsigned32;
31 type AclEntryPrototypeBlob = Data
32 ctype: AclEntryPrototypePtr;
33 type AclEntryPrototypePtr = BasePointer;
35 type AclEntryInfoBlob = Data
36 ctype: AclEntryInfoPtr;
37 type AclEntryInfoPtr = BasePointer;
39 type AclEntryInputBlob = Data
40 ctype: AclEntryInputPtr;
41 type AclEntryInputPtr = BasePointer;
43 type AclOwnerPrototypeBlob = Data
44 ctype: AclOwnerPrototypePtr;
45 type AclOwnerPrototypePtr = BasePointer;
47 type AccessCredentialsBlob = Data
48 ctype: AccessCredentialsPtr;
49 type AccessCredentialsPtr = BasePointer;
51 type DLDbIdentBlob = Data
53 type DLDbIdentPtr = BasePointer;
55 type ParamInputBlob = Data
57 type ParamInputPtr = BasePointer;
61 type VoidPtr = unsigned32;
63 type SetupInfo = struct[4] of uint8_t
64 ctype: ClientSetupInfo;
66 type Context = struct [9*4] of uint8_t
68 intran: Context inTrans(CSSM_CONTEXT);
69 type ContextAttributes = array [] of char
70 cservertype: ContextAttributesPointer;
72 type CssmKeyHeader = struct [23*4] of uint8_t;
74 type CssmKey = struct [(23+2)*4] of uint8_t
76 intran: CssmKey inTrans(CSSM_KEY)
77 outtran: CSSM_KEY outTrans(CssmKey);
79 type CSSM_KEY_SIZE = struct [2*4] of uint32_t
82 type DBParameters = struct [1*4] of uint32_t;
84 type AuthorizationItemSetBlob = Data
85 ctype: AuthorizationItemSetPtr;
86 type AuthorizationItemSetPtr = BasePointer;
88 type AuthorizationBlob = struct [8] of uint8_t; // 8 opaque bytes
89 type AuthorizationExternalForm = struct [32] of uint8_t; // 32 opaque bytes
91 type CssmString = c_string[*:64+4];
92 type AuthorizationString = c_string[*:1024];
93 type CSSM_RETURN = int32;
94 type CSSM_ALGORITHMS = unsigned32;
95 type CSSM_ACL_EDIT_MODE = unsigned32;
96 type CSSM_ACL_HANDLE = unsigned32;
97 type AclKind = unsigned32;
98 type uint32 = unsigned32;
99 type SecuritySessionId = unsigned32;
100 type SessionAttributeBits = unsigned32;
101 type SessionCreationFlags = unsigned32;
103 type ExecutablePath = c_string[*:2048];
107 // Common argument profiles
109 #define UCSP_PORTS requestport sport: mach_port_t; \
110 replyport rport: mach_port_make_send_t; \
111 serveraudittoken sourceAudit: audit_token_t; \
112 out rcode: CSSM_RETURN
113 #define IN_CONTEXT in context: Context; in contextBase: BasePointer; in attrs: ContextAttributes
114 #define IN_BLOB(name,type) in name: type##Blob; in name##Base: type##Ptr
115 #define OUT_BLOB(name,type) out name: type##Blob; out name##Base: type##Ptr
119 // Management and administrative functions
121 routine setup(UCSP_PORTS; in tport: mach_port_t; in info: SetupInfo; in executablePath: ExecutablePath);
122 routine setupNew(UCSP_PORTS; in tport: mach_port_t; in info: SetupInfo; in executablePath: ExecutablePath;
123 out newServicePort: mach_port_make_send_t);
124 routine setupThread(UCSP_PORTS; in tport: mach_port_t);
125 routine teardown(UCSP_PORTS);
129 // Database management
131 routine createDb(UCSP_PORTS; out db: DbHandle; IN_BLOB(ident,DLDbIdent);
132 IN_BLOB(accessCredentials,AccessCredentials); IN_BLOB(aclEntryPrototype,AclEntryPrototype);
133 in params: DBParameters);
134 routine decodeDb(UCSP_PORTS; out db: DbHandle; IN_BLOB(ident,DLDbIdent);
135 IN_BLOB(accessCredentials,AccessCredentials); in blob: DbBlob);
136 routine encodeDb(UCSP_PORTS; in db: DbHandle; out blob: DbBlob);
137 routine releaseDb(UCSP_PORTS; in db: DbHandle);
138 routine authenticateDb(UCSP_PORTS; in db: DbHandle; IN_BLOB(accessCredentials,AccessCredentials));
139 routine setDbParameters(UCSP_PORTS; in db: DbHandle; in params: DBParameters);
140 routine getDbParameters(UCSP_PORTS; in db: DbHandle; out params: DBParameters);
141 routine changePassphrase(UCSP_PORTS; in db: DbHandle;
142 IN_BLOB(accessCredentials,AccessCredentials));
143 routine lockDb(UCSP_PORTS; in db: DbHandle);
144 routine lockAll(UCSP_PORTS; in forSleep: boolean_t);
145 routine unlockDb(UCSP_PORTS; in db: DbHandle);
146 routine unlockDbWithPassphrase(UCSP_PORTS; in db: DbHandle; in passPhrase: Data);
147 routine isLocked(UCSP_PORTS; in db: DbHandle; out locked: boolean_t);
153 routine encodeKey(UCSP_PORTS; in key: KeyHandle; out blob: KeyBlob;
154 in wantUid: boolean_t; out uid: Data);
155 routine decodeKey(UCSP_PORTS; out key: KeyHandle; out header: CssmKeyHeader;
156 in db: DbHandle; in blob: KeyBlob);
157 routine releaseKey(UCSP_PORTS; in key: KeyHandle);
159 routine queryKeySizeInBits(UCSP_PORTS; in key: KeyHandle; out length: CSSM_KEY_SIZE);
160 routine getOutputSize(UCSP_PORTS; IN_CONTEXT; in key: KeyHandle;
161 in inputSize: uint32; in encrypt: boolean_t; out outputSize: uint32);
163 routine getKeyDigest(UCSP_PORTS; in key: KeyHandle; out digest: Data);
168 routine generateRandom(UCSP_PORTS; in bytes: uint32; out data: Data);
172 // Cryptographic operations
174 routine generateSignature(UCSP_PORTS; IN_CONTEXT; in key: KeyHandle;
175 in signOnlyAlgorithm: CSSM_ALGORITHMS; in data: Data; out signature: Data);
176 routine verifySignature(UCSP_PORTS; IN_CONTEXT; in key: KeyHandle;
177 in signOnlyAlgorithm: CSSM_ALGORITHMS; in data: Data; in signature: Data);
178 routine generateMac(UCSP_PORTS; IN_CONTEXT; in key: KeyHandle;
179 in data: Data; out signature: Data);
180 routine verifyMac(UCSP_PORTS; IN_CONTEXT; in key: KeyHandle;
181 in data: Data; in signature: Data);
183 routine encrypt(UCSP_PORTS; IN_CONTEXT; in key: KeyHandle; in clear: Data; out cipher: Data);
184 routine decrypt(UCSP_PORTS; IN_CONTEXT; in key: KeyHandle; in cipher: Data; out clear: Data);
186 routine generateKey(UCSP_PORTS; in db: DbHandle; IN_CONTEXT;
187 IN_BLOB(accessCredentials,AccessCredentials); IN_BLOB(aclEntryPrototype,AclEntryPrototype);
188 in keyUsage: uint32; in keyAttrs: uint32; out key: KeyHandle; out header: CssmKeyHeader);
189 routine generateKeyPair(UCSP_PORTS; in db: DbHandle; IN_CONTEXT;
190 IN_BLOB(accessCredentials,AccessCredentials); IN_BLOB(aclEntryPrototype,AclEntryPrototype);
191 in pubUsage: uint32; in pubAttrs: uint32; in privUsage: uint32; in privAttrs: uint32;
192 out pubKey: KeyHandle; out pubHeader: CssmKeyHeader;
193 out privKey: KeyHandle; out privHeader: CssmKeyHeader);
194 routine deriveKey(UCSP_PORTS; in db: DbHandle; IN_CONTEXT; in baseKey: KeyHandle;
195 IN_BLOB(accessCredentials,AccessCredentials); IN_BLOB(aclEntryPrototype,AclEntryPrototype);
196 IN_BLOB(paramInput,ParamInput); out paramOutput: Data;
197 in keyUsage: uint32; in keyAttrs: uint32; out key: KeyHandle; out header: CssmKeyHeader);
199 routine wrapKey(UCSP_PORTS; IN_CONTEXT; in key: KeyHandle;
200 IN_BLOB(accessCredentials,AccessCredentials); in keyToBeWrapped: KeyHandle;
201 in data: Data; out wrappedKey: CssmKey; out wrappedKeyData: Data);
202 routine unwrapKey(UCSP_PORTS; in db: DbHandle; IN_CONTEXT; in key: KeyHandle;
203 IN_BLOB(accessCredentials,AccessCredentials); IN_BLOB(aclEntryPrototype,AclEntryPrototype);
204 in publicKey: KeyHandle; in wrappedKey: CssmKey; in wrappedKeyData: Data;
205 in usage: uint32; in attributes: uint32; out data: Data;
206 out resultKey: KeyHandle; out header: CssmKeyHeader);
212 routine getOwner(UCSP_PORTS; in kind: AclKind; in key: KeyHandle;
213 out proto: AclOwnerPrototypeBlob; out protoBase: AclOwnerPrototypePtr);
214 routine setOwner(UCSP_PORTS; in kind: AclKind; in key: KeyHandle;
215 IN_BLOB(accessCredentials,AccessCredentials); IN_BLOB(aclOwnerPrototype,AclOwnerPrototype));
216 routine getAcl(UCSP_PORTS; in kind: AclKind; in key: KeyHandle;
217 in haveTag: boolean_t; in tag: CssmString;
218 out count: uint32; out acls: AclEntryInfoBlob; out aclsBase: AclEntryInfoPtr);
219 routine changeAcl(UCSP_PORTS; in kind: AclKind; in key: KeyHandle;
220 IN_BLOB(accessCredentials,AccessCredentials);
221 in mode: CSSM_ACL_EDIT_MODE; in handle: CSSM_ACL_HANDLE;
222 IN_BLOB(aclEntryInput,AclEntryInput));
226 // Authorization subsystem
228 routine authorizationCreate(UCSP_PORTS; IN_BLOB(rights,AuthorizationItemSet);
230 IN_BLOB(environment,AuthorizationItemSet);
231 out authorization: AuthorizationBlob);
233 routine authorizationRelease(UCSP_PORTS; in authorization: AuthorizationBlob;
236 routine authorizationCopyRights(UCSP_PORTS; in authorization: AuthorizationBlob;
237 IN_BLOB(rights,AuthorizationItemSet); in flags: uint32;
238 IN_BLOB(environment,AuthorizationItemSet);
239 OUT_BLOB(result,AuthorizationItemSet));
241 routine authorizationCopyInfo(UCSP_PORTS; in authorization: AuthorizationBlob;
242 in tag: AuthorizationString;
243 OUT_BLOB(info,AuthorizationItemSet));
245 routine authorizationExternalize(UCSP_PORTS; in authorization: AuthorizationBlob;
246 out form: AuthorizationExternalForm);
248 routine authorizationInternalize(UCSP_PORTS; in form: AuthorizationExternalForm;
249 out authorization: AuthorizationBlob);
253 // Session management subsystem
255 routine getSessionInfo(UCSP_PORTS; inout sessionId: SecuritySessionId;
256 out attrs: SessionAttributeBits);
258 routine setupSession(UCSP_PORTS; in flags: SessionCreationFlags; in attrs: SessionAttributeBits);
262 // Notification subsystem
264 routine requestNotification(UCSP_PORTS; in receiver: mach_port_t; in domain: uint32; in events: uint32);
265 routine stopNotification(UCSP_PORTS; in receiver: mach_port_t);
266 routine postNotification(UCSP_PORTS; in domain: uint32; in event: uint32; in data: Data);
270 // Database key management
272 routine extractMasterKey(UCSP_PORTS; in db: DbHandle; IN_CONTEXT; in sourceDb: DbHandle;
273 IN_BLOB(accessCredentials,AccessCredentials); IN_BLOB(aclEntryPrototype,AclEntryPrototype);
274 in keyUsage: uint32; in keyAttrs: uint32; out key: KeyHandle; out header: CssmKeyHeader);
276 routine getDbIndex(UCSP_PORTS; in db: DbHandle; out index: Data);
279 // AuthorizationDB operations
281 routine authorizationdbGet(UCSP_PORTS; in rightname: AuthorizationString; out rightdefinition: Data);
282 routine authorizationdbSet(UCSP_PORTS; in authorization: AuthorizationBlob; in rightname: AuthorizationString; in rightDefinition: Data);
283 routine authorizationdbRemove(UCSP_PORTS; in authorization: AuthorizationBlob; in rightname: AuthorizationString);
287 // Miscellaneous administrative calls
289 routine addCodeEquivalence(UCSP_PORTS; in oldCode: Data; in newCode: Data; in name: ExecutablePath;
290 in forSystem: boolean_t);
291 routine removeCodeEquivalence(UCSP_PORTS; in code: Data; in name: ExecutablePath;
292 in forSystem: boolean_t);
293 routine setAlternateSystemRoot(UCSP_PORTS; in path: ExecutablePath);