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_UTIL_OPENSSL_INTERNAL_H__
17 #define __NET_NFC_UTIL_OPENSSL_INTERNAL_H__
19 #include <openssl/x509.h>
27 OPENSSL_FORMAT_NETSCAPE,
28 OPENSSL_FORMAT_PKCS12,
30 OPENSSL_FORMAT_ENGINE,
31 OPENSSL_FORMAT_IISSGC,
32 OPENSSL_FORMAT_PEMRSA,
33 OPENSSL_FORMAT_ASN1RSA,
34 OPENSSL_FORMAT_MSBLOB,
38 typedef struct _net_nfc_openssl_verify_context_s
42 X509_STORE_CTX *store_ctx;
44 net_nfc_openssl_verify_context_s;
46 typedef net_nfc_openssl_verify_context_s *net_nfc_openssl_verify_context_h;
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);
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);
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);
63 #endif //__NET_NFC_UTIL_OPENSSL_INTERNAL_H__