82cb043081c4c3f9e924687aaf61fe274a85211b
[platform/core/connectivity/smartcard-service.git] / common / include / ISO7816BERTLV.h
1 /*
2  * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
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 #ifndef ISO7816BERTLV_H_
18 #define ISO7816BERTLV_H_
19
20 #include "ByteArray.h"
21 #include "TLVHelper.h"
22
23 namespace smartcard_service_api
24 {
25         class ISO7816BERTLV : public TLVHelper
26         {
27         private:
28                 unsigned char firstByte;
29                 unsigned int tagClass;
30                 unsigned int encoding;
31
32                 ISO7816BERTLV(TLVHelper *parent);
33                 ISO7816BERTLV(const ByteArray &array, TLVHelper *parent);
34
35                 int decodeTag(const unsigned char *buffer);
36                 int decodeLength(const unsigned char *buffer);
37                 int decodeValue(const unsigned char *buffer);
38
39                 TLVHelper *getChildTLV(const ByteArray &data);
40
41         public:
42                 ISO7816BERTLV();
43                 ISO7816BERTLV(const ByteArray &array);
44                 ~ISO7816BERTLV();
45
46                 unsigned int getClass() const;
47                 unsigned int getEncoding() const;
48
49                 static const ByteArray encode(unsigned int tagClass, unsigned int encoding, unsigned int tag, const ByteArray &buffer);
50                 static const ByteArray encode(unsigned int tagClass, unsigned int encoding, unsigned int tag, unsigned char *buffer, unsigned int length);
51         };
52
53 } /* namespace smartcard_service_api */
54 #endif /* ISO7816BERTLV_H_ */