Kenny Root | 6b77645 | 2012-11-02 15:40:32 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.security; |
| 18 | |
| 19 | import android.os.Binder; |
| 20 | import android.os.IBinder; |
| 21 | import android.os.IInterface; |
| 22 | import android.os.Parcel; |
| 23 | import android.os.RemoteException; |
| 24 | |
| 25 | /** |
| 26 | * This must be kept manually in sync with system/security/keystore until AIDL |
| 27 | * can generate both Java and C++ bindings. |
| 28 | * |
| 29 | * @hide |
| 30 | */ |
| 31 | public interface IKeystoreService extends IInterface { |
| 32 | public static abstract class Stub extends Binder implements IKeystoreService { |
| 33 | private static class Proxy implements IKeystoreService { |
| 34 | private final IBinder mRemote; |
| 35 | |
| 36 | Proxy(IBinder remote) { |
| 37 | mRemote = remote; |
| 38 | } |
| 39 | |
| 40 | public IBinder asBinder() { |
| 41 | return mRemote; |
| 42 | } |
| 43 | |
| 44 | public String getInterfaceDescriptor() { |
| 45 | return DESCRIPTOR; |
| 46 | } |
| 47 | |
| 48 | public int test() throws RemoteException { |
| 49 | Parcel _data = Parcel.obtain(); |
| 50 | Parcel _reply = Parcel.obtain(); |
| 51 | int _result; |
| 52 | try { |
| 53 | _data.writeInterfaceToken(DESCRIPTOR); |
| 54 | mRemote.transact(Stub.TRANSACTION_test, _data, _reply, 0); |
| 55 | _reply.readException(); |
| 56 | _result = _reply.readInt(); |
| 57 | } finally { |
| 58 | _reply.recycle(); |
| 59 | _data.recycle(); |
| 60 | } |
| 61 | return _result; |
| 62 | } |
| 63 | |
| 64 | public byte[] get(String name) throws RemoteException { |
| 65 | Parcel _data = Parcel.obtain(); |
| 66 | Parcel _reply = Parcel.obtain(); |
| 67 | byte[] _result; |
| 68 | try { |
| 69 | _data.writeInterfaceToken(DESCRIPTOR); |
| 70 | _data.writeString(name); |
| 71 | mRemote.transact(Stub.TRANSACTION_get, _data, _reply, 0); |
| 72 | _reply.readException(); |
| 73 | _result = _reply.createByteArray(); |
| 74 | } finally { |
| 75 | _reply.recycle(); |
| 76 | _data.recycle(); |
| 77 | } |
| 78 | return _result; |
| 79 | } |
| 80 | |
Kenny Root | a3788b0 | 2013-04-10 10:37:55 -0700 | [diff] [blame] | 81 | public int insert(String name, byte[] item, int uid, int flags) throws RemoteException { |
Kenny Root | 6b77645 | 2012-11-02 15:40:32 -0700 | [diff] [blame] | 82 | Parcel _data = Parcel.obtain(); |
| 83 | Parcel _reply = Parcel.obtain(); |
| 84 | int _result; |
| 85 | try { |
| 86 | _data.writeInterfaceToken(DESCRIPTOR); |
| 87 | _data.writeString(name); |
| 88 | _data.writeByteArray(item); |
Kenny Root | e151f28 | 2013-02-13 15:22:25 -0800 | [diff] [blame] | 89 | _data.writeInt(uid); |
Kenny Root | a3788b0 | 2013-04-10 10:37:55 -0700 | [diff] [blame] | 90 | _data.writeInt(flags); |
Kenny Root | 6b77645 | 2012-11-02 15:40:32 -0700 | [diff] [blame] | 91 | mRemote.transact(Stub.TRANSACTION_insert, _data, _reply, 0); |
| 92 | _reply.readException(); |
| 93 | _result = _reply.readInt(); |
| 94 | } finally { |
| 95 | _reply.recycle(); |
| 96 | _data.recycle(); |
| 97 | } |
| 98 | return _result; |
| 99 | } |
| 100 | |
Kenny Root | e151f28 | 2013-02-13 15:22:25 -0800 | [diff] [blame] | 101 | public int del(String name, int uid) throws RemoteException { |
Kenny Root | 6b77645 | 2012-11-02 15:40:32 -0700 | [diff] [blame] | 102 | Parcel _data = Parcel.obtain(); |
| 103 | Parcel _reply = Parcel.obtain(); |
| 104 | int _result; |
| 105 | try { |
| 106 | _data.writeInterfaceToken(DESCRIPTOR); |
| 107 | _data.writeString(name); |
Kenny Root | e151f28 | 2013-02-13 15:22:25 -0800 | [diff] [blame] | 108 | _data.writeInt(uid); |
Kenny Root | 6b77645 | 2012-11-02 15:40:32 -0700 | [diff] [blame] | 109 | mRemote.transact(Stub.TRANSACTION_del, _data, _reply, 0); |
| 110 | _reply.readException(); |
| 111 | _result = _reply.readInt(); |
| 112 | } finally { |
| 113 | _reply.recycle(); |
| 114 | _data.recycle(); |
| 115 | } |
| 116 | return _result; |
| 117 | } |
| 118 | |
Kenny Root | e151f28 | 2013-02-13 15:22:25 -0800 | [diff] [blame] | 119 | public int exist(String name, int uid) throws RemoteException { |
Kenny Root | 6b77645 | 2012-11-02 15:40:32 -0700 | [diff] [blame] | 120 | Parcel _data = Parcel.obtain(); |
| 121 | Parcel _reply = Parcel.obtain(); |
| 122 | int _result; |
| 123 | try { |
| 124 | _data.writeInterfaceToken(DESCRIPTOR); |
| 125 | _data.writeString(name); |
Kenny Root | e151f28 | 2013-02-13 15:22:25 -0800 | [diff] [blame] | 126 | _data.writeInt(uid); |
Kenny Root | 6b77645 | 2012-11-02 15:40:32 -0700 | [diff] [blame] | 127 | mRemote.transact(Stub.TRANSACTION_exist, _data, _reply, 0); |
| 128 | _reply.readException(); |
| 129 | _result = _reply.readInt(); |
| 130 | } finally { |
| 131 | _reply.recycle(); |
| 132 | _data.recycle(); |
| 133 | } |
| 134 | return _result; |
| 135 | } |
| 136 | |
Kenny Root | e151f28 | 2013-02-13 15:22:25 -0800 | [diff] [blame] | 137 | public String[] saw(String name, int uid) throws RemoteException { |
Kenny Root | 6b77645 | 2012-11-02 15:40:32 -0700 | [diff] [blame] | 138 | Parcel _data = Parcel.obtain(); |
| 139 | Parcel _reply = Parcel.obtain(); |
| 140 | String[] _result; |
| 141 | try { |
| 142 | _data.writeInterfaceToken(DESCRIPTOR); |
| 143 | _data.writeString(name); |
Kenny Root | e151f28 | 2013-02-13 15:22:25 -0800 | [diff] [blame] | 144 | _data.writeInt(uid); |
Kenny Root | 6b77645 | 2012-11-02 15:40:32 -0700 | [diff] [blame] | 145 | mRemote.transact(Stub.TRANSACTION_saw, _data, _reply, 0); |
| 146 | _reply.readException(); |
| 147 | int size = _reply.readInt(); |
| 148 | _result = new String[size]; |
| 149 | for (int i = 0; i < size; i++) { |
| 150 | _result[i] = _reply.readString(); |
| 151 | } |
Kenny Root | 78ad849 | 2013-02-13 17:02:57 -0800 | [diff] [blame] | 152 | int _ret = _reply.readInt(); |
| 153 | if (_ret != 1) { |
| 154 | return null; |
| 155 | } |
Kenny Root | 6b77645 | 2012-11-02 15:40:32 -0700 | [diff] [blame] | 156 | } finally { |
| 157 | _reply.recycle(); |
| 158 | _data.recycle(); |
| 159 | } |
| 160 | return _result; |
| 161 | } |
| 162 | |
| 163 | @Override |
| 164 | public int reset() throws RemoteException { |
| 165 | Parcel _data = Parcel.obtain(); |
| 166 | Parcel _reply = Parcel.obtain(); |
| 167 | int _result; |
| 168 | try { |
| 169 | _data.writeInterfaceToken(DESCRIPTOR); |
| 170 | mRemote.transact(Stub.TRANSACTION_reset, _data, _reply, 0); |
| 171 | _reply.readException(); |
| 172 | _result = _reply.readInt(); |
| 173 | } finally { |
| 174 | _reply.recycle(); |
| 175 | _data.recycle(); |
| 176 | } |
| 177 | return _result; |
| 178 | } |
| 179 | |
| 180 | public int password(String password) throws RemoteException { |
| 181 | Parcel _data = Parcel.obtain(); |
| 182 | Parcel _reply = Parcel.obtain(); |
| 183 | int _result; |
| 184 | try { |
| 185 | _data.writeInterfaceToken(DESCRIPTOR); |
| 186 | _data.writeString(password); |
| 187 | mRemote.transact(Stub.TRANSACTION_password, _data, _reply, 0); |
| 188 | _reply.readException(); |
| 189 | _result = _reply.readInt(); |
| 190 | } finally { |
| 191 | _reply.recycle(); |
| 192 | _data.recycle(); |
| 193 | } |
| 194 | return _result; |
| 195 | } |
| 196 | |
| 197 | public int lock() throws RemoteException { |
| 198 | Parcel _data = Parcel.obtain(); |
| 199 | Parcel _reply = Parcel.obtain(); |
| 200 | int _result; |
| 201 | try { |
| 202 | _data.writeInterfaceToken(DESCRIPTOR); |
| 203 | mRemote.transact(Stub.TRANSACTION_lock, _data, _reply, 0); |
| 204 | _reply.readException(); |
| 205 | _result = _reply.readInt(); |
| 206 | } finally { |
| 207 | _reply.recycle(); |
| 208 | _data.recycle(); |
| 209 | } |
| 210 | return _result; |
| 211 | } |
| 212 | |
| 213 | public int unlock(String password) throws RemoteException { |
| 214 | Parcel _data = Parcel.obtain(); |
| 215 | Parcel _reply = Parcel.obtain(); |
| 216 | int _result; |
| 217 | try { |
| 218 | _data.writeInterfaceToken(DESCRIPTOR); |
| 219 | _data.writeString(password); |
| 220 | mRemote.transact(Stub.TRANSACTION_unlock, _data, _reply, 0); |
| 221 | _reply.readException(); |
| 222 | _result = _reply.readInt(); |
| 223 | } finally { |
| 224 | _reply.recycle(); |
| 225 | _data.recycle(); |
| 226 | } |
| 227 | return _result; |
| 228 | } |
| 229 | |
| 230 | @Override |
| 231 | public int zero() throws RemoteException { |
| 232 | Parcel _data = Parcel.obtain(); |
| 233 | Parcel _reply = Parcel.obtain(); |
| 234 | int _result; |
| 235 | try { |
| 236 | _data.writeInterfaceToken(DESCRIPTOR); |
| 237 | mRemote.transact(Stub.TRANSACTION_zero, _data, _reply, 0); |
| 238 | _reply.readException(); |
| 239 | _result = _reply.readInt(); |
| 240 | } finally { |
| 241 | _reply.recycle(); |
| 242 | _data.recycle(); |
| 243 | } |
| 244 | return _result; |
| 245 | } |
| 246 | |
Kenny Root | a398598 | 2013-08-16 14:03:29 -0700 | [diff] [blame] | 247 | public int generate(String name, int uid, int keyType, int keySize, int flags, |
| 248 | byte[][] args) throws RemoteException { |
Kenny Root | 6b77645 | 2012-11-02 15:40:32 -0700 | [diff] [blame] | 249 | Parcel _data = Parcel.obtain(); |
| 250 | Parcel _reply = Parcel.obtain(); |
| 251 | int _result; |
| 252 | try { |
| 253 | _data.writeInterfaceToken(DESCRIPTOR); |
| 254 | _data.writeString(name); |
Kenny Root | e151f28 | 2013-02-13 15:22:25 -0800 | [diff] [blame] | 255 | _data.writeInt(uid); |
Kenny Root | a398598 | 2013-08-16 14:03:29 -0700 | [diff] [blame] | 256 | _data.writeInt(keyType); |
| 257 | _data.writeInt(keySize); |
Kenny Root | a3788b0 | 2013-04-10 10:37:55 -0700 | [diff] [blame] | 258 | _data.writeInt(flags); |
Kenny Root | a398598 | 2013-08-16 14:03:29 -0700 | [diff] [blame] | 259 | if (args == null) { |
| 260 | _data.writeInt(0); |
| 261 | } else { |
| 262 | _data.writeInt(args.length); |
| 263 | for (int i = 0; i < args.length; i++) { |
| 264 | _data.writeByteArray(args[i]); |
| 265 | } |
| 266 | } |
Kenny Root | 6b77645 | 2012-11-02 15:40:32 -0700 | [diff] [blame] | 267 | mRemote.transact(Stub.TRANSACTION_generate, _data, _reply, 0); |
| 268 | _reply.readException(); |
| 269 | _result = _reply.readInt(); |
| 270 | } finally { |
| 271 | _reply.recycle(); |
| 272 | _data.recycle(); |
| 273 | } |
| 274 | return _result; |
| 275 | } |
| 276 | |
Kenny Root | a3788b0 | 2013-04-10 10:37:55 -0700 | [diff] [blame] | 277 | public int import_key(String name, byte[] data, int uid, int flags) |
| 278 | throws RemoteException { |
Kenny Root | 6b77645 | 2012-11-02 15:40:32 -0700 | [diff] [blame] | 279 | Parcel _data = Parcel.obtain(); |
| 280 | Parcel _reply = Parcel.obtain(); |
| 281 | int _result; |
| 282 | try { |
| 283 | _data.writeInterfaceToken(DESCRIPTOR); |
| 284 | _data.writeString(name); |
| 285 | _data.writeByteArray(data); |
Kenny Root | e151f28 | 2013-02-13 15:22:25 -0800 | [diff] [blame] | 286 | _data.writeInt(uid); |
Kenny Root | a3788b0 | 2013-04-10 10:37:55 -0700 | [diff] [blame] | 287 | _data.writeInt(flags); |
Kenny Root | 6b77645 | 2012-11-02 15:40:32 -0700 | [diff] [blame] | 288 | mRemote.transact(Stub.TRANSACTION_import, _data, _reply, 0); |
| 289 | _reply.readException(); |
| 290 | _result = _reply.readInt(); |
| 291 | } finally { |
| 292 | _reply.recycle(); |
| 293 | _data.recycle(); |
| 294 | } |
| 295 | return _result; |
| 296 | } |
| 297 | |
| 298 | public byte[] sign(String name, byte[] data) throws RemoteException { |
| 299 | Parcel _data = Parcel.obtain(); |
| 300 | Parcel _reply = Parcel.obtain(); |
| 301 | byte[] _result; |
| 302 | try { |
| 303 | _data.writeInterfaceToken(DESCRIPTOR); |
| 304 | _data.writeString(name); |
| 305 | _data.writeByteArray(data); |
| 306 | mRemote.transact(Stub.TRANSACTION_sign, _data, _reply, 0); |
| 307 | _reply.readException(); |
| 308 | _result = _reply.createByteArray(); |
| 309 | } finally { |
| 310 | _reply.recycle(); |
| 311 | _data.recycle(); |
| 312 | } |
| 313 | return _result; |
| 314 | } |
| 315 | |
| 316 | public int verify(String name, byte[] data, byte[] signature) throws RemoteException { |
| 317 | Parcel _data = Parcel.obtain(); |
| 318 | Parcel _reply = Parcel.obtain(); |
| 319 | int _result; |
| 320 | try { |
| 321 | _data.writeInterfaceToken(DESCRIPTOR); |
| 322 | _data.writeString(name); |
| 323 | _data.writeByteArray(data); |
| 324 | _data.writeByteArray(signature); |
| 325 | mRemote.transact(Stub.TRANSACTION_verify, _data, _reply, 0); |
| 326 | _reply.readException(); |
| 327 | _result = _reply.readInt(); |
| 328 | } finally { |
| 329 | _reply.recycle(); |
| 330 | _data.recycle(); |
| 331 | } |
| 332 | return _result; |
| 333 | } |
| 334 | |
| 335 | public byte[] get_pubkey(String name) throws RemoteException { |
| 336 | Parcel _data = Parcel.obtain(); |
| 337 | Parcel _reply = Parcel.obtain(); |
| 338 | byte[] _result; |
| 339 | try { |
| 340 | _data.writeInterfaceToken(DESCRIPTOR); |
| 341 | _data.writeString(name); |
| 342 | mRemote.transact(Stub.TRANSACTION_get_pubkey, _data, _reply, 0); |
| 343 | _reply.readException(); |
| 344 | _result = _reply.createByteArray(); |
| 345 | } finally { |
| 346 | _reply.recycle(); |
| 347 | _data.recycle(); |
| 348 | } |
| 349 | return _result; |
| 350 | } |
| 351 | |
Kenny Root | e151f28 | 2013-02-13 15:22:25 -0800 | [diff] [blame] | 352 | public int del_key(String name, int uid) throws RemoteException { |
Kenny Root | 6b77645 | 2012-11-02 15:40:32 -0700 | [diff] [blame] | 353 | Parcel _data = Parcel.obtain(); |
| 354 | Parcel _reply = Parcel.obtain(); |
| 355 | int _result; |
| 356 | try { |
| 357 | _data.writeInterfaceToken(DESCRIPTOR); |
| 358 | _data.writeString(name); |
Kenny Root | e151f28 | 2013-02-13 15:22:25 -0800 | [diff] [blame] | 359 | _data.writeInt(uid); |
Kenny Root | 6b77645 | 2012-11-02 15:40:32 -0700 | [diff] [blame] | 360 | mRemote.transact(Stub.TRANSACTION_del_key, _data, _reply, 0); |
| 361 | _reply.readException(); |
| 362 | _result = _reply.readInt(); |
| 363 | } finally { |
| 364 | _reply.recycle(); |
| 365 | _data.recycle(); |
| 366 | } |
| 367 | return _result; |
| 368 | } |
| 369 | |
| 370 | public int grant(String name, int granteeUid) throws RemoteException { |
| 371 | Parcel _data = Parcel.obtain(); |
| 372 | Parcel _reply = Parcel.obtain(); |
| 373 | int _result; |
| 374 | try { |
| 375 | _data.writeInterfaceToken(DESCRIPTOR); |
| 376 | _data.writeString(name); |
| 377 | _data.writeInt(granteeUid); |
| 378 | mRemote.transact(Stub.TRANSACTION_grant, _data, _reply, 0); |
| 379 | _reply.readException(); |
| 380 | _result = _reply.readInt(); |
| 381 | } finally { |
| 382 | _reply.recycle(); |
| 383 | _data.recycle(); |
| 384 | } |
| 385 | return _result; |
| 386 | } |
| 387 | |
| 388 | public int ungrant(String name, int granteeUid) throws RemoteException { |
| 389 | Parcel _data = Parcel.obtain(); |
| 390 | Parcel _reply = Parcel.obtain(); |
| 391 | int _result; |
| 392 | try { |
| 393 | _data.writeInterfaceToken(DESCRIPTOR); |
| 394 | _data.writeString(name); |
| 395 | _data.writeInt(granteeUid); |
| 396 | mRemote.transact(Stub.TRANSACTION_ungrant, _data, _reply, 0); |
| 397 | _reply.readException(); |
| 398 | _result = _reply.readInt(); |
| 399 | } finally { |
| 400 | _reply.recycle(); |
| 401 | _data.recycle(); |
| 402 | } |
| 403 | return _result; |
| 404 | } |
| 405 | |
| 406 | @Override |
| 407 | public long getmtime(String name) throws RemoteException { |
| 408 | Parcel _data = Parcel.obtain(); |
| 409 | Parcel _reply = Parcel.obtain(); |
| 410 | long _result; |
| 411 | try { |
| 412 | _data.writeInterfaceToken(DESCRIPTOR); |
| 413 | _data.writeString(name); |
| 414 | mRemote.transact(Stub.TRANSACTION_getmtime, _data, _reply, 0); |
| 415 | _reply.readException(); |
| 416 | _result = _reply.readLong(); |
| 417 | } finally { |
| 418 | _reply.recycle(); |
| 419 | _data.recycle(); |
| 420 | } |
| 421 | return _result; |
| 422 | } |
Kenny Root | bd79419 | 2013-03-20 11:36:50 -0700 | [diff] [blame] | 423 | |
| 424 | @Override |
Kenny Root | 5f1d965 | 2013-03-21 14:21:50 -0700 | [diff] [blame] | 425 | public int duplicate(String srcKey, int srcUid, String destKey, int destUid) |
| 426 | throws RemoteException { |
Kenny Root | bd79419 | 2013-03-20 11:36:50 -0700 | [diff] [blame] | 427 | Parcel _data = Parcel.obtain(); |
| 428 | Parcel _reply = Parcel.obtain(); |
| 429 | int _result; |
| 430 | try { |
| 431 | _data.writeInterfaceToken(DESCRIPTOR); |
Kenny Root | 5f1d965 | 2013-03-21 14:21:50 -0700 | [diff] [blame] | 432 | _data.writeString(srcKey); |
| 433 | _data.writeInt(srcUid); |
| 434 | _data.writeString(destKey); |
| 435 | _data.writeInt(destUid); |
| 436 | mRemote.transact(Stub.TRANSACTION_duplicate, _data, _reply, 0); |
Kenny Root | bd79419 | 2013-03-20 11:36:50 -0700 | [diff] [blame] | 437 | _reply.readException(); |
| 438 | _result = _reply.readInt(); |
| 439 | } finally { |
| 440 | _reply.recycle(); |
| 441 | _data.recycle(); |
| 442 | } |
| 443 | return _result; |
| 444 | } |
Kenny Root | 5cb5cec | 2013-03-29 11:14:17 -0700 | [diff] [blame] | 445 | |
| 446 | @Override |
Kenny Root | b91773b | 2013-09-05 13:03:16 -0700 | [diff] [blame] | 447 | public int is_hardware_backed(String keyType) throws RemoteException { |
Kenny Root | 5cb5cec | 2013-03-29 11:14:17 -0700 | [diff] [blame] | 448 | Parcel _data = Parcel.obtain(); |
| 449 | Parcel _reply = Parcel.obtain(); |
| 450 | int _result; |
| 451 | try { |
| 452 | _data.writeInterfaceToken(DESCRIPTOR); |
Kenny Root | b91773b | 2013-09-05 13:03:16 -0700 | [diff] [blame] | 453 | _data.writeString(keyType); |
Kenny Root | 5cb5cec | 2013-03-29 11:14:17 -0700 | [diff] [blame] | 454 | mRemote.transact(Stub.TRANSACTION_is_hardware_backed, _data, _reply, 0); |
| 455 | _reply.readException(); |
| 456 | _result = _reply.readInt(); |
| 457 | } finally { |
| 458 | _reply.recycle(); |
| 459 | _data.recycle(); |
| 460 | } |
| 461 | return _result; |
| 462 | } |
Kenny Root | d72317a | 2013-04-01 15:59:59 -0700 | [diff] [blame] | 463 | |
| 464 | @Override |
| 465 | public int clear_uid(long uid) throws RemoteException { |
| 466 | Parcel _data = Parcel.obtain(); |
| 467 | Parcel _reply = Parcel.obtain(); |
| 468 | int _result; |
| 469 | try { |
| 470 | _data.writeInterfaceToken(DESCRIPTOR); |
| 471 | _data.writeLong(uid); |
| 472 | mRemote.transact(Stub.TRANSACTION_clear_uid, _data, _reply, 0); |
| 473 | _reply.readException(); |
| 474 | _result = _reply.readInt(); |
| 475 | } finally { |
| 476 | _reply.recycle(); |
| 477 | _data.recycle(); |
| 478 | } |
| 479 | return _result; |
| 480 | } |
Kenny Root | 6b77645 | 2012-11-02 15:40:32 -0700 | [diff] [blame] | 481 | } |
| 482 | |
| 483 | private static final String DESCRIPTOR = "android.security.keystore"; |
| 484 | |
| 485 | static final int TRANSACTION_test = IBinder.FIRST_CALL_TRANSACTION + 0; |
| 486 | static final int TRANSACTION_get = IBinder.FIRST_CALL_TRANSACTION + 1; |
| 487 | static final int TRANSACTION_insert = IBinder.FIRST_CALL_TRANSACTION + 2; |
| 488 | static final int TRANSACTION_del = IBinder.FIRST_CALL_TRANSACTION + 3; |
| 489 | static final int TRANSACTION_exist = IBinder.FIRST_CALL_TRANSACTION + 4; |
| 490 | static final int TRANSACTION_saw = IBinder.FIRST_CALL_TRANSACTION + 5; |
| 491 | static final int TRANSACTION_reset = IBinder.FIRST_CALL_TRANSACTION + 6; |
| 492 | static final int TRANSACTION_password = IBinder.FIRST_CALL_TRANSACTION + 7; |
| 493 | static final int TRANSACTION_lock = IBinder.FIRST_CALL_TRANSACTION + 8; |
| 494 | static final int TRANSACTION_unlock = IBinder.FIRST_CALL_TRANSACTION + 9; |
| 495 | static final int TRANSACTION_zero = IBinder.FIRST_CALL_TRANSACTION + 10; |
| 496 | static final int TRANSACTION_generate = IBinder.FIRST_CALL_TRANSACTION + 11; |
| 497 | static final int TRANSACTION_import = IBinder.FIRST_CALL_TRANSACTION + 12; |
| 498 | static final int TRANSACTION_sign = IBinder.FIRST_CALL_TRANSACTION + 13; |
| 499 | static final int TRANSACTION_verify = IBinder.FIRST_CALL_TRANSACTION + 14; |
| 500 | static final int TRANSACTION_get_pubkey = IBinder.FIRST_CALL_TRANSACTION + 15; |
| 501 | static final int TRANSACTION_del_key = IBinder.FIRST_CALL_TRANSACTION + 16; |
| 502 | static final int TRANSACTION_grant = IBinder.FIRST_CALL_TRANSACTION + 17; |
| 503 | static final int TRANSACTION_ungrant = IBinder.FIRST_CALL_TRANSACTION + 18; |
| 504 | static final int TRANSACTION_getmtime = IBinder.FIRST_CALL_TRANSACTION + 19; |
Kenny Root | 5f1d965 | 2013-03-21 14:21:50 -0700 | [diff] [blame] | 505 | static final int TRANSACTION_duplicate = IBinder.FIRST_CALL_TRANSACTION + 20; |
Kenny Root | 5cb5cec | 2013-03-29 11:14:17 -0700 | [diff] [blame] | 506 | static final int TRANSACTION_is_hardware_backed = IBinder.FIRST_CALL_TRANSACTION + 21; |
Kenny Root | d72317a | 2013-04-01 15:59:59 -0700 | [diff] [blame] | 507 | static final int TRANSACTION_clear_uid = IBinder.FIRST_CALL_TRANSACTION + 22; |
Kenny Root | 6b77645 | 2012-11-02 15:40:32 -0700 | [diff] [blame] | 508 | |
| 509 | /** |
| 510 | * Cast an IBinder object into an IKeystoreService interface, generating |
| 511 | * a proxy if needed. |
| 512 | */ |
| 513 | public static IKeystoreService asInterface(IBinder obj) { |
| 514 | if (obj == null) { |
| 515 | return null; |
| 516 | } |
| 517 | IInterface iin = obj.queryLocalInterface(DESCRIPTOR); |
| 518 | if (iin != null && iin instanceof IKeystoreService) { |
| 519 | return (IKeystoreService) iin; |
| 520 | } |
| 521 | return new IKeystoreService.Stub.Proxy(obj); |
| 522 | } |
| 523 | |
| 524 | /** Construct the stub at attach it to the interface. */ |
| 525 | public Stub() { |
| 526 | attachInterface(this, DESCRIPTOR); |
| 527 | } |
| 528 | |
| 529 | public IBinder asBinder() { |
| 530 | return this; |
| 531 | } |
| 532 | |
| 533 | @Override |
| 534 | public boolean onTransact(int code, Parcel data, Parcel reply, int flags) |
| 535 | throws RemoteException { |
| 536 | switch (code) { |
| 537 | case INTERFACE_TRANSACTION: { |
| 538 | reply.writeString(DESCRIPTOR); |
| 539 | return true; |
| 540 | } |
| 541 | case TRANSACTION_test: { |
| 542 | data.enforceInterface(DESCRIPTOR); |
| 543 | int resultCode = test(); |
| 544 | reply.writeNoException(); |
| 545 | reply.writeInt(resultCode); |
| 546 | return true; |
| 547 | } |
| 548 | } |
| 549 | return super.onTransact(code, data, reply, flags); |
| 550 | } |
| 551 | } |
| 552 | |
| 553 | public int test() throws RemoteException; |
| 554 | |
| 555 | public byte[] get(String name) throws RemoteException; |
| 556 | |
Kenny Root | a3788b0 | 2013-04-10 10:37:55 -0700 | [diff] [blame] | 557 | public int insert(String name, byte[] item, int uid, int flags) throws RemoteException; |
Kenny Root | 6b77645 | 2012-11-02 15:40:32 -0700 | [diff] [blame] | 558 | |
Kenny Root | e151f28 | 2013-02-13 15:22:25 -0800 | [diff] [blame] | 559 | public int del(String name, int uid) throws RemoteException; |
Kenny Root | 6b77645 | 2012-11-02 15:40:32 -0700 | [diff] [blame] | 560 | |
Kenny Root | e151f28 | 2013-02-13 15:22:25 -0800 | [diff] [blame] | 561 | public int exist(String name, int uid) throws RemoteException; |
Kenny Root | 6b77645 | 2012-11-02 15:40:32 -0700 | [diff] [blame] | 562 | |
Kenny Root | e151f28 | 2013-02-13 15:22:25 -0800 | [diff] [blame] | 563 | public String[] saw(String name, int uid) throws RemoteException; |
Kenny Root | 6b77645 | 2012-11-02 15:40:32 -0700 | [diff] [blame] | 564 | |
| 565 | public int reset() throws RemoteException; |
| 566 | |
| 567 | public int password(String password) throws RemoteException; |
| 568 | |
| 569 | public int lock() throws RemoteException; |
| 570 | |
| 571 | public int unlock(String password) throws RemoteException; |
| 572 | |
| 573 | public int zero() throws RemoteException; |
| 574 | |
Kenny Root | a398598 | 2013-08-16 14:03:29 -0700 | [diff] [blame] | 575 | public int generate(String name, int uid, int keyType, int keySize, int flags, byte[][] args) |
| 576 | throws RemoteException; |
Kenny Root | 6b77645 | 2012-11-02 15:40:32 -0700 | [diff] [blame] | 577 | |
Kenny Root | a3788b0 | 2013-04-10 10:37:55 -0700 | [diff] [blame] | 578 | public int import_key(String name, byte[] data, int uid, int flags) throws RemoteException; |
Kenny Root | 6b77645 | 2012-11-02 15:40:32 -0700 | [diff] [blame] | 579 | |
| 580 | public byte[] sign(String name, byte[] data) throws RemoteException; |
| 581 | |
| 582 | public int verify(String name, byte[] data, byte[] signature) throws RemoteException; |
| 583 | |
| 584 | public byte[] get_pubkey(String name) throws RemoteException; |
| 585 | |
Kenny Root | e151f28 | 2013-02-13 15:22:25 -0800 | [diff] [blame] | 586 | public int del_key(String name, int uid) throws RemoteException; |
Kenny Root | 6b77645 | 2012-11-02 15:40:32 -0700 | [diff] [blame] | 587 | |
| 588 | public int grant(String name, int granteeUid) throws RemoteException; |
| 589 | |
| 590 | public int ungrant(String name, int granteeUid) throws RemoteException; |
| 591 | |
| 592 | public long getmtime(String name) throws RemoteException; |
Kenny Root | bd79419 | 2013-03-20 11:36:50 -0700 | [diff] [blame] | 593 | |
Kenny Root | 5f1d965 | 2013-03-21 14:21:50 -0700 | [diff] [blame] | 594 | public int duplicate(String srcKey, int srcUid, String destKey, int destUid) |
| 595 | throws RemoteException; |
Kenny Root | 5cb5cec | 2013-03-29 11:14:17 -0700 | [diff] [blame] | 596 | |
Kenny Root | b91773b | 2013-09-05 13:03:16 -0700 | [diff] [blame] | 597 | public int is_hardware_backed(String string) throws RemoteException; |
Kenny Root | d72317a | 2013-04-01 15:59:59 -0700 | [diff] [blame] | 598 | |
| 599 | public int clear_uid(long uid) throws RemoteException; |
Kenny Root | 6b77645 | 2012-11-02 15:40:32 -0700 | [diff] [blame] | 600 | } |