1//
2// Copyright (C) 2017 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
17package com.android.verifiedboot.storage;
18
19import javacard.framework.AID;
20import javacard.framework.Shareable;
21
22import com.android.verifiedboot.storage.BackupInterface;
23
24public interface OsBackupInterface extends Shareable {
25    final public static byte TAG_VERSION_STORAGE = 0x0;
26    final public static byte TAG_LOCK_CARRIER = 0x1;
27    final public static byte TAG_LOCK_DEVICE = 0x2;
28    final public static byte TAG_LOCK_BOOT = 0x3;
29    final public static byte TAG_LOCK_OWNER = 0x4;
30    final public static byte TAG_MAX = TAG_LOCK_OWNER;
31
32    final public static byte TAG_MAGIC = (byte) 0xf0;
33
34
35    /**
36     * Αdds the given BackupInterface object for tracking
37     * on backup or restore. Only one object is allowed
38     * per tag.
39     *
40     * @param tag The tag mapping the specific object to the tagḣ
41     * @param bObj Object to track.
42     */
43    void track(byte tag, Object bObj);
44
45    /**
46     * Returns true on a successful reimport of data.
47     *
48     * @param inBytes array to read from
49     * @param inBytesOffset offset to begin copying from.
50     */
51    boolean restore(byte[] inBytes, short inBytesOffset);
52
53    /**
54     * Mimic the applet call.
55     *
56     * @param aid caller's AID
57     * @param arg requesting argument
58     */
59    Shareable getShareableInterfaceObject(AID aid, byte arg);
60}
61