• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 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.keystore2;
18 
19 import android.security.KeyStoreException;
20 
21 /**
22  * Helper for streaming a crypto operation's input and output via KeyStore service's {@code update}
23  * and {@code finish} operations.
24  *
25  * <p>The helper abstracts away to issues that need to be solved in most code that uses KeyStore's
26  * update and finish operations. Firstly, KeyStore's update operation can consume only a limited
27  * amount of data in one go because the operations are marshalled via Binder. Secondly, the update
28  * operation may consume less data than provided, in which case the caller has to buffer the
29  * remainder for next time. The helper exposes {@link #update(byte[], int, int) update} and
30  * {@link #doFinal(byte[], int, int, byte[]) doFinal} operations which can be used to
31  * conveniently implement various JCA crypto primitives.
32  *
33  * @hide
34  */
35 interface KeyStoreCryptoOperationStreamer {
update(byte[] input, int inputOffset, int inputLength)36     byte[] update(byte[] input, int inputOffset, int inputLength) throws KeyStoreException;
doFinal(byte[] input, int inputOffset, int inputLength, byte[] signature)37     byte[] doFinal(byte[] input, int inputOffset, int inputLength, byte[] signature)
38             throws KeyStoreException;
getConsumedInputSizeBytes()39     long getConsumedInputSizeBytes();
getProducedOutputSizeBytes()40     long getProducedOutputSizeBytes();
41 }
42