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 KeyHandle = unsigned32;
24 type DbHandle = unsigned32;
28 type AclEntryPrototypeBlob = Data
29 ctype: AclEntryPrototypePtr;
30 type AclEntryPrototypePtr = unsigned32;
32 type AclEntryInfoBlob = Data
33 ctype: AclEntryInfoPtr;
34 type AclEntryInfoPtr = unsigned32;
36 type AclOwnerPrototypeBlob = Data
37 ctype: AclOwnerPrototypePtr;
38 type AclOwnerPrototypePtr = unsigned32;
40 type AccessCredentialsBlob = Data
41 ctype: AccessCredentialsPtr;
42 type AccessCredentialsPtr = unsigned32;
44 type DLDbIdentBlob = Data
46 type DLDbIdentPtr = unsigned32;
48 type Context = struct [9] of unsigned32
50 intran: Context inTrans(CSSM_CONTEXT);
51 type ContextAttributes = array [] of char
52 cservertype: ContextAttributesPointer;
54 type CssmKeyHeader = struct [23] of unsigned32;
56 type CssmKey = struct [23+2] of unsigned32
58 intran: CssmKey inTrans(CSSM_KEY)
59 outtran: CSSM_KEY outTrans(CssmKey);
61 type DBParameters = struct [1] of unsigned32;
63 type AuthorizationItemSetBlob = Data
64 ctype: AuthorizationItemSetPtr;
65 type AuthorizationItemSetPtr = unsigned32;
67 type AuthorizationBlob = struct [2] of unsigned32; // 8 opaque bytes
68 type AuthorizationExternalForm = struct [8] of unsigned32; // 32 opaque bytes
70 type CssmString = c_string[*:64+4];
71 type AuthorizationString = c_string[*:1024];
72 type CSSM_RETURN = int32;
73 type CSSM_ALGORITHMS = unsigned32;
74 type CSSM_ACL_EDIT_MODE = unsigned32;
75 type CSSM_ACL_HANDLE = unsigned32;
76 type AclKind = unsigned32;
77 type uint32 = unsigned32;
78 type SecuritySessionId = unsigned32;
79 type SessionAttributeBits = unsigned32;
80 type SessionCreationFlags = unsigned32;
82 type Pointer = unsigned32;
84 type ExecutablePath = c_string[*:2048];
88 // Common argument profiles
90 #define UCSP_PORTS requestport sport: mach_port_t; \
91 replyport rport: mach_port_make_send_t; \
92 serversectoken sourceSecurity: security_token_t; \
93 out rcode: CSSM_RETURN
94 #define IN_CONTEXT in context: Context; in contextBase: Pointer; in attrs: ContextAttributes
95 #define IN_BLOB(name,type) in name: type##Blob; in name##Base: type##Ptr
96 #define OUT_BLOB(name,type) out name: type##Blob; out name##Base: type##Ptr
100 // Management and administrative functions
102 routine setup(UCSP_PORTS; in tport: mach_port_t; in executablePath: ExecutablePath);
103 routine teardown(UCSP_PORTS);
107 // Database management
109 routine createDb(UCSP_PORTS; out db: DbHandle; IN_BLOB(ident,DLDbIdent);
110 IN_BLOB(accessCredentials,AccessCredentials); IN_BLOB(aclEntryPrototype,AclEntryPrototype);
111 in params: DBParameters);
112 routine decodeDb(UCSP_PORTS; out db: DbHandle; IN_BLOB(ident,DLDbIdent);
113 IN_BLOB(accessCredentials,AccessCredentials); in blob: DbBlob);
114 routine encodeDb(UCSP_PORTS; in db: DbHandle; out blob: DbBlob);
115 routine releaseDb(UCSP_PORTS; in db: DbHandle);
116 routine authenticateDb(UCSP_PORTS; in db: DbHandle; IN_BLOB(accessCredentials,AccessCredentials));
117 routine setDbParameters(UCSP_PORTS; in db: DbHandle; in params: DBParameters);
118 routine getDbParameters(UCSP_PORTS; in db: DbHandle; out params: DBParameters);
119 routine changePassphrase(UCSP_PORTS; in db: DbHandle;
120 IN_BLOB(accessCredentials,AccessCredentials));
121 routine lockDb(UCSP_PORTS; in db: DbHandle);
122 routine unlockDb(UCSP_PORTS; in db: DbHandle);
123 routine unlockDbWithPassphrase(UCSP_PORTS; in db: DbHandle; in passPhrase: Data);
124 routine isLocked(UCSP_PORTS; in db: DbHandle; out locked: boolean_t);
130 routine encodeKey(UCSP_PORTS; in key: KeyHandle; out blob: KeyBlob;
131 in wantUid: boolean_t; out uid: Data);
132 routine decodeKey(UCSP_PORTS; out key: KeyHandle; out header: CssmKeyHeader;
133 in db: DbHandle; in blob: KeyBlob);
134 routine releaseKey(UCSP_PORTS; in key: KeyHandle);
140 routine generateRandom(UCSP_PORTS; in bytes: uint32; out data: Data);
144 // Cryptographic operations
146 routine generateSignature(UCSP_PORTS; IN_CONTEXT; in key: KeyHandle;
147 in data: Data; out signature: Data);
148 routine verifySignature(UCSP_PORTS; IN_CONTEXT; in key: KeyHandle;
149 in data: Data; in signature: Data);
150 routine generateMac(UCSP_PORTS; IN_CONTEXT; in key: KeyHandle;
151 in data: Data; out signature: Data);
152 routine verifyMac(UCSP_PORTS; IN_CONTEXT; in key: KeyHandle;
153 in data: Data; in signature: Data);
155 routine encrypt(UCSP_PORTS; IN_CONTEXT; in key: KeyHandle; in clear: Data; out cipher: Data);
156 routine decrypt(UCSP_PORTS; IN_CONTEXT; in key: KeyHandle; in cipher: Data; out clear: Data);
158 routine generateKey(UCSP_PORTS; in db: DbHandle; IN_CONTEXT;
159 IN_BLOB(accessCredentials,AccessCredentials); IN_BLOB(aclEntryPrototype,AclEntryPrototype);
160 in keyUsage: uint32; in keyAttrs: uint32; out key: KeyHandle; out header: CssmKeyHeader);
161 routine generateKeyPair(UCSP_PORTS; in db: DbHandle; IN_CONTEXT;
162 IN_BLOB(accessCredentials,AccessCredentials); IN_BLOB(aclEntryPrototype,AclEntryPrototype);
163 in pubUsage: uint32; in pubAttrs: uint32; in privUsage: uint32; in privAttrs: uint32;
164 out pubKey: KeyHandle; out pubHeader: CssmKeyHeader;
165 out privKey: KeyHandle; out privHeader: CssmKeyHeader);
167 routine wrapKey(UCSP_PORTS; IN_CONTEXT; in key: KeyHandle;
168 IN_BLOB(accessCredentials,AccessCredentials); in keyToBeWrapped: KeyHandle;
169 in data: Data; out wrappedKey: CssmKey; out wrappedKeyData: Data);
170 routine unwrapKey(UCSP_PORTS; in db: DbHandle; IN_CONTEXT; in key: KeyHandle;
171 IN_BLOB(accessCredentials,AccessCredentials); IN_BLOB(aclEntryPrototype,AclEntryPrototype);
172 in publicKey: KeyHandle; in wrappedKey: CssmKey; in wrappedKeyData: Data;
173 in usage: uint32; in attributes: uint32; out data: Data;
174 out resultKey: KeyHandle; out header: CssmKeyHeader);
180 routine getOwner(UCSP_PORTS; in kind: AclKind; in key: KeyHandle;
181 out proto: AclOwnerPrototypeBlob; out protoBase: AclOwnerPrototypePtr);
182 routine setOwner(UCSP_PORTS; in kind: AclKind; in key: KeyHandle;
183 IN_BLOB(accessCredentials,AccessCredentials); IN_BLOB(aclOwnerPrototype,AclOwnerPrototype));
184 routine getAcl(UCSP_PORTS; in kind: AclKind; in key: KeyHandle;
185 in haveTag: boolean_t; in tag: CssmString;
186 out count: uint32; out acls: AclEntryInfoBlob; out aclsBase: AclEntryInfoPtr);
187 routine changeAcl(UCSP_PORTS; in kind: AclKind; in key: KeyHandle;
188 IN_BLOB(accessCredentials,AccessCredentials);
189 in mode: CSSM_ACL_EDIT_MODE; in handle: CSSM_ACL_HANDLE;
190 IN_BLOB(aclEntryPrototype,AclEntryPrototype));
194 // Authorization subsystem
196 routine authorizationCreate(UCSP_PORTS; IN_BLOB(rights,AuthorizationItemSet);
198 IN_BLOB(environment,AuthorizationItemSet);
199 out authorization: AuthorizationBlob);
201 routine authorizationRelease(UCSP_PORTS; in authorization: AuthorizationBlob;
204 routine authorizationCopyRights(UCSP_PORTS; in authorization: AuthorizationBlob;
205 IN_BLOB(rights,AuthorizationItemSet); in flags: uint32;
206 IN_BLOB(environment,AuthorizationItemSet);
207 OUT_BLOB(result,AuthorizationItemSet));
209 routine authorizationCopyInfo(UCSP_PORTS; in authorization: AuthorizationBlob;
210 in tag: AuthorizationString;
211 OUT_BLOB(info,AuthorizationItemSet));
213 routine authorizationExternalize(UCSP_PORTS; in authorization: AuthorizationBlob;
214 out form: AuthorizationExternalForm);
216 routine authorizationInternalize(UCSP_PORTS; in form: AuthorizationExternalForm;
217 out authorization: AuthorizationBlob);
221 // Session management subsystem
223 routine getSessionInfo(UCSP_PORTS; inout sessionId: SecuritySessionId;
224 out attrs: SessionAttributeBits);
226 routine setupSession(UCSP_PORTS; in flags: SessionCreationFlags; in attrs: SessionAttributeBits);