annotate src/core/ngx_crc32.h @ 7360:8f25a44d9add

SSL: logging level of "no suitable key share". The "no suitable key share" errors are reported by OpenSSL 1.1.1 when using TLSv1.3 if there are no shared groups (that is, elliptic curves). In particular, it is easy enough to trigger by using only a single curve in ssl_ecdh_curve: ssl_ecdh_curve secp384r1; and using a different curve in the client: openssl s_client -connect 127.0.0.1:443 -curves prime256v1 On the client side it is seen as "sslv3 alert handshake failure", "SSL alert number 40": 0:error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure:ssl/record/rec_layer_s3.c:1528:SSL alert number 40 It can be also triggered with default ssl_ecdh_curve by using a curve which is not in the default list (X25519, prime256v1, X448, secp521r1, secp384r1): openssl s_client -connect 127.0.0.1:8443 -curves brainpoolP512r1 Given that many clients hardcode prime256v1, these errors might become a common problem with TLSv1.3 if ssl_ecdh_curve is redefined. Previously this resulted in not using ECDH with such clients, but with TLSv1.3 it is no longer possible and will result in a handshake failure. The SSL_R_NO_SHARED_GROUP error is what BoringSSL returns in the same situation. Seen at: https://serverfault.com/questions/932102/nginx-ssl-handshake-error-no-suitable-key-share
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 25 Sep 2018 13:59:53 +0300
parents d620f497c50f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
790
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
2 /*
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
3 * Copyright (C) Igor Sysoev
4412
d620f497c50f Copyright updated.
Maxim Konovalov <maxim@nginx.com>
parents: 1697
diff changeset
4 * Copyright (C) Nginx, Inc.
790
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
5 */
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
6
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
7
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
8 #ifndef _NGX_CRC32_H_INCLUDED_
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
9 #define _NGX_CRC32_H_INCLUDED_
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
10
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
11
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
12 #include <ngx_config.h>
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
13 #include <ngx_core.h>
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
14
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
15
793
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
16 extern uint32_t *ngx_crc32_table_short;
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
17 extern uint32_t ngx_crc32_table256[];
790
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
18
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
19
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
20 static ngx_inline uint32_t
793
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
21 ngx_crc32_short(u_char *p, size_t len)
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
22 {
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
23 u_char c;
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
24 uint32_t crc;
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
25
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
26 crc = 0xffffffff;
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
27
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
28 while (len--) {
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
29 c = *p++;
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
30 crc = ngx_crc32_table_short[(crc ^ (c & 0xf)) & 0xf] ^ (crc >> 4);
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
31 crc = ngx_crc32_table_short[(crc ^ (c >> 4)) & 0xf] ^ (crc >> 4);
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
32 }
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
33
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
34 return crc ^ 0xffffffff;
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
35 }
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
36
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
37
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
38 static ngx_inline uint32_t
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
39 ngx_crc32_long(u_char *p, size_t len)
790
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
40 {
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
41 uint32_t crc;
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
42
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
43 crc = 0xffffffff;
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
44
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
45 while (len--) {
793
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
46 crc = ngx_crc32_table256[(crc ^ *p++) & 0xff] ^ (crc >> 8);
790
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
47 }
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
48
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
49 return crc ^ 0xffffffff;
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
50 }
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
51
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
52
1694
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
53 #define ngx_crc32_init(crc) \
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
54 crc = 0xffffffff
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
55
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
56
1697
d6afb8723155 fix r1695
Igor Sysoev <igor@sysoev.ru>
parents: 1694
diff changeset
57 static ngx_inline void
1694
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
58 ngx_crc32_update(uint32_t *crc, u_char *p, size_t len)
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
59 {
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
60 uint32_t c;
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
61
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
62 c = *crc;
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
63
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
64 while (len--) {
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
65 c = ngx_crc32_table256[(c ^ *p++) & 0xff] ^ (c >> 8);
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
66 }
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
67
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
68 *crc = c;
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
69 }
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
70
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
71
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
72 #define ngx_crc32_final(crc) \
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
73 crc ^= 0xffffffff
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
74
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
75
8c696afe46b3 rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents: 930
diff changeset
76 ngx_int_t ngx_crc32_table_init(void);
793
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
77
8d39da951bbd split ngx_crc32() to short and long version
Igor Sysoev <igor@sysoev.ru>
parents: 790
diff changeset
78
790
f9a971440614 ngx_crc32()
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
79 #endif /* _NGX_CRC32_H_INCLUDED_ */