Ticket #250: freetz.org-openvpn-2.3.0-polarssl-1.2.x-support.patch

File freetz.org-openvpn-2.3.0-polarssl-1.2.x-support.patch, 5.2 KB (added by er13, 11 years ago)

A more complete patch from freetz.org project (based on patch by MaxMuster?)

  • src/openvpn/crypto_polarssl.h

     
    6060#define OPENVPN_MODE_OFB        POLARSSL_MODE_OFB
    6161
    6262/** Cipher is in CFB mode */
     63#if POLARSSL_VERSION_NUMBER < 0x01020000
    6364#define OPENVPN_MODE_CFB        POLARSSL_MODE_CFB128
     65#else
     66#define OPENVPN_MODE_CFB        POLARSSL_MODE_CFB
     67#endif
    6468
    6569/** Cipher should encrypt */
    6670#define OPENVPN_OP_ENCRYPT      POLARSSL_ENCRYPT
  • src/openvpn/options.c

     
    827827  o->server_poll_timeout = 0;
    828828#endif
    829829#ifdef ENABLE_CRYPTO
     830#ifdef ENABLE_CRYPTO_POLARSSL
     831  o->ciphername = "BLOWFISH-CBC";
     832  o->keysize = 16;
     833#else
    830834  o->ciphername = "BF-CBC";
     835#endif
    831836  o->ciphername_defined = true;
    832837  o->authname = "SHA1";
    833838  o->authname_defined = true;
  • src/openvpn/ssl_polarssl.h

     
    3030#ifndef SSL_POLARSSL_H_
    3131#define SSL_POLARSSL_H_
    3232
     33#include <polarssl/version.h>
    3334#include <polarssl/ssl.h>
    3435
    3536#if defined(ENABLE_PKCS11)
     
    7374
    7475struct key_state_ssl {
    7576        ssl_context *ctx;
     77#if POLARSSL_VERSION_NUMBER < 0x01020000
    7678        ssl_session *ssn;
     79#endif
    7780        endless_buffer *ct_in;
    7881        endless_buffer *ct_out;
    7982};
  • src/openvpn/ssl_polarssl.c

     
    6565{
    6666}
    6767
     68#if POLARSSL_VERSION_NUMBER < 0x0102000
    6869static int default_ciphersuites[] =
    6970{
    7071    SSL_EDH_RSA_AES_256_SHA,
     
    8182    SSL_RSA_RC4_128_MD5,
    8283    0
    8384};
     85#endif
    8486
    8587void
    8688tls_ctx_server_new(struct tls_root_ctx *ctx)
     
    514516
    515517      ssl_set_rng (ks_ssl->ctx, ctr_drbg_random, rand_ctx_get());
    516518
     519#if POLARSSL_VERSION_NUMBER < 0x01020000
    517520      ALLOC_OBJ_CLEAR (ks_ssl->ssn, ssl_session);
    518521      ssl_set_session (ks_ssl->ctx, 0, 0, ks_ssl->ssn );
     522#endif
    519523      if (ssl_ctx->allowed_ciphers)
    520524        ssl_set_ciphersuites (ks_ssl->ctx, ssl_ctx->allowed_ciphers);
    521525      else
     526#if POLARSSL_VERSION_NUMBER < 0x01020000
    522527        ssl_set_ciphersuites (ks_ssl->ctx, default_ciphersuites);
     528#else
     529        ssl_set_ciphersuites (ks_ssl->ctx, ssl_default_ciphersuites);
     530#endif
    523531
    524532      /* Initialise authentication information */
    525533      if (is_server)
     
    556564          ssl_free(ks_ssl->ctx);
    557565          free(ks_ssl->ctx);
    558566        }
     567#if POLARSSL_VERSION_NUMBER < 0x01020000
    559568      if (ks_ssl->ssn)
    560569        free(ks_ssl->ssn);
     570#endif
    561571      if (ks_ssl->ct_in) {
    562572        buf_free_entries(ks_ssl->ct_in);
    563573        free(ks_ssl->ct_in);
     
    818828void
    819829print_details (struct key_state_ssl * ks_ssl, const char *prefix)
    820830{
    821   x509_cert *cert;
     831  const x509_cert *cert;
    822832  char s1[256];
    823833  char s2[256];
    824834
     
    828838                    ssl_get_version (ks_ssl->ctx),
    829839                    ssl_get_ciphersuite(ks_ssl->ctx));
    830840
     841#if POLARSSL_VERSION_NUMBER < 0x01020000
    831842  cert = ks_ssl->ctx->peer_cert;
     843#else
     844  cert = ssl_get_peer_cert(ks_ssl->ctx);
     845#endif
    832846  if (cert != NULL)
    833847    {
    834848      openvpn_snprintf (s2, sizeof (s2), ", " counter_format " bit RSA", (counter_type) cert->rsa.len * 8);
  • src/openvpn/ssl_verify_polarssl.h

     
    3333#include "syshead.h"
    3434#include "misc.h"
    3535#include "manage.h"
     36#include <polarssl/version.h>
    3637#include <polarssl/x509.h>
    3738
    3839#ifndef __OPENVPN_X509_CERT_T_DECLARED
     
    6465 * @param cert         - The certificate used by PolarSSL.
    6566 * @param cert_depth   - The depth of the current certificate in the chain, with
    6667 *                       0 being the actual certificate.
     68 * PolarSSL < 1.2.x
    6769 * @param preverify_ok - Whether the remote OpenVPN peer's certificate
    6870 *                       past verification.  A value of 1 means it
    6971 *                       verified successfully, 0 means it failed.
     72 * PolarSSL >= 1.2.x
     73 * @param preverify_flags - Pointer to preverify flags.
     74 *                          ((*flags) == 0) means verified successfully
     75 *                          ((*flags) != 0) means verification failed
    7076 *
    7177 * @return The return value indicates whether the supplied certificate is
    7278 *     allowed to set up a VPN tunnel.  The following values can be
     
    7581 *      - \c 1: success, this certificate is allowed to connect.
    7682 */
    7783int verify_callback (void *session_obj, x509_cert *cert, int cert_depth,
     84#if POLARSSL_VERSION_NUMBER < 0x01020000
    7885    int preverify_ok);
     86#else
     87    int *preverify_flags);
     88#endif
    7989
    8090/** @} name Function for authenticating a new connection from a remote OpenVPN peer */
    8191
  • src/openvpn/ssl_verify_polarssl.c

     
    4444
    4545int
    4646verify_callback (void *session_obj, x509_cert *cert, int cert_depth,
     47#if POLARSSL_VERSION_NUMBER < 0x01020000
    4748    int preverify_ok)
     49#else
     50    int *preverify_flags)
     51#endif
    4852{
    4953  struct tls_session *session = (struct tls_session *) session_obj;
    5054  struct gc_arena gc = gc_new();
     
    5963  cert_hash_remember (session, cert_depth, x509_get_sha1_hash(cert, &gc));
    6064
    6165  /* did peer present cert which was signed by our root cert? */
     66#if POLARSSL_VERSION_NUMBER < 0x01020000
    6267  if (!preverify_ok)
     68#else
     69  if (preverify_flags && (*preverify_flags) != 0)
     70  /*
     71   * In case of PolarSSL>=1.2.x the actual reason could be determined and printed out,
     72   * see polarssl-1.2.x/programs/ssl/ssl_client2.c::my_verify for details.
     73   */
     74#endif
    6375    {
    6476      char *subject = x509_get_subject(cert, &gc);
    6577