umurmur: add support for the new polarssl library
[packages.git] / net / umurmur / patches / 100-polarssl_backport.patch
1 --- a/src/ssl.c
2 +++ b/src/ssl.c
3 @@ -46,20 +46,23 @@
4  #include <polarssl/ssl.h>
5  #include <polarssl/net.h>
6  
7 +#ifdef POLARSSL_API_V1_2
8 +int ciphers[] =
9 +{
10 +    TLS_DHE_RSA_WITH_AES_256_CBC_SHA,
11 +    TLS_RSA_WITH_AES_256_CBC_SHA,
12 +    TLS_RSA_WITH_AES_128_CBC_SHA,
13 +    0
14 +};
15 +#else
16  int ciphers[] =
17  {
18      SSL_EDH_RSA_AES_256_SHA,
19 -    SSL_EDH_RSA_CAMELLIA_256_SHA,
20 -    SSL_EDH_RSA_DES_168_SHA,
21      SSL_RSA_AES_256_SHA,
22 -    SSL_RSA_CAMELLIA_256_SHA,
23      SSL_RSA_AES_128_SHA,
24 -    SSL_RSA_CAMELLIA_128_SHA,
25 -    SSL_RSA_DES_168_SHA,
26 -    SSL_RSA_RC4_128_SHA,
27 -    SSL_RSA_RC4_128_MD5,
28      0
29  };
30 +#endif
31  static x509_cert certificate;
32  static rsa_context key;
33  bool_t builtInTestCertificate;
34 @@ -170,8 +173,13 @@ void SSLi_deinit(void)
35  /* Create SHA1 of last certificate in the peer's chain. */
36  bool_t SSLi_getSHA1Hash(SSL_handle_t *ssl, uint8_t *hash)
37  {
38 -       x509_cert *cert = ssl->peer_cert;
39 -       if (!ssl->peer_cert) {
40 +       x509_cert *cert;
41 +#ifdef POLARSSL_API_V1_2
42 +       cert = ssl_get_peer_cert(ssl);
43 +#else
44 +       cert = ssl->peer_cert;
45 +#endif
46 +       if (!cert) {
47                 return false;
48         }       
49         sha1(cert->raw.p, cert->raw.len, hash);
50 @@ -207,7 +215,12 @@ SSL_handle_t *SSLi_newconnection(int *fd
51  #else
52         ssl_set_ciphers(ssl, ciphers);
53  #endif
54 +
55 +#ifdef POLARSSL_API_V1_2
56 +    ssl_set_session(ssl, ssn);
57 +#else
58      ssl_set_session(ssl, 0, 0, ssn);
59 +#endif
60      
61      ssl_set_ca_chain(ssl, &certificate, NULL, NULL);
62         ssl_set_own_cert(ssl, &certificate, &key);
63 --- a/src/ssl.h
64 +++ b/src/ssl.h
65 @@ -68,6 +68,9 @@
66                  } \
67          } while (0)
68      #endif
69 +    #if (POLARSSL_VERSION_MINOR >= 2)
70 +           #define POLARSSL_API_V1_2
71 +    #endif
72  #endif
73  #endif
74