Home | History | Annotate | Download | only in vtls
      1 #ifndef HEADER_CURL_POLARSSL_H
      2 #define HEADER_CURL_POLARSSL_H
      3 /***************************************************************************
      4  *                                  _   _ ____  _
      5  *  Project                     ___| | | |  _ \| |
      6  *                             / __| | | | |_) | |
      7  *                            | (__| |_| |  _ <| |___
      8  *                             \___|\___/|_| \_\_____|
      9  *
     10  * Copyright (C) 2012 - 2016, Daniel Stenberg, <daniel (at) haxx.se>, et al.
     11  * Copyright (C) 2010, Hoi-Ho Chan, <hoiho.chan (at) gmail.com>
     12  *
     13  * This software is licensed as described in the file COPYING, which
     14  * you should have received as part of this distribution. The terms
     15  * are also available at https://curl.haxx.se/docs/copyright.html.
     16  *
     17  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
     18  * copies of the Software, and permit persons to whom the Software is
     19  * furnished to do so, under the terms of the COPYING file.
     20  *
     21  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
     22  * KIND, either express or implied.
     23  *
     24  ***************************************************************************/
     25 #include "curl_setup.h"
     26 
     27 #ifdef USE_POLARSSL
     28 
     29 #include <polarssl/sha256.h>
     30 
     31 /* Called on first use PolarSSL, setup threading if supported */
     32 int  Curl_polarssl_init(void);
     33 void Curl_polarssl_cleanup(void);
     34 
     35 
     36 CURLcode Curl_polarssl_connect(struct connectdata *conn, int sockindex);
     37 
     38 CURLcode Curl_polarssl_connect_nonblocking(struct connectdata *conn,
     39                                            int sockindex,
     40                                            bool *done);
     41 
     42  /* close a SSL connection */
     43 void Curl_polarssl_close(struct connectdata *conn, int sockindex);
     44 
     45 void Curl_polarssl_session_free(void *ptr);
     46 size_t Curl_polarssl_version(char *buffer, size_t size);
     47 int Curl_polarssl_shutdown(struct connectdata *conn, int sockindex);
     48 
     49 /* Set the API backend definition to PolarSSL */
     50 #define CURL_SSL_BACKEND CURLSSLBACKEND_POLARSSL
     51 
     52 /* this backend supports the CAPATH option */
     53 #define have_curlssl_ca_path 1
     54 
     55 /* this backends supports CURLOPT_PINNEDPUBLICKEY */
     56 #define have_curlssl_pinnedpubkey 1
     57 
     58 /* API setup for PolarSSL */
     59 #define curlssl_init() Curl_polarssl_init()
     60 #define curlssl_cleanup() Curl_polarssl_cleanup()
     61 #define curlssl_connect Curl_polarssl_connect
     62 #define curlssl_connect_nonblocking Curl_polarssl_connect_nonblocking
     63 #define curlssl_session_free(x)  Curl_polarssl_session_free(x)
     64 #define curlssl_close_all(x) ((void)x)
     65 #define curlssl_close Curl_polarssl_close
     66 #define curlssl_shutdown(x,y) 0
     67 #define curlssl_set_engine(x,y) ((void)x, (void)y, CURLE_NOT_BUILT_IN)
     68 #define curlssl_set_engine_default(x) ((void)x, CURLE_NOT_BUILT_IN)
     69 #define curlssl_engines_list(x) ((void)x, (struct curl_slist *)NULL)
     70 #define curlssl_version Curl_polarssl_version
     71 #define curlssl_check_cxn(x) ((void)x, -1)
     72 #define curlssl_data_pending(x,y) ((void)x, (void)y, 0)
     73 #define curlssl_sha256sum(a,b,c,d) sha256(a,b,c,0)
     74 
     75 /* This might cause libcurl to use a weeker random!
     76    TODO: implement proper use of Polarssl's CTR-DRBG or HMAC-DRBG and use that
     77 */
     78 #define curlssl_random(x,y,z) ((void)x, (void)y, (void)z, CURLE_NOT_BUILT_IN)
     79 
     80 #endif /* USE_POLARSSL */
     81 #endif /* HEADER_CURL_POLARSSL_H */
     82