• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /*
17  * Copyright (c) 2017, The Linux Foundation.
18  */
19 
20 /*
21  * Copyright 2012 Giesecke & Devrient GmbH.
22  *
23  * Licensed under the Apache License, Version 2.0 (the "License");
24  * you may not use this file except in compliance with the License.
25  * You may obtain a copy of the License at
26  *
27  *      http://www.apache.org/licenses/LICENSE-2.0
28  *
29  * Unless required by applicable law or agreed to in writing, software
30  * distributed under the License is distributed on an "AS IS" BASIS,
31  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32  * See the License for the specific language governing permissions and
33  * limitations under the License.
34  */
35 package com.android.se.security.gpac;
36 
37 /**
38  * Response-RefreshTag DO The GET DATA (RefreshTag) command has to return a refresh tag indicating
39  * changes in the access control data in a RefreshTag DO. This refresh tag is an attribute (8-byte
40  * random number) of the ARA-M which is newly generated if the ARA-M detects an update of access
41  * control data in the Secure Element.
42  */
43 public class Response_RefreshTag_DO extends BerTlv {
44 
45     public static final int TAG = 0xDF20;
46 
47     private long mRefreshTag;
48     private byte[] mRefreshTagArray = null;
49 
Response_RefreshTag_DO(byte[] rawData, int valueIndex, int valueLength)50     public Response_RefreshTag_DO(byte[] rawData, int valueIndex, int valueLength) {
51         super(rawData, TAG, valueIndex, valueLength);
52     }
53 
getRefreshTag()54     public long getRefreshTag() {
55         return mRefreshTag;
56     }
57 
getRefreshTagArray()58     public byte[] getRefreshTagArray() {
59         return mRefreshTagArray;
60     }
61 
62     @Override
63     /**
64      * Tag: DF 20 Length: 8 bytes Value: The RefreshTag is an 8 bytes random number. A new
65      * RefreshTag
66      * value indicates changes in the access control data stored in the SE.
67      */
interpret()68     public void interpret() throws ParserException {
69 
70         mRefreshTag = 0;
71 
72         if (super.getValueLength() != 8) {
73             throw new ParserException("Invalid length of RefreshTag DO!");
74         }
75 
76         byte[] data = super.getRawData();
77         int index = super.getValueIndex();
78 
79         if (index + super.getValueLength() > data.length) {
80             throw new ParserException("Not enough data for RefreshTag DO!");
81         }
82         mRefreshTagArray = new byte[super.getValueLength()];
83         System.arraycopy(data, index, mRefreshTagArray, 0, mRefreshTagArray.length);
84 
85         long temp;
86         temp = data[index++];
87         mRefreshTag = (temp << 56L);
88         temp = data[index++];
89         mRefreshTag += (temp << 48L);
90         temp = data[index++];
91         mRefreshTag += (temp << 40L);
92         temp = data[index++];
93         mRefreshTag += (temp << 32L);
94         temp = data[index++];
95         mRefreshTag += (temp << 24L);
96         temp = data[index++];
97         mRefreshTag += (temp << 16L);
98         temp = data[index++];
99         mRefreshTag += (temp << 8L);
100         temp = data[index++];
101         mRefreshTag += (temp);
102     }
103 }
104