Get the latest NFC state from neard
[platform/core/connectivity/nfc-manager-neard.git] / common / net_nfc_util_openssl_internal.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_UTIL_OPENSSL_INTERNAL_H__
17 #define __NET_NFC_UTIL_OPENSSL_INTERNAL_H__
18
19 #include <openssl/x509.h>
20
21 enum
22 {
23         OPENSSL_FORMAT_UNDEF,
24         OPENSSL_FORMAT_ASN1,
25         OPENSSL_FORMAT_TEXT,
26         OPENSSL_FORMAT_PEM,
27         OPENSSL_FORMAT_NETSCAPE,
28         OPENSSL_FORMAT_PKCS12,
29         OPENSSL_FORMAT_SMIME,
30         OPENSSL_FORMAT_ENGINE,
31         OPENSSL_FORMAT_IISSGC,
32         OPENSSL_FORMAT_PEMRSA,
33         OPENSSL_FORMAT_ASN1RSA,
34         OPENSSL_FORMAT_MSBLOB,
35         OPENSSL_FORMAT_PVK,
36 };
37
38 typedef struct _net_nfc_openssl_verify_context_s
39 {
40         X509 *signer_cert;
41         X509_STORE *store;
42         X509_STORE_CTX *store_ctx;
43 }
44 net_nfc_openssl_verify_context_s;
45
46 typedef net_nfc_openssl_verify_context_s *net_nfc_openssl_verify_context_h;
47
48 net_nfc_openssl_verify_context_h net_nfc_util_openssl_init_verify_certificate(void);
49 bool net_nfc_util_openssl_add_certificate_of_signer(net_nfc_openssl_verify_context_h context, uint8_t *buffer, uint32_t length);
50 bool net_nfc_util_openssl_add_certificate_of_ca(net_nfc_openssl_verify_context_h context, uint8_t *buffer, uint32_t length);
51 int net_nfc_util_openssl_verify_certificate(net_nfc_openssl_verify_context_h context);
52 void net_nfc_util_openssl_release_verify_certificate(net_nfc_openssl_verify_context_h context);
53
54 int net_nfc_util_openssl_sign_buffer(uint32_t type, uint8_t *buffer, uint32_t length, char *key_file, char *password, uint8_t *sign, uint32_t *sign_len);
55 int net_nfc_util_openssl_verify_signature(uint32_t type, uint8_t *buffer, uint32_t length, uint8_t *cert, uint32_t cert_len, uint8_t *sign, uint32_t sign_len);
56 int net_nfc_util_get_cert_list_from_file(char *file_name, char *password, uint8_t **buffer, uint32_t *length, uint32_t *cert_count);
57
58
59 bool net_nfc_util_openssl_encode_base64(const uint8_t *buffer, const uint32_t buf_len, char *result, uint32_t max_len, bool new_line_char);
60 bool net_nfc_util_openssl_decode_base64(const char *buffer, uint8_t *result, uint32_t *out_len, bool new_line_char);
61 bool net_nfc_util_openssl_digest(const char *algorithm, const uint8_t *buffer, const uint32_t buf_len, uint8_t *result, uint32_t *out_len);
62
63 #endif //__NET_NFC_UTIL_OPENSSL_INTERNAL_H__