2 * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
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
8 * http://floralicense.org/license/
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.
16 #ifndef __NET_NFC_SIGN_RECORD_H__
17 #define __NET_NFC_SIGN_RECORD_H__
19 #include "net_nfc_typedef.h"
23 @addtogroup NET_NFC_MANAGER_RECORD
25 This document is for the APIs reference document
27 NFC Manager defines are defined in <nfc-typedef.h>
32 this function make the signature of some continuous records
33 please refer the NFC forum specification "Signature Record type Definition"
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
41 @return return the result of the calling the function
43 @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
44 @exception NET_NFC_ALLOC_FAIL memory allocation is failed
47 ndef_message_h msg = NULL;
49 // create a ndef message and add some records
52 net_nfc_sign_records(msg, 0, 1, "/tmp/cert.p12", "abcdef");
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);
59 this function make the signature of whole records in NDEF message
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
65 @return return the result of the calling the function
67 @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
68 @exception NET_NFC_ALLOC_FAIL memory allocation is failed
71 ndef_message_h msg = NULL;
73 // create a ndef message and add some records
76 net_nfc_sign_ndef_message(msg, "/tmp/cert.p12", "abcdef");
79 net_nfc_error_e net_nfc_sign_ndef_message(ndef_message_h msg, char *cert_file,
83 This function does verify signature of records
84 record MUST be continuous.
86 @param[in] begin_record the handle of beginning record that will be verified
87 @param[in] sign_record the handle of signature record
89 @return return the result of the calling the function
91 @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
92 @exception NET_NFC_ALLOC_FAIL memory allocation is failed
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;
100 // import NDEF message including the signature record.
103 net_nfc_get_record_by_index(msg, 0, &begin_record);
104 net_nfc_get_record_by_index(msg, 2, &sign_record);
106 error = net_nfc_verify_signature_records(begin_record, sign_record);
108 return (error == NET_NFC_OK);
111 net_nfc_error_e net_nfc_verify_signature_records(ndef_record_h begin_record,
112 ndef_record_h sign_record);
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.)
119 @param[in] msg NDEF message that will be verified.
121 @return return the result of the calling the function
123 @exception NET_NFC_NULL_PARAMETER parameter(s) has(have) illegal NULL pointer(s)
124 @exception NET_NFC_ALLOC_FAIL memory allocation is failed
127 net_nfc_error_e error = NET_NFC_OK;
128 ndef_message_h msg = NULL;
130 // import NDEF message including the signature record.
133 error = net_nfc_verify_signature_ndef_message(msg);
135 return (error == NET_NFC_OK);
138 net_nfc_error_e net_nfc_verify_signature_ndef_message(ndef_message_h msg);
140 #endif //__NET_NFC_SIGN_RECORD_H__