code cleanup
[platform/core/connectivity/nfc-manager-neard.git] / client / include / net_nfc_sign_record.h
1 /*
2  * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Flora License, Version 1.1 (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://floralicense.org/license/
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 #ifndef __NET_NFC_SIGN_RECORD_H__
17 #define __NET_NFC_SIGN_RECORD_H__
18
19 #include "net_nfc_typedef.h"
20
21 /**
22
23   @addtogroup NET_NFC_MANAGER_RECORD
24   @{
25   This document is for the APIs reference document
26
27   NFC Manager defines are defined in <nfc-typedef.h>
28
29 */
30
31 /**
32   this function make the signature of some continuous records
33   please refer the NFC forum specification "Signature Record type Definition"
34
35   @param[in/out]        msg                                     NDEF message handler. After executing this function, a signature record will be added.
36   @param[in]            begin_index                     the index of beginning record that will be signed.
37   @param[in]            end_index                       the last index of record that will be signed.
38   @param[in]            cert_file                       PKCS #12 type certificate file (.p12). And the file should be encoded in DER type. (NOT PEM type)
39   @param[in]            passowrd                        the password of cert_file
40
41   @return               return the result of the calling the function
42
43   @exception NET_NFC_NULL_PARAMETER             parameter(s) has(have) illegal NULL pointer(s)
44   @exception NET_NFC_ALLOC_FAIL                 memory allocation is failed
45
46   @code
47   ndef_message_h msg = NULL;
48
49   // create a ndef message and add some records
50   // ...
51
52   net_nfc_sign_records(msg, 0, 1, "/tmp/cert.p12", "abcdef");
53   @endcode
54 */
55 net_nfc_error_e net_nfc_sign_records(ndef_message_h msg, int begin_index,
56                 int end_index, char *cert_file, char *password);
57
58 /**
59   this function make the signature of whole records in NDEF message
60
61   @param[in/out]        msg                                     NDEF message handler. After executing this function, a signature record will be added.
62   @param[in]            cert_file                       PKCS #12 type certificate file (.p12). And the file should be encoded in DER type. (NOT PEM type)
63   @param[in]            passowrd                        the password of cert_file
64
65   @return               return the result of the calling the function
66
67   @exception NET_NFC_NULL_PARAMETER             parameter(s) has(have) illegal NULL pointer(s)
68   @exception NET_NFC_ALLOC_FAIL                 memory allocation is failed
69
70   @code
71   ndef_message_h msg = NULL;
72
73   // create a ndef message and add some records
74   // ...
75
76   net_nfc_sign_ndef_message(msg, "/tmp/cert.p12", "abcdef");
77   @endcode
78 */
79 net_nfc_error_e net_nfc_sign_ndef_message(ndef_message_h msg, char *cert_file,
80                 char *password);
81
82 /**
83   This function does verify signature of records
84   record MUST be continuous.
85
86   @param[in]    begin_record                            the handle of beginning record that will be verified
87   @param[in]    sign_record                                     the handle of signature record
88
89   @return               return the result of the calling the function
90
91   @exception NET_NFC_NULL_PARAMETER             parameter(s) has(have) illegal NULL pointer(s)
92   @exception NET_NFC_ALLOC_FAIL                 memory allocation is failed
93
94   @code
95   net_nfc_error_e error = NET_NFC_OK;
96   ndef_message_h msg = NULL;
97   ndef_record_h begin_record = NULL;
98   ndef_record_h sign_record = NULL;
99
100   // import NDEF message including the signature record.
101   // ...
102
103   net_nfc_get_record_by_index(msg, 0, &begin_record);
104   net_nfc_get_record_by_index(msg, 2, &sign_record);
105
106   error = net_nfc_verify_signature_records(begin_record, sign_record);
107
108   return (error == NET_NFC_OK);
109   @endcode
110 */
111 net_nfc_error_e net_nfc_verify_signature_records(ndef_record_h begin_record,
112                 ndef_record_h sign_record);
113
114 /**
115   This function does verify signature in NDEF message
116   If message has 2 or more signature record, it should do verify every signatures and return result.
117   (Despite of failing only one signature record, this function will return error.)
118
119   @param[in]    msg                             NDEF message that will be verified.
120
121   @return               return the result of the calling the function
122
123   @exception NET_NFC_NULL_PARAMETER             parameter(s) has(have) illegal NULL pointer(s)
124   @exception NET_NFC_ALLOC_FAIL                 memory allocation is failed
125
126   @code
127   net_nfc_error_e error = NET_NFC_OK;
128   ndef_message_h msg = NULL;
129
130   // import NDEF message including the signature record.
131   // ...
132
133   error = net_nfc_verify_signature_ndef_message(msg);
134
135   return (error == NET_NFC_OK);
136   @endcode
137 */
138 net_nfc_error_e net_nfc_verify_signature_ndef_message(ndef_message_h msg);
139
140 #endif //__NET_NFC_SIGN_RECORD_H__