@fails-components/webtransport 0.0.1-rc.0 → 0.0.1-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/npm-publish-packages.yml +0 -0
- package/CMakeLists.txt +2 -0
- package/package.json +1 -1
- package/readme.md +0 -0
- package/src/http3serversession.h +1 -1
- package/src/webtransport.js +4 -2
- package/third_party/boringssl/src/CMakeLists.txt +9 -12
- package/third_party/boringssl/src/crypto/CMakeLists.txt +2 -3
- package/third_party/boringssl/src/crypto/asn1/time_support.c +206 -206
- package/third_party/boringssl/src/crypto/bio/socket_helper.c +124 -122
- package/third_party/boringssl/src/crypto/evp/digestsign.c +268 -231
- package/third_party/boringssl/src/crypto/evp/p_ec.c +286 -286
- package/third_party/boringssl/src/crypto/fipsmodule/aes/key_wrap.c +246 -236
- package/third_party/boringssl/src/crypto/fipsmodule/aes/mode_wrappers.c +124 -122
- package/third_party/boringssl/src/crypto/fipsmodule/bcm.c +3 -0
- package/third_party/boringssl/src/crypto/fipsmodule/bn/bytes.c +246 -230
- package/third_party/boringssl/src/crypto/fipsmodule/bn/internal.h +734 -715
- package/third_party/boringssl/src/crypto/fipsmodule/bn/random.c +349 -341
- package/third_party/boringssl/src/crypto/fipsmodule/cipher/cipher.c +670 -648
- package/third_party/boringssl/src/crypto/fipsmodule/cipher/e_aes.c +1504 -1472
- package/third_party/boringssl/src/crypto/{cipher_extra → fipsmodule/cipher}/e_aesccm.c +435 -446
- package/third_party/boringssl/src/crypto/{cmac → fipsmodule/cmac}/cavp_3des_cmac_tests.txt +0 -0
- package/third_party/boringssl/src/crypto/{cmac → fipsmodule/cmac}/cavp_aes128_cmac_tests.txt +0 -0
- package/third_party/boringssl/src/crypto/{cmac → fipsmodule/cmac}/cavp_aes192_cmac_tests.txt +0 -0
- package/third_party/boringssl/src/crypto/{cmac → fipsmodule/cmac}/cavp_aes256_cmac_tests.txt +0 -0
- package/third_party/boringssl/src/crypto/{cmac → fipsmodule/cmac}/cmac.c +318 -278
- package/third_party/boringssl/src/crypto/{cmac → fipsmodule/cmac}/cmac_test.cc +268 -267
- package/third_party/boringssl/src/crypto/fipsmodule/dh/dh.c +5 -1
- package/third_party/boringssl/src/crypto/fipsmodule/ec/ec.c +11 -17
- package/third_party/boringssl/src/crypto/fipsmodule/ec/ec_key.c +15 -4
- package/third_party/boringssl/src/crypto/fipsmodule/ec/internal.h +2 -6
- package/third_party/boringssl/src/crypto/fipsmodule/ec/p224-64.c +1164 -1180
- package/third_party/boringssl/src/crypto/fipsmodule/ec/p256-nistz.c +3 -3
- package/third_party/boringssl/src/crypto/fipsmodule/ec/p256-nistz_test.cc +2 -2
- package/third_party/boringssl/src/crypto/fipsmodule/ec/p256.c +44 -33
- package/third_party/boringssl/src/crypto/fipsmodule/ec/scalar.c +169 -175
- package/third_party/boringssl/src/crypto/fipsmodule/ec/simple.c +352 -357
- package/third_party/boringssl/src/crypto/fipsmodule/ecdh/ecdh.c +4 -0
- package/third_party/boringssl/src/crypto/fipsmodule/ecdsa/ecdsa.c +14 -9
- package/third_party/boringssl/src/crypto/fipsmodule/hmac/hmac.c +256 -235
- package/third_party/boringssl/src/crypto/fipsmodule/rand/ctrdrbg.c +204 -202
- package/third_party/boringssl/src/crypto/fipsmodule/rsa/padding.c +702 -695
- package/third_party/boringssl/src/crypto/fipsmodule/rsa/rsa_impl.c +7 -2
- package/third_party/boringssl/src/crypto/fipsmodule/self_check/self_check.c +7 -0
- package/third_party/boringssl/src/crypto/fipsmodule/service_indicator/internal.h +89 -0
- package/third_party/boringssl/src/crypto/fipsmodule/service_indicator/service_indicator.c +333 -0
- package/third_party/boringssl/src/crypto/fipsmodule/service_indicator/service_indicator_test.cc +2410 -0
- package/third_party/boringssl/src/crypto/fipsmodule/sha/sha1.c +359 -357
- package/third_party/boringssl/src/crypto/fipsmodule/sha/sha256.c +325 -321
- package/third_party/boringssl/src/crypto/fipsmodule/sha/sha512.c +510 -508
- package/third_party/boringssl/src/crypto/fipsmodule/tls/kdf.c +177 -165
- package/third_party/boringssl/src/crypto/internal.h +13 -0
- package/third_party/boringssl/src/crypto/trust_token/trust_token_test.cc +884 -884
- package/third_party/boringssl/src/crypto/x509/internal.h +0 -2
- package/third_party/boringssl/src/crypto/x509/t_crl.c +148 -148
- package/third_party/boringssl/src/crypto/x509/t_req.c +249 -250
- package/third_party/boringssl/src/crypto/x509/t_x509.c +2 -3
- package/third_party/boringssl/src/crypto/x509/x509_req.c +262 -304
- package/third_party/boringssl/src/crypto/x509/x509_set.c +250 -240
- package/third_party/boringssl/src/crypto/x509/x509_test.cc +466 -4
- package/third_party/boringssl/src/crypto/x509/x509cset.c +292 -279
- package/third_party/boringssl/src/crypto/x509/x509rset.c +89 -86
- package/third_party/boringssl/src/crypto/x509/x_crl.c +37 -125
- package/third_party/boringssl/src/crypto/x509/x_req.c +114 -109
- package/third_party/boringssl/src/crypto/x509/x_x509.c +394 -394
- package/third_party/boringssl/src/crypto/x509v3/v3_akey.c +11 -16
- package/third_party/boringssl/src/crypto/x509v3/v3_alt.c +644 -642
- package/third_party/boringssl/src/crypto/x509v3/v3_bcons.c +130 -133
- package/third_party/boringssl/src/crypto/x509v3/v3_bitst.c +149 -144
- package/third_party/boringssl/src/crypto/x509v3/v3_cpols.c +496 -500
- package/third_party/boringssl/src/crypto/x509v3/v3_enum.c +105 -106
- package/third_party/boringssl/src/crypto/x509v3/v3_ia5.c +126 -121
- package/third_party/boringssl/src/crypto/x509v3/v3_info.c +206 -218
- package/third_party/boringssl/src/crypto/x509v3/v3_int.c +97 -91
- package/third_party/boringssl/src/crypto/x509v3/v3_pci.c +290 -289
- package/third_party/boringssl/src/crypto/x509v3/v3_skey.c +161 -156
- package/third_party/boringssl/src/crypto/x509v3/v3_utl.c +5 -3
- package/third_party/boringssl/src/include/openssl/aead.h +480 -480
- package/third_party/boringssl/src/include/openssl/asn1.h +2 -0
- package/third_party/boringssl/src/include/openssl/base.h +1 -1
- package/third_party/boringssl/src/include/openssl/service_indicator.h +96 -0
- package/third_party/boringssl/src/include/openssl/ssl.h +7 -0
- package/third_party/boringssl/src/include/openssl/x509.h +11 -33
- package/third_party/boringssl/src/include/openssl/x509v3.h +990 -1018
- package/third_party/boringssl/src/sources.cmake +4 -4
- package/third_party/boringssl/src/ssl/internal.h +10 -0
- package/third_party/boringssl/src/ssl/ssl_lib.cc +3081 -3072
- package/third_party/boringssl/src/ssl/ssl_test.cc +46 -0
- package/third_party/boringssl/src/ssl/tls13_server.cc +4 -6
- package/third_party/boringssl/src/util/bot/DEPS +14 -27
- package/third_party/boringssl/src/util/bot/UPDATING +3 -9
- package/third_party/boringssl/src/util/bot/update_clang.py +172 -172
- package/third_party/boringssl/src/util/bot/vs_toolchain.py +3 -3
- package/third_party/quiche/.bazelrc +8 -0
- package/third_party/quiche/BUILD.bazel +7 -0
- package/third_party/quiche/WHITESPACE +3 -1
- package/third_party/quiche/WORKSPACE.bazel +87 -0
- package/third_party/quiche/build/BUILD.bazel +7 -0
- package/third_party/quiche/build/source_list.bzl +1511 -0
- package/third_party/quiche/build/source_list.gni +1511 -0
- package/third_party/quiche/build/source_list.json +1511 -0
- package/third_party/quiche/build/test.bzl +26 -0
- package/third_party/quiche/build/zlib.BUILD +25 -0
- package/third_party/quiche/quiche/BUILD.bazel +270 -0
- package/third_party/quiche/quiche/{common/balsa → balsa}/balsa_enums.cc +3 -3
- package/third_party/quiche/quiche/{common/balsa → balsa}/balsa_enums.h +7 -7
- package/third_party/quiche/quiche/{common/balsa → balsa}/balsa_frame.cc +39 -18
- package/third_party/quiche/quiche/{common/balsa → balsa}/balsa_frame.h +11 -10
- package/third_party/quiche/quiche/{common/balsa → balsa}/balsa_frame_test.cc +67 -63
- package/third_party/quiche/quiche/{common/balsa → balsa}/balsa_headers.cc +13 -12
- package/third_party/quiche/quiche/{common/balsa → balsa}/balsa_headers.h +16 -8
- package/third_party/quiche/quiche/{common/balsa → balsa}/balsa_headers_test.cc +9 -9
- package/third_party/quiche/quiche/{common/balsa → balsa}/balsa_visitor_interface.h +4 -4
- package/third_party/quiche/quiche/{common/balsa → balsa}/framer_interface.h +3 -3
- package/third_party/quiche/quiche/{common/balsa → balsa}/header_api.h +3 -3
- package/third_party/quiche/quiche/{common/balsa → balsa}/header_properties.cc +1 -1
- package/third_party/quiche/quiche/{common/balsa → balsa}/header_properties.h +3 -3
- package/third_party/quiche/quiche/{common/balsa → balsa}/header_properties_test.cc +1 -1
- package/third_party/quiche/quiche/{common/balsa → balsa}/http_validation_policy.cc +1 -1
- package/third_party/quiche/quiche/{common/balsa → balsa}/http_validation_policy.h +3 -3
- package/third_party/quiche/quiche/{common/balsa → balsa}/noop_balsa_visitor.h +4 -4
- package/third_party/quiche/quiche/{common/balsa → balsa}/simple_buffer.cc +22 -29
- package/third_party/quiche/quiche/{common/balsa → balsa}/simple_buffer.h +18 -16
- package/third_party/quiche/quiche/{common/balsa → balsa}/simple_buffer_test.cc +79 -32
- package/third_party/quiche/quiche/{common/balsa → balsa}/standard_header_map.cc +1 -1
- package/third_party/quiche/quiche/{common/balsa → balsa}/standard_header_map.h +3 -3
- package/third_party/quiche/quiche/common/platform/api/quiche_command_line_flags.h +6 -1
- package/third_party/quiche/quiche/common/platform/api/quiche_flags.h +8 -0
- package/third_party/quiche/quiche/common/platform/api/quiche_logging.h +0 -3
- package/third_party/quiche/quiche/common/platform/api/quiche_lower_case_string_test.cc +29 -0
- package/third_party/quiche/quiche/common/platform/api/quiche_test.h +5 -7
- package/third_party/quiche/quiche/common/platform/default/quiche_platform_impl/quic_flags_impl.h +1 -1
- package/third_party/quiche/quiche/common/platform/default/quiche_platform_impl/quiche_bug_tracker_impl.h +3 -2
- package/third_party/quiche/quiche/common/platform/default/quiche_platform_impl/quiche_command_line_flags_impl.cc +41 -0
- package/third_party/quiche/quiche/common/platform/default/quiche_platform_impl/quiche_command_line_flags_impl.h +33 -0
- package/third_party/quiche/quiche/common/platform/default/quiche_platform_impl/quiche_expect_bug_impl.h +15 -0
- package/third_party/quiche/quiche/common/platform/default/quiche_platform_impl/quiche_logging_impl.h +84 -50
- package/third_party/quiche/quiche/common/platform/default/quiche_platform_impl/quiche_lower_case_string_impl.h +25 -0
- package/third_party/quiche/quiche/common/platform/default/quiche_platform_impl/quiche_stack_trace_impl.cc +1 -1
- package/third_party/quiche/quiche/common/platform/default/quiche_platform_impl/quiche_test_impl.cc +25 -0
- package/third_party/quiche/quiche/common/platform/default/quiche_platform_impl/quiche_test_impl.h +56 -0
- package/third_party/quiche/quiche/common/platform/default/quiche_platform_impl/quiche_test_output_impl.h +27 -0
- package/third_party/quiche/quiche/common/platform/default/quiche_platform_impl/quiche_thread_impl.h +26 -0
- package/third_party/quiche/quiche/common/platform/default/quiche_platform_impl/quiche_url_utils_impl.cc +1 -0
- package/third_party/quiche/quiche/common/quiche_buffer_allocator_test.cc +1 -1
- package/third_party/quiche/quiche/common/quiche_mem_slice_storage.h +2 -3
- package/third_party/quiche/quiche/common/structured_headers.cc +14 -12
- package/third_party/quiche/quiche/http2/adapter/event_forwarder.cc +7 -5
- package/third_party/quiche/quiche/http2/adapter/event_forwarder.h +4 -2
- package/third_party/quiche/quiche/http2/adapter/event_forwarder_test.cc +14 -9
- package/third_party/quiche/quiche/http2/adapter/header_validator.cc +43 -19
- package/third_party/quiche/quiche/http2/adapter/header_validator.h +11 -40
- package/third_party/quiche/quiche/http2/adapter/header_validator_base.h +69 -0
- package/third_party/quiche/quiche/http2/adapter/header_validator_test.cc +73 -1
- package/third_party/quiche/quiche/http2/adapter/nghttp2_adapter_test.cc +66 -0
- package/third_party/quiche/quiche/http2/adapter/nghttp2_session_test.cc +8 -5
- package/third_party/quiche/quiche/http2/adapter/nghttp2_test.cc +1 -1
- package/third_party/quiche/quiche/http2/adapter/noop_header_validator.cc +22 -0
- package/third_party/quiche/quiche/http2/adapter/noop_header_validator.h +25 -0
- package/third_party/quiche/quiche/http2/adapter/noop_header_validator_test.cc +523 -0
- package/third_party/quiche/quiche/http2/adapter/oghttp2_adapter_test.cc +186 -5
- package/third_party/quiche/quiche/http2/adapter/oghttp2_session.cc +37 -43
- package/third_party/quiche/quiche/http2/adapter/oghttp2_session.h +22 -23
- package/third_party/quiche/quiche/http2/adapter/test_utils.cc +1 -1
- package/third_party/quiche/quiche/http2/adapter/window_manager_test.cc +11 -5
- package/third_party/quiche/quiche/http2/core/http2_trace_logging.cc +13 -11
- package/third_party/quiche/quiche/http2/core/http2_trace_logging.h +5 -4
- package/third_party/quiche/quiche/http2/core/priority_write_scheduler.h +42 -36
- package/third_party/quiche/quiche/http2/core/priority_write_scheduler_test.cc +2 -2
- package/third_party/quiche/quiche/http2/decoder/decode_buffer_test.cc +9 -9
- package/third_party/quiche/quiche/http2/decoder/decode_http2_structures_test.cc +1 -1
- package/third_party/quiche/quiche/http2/decoder/http2_frame_decoder_test.cc +14 -14
- package/third_party/quiche/quiche/http2/decoder/http2_structure_decoder_test.cc +17 -17
- package/third_party/quiche/quiche/http2/decoder/payload_decoders/altsvc_payload_decoder_test.cc +1 -1
- package/third_party/quiche/quiche/http2/decoder/payload_decoders/continuation_payload_decoder_test.cc +1 -1
- package/third_party/quiche/quiche/http2/decoder/payload_decoders/data_payload_decoder_test.cc +2 -2
- package/third_party/quiche/quiche/http2/decoder/payload_decoders/goaway_payload_decoder_test.cc +1 -1
- package/third_party/quiche/quiche/http2/decoder/payload_decoders/headers_payload_decoder_test.cc +1 -1
- package/third_party/quiche/quiche/http2/decoder/payload_decoders/ping_payload_decoder_test.cc +1 -1
- package/third_party/quiche/quiche/http2/decoder/payload_decoders/priority_payload_decoder_test.cc +1 -1
- package/third_party/quiche/quiche/http2/decoder/payload_decoders/priority_update_payload_decoder_test.cc +1 -1
- package/third_party/quiche/quiche/http2/decoder/payload_decoders/push_promise_payload_decoder_test.cc +1 -1
- package/third_party/quiche/quiche/http2/decoder/payload_decoders/rst_stream_payload_decoder_test.cc +1 -1
- package/third_party/quiche/quiche/http2/decoder/payload_decoders/settings_payload_decoder_test.cc +1 -1
- package/third_party/quiche/quiche/http2/decoder/payload_decoders/unknown_payload_decoder_test.cc +1 -1
- package/third_party/quiche/quiche/http2/decoder/payload_decoders/window_update_payload_decoder_test.cc +1 -1
- package/third_party/quiche/quiche/http2/hpack/decoder/hpack_block_decoder_test.cc +2 -2
- package/third_party/quiche/quiche/http2/hpack/decoder/hpack_decoder_state_test.cc +8 -8
- package/third_party/quiche/quiche/http2/hpack/decoder/hpack_decoder_string_buffer_test.cc +4 -3
- package/third_party/quiche/quiche/http2/hpack/decoder/hpack_decoder_tables_test.cc +17 -17
- package/third_party/quiche/quiche/http2/hpack/decoder/hpack_decoder_test.cc +25 -25
- package/third_party/quiche/quiche/http2/hpack/decoder/hpack_entry_decoder_test.cc +2 -2
- package/third_party/quiche/quiche/http2/hpack/decoder/hpack_entry_type_decoder_test.cc +7 -6
- package/third_party/quiche/quiche/http2/hpack/decoder/hpack_string_decoder_test.cc +6 -6
- package/third_party/quiche/quiche/http2/hpack/decoder/hpack_whole_entry_buffer_test.cc +1 -1
- package/third_party/quiche/quiche/http2/hpack/huffman/hpack_huffman_decoder_test.cc +2 -2
- package/third_party/quiche/quiche/http2/hpack/huffman/hpack_huffman_encoder_test.cc +1 -1
- package/third_party/quiche/quiche/http2/hpack/huffman/hpack_huffman_transcoder_test.cc +5 -5
- package/third_party/quiche/quiche/http2/hpack/varint/hpack_varint_decoder_test.cc +4 -4
- package/third_party/quiche/quiche/http2/hpack/varint/hpack_varint_round_trip_test.cc +1 -1
- package/third_party/quiche/quiche/http2/http2_constants_test.cc +1 -1
- package/third_party/quiche/quiche/http2/http2_structures_test.cc +23 -22
- package/third_party/quiche/quiche/http2/test_tools/frame_decoder_state_test_util.cc +1 -1
- package/third_party/quiche/quiche/http2/test_tools/frame_decoder_state_test_util.h +1 -1
- package/third_party/quiche/quiche/http2/test_tools/frame_parts.cc +38 -38
- package/third_party/quiche/quiche/http2/test_tools/hpack_block_collector.cc +15 -15
- package/third_party/quiche/quiche/http2/test_tools/hpack_entry_collector.cc +24 -22
- package/third_party/quiche/quiche/http2/test_tools/hpack_string_collector.cc +5 -5
- package/third_party/quiche/quiche/http2/test_tools/http2_frame_builder_test.cc +70 -89
- package/third_party/quiche/quiche/http2/test_tools/payload_decoder_base_test_util.cc +1 -1
- package/third_party/quiche/quiche/http2/test_tools/payload_decoder_base_test_util.h +29 -26
- package/third_party/quiche/quiche/http2/test_tools/{random_decoder_test.cc → random_decoder_test_base.cc} +13 -10
- package/third_party/quiche/quiche/http2/test_tools/{random_decoder_test.h → random_decoder_test_base.h} +15 -17
- package/third_party/quiche/quiche/http2/test_tools/{random_decoder_test_test.cc → random_decoder_test_base_test.cc} +1 -1
- package/third_party/quiche/quiche/http2/test_tools/verify_macros.h +32 -0
- package/third_party/quiche/quiche/quic/core/congestion_control/bbr2_sender.cc +2 -1
- package/third_party/quiche/quiche/quic/core/congestion_control/bbr2_simulator_test.cc +3 -2
- package/third_party/quiche/quiche/quic/core/congestion_control/bbr_sender_test.cc +3 -2
- package/third_party/quiche/quiche/quic/core/congestion_control/rtt_stats.cc +3 -2
- package/third_party/quiche/quiche/quic/core/congestion_control/rtt_stats.h +2 -1
- package/third_party/quiche/quiche/quic/core/congestion_control/rtt_stats_test.cc +2 -13
- package/third_party/quiche/quiche/quic/core/crypto/certificate_view.cc +15 -0
- package/third_party/quiche/quiche/quic/core/crypto/certificate_view.h +7 -0
- package/third_party/quiche/quiche/quic/core/crypto/certificate_view_test.cc +16 -0
- package/third_party/quiche/quiche/quic/core/crypto/crypto_protocol.h +1 -0
- package/third_party/quiche/quiche/quic/core/crypto/proof_source.h +2 -2
- package/third_party/quiche/quiche/quic/core/crypto/proof_source_x509.cc +3 -5
- package/third_party/quiche/quiche/quic/core/crypto/proof_source_x509.h +1 -2
- package/third_party/quiche/quiche/quic/core/crypto/quic_crypto_server_config.cc +1 -1
- package/third_party/quiche/quiche/quic/core/crypto/quic_crypto_server_config.h +3 -3
- package/third_party/quiche/quiche/quic/core/frames/quic_blocked_frame.cc +2 -8
- package/third_party/quiche/quiche/quic/core/frames/quic_blocked_frame.h +0 -1
- package/third_party/quiche/quiche/quic/core/frames/quic_crypto_frame.h +2 -0
- package/third_party/quiche/quiche/quic/core/frames/quic_frames_test.cc +2 -1
- package/third_party/quiche/quiche/quic/core/http/capsule.cc +2 -22
- package/third_party/quiche/quiche/quic/core/http/capsule.h +0 -2
- package/third_party/quiche/quiche/quic/core/http/capsule_test.cc +1 -2
- package/third_party/quiche/quiche/quic/core/http/end_to_end_test.cc +148 -57
- package/third_party/quiche/quiche/quic/core/http/http_constants.cc +1 -1
- package/third_party/quiche/quiche/quic/core/http/http_constants.h +2 -2
- package/third_party/quiche/quiche/quic/core/http/quic_header_list_test.cc +2 -2
- package/third_party/quiche/quiche/quic/core/http/quic_headers_stream_test.cc +18 -14
- package/third_party/quiche/quiche/quic/core/http/quic_send_control_stream.h +2 -1
- package/third_party/quiche/quiche/quic/core/http/quic_send_control_stream_test.cc +3 -7
- package/third_party/quiche/quiche/quic/core/http/quic_server_session_base.h +4 -0
- package/third_party/quiche/quiche/quic/core/http/quic_spdy_session.cc +47 -65
- package/third_party/quiche/quiche/quic/core/http/quic_spdy_session.h +5 -17
- package/third_party/quiche/quiche/quic/core/http/quic_spdy_session_test.cc +63 -54
- package/third_party/quiche/quiche/quic/core/http/quic_spdy_stream.cc +34 -91
- package/third_party/quiche/quiche/quic/core/http/quic_spdy_stream.h +1 -9
- package/third_party/quiche/quiche/quic/core/http/quic_spdy_stream_test.cc +27 -134
- package/third_party/quiche/quiche/quic/core/http/spdy_utils.cc +0 -41
- package/third_party/quiche/quiche/quic/core/http/spdy_utils.h +0 -9
- package/third_party/quiche/quiche/quic/core/http/spdy_utils_test.cc +0 -32
- package/third_party/quiche/quiche/quic/core/http/web_transport_http3.cc +0 -1
- package/third_party/quiche/quiche/quic/core/packet_number_indexed_queue_test.cc +2 -2
- package/third_party/quiche/quiche/quic/core/qpack/qpack_header_table.cc +2 -1
- package/third_party/quiche/quiche/quic/core/qpack/qpack_send_stream.h +2 -1
- package/third_party/quiche/quiche/quic/core/quic_arena_scoped_ptr_test.cc +2 -2
- package/third_party/quiche/quiche/quic/core/quic_connection.cc +68 -46
- package/third_party/quiche/quiche/quic/core/quic_connection.h +7 -6
- package/third_party/quiche/quiche/quic/core/quic_connection_context_test.cc +2 -2
- package/third_party/quiche/quiche/quic/core/quic_connection_id_manager_test.cc +2 -2
- package/third_party/quiche/quiche/quic/core/quic_connection_id_test.cc +2 -2
- package/third_party/quiche/quiche/quic/core/quic_connection_test.cc +45 -132
- package/third_party/quiche/quiche/quic/core/quic_constants.h +0 -7
- package/third_party/quiche/quiche/quic/core/quic_control_frame_manager.cc +11 -3
- package/third_party/quiche/quiche/quic/core/quic_control_frame_manager.h +1 -1
- package/third_party/quiche/quiche/quic/core/quic_control_frame_manager_test.cc +2 -2
- package/third_party/quiche/quiche/quic/core/quic_crypto_client_handshaker.cc +13 -1
- package/third_party/quiche/quiche/quic/core/quic_crypto_client_handshaker.h +3 -0
- package/third_party/quiche/quiche/quic/core/quic_crypto_client_handshaker_test.cc +2 -2
- package/third_party/quiche/quiche/quic/core/quic_crypto_client_stream.cc +6 -0
- package/third_party/quiche/quiche/quic/core/quic_crypto_client_stream.h +8 -0
- package/third_party/quiche/quiche/quic/core/quic_crypto_server_stream.cc +26 -13
- package/third_party/quiche/quiche/quic/core/quic_crypto_server_stream.h +5 -2
- package/third_party/quiche/quiche/quic/core/quic_crypto_stream.cc +55 -47
- package/third_party/quiche/quiche/quic/core/quic_crypto_stream.h +15 -10
- package/third_party/quiche/quiche/quic/core/quic_crypto_stream_test.cc +34 -5
- package/third_party/quiche/quiche/quic/core/quic_dispatcher.cc +20 -11
- package/third_party/quiche/quiche/quic/core/quic_dispatcher_test.cc +37 -13
- package/third_party/quiche/quiche/quic/core/quic_flags_list.h +6 -10
- package/third_party/quiche/quiche/quic/core/quic_flow_controller.cc +3 -3
- package/third_party/quiche/quiche/quic/core/quic_flow_controller.h +2 -2
- package/third_party/quiche/quiche/quic/core/quic_flow_controller_test.cc +15 -10
- package/third_party/quiche/quiche/quic/core/quic_framer.cc +1 -1
- package/third_party/quiche/quiche/quic/core/quic_one_block_arena.h +3 -2
- package/third_party/quiche/quiche/quic/core/quic_one_block_arena_test.cc +2 -2
- package/third_party/quiche/quiche/quic/core/quic_packet_creator.cc +3 -11
- package/third_party/quiche/quiche/quic/core/quic_packet_creator.h +0 -8
- package/third_party/quiche/quiche/quic/core/quic_ping_manager.cc +14 -14
- package/third_party/quiche/quiche/quic/core/quic_ping_manager_test.cc +48 -0
- package/third_party/quiche/quiche/quic/core/quic_received_packet_manager.cc +3 -18
- package/third_party/quiche/quiche/quic/core/quic_received_packet_manager_test.cc +4 -14
- package/third_party/quiche/quiche/quic/core/quic_server_id_test.cc +2 -2
- package/third_party/quiche/quiche/quic/core/quic_session.cc +4 -4
- package/third_party/quiche/quiche/quic/core/quic_session.h +1 -1
- package/third_party/quiche/quiche/quic/core/quic_session_test.cc +21 -1
- package/third_party/quiche/quiche/quic/core/quic_stream.cc +4 -7
- package/third_party/quiche/quiche/quic/core/quic_stream_test.cc +2 -4
- package/third_party/quiche/quiche/quic/core/quic_trace_visitor_test.cc +2 -2
- package/third_party/quiche/quiche/quic/core/quic_types.h +3 -8
- package/third_party/quiche/quiche/quic/core/quic_udp_socket_posix.cc +5 -4
- package/third_party/quiche/quiche/quic/core/quic_unacked_packet_map_test.cc +1 -1
- package/third_party/quiche/quiche/quic/core/quic_utils.cc +1 -1
- package/third_party/quiche/quiche/quic/core/quic_utils.h +2 -2
- package/third_party/quiche/quiche/quic/core/quic_versions_test.cc +0 -1
- package/third_party/quiche/quiche/quic/core/tls_client_handshaker.cc +13 -0
- package/third_party/quiche/quiche/quic/core/tls_client_handshaker.h +2 -0
- package/third_party/quiche/quiche/quic/core/tls_server_handshaker.cc +17 -3
- package/third_party/quiche/quiche/quic/core/tls_server_handshaker.h +3 -1
- package/third_party/quiche/quiche/quic/core/uber_received_packet_manager_test.cc +18 -10
- package/third_party/quiche/quiche/quic/masque/masque_client_bin.cc +6 -4
- package/third_party/quiche/quiche/quic/masque/masque_client_session.cc +23 -7
- package/third_party/quiche/quiche/quic/masque/masque_client_session.h +1 -1
- package/third_party/quiche/quiche/quic/masque/masque_server_backend.cc +13 -0
- package/third_party/quiche/quiche/quic/masque/masque_server_backend.h +2 -0
- package/third_party/quiche/quiche/quic/masque/masque_server_bin.cc +5 -4
- package/third_party/quiche/quiche/quic/masque/masque_server_session.cc +30 -40
- package/third_party/quiche/quiche/quic/masque/masque_server_session.h +1 -1
- package/third_party/quiche/quiche/quic/platform/api/quic_export.h +4 -4
- package/third_party/quiche/quiche/quic/platform/api/quic_flags.h +0 -1
- package/third_party/quiche/quiche/quic/platform/api/quic_logging.h +0 -6
- package/third_party/quiche/quiche/quic/platform/api/quic_test.h +6 -5
- package/third_party/quiche/quiche/quic/qbone/bonnet/icmp_reachable_test.cc +2 -2
- package/third_party/quiche/quiche/quic/qbone/bonnet/mock_qbone_tunnel.h +2 -0
- package/third_party/quiche/quiche/quic/qbone/bonnet/qbone_tunnel_interface.h +2 -0
- package/third_party/quiche/quiche/quic/qbone/bonnet/tun_device_controller_test.cc +2 -2
- package/third_party/quiche/quiche/quic/qbone/bonnet/tun_device_packet_exchanger_test.cc +2 -2
- package/third_party/quiche/quiche/quic/qbone/bonnet/tun_device_test.cc +2 -2
- package/third_party/quiche/quiche/quic/qbone/platform/netlink_test.cc +2 -2
- package/third_party/quiche/quiche/quic/qbone/platform/tcp_packet.cc +5 -4
- package/third_party/quiche/quiche/quic/qbone/qbone_client_session.cc +4 -2
- package/third_party/quiche/quiche/quic/qbone/qbone_packet_processor.cc +2 -1
- package/third_party/quiche/quiche/quic/qbone/qbone_packet_processor_test.cc +2 -2
- package/third_party/quiche/quiche/quic/qbone/qbone_server_session.cc +4 -2
- package/third_party/quiche/quiche/quic/qbone/qbone_session_base.cc +3 -2
- package/third_party/quiche/quiche/quic/qbone/qbone_stream.cc +4 -4
- package/third_party/quiche/quiche/quic/test_tools/quic_connection_peer.cc +1 -1
- package/third_party/quiche/quiche/quic/test_tools/quic_http_response_cache_data/test.example.com/index.html +63 -0
- package/third_party/quiche/quiche/quic/test_tools/quic_http_response_cache_data/test.example.com/map.html +65 -0
- package/third_party/quiche/quiche/quic/test_tools/quic_test_utils.cc +4 -3
- package/third_party/quiche/quiche/quic/test_tools/quic_test_utils.h +18 -1
- package/third_party/quiche/quiche/quic/test_tools/simulator/quic_endpoint_test.cc +1 -1
- package/third_party/quiche/quiche/quic/test_tools/simulator/simulator_test.cc +1 -1
- package/third_party/quiche/quiche/quic/test_tools/test_ticket_crypter.cc +1 -1
- package/third_party/quiche/quiche/quic/test_tools/test_ticket_crypter.h +2 -2
- package/third_party/quiche/quiche/quic/{core/crypto → tools}/crypto_message_printer_bin.cc +0 -0
- package/third_party/quiche/quiche/quic/{core/qpack → tools}/qpack_offline_decoder_bin.cc +0 -0
- package/third_party/quiche/quiche/quic/tools/quic_client_interop_test_bin.cc +4 -3
- package/third_party/quiche/quiche/quic/tools/quic_memory_cache_backend_test.cc +3 -31
- package/third_party/quiche/quiche/quic/tools/quic_packet_printer_bin.cc +2 -2
- package/third_party/quiche/quiche/quic/tools/quic_simple_server_session.h +1 -1
- package/third_party/quiche/quiche/quic/tools/quic_simple_server_session_test.cc +1 -1
- package/third_party/quiche/quiche/quic/tools/quic_toy_client.cc +52 -38
- package/third_party/quiche/quiche/quic/tools/quic_toy_server.cc +10 -7
- package/third_party/quiche/quiche/quic/tools/simple_ticket_crypter.cc +1 -1
- package/third_party/quiche/quiche/quic/tools/simple_ticket_crypter.h +1 -1
- package/third_party/quiche/quiche/quic/tools/web_transport_test_visitors.h +3 -2
- package/third_party/quiche/quiche/spdy/core/array_output_buffer.h +1 -1
- package/third_party/quiche/quiche/spdy/core/hpack/hpack_decoder_adapter_test.cc +1 -1
- package/third_party/quiche/quiche/spdy/core/hpack/hpack_encoder_test.cc +2 -1
- package/third_party/quiche/quiche/spdy/core/hpack/hpack_header_table_test.cc +1 -1
- package/third_party/quiche/quiche/spdy/core/hpack/hpack_round_trip_test.cc +2 -1
- package/third_party/quiche/quiche/spdy/core/hpack/hpack_static_table_test.cc +1 -1
- package/third_party/quiche/quiche/spdy/core/http2_frame_decoder_adapter.cc +8 -6
- package/third_party/quiche/quiche/spdy/core/http2_frame_decoder_adapter.h +17 -6
- package/third_party/quiche/quiche/spdy/core/metadata_extension.cc +1 -1
- package/third_party/quiche/quiche/spdy/core/metadata_extension_test.cc +1 -1
- package/third_party/quiche/quiche/spdy/core/spdy_framer_test.cc +21 -17
- package/third_party/quiche/quiche/spdy/core/spdy_intrusive_list_test.cc +3 -3
- package/third_party/quiche/quiche/spdy/core/spdy_no_op_visitor.h +6 -4
- package/third_party/quiche/quiche/spdy/core/spdy_pinnable_buffer_piece_test.cc +1 -1
- package/third_party/quiche/quiche/spdy/core/spdy_prefixed_buffer_reader_test.cc +1 -1
- package/third_party/quiche/quiche/spdy/core/spdy_protocol_test.cc +1 -1
- package/third_party/quiche/quiche/spdy/test_tools/mock_spdy_framer_visitor.h +5 -4
- package/third_party/boringssl/src/util/bot/cmake-win32.zip.sha1 +0 -1
- package/third_party/quiche/quiche/common/platform/api/quiche_mock_log.h +0 -18
- package/third_party/quiche/quiche/common/platform/api/quiche_test_helpers.h +0 -8
- package/third_party/quiche/quiche/quic/platform/api/quic_mock_log.h +0 -19
- package/third_party/quiche/quiche/quic/tools/quic_transport_simple_server_dispatcher.cc +0 -51
- package/third_party/quiche/quiche/quic/tools/quic_transport_simple_server_dispatcher.h +0 -41
- package/third_party/quiche/quiche/quic/tools/quic_transport_simple_server_session.cc +0 -168
- package/third_party/quiche/quiche/quic/tools/quic_transport_simple_server_session.h +0 -78
|
@@ -1,1472 +1,1504 @@
|
|
|
1
|
-
/* ====================================================================
|
|
2
|
-
* Copyright (c) 2001-2011 The OpenSSL Project. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* Redistribution and use in source and binary forms, with or without
|
|
5
|
-
* modification, are permitted provided that the following conditions
|
|
6
|
-
* are met:
|
|
7
|
-
*
|
|
8
|
-
* 1. Redistributions of source code must retain the above copyright
|
|
9
|
-
* notice, this list of conditions and the following disclaimer.
|
|
10
|
-
*
|
|
11
|
-
* 2. Redistributions in binary form must reproduce the above copyright
|
|
12
|
-
* notice, this list of conditions and the following disclaimer in
|
|
13
|
-
* the documentation and/or other materials provided with the
|
|
14
|
-
* distribution.
|
|
15
|
-
*
|
|
16
|
-
* 3. All advertising materials mentioning features or use of this
|
|
17
|
-
* software must display the following acknowledgment:
|
|
18
|
-
* "This product includes software developed by the OpenSSL Project
|
|
19
|
-
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
|
20
|
-
*
|
|
21
|
-
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
|
22
|
-
* endorse or promote products derived from this software without
|
|
23
|
-
* prior written permission. For written permission, please contact
|
|
24
|
-
* openssl-core@openssl.org.
|
|
25
|
-
*
|
|
26
|
-
* 5. Products derived from this software may not be called "OpenSSL"
|
|
27
|
-
* nor may "OpenSSL" appear in their names without prior written
|
|
28
|
-
* permission of the OpenSSL Project.
|
|
29
|
-
*
|
|
30
|
-
* 6. Redistributions of any form whatsoever must retain the following
|
|
31
|
-
* acknowledgment:
|
|
32
|
-
* "This product includes software developed by the OpenSSL Project
|
|
33
|
-
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
|
34
|
-
*
|
|
35
|
-
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
|
36
|
-
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
37
|
-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
38
|
-
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
|
39
|
-
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
40
|
-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
41
|
-
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
42
|
-
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
43
|
-
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
44
|
-
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
45
|
-
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
|
46
|
-
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
47
|
-
* ==================================================================== */
|
|
48
|
-
|
|
49
|
-
#include <assert.h>
|
|
50
|
-
#include <string.h>
|
|
51
|
-
|
|
52
|
-
#include <openssl/aead.h>
|
|
53
|
-
#include <openssl/aes.h>
|
|
54
|
-
#include <openssl/cipher.h>
|
|
55
|
-
#include <openssl/err.h>
|
|
56
|
-
#include <openssl/mem.h>
|
|
57
|
-
#include <openssl/nid.h>
|
|
58
|
-
#include <openssl/rand.h>
|
|
59
|
-
|
|
60
|
-
#include "internal.h"
|
|
61
|
-
#include "../../internal.h"
|
|
62
|
-
#include "../aes/internal.h"
|
|
63
|
-
#include "../modes/internal.h"
|
|
64
|
-
#include "../
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
OPENSSL_MSVC_PRAGMA(warning(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
//
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
//
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
new_ivec.u32[3]
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
int
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
int
|
|
137
|
-
int
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
dat->
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
dat->block
|
|
175
|
-
dat->
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
dat->
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
dat->
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
dat->
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
dat->
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
dat->
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
#
|
|
335
|
-
#
|
|
336
|
-
#
|
|
337
|
-
#
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
//
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
gctx->
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
gctx->
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
gctx->
|
|
434
|
-
gctx->
|
|
435
|
-
gctx->
|
|
436
|
-
gctx->
|
|
437
|
-
gctx->
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
gctx->
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
// at least
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
if (!
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
out
|
|
608
|
-
|
|
609
|
-
out->
|
|
610
|
-
out->
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
out->
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
out
|
|
621
|
-
|
|
622
|
-
out->
|
|
623
|
-
out->
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
out->
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
out
|
|
634
|
-
|
|
635
|
-
out->
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
out->
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
out
|
|
646
|
-
|
|
647
|
-
out->
|
|
648
|
-
out->
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
out->
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
out
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
out->
|
|
663
|
-
out->
|
|
664
|
-
out->
|
|
665
|
-
out->
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
out->
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
out
|
|
676
|
-
|
|
677
|
-
out->
|
|
678
|
-
out->
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
out->
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
out
|
|
689
|
-
|
|
690
|
-
out->
|
|
691
|
-
out->
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
out->
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
out
|
|
702
|
-
|
|
703
|
-
out->
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
out->
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
out
|
|
714
|
-
|
|
715
|
-
out->
|
|
716
|
-
out->
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
out->
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
out
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
out->
|
|
731
|
-
out->
|
|
732
|
-
out->
|
|
733
|
-
out->
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
out->
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
out
|
|
744
|
-
|
|
745
|
-
out->
|
|
746
|
-
out->
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
out->
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
out
|
|
757
|
-
|
|
758
|
-
out->
|
|
759
|
-
out->
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
out->
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
out
|
|
770
|
-
|
|
771
|
-
out->
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
out->
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
out
|
|
782
|
-
|
|
783
|
-
out->
|
|
784
|
-
out->
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
out->
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
out
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
out->
|
|
799
|
-
out->
|
|
800
|
-
out->
|
|
801
|
-
out->
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
out
|
|
827
|
-
|
|
828
|
-
out->
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
out->
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
out
|
|
839
|
-
|
|
840
|
-
out->
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
out->
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
out
|
|
851
|
-
|
|
852
|
-
out->
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
EVP_CIPHER_FUNCTION(
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
EVP_CIPHER_FUNCTION(
|
|
884
|
-
EVP_CIPHER_FUNCTION(
|
|
885
|
-
EVP_CIPHER_FUNCTION(
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
EVP_CIPHER_FUNCTION(
|
|
889
|
-
EVP_CIPHER_FUNCTION(
|
|
890
|
-
EVP_CIPHER_FUNCTION(
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
if (
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
out
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
out->
|
|
1126
|
-
|
|
1127
|
-
out->
|
|
1128
|
-
out->
|
|
1129
|
-
out->
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
out
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
out->
|
|
1141
|
-
|
|
1142
|
-
out->
|
|
1143
|
-
out->
|
|
1144
|
-
out->
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
out
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
return 0;
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
out->
|
|
1258
|
-
out->
|
|
1259
|
-
out->
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
}
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
}
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
out
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1
|
+
/* ====================================================================
|
|
2
|
+
* Copyright (c) 2001-2011 The OpenSSL Project. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Redistribution and use in source and binary forms, with or without
|
|
5
|
+
* modification, are permitted provided that the following conditions
|
|
6
|
+
* are met:
|
|
7
|
+
*
|
|
8
|
+
* 1. Redistributions of source code must retain the above copyright
|
|
9
|
+
* notice, this list of conditions and the following disclaimer.
|
|
10
|
+
*
|
|
11
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
|
12
|
+
* notice, this list of conditions and the following disclaimer in
|
|
13
|
+
* the documentation and/or other materials provided with the
|
|
14
|
+
* distribution.
|
|
15
|
+
*
|
|
16
|
+
* 3. All advertising materials mentioning features or use of this
|
|
17
|
+
* software must display the following acknowledgment:
|
|
18
|
+
* "This product includes software developed by the OpenSSL Project
|
|
19
|
+
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
|
20
|
+
*
|
|
21
|
+
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
|
22
|
+
* endorse or promote products derived from this software without
|
|
23
|
+
* prior written permission. For written permission, please contact
|
|
24
|
+
* openssl-core@openssl.org.
|
|
25
|
+
*
|
|
26
|
+
* 5. Products derived from this software may not be called "OpenSSL"
|
|
27
|
+
* nor may "OpenSSL" appear in their names without prior written
|
|
28
|
+
* permission of the OpenSSL Project.
|
|
29
|
+
*
|
|
30
|
+
* 6. Redistributions of any form whatsoever must retain the following
|
|
31
|
+
* acknowledgment:
|
|
32
|
+
* "This product includes software developed by the OpenSSL Project
|
|
33
|
+
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
|
34
|
+
*
|
|
35
|
+
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
|
36
|
+
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
37
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
38
|
+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
|
39
|
+
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
40
|
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
41
|
+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
42
|
+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
43
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
44
|
+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
45
|
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
|
46
|
+
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
47
|
+
* ==================================================================== */
|
|
48
|
+
|
|
49
|
+
#include <assert.h>
|
|
50
|
+
#include <string.h>
|
|
51
|
+
|
|
52
|
+
#include <openssl/aead.h>
|
|
53
|
+
#include <openssl/aes.h>
|
|
54
|
+
#include <openssl/cipher.h>
|
|
55
|
+
#include <openssl/err.h>
|
|
56
|
+
#include <openssl/mem.h>
|
|
57
|
+
#include <openssl/nid.h>
|
|
58
|
+
#include <openssl/rand.h>
|
|
59
|
+
|
|
60
|
+
#include "internal.h"
|
|
61
|
+
#include "../../internal.h"
|
|
62
|
+
#include "../aes/internal.h"
|
|
63
|
+
#include "../modes/internal.h"
|
|
64
|
+
#include "../service_indicator/internal.h"
|
|
65
|
+
#include "../delocate.h"
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
OPENSSL_MSVC_PRAGMA(warning(push))
|
|
69
|
+
OPENSSL_MSVC_PRAGMA(warning(disable: 4702)) // Unreachable code.
|
|
70
|
+
|
|
71
|
+
#define AES_GCM_NONCE_LENGTH 12
|
|
72
|
+
|
|
73
|
+
#if defined(BSAES)
|
|
74
|
+
static void vpaes_ctr32_encrypt_blocks_with_bsaes(const uint8_t *in,
|
|
75
|
+
uint8_t *out, size_t blocks,
|
|
76
|
+
const AES_KEY *key,
|
|
77
|
+
const uint8_t ivec[16]) {
|
|
78
|
+
// |bsaes_ctr32_encrypt_blocks| is faster than |vpaes_ctr32_encrypt_blocks|,
|
|
79
|
+
// but it takes at least one full 8-block batch to amortize the conversion.
|
|
80
|
+
if (blocks < 8) {
|
|
81
|
+
vpaes_ctr32_encrypt_blocks(in, out, blocks, key, ivec);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
size_t bsaes_blocks = blocks;
|
|
86
|
+
if (bsaes_blocks % 8 < 6) {
|
|
87
|
+
// |bsaes_ctr32_encrypt_blocks| internally works in 8-block batches. If the
|
|
88
|
+
// final batch is too small (under six blocks), it is faster to loop over
|
|
89
|
+
// |vpaes_encrypt|. Round |bsaes_blocks| down to a multiple of 8.
|
|
90
|
+
bsaes_blocks -= bsaes_blocks % 8;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
AES_KEY bsaes;
|
|
94
|
+
vpaes_encrypt_key_to_bsaes(&bsaes, key);
|
|
95
|
+
bsaes_ctr32_encrypt_blocks(in, out, bsaes_blocks, &bsaes, ivec);
|
|
96
|
+
OPENSSL_cleanse(&bsaes, sizeof(bsaes));
|
|
97
|
+
|
|
98
|
+
in += 16 * bsaes_blocks;
|
|
99
|
+
out += 16 * bsaes_blocks;
|
|
100
|
+
blocks -= bsaes_blocks;
|
|
101
|
+
|
|
102
|
+
union {
|
|
103
|
+
uint32_t u32[4];
|
|
104
|
+
uint8_t u8[16];
|
|
105
|
+
} new_ivec;
|
|
106
|
+
memcpy(new_ivec.u8, ivec, 16);
|
|
107
|
+
uint32_t ctr = CRYPTO_bswap4(new_ivec.u32[3]) + bsaes_blocks;
|
|
108
|
+
new_ivec.u32[3] = CRYPTO_bswap4(ctr);
|
|
109
|
+
|
|
110
|
+
// Finish any remaining blocks with |vpaes_ctr32_encrypt_blocks|.
|
|
111
|
+
vpaes_ctr32_encrypt_blocks(in, out, blocks, key, new_ivec.u8);
|
|
112
|
+
}
|
|
113
|
+
#endif // BSAES
|
|
114
|
+
|
|
115
|
+
typedef struct {
|
|
116
|
+
union {
|
|
117
|
+
double align;
|
|
118
|
+
AES_KEY ks;
|
|
119
|
+
} ks;
|
|
120
|
+
block128_f block;
|
|
121
|
+
union {
|
|
122
|
+
cbc128_f cbc;
|
|
123
|
+
ctr128_f ctr;
|
|
124
|
+
} stream;
|
|
125
|
+
} EVP_AES_KEY;
|
|
126
|
+
|
|
127
|
+
typedef struct {
|
|
128
|
+
GCM128_CONTEXT gcm;
|
|
129
|
+
union {
|
|
130
|
+
double align;
|
|
131
|
+
AES_KEY ks;
|
|
132
|
+
} ks; // AES key schedule to use
|
|
133
|
+
int key_set; // Set if key initialised
|
|
134
|
+
int iv_set; // Set if an iv is set
|
|
135
|
+
uint8_t *iv; // Temporary IV store
|
|
136
|
+
int ivlen; // IV length
|
|
137
|
+
int taglen;
|
|
138
|
+
int iv_gen; // It is OK to generate IVs
|
|
139
|
+
ctr128_f ctr;
|
|
140
|
+
} EVP_AES_GCM_CTX;
|
|
141
|
+
|
|
142
|
+
static int aes_init_key(EVP_CIPHER_CTX *ctx, const uint8_t *key,
|
|
143
|
+
const uint8_t *iv, int enc) {
|
|
144
|
+
int ret;
|
|
145
|
+
EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data;
|
|
146
|
+
const int mode = ctx->cipher->flags & EVP_CIPH_MODE_MASK;
|
|
147
|
+
|
|
148
|
+
if (mode == EVP_CIPH_CTR_MODE) {
|
|
149
|
+
switch (ctx->key_len) {
|
|
150
|
+
case 16:
|
|
151
|
+
boringssl_fips_inc_counter(fips_counter_evp_aes_128_ctr);
|
|
152
|
+
break;
|
|
153
|
+
|
|
154
|
+
case 32:
|
|
155
|
+
boringssl_fips_inc_counter(fips_counter_evp_aes_256_ctr);
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if ((mode == EVP_CIPH_ECB_MODE || mode == EVP_CIPH_CBC_MODE) && !enc) {
|
|
161
|
+
if (hwaes_capable()) {
|
|
162
|
+
ret = aes_hw_set_decrypt_key(key, ctx->key_len * 8, &dat->ks.ks);
|
|
163
|
+
dat->block = aes_hw_decrypt;
|
|
164
|
+
dat->stream.cbc = NULL;
|
|
165
|
+
if (mode == EVP_CIPH_CBC_MODE) {
|
|
166
|
+
dat->stream.cbc = aes_hw_cbc_encrypt;
|
|
167
|
+
}
|
|
168
|
+
} else if (bsaes_capable() && mode == EVP_CIPH_CBC_MODE) {
|
|
169
|
+
assert(vpaes_capable());
|
|
170
|
+
ret = vpaes_set_decrypt_key(key, ctx->key_len * 8, &dat->ks.ks);
|
|
171
|
+
if (ret == 0) {
|
|
172
|
+
vpaes_decrypt_key_to_bsaes(&dat->ks.ks, &dat->ks.ks);
|
|
173
|
+
}
|
|
174
|
+
// If |dat->stream.cbc| is provided, |dat->block| is never used.
|
|
175
|
+
dat->block = NULL;
|
|
176
|
+
dat->stream.cbc = bsaes_cbc_encrypt;
|
|
177
|
+
} else if (vpaes_capable()) {
|
|
178
|
+
ret = vpaes_set_decrypt_key(key, ctx->key_len * 8, &dat->ks.ks);
|
|
179
|
+
dat->block = vpaes_decrypt;
|
|
180
|
+
dat->stream.cbc = NULL;
|
|
181
|
+
#if defined(VPAES_CBC)
|
|
182
|
+
if (mode == EVP_CIPH_CBC_MODE) {
|
|
183
|
+
dat->stream.cbc = vpaes_cbc_encrypt;
|
|
184
|
+
}
|
|
185
|
+
#endif
|
|
186
|
+
} else {
|
|
187
|
+
ret = aes_nohw_set_decrypt_key(key, ctx->key_len * 8, &dat->ks.ks);
|
|
188
|
+
dat->block = aes_nohw_decrypt;
|
|
189
|
+
dat->stream.cbc = NULL;
|
|
190
|
+
if (mode == EVP_CIPH_CBC_MODE) {
|
|
191
|
+
dat->stream.cbc = aes_nohw_cbc_encrypt;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
} else if (hwaes_capable()) {
|
|
195
|
+
ret = aes_hw_set_encrypt_key(key, ctx->key_len * 8, &dat->ks.ks);
|
|
196
|
+
dat->block = aes_hw_encrypt;
|
|
197
|
+
dat->stream.cbc = NULL;
|
|
198
|
+
if (mode == EVP_CIPH_CBC_MODE) {
|
|
199
|
+
dat->stream.cbc = aes_hw_cbc_encrypt;
|
|
200
|
+
} else if (mode == EVP_CIPH_CTR_MODE) {
|
|
201
|
+
dat->stream.ctr = aes_hw_ctr32_encrypt_blocks;
|
|
202
|
+
}
|
|
203
|
+
} else if (vpaes_capable()) {
|
|
204
|
+
ret = vpaes_set_encrypt_key(key, ctx->key_len * 8, &dat->ks.ks);
|
|
205
|
+
dat->block = vpaes_encrypt;
|
|
206
|
+
dat->stream.cbc = NULL;
|
|
207
|
+
#if defined(VPAES_CBC)
|
|
208
|
+
if (mode == EVP_CIPH_CBC_MODE) {
|
|
209
|
+
dat->stream.cbc = vpaes_cbc_encrypt;
|
|
210
|
+
}
|
|
211
|
+
#endif
|
|
212
|
+
if (mode == EVP_CIPH_CTR_MODE) {
|
|
213
|
+
#if defined(BSAES)
|
|
214
|
+
assert(bsaes_capable());
|
|
215
|
+
dat->stream.ctr = vpaes_ctr32_encrypt_blocks_with_bsaes;
|
|
216
|
+
#elif defined(VPAES_CTR32)
|
|
217
|
+
dat->stream.ctr = vpaes_ctr32_encrypt_blocks;
|
|
218
|
+
#endif
|
|
219
|
+
}
|
|
220
|
+
} else {
|
|
221
|
+
ret = aes_nohw_set_encrypt_key(key, ctx->key_len * 8, &dat->ks.ks);
|
|
222
|
+
dat->block = aes_nohw_encrypt;
|
|
223
|
+
dat->stream.cbc = NULL;
|
|
224
|
+
if (mode == EVP_CIPH_CBC_MODE) {
|
|
225
|
+
dat->stream.cbc = aes_nohw_cbc_encrypt;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (ret < 0) {
|
|
230
|
+
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_AES_KEY_SETUP_FAILED);
|
|
231
|
+
return 0;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return 1;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
static int aes_cbc_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out, const uint8_t *in,
|
|
238
|
+
size_t len) {
|
|
239
|
+
EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data;
|
|
240
|
+
|
|
241
|
+
if (dat->stream.cbc) {
|
|
242
|
+
(*dat->stream.cbc)(in, out, len, &dat->ks.ks, ctx->iv, ctx->encrypt);
|
|
243
|
+
} else if (ctx->encrypt) {
|
|
244
|
+
CRYPTO_cbc128_encrypt(in, out, len, &dat->ks.ks, ctx->iv, dat->block);
|
|
245
|
+
} else {
|
|
246
|
+
CRYPTO_cbc128_decrypt(in, out, len, &dat->ks.ks, ctx->iv, dat->block);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return 1;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
static int aes_ecb_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out, const uint8_t *in,
|
|
253
|
+
size_t len) {
|
|
254
|
+
size_t bl = ctx->cipher->block_size;
|
|
255
|
+
EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data;
|
|
256
|
+
|
|
257
|
+
if (len < bl) {
|
|
258
|
+
return 1;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
len -= bl;
|
|
262
|
+
for (size_t i = 0; i <= len; i += bl) {
|
|
263
|
+
(*dat->block)(in + i, out + i, &dat->ks.ks);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return 1;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
static int aes_ctr_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out, const uint8_t *in,
|
|
270
|
+
size_t len) {
|
|
271
|
+
EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data;
|
|
272
|
+
|
|
273
|
+
if (dat->stream.ctr) {
|
|
274
|
+
CRYPTO_ctr128_encrypt_ctr32(in, out, len, &dat->ks.ks, ctx->iv, ctx->buf,
|
|
275
|
+
&ctx->num, dat->stream.ctr);
|
|
276
|
+
} else {
|
|
277
|
+
CRYPTO_ctr128_encrypt(in, out, len, &dat->ks.ks, ctx->iv, ctx->buf,
|
|
278
|
+
&ctx->num, dat->block);
|
|
279
|
+
}
|
|
280
|
+
return 1;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
static int aes_ofb_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out, const uint8_t *in,
|
|
284
|
+
size_t len) {
|
|
285
|
+
EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data;
|
|
286
|
+
|
|
287
|
+
CRYPTO_ofb128_encrypt(in, out, len, &dat->ks.ks, ctx->iv, &ctx->num,
|
|
288
|
+
dat->block);
|
|
289
|
+
return 1;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
ctr128_f aes_ctr_set_key(AES_KEY *aes_key, GCM128_KEY *gcm_key,
|
|
293
|
+
block128_f *out_block, const uint8_t *key,
|
|
294
|
+
size_t key_bytes) {
|
|
295
|
+
if (hwaes_capable()) {
|
|
296
|
+
aes_hw_set_encrypt_key(key, key_bytes * 8, aes_key);
|
|
297
|
+
if (gcm_key != NULL) {
|
|
298
|
+
CRYPTO_gcm128_init_key(gcm_key, aes_key, aes_hw_encrypt, 1);
|
|
299
|
+
}
|
|
300
|
+
if (out_block) {
|
|
301
|
+
*out_block = aes_hw_encrypt;
|
|
302
|
+
}
|
|
303
|
+
return aes_hw_ctr32_encrypt_blocks;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (vpaes_capable()) {
|
|
307
|
+
vpaes_set_encrypt_key(key, key_bytes * 8, aes_key);
|
|
308
|
+
if (out_block) {
|
|
309
|
+
*out_block = vpaes_encrypt;
|
|
310
|
+
}
|
|
311
|
+
if (gcm_key != NULL) {
|
|
312
|
+
CRYPTO_gcm128_init_key(gcm_key, aes_key, vpaes_encrypt, 0);
|
|
313
|
+
}
|
|
314
|
+
#if defined(BSAES)
|
|
315
|
+
assert(bsaes_capable());
|
|
316
|
+
return vpaes_ctr32_encrypt_blocks_with_bsaes;
|
|
317
|
+
#elif defined(VPAES_CTR32)
|
|
318
|
+
return vpaes_ctr32_encrypt_blocks;
|
|
319
|
+
#else
|
|
320
|
+
return NULL;
|
|
321
|
+
#endif
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
aes_nohw_set_encrypt_key(key, key_bytes * 8, aes_key);
|
|
325
|
+
if (gcm_key != NULL) {
|
|
326
|
+
CRYPTO_gcm128_init_key(gcm_key, aes_key, aes_nohw_encrypt, 0);
|
|
327
|
+
}
|
|
328
|
+
if (out_block) {
|
|
329
|
+
*out_block = aes_nohw_encrypt;
|
|
330
|
+
}
|
|
331
|
+
return aes_nohw_ctr32_encrypt_blocks;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
#if defined(OPENSSL_32_BIT)
|
|
335
|
+
#define EVP_AES_GCM_CTX_PADDING (4+8)
|
|
336
|
+
#else
|
|
337
|
+
#define EVP_AES_GCM_CTX_PADDING 8
|
|
338
|
+
#endif
|
|
339
|
+
|
|
340
|
+
static EVP_AES_GCM_CTX *aes_gcm_from_cipher_ctx(EVP_CIPHER_CTX *ctx) {
|
|
341
|
+
#if defined(__GNUC__) || defined(__clang__)
|
|
342
|
+
OPENSSL_STATIC_ASSERT(
|
|
343
|
+
alignof(EVP_AES_GCM_CTX) <= 16,
|
|
344
|
+
"EVP_AES_GCM_CTX needs more alignment than this function provides");
|
|
345
|
+
#endif
|
|
346
|
+
|
|
347
|
+
// |malloc| guarantees up to 4-byte alignment on 32-bit and 8-byte alignment
|
|
348
|
+
// on 64-bit systems, so we need to adjust to reach 16-byte alignment.
|
|
349
|
+
assert(ctx->cipher->ctx_size ==
|
|
350
|
+
sizeof(EVP_AES_GCM_CTX) + EVP_AES_GCM_CTX_PADDING);
|
|
351
|
+
|
|
352
|
+
char *ptr = ctx->cipher_data;
|
|
353
|
+
#if defined(OPENSSL_32_BIT)
|
|
354
|
+
assert((uintptr_t)ptr % 4 == 0);
|
|
355
|
+
ptr += (uintptr_t)ptr & 4;
|
|
356
|
+
#endif
|
|
357
|
+
assert((uintptr_t)ptr % 8 == 0);
|
|
358
|
+
ptr += (uintptr_t)ptr & 8;
|
|
359
|
+
return (EVP_AES_GCM_CTX *)ptr;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
static int aes_gcm_init_key(EVP_CIPHER_CTX *ctx, const uint8_t *key,
|
|
363
|
+
const uint8_t *iv, int enc) {
|
|
364
|
+
EVP_AES_GCM_CTX *gctx = aes_gcm_from_cipher_ctx(ctx);
|
|
365
|
+
if (!iv && !key) {
|
|
366
|
+
return 1;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
switch (ctx->key_len) {
|
|
370
|
+
case 16:
|
|
371
|
+
boringssl_fips_inc_counter(fips_counter_evp_aes_128_gcm);
|
|
372
|
+
break;
|
|
373
|
+
|
|
374
|
+
case 32:
|
|
375
|
+
boringssl_fips_inc_counter(fips_counter_evp_aes_256_gcm);
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
if (key) {
|
|
380
|
+
OPENSSL_memset(&gctx->gcm, 0, sizeof(gctx->gcm));
|
|
381
|
+
gctx->ctr = aes_ctr_set_key(&gctx->ks.ks, &gctx->gcm.gcm_key, NULL, key,
|
|
382
|
+
ctx->key_len);
|
|
383
|
+
// If we have an iv can set it directly, otherwise use saved IV.
|
|
384
|
+
if (iv == NULL && gctx->iv_set) {
|
|
385
|
+
iv = gctx->iv;
|
|
386
|
+
}
|
|
387
|
+
if (iv) {
|
|
388
|
+
CRYPTO_gcm128_setiv(&gctx->gcm, &gctx->ks.ks, iv, gctx->ivlen);
|
|
389
|
+
gctx->iv_set = 1;
|
|
390
|
+
}
|
|
391
|
+
gctx->key_set = 1;
|
|
392
|
+
} else {
|
|
393
|
+
// If key set use IV, otherwise copy
|
|
394
|
+
if (gctx->key_set) {
|
|
395
|
+
CRYPTO_gcm128_setiv(&gctx->gcm, &gctx->ks.ks, iv, gctx->ivlen);
|
|
396
|
+
} else {
|
|
397
|
+
OPENSSL_memcpy(gctx->iv, iv, gctx->ivlen);
|
|
398
|
+
}
|
|
399
|
+
gctx->iv_set = 1;
|
|
400
|
+
gctx->iv_gen = 0;
|
|
401
|
+
}
|
|
402
|
+
return 1;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
static void aes_gcm_cleanup(EVP_CIPHER_CTX *c) {
|
|
406
|
+
EVP_AES_GCM_CTX *gctx = aes_gcm_from_cipher_ctx(c);
|
|
407
|
+
OPENSSL_cleanse(&gctx->gcm, sizeof(gctx->gcm));
|
|
408
|
+
if (gctx->iv != c->iv) {
|
|
409
|
+
OPENSSL_free(gctx->iv);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
// increment counter (64-bit int) by 1
|
|
414
|
+
static void ctr64_inc(uint8_t *counter) {
|
|
415
|
+
int n = 8;
|
|
416
|
+
uint8_t c;
|
|
417
|
+
|
|
418
|
+
do {
|
|
419
|
+
--n;
|
|
420
|
+
c = counter[n];
|
|
421
|
+
++c;
|
|
422
|
+
counter[n] = c;
|
|
423
|
+
if (c) {
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
} while (n);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
static int aes_gcm_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr) {
|
|
430
|
+
EVP_AES_GCM_CTX *gctx = aes_gcm_from_cipher_ctx(c);
|
|
431
|
+
switch (type) {
|
|
432
|
+
case EVP_CTRL_INIT:
|
|
433
|
+
gctx->key_set = 0;
|
|
434
|
+
gctx->iv_set = 0;
|
|
435
|
+
gctx->ivlen = c->cipher->iv_len;
|
|
436
|
+
gctx->iv = c->iv;
|
|
437
|
+
gctx->taglen = -1;
|
|
438
|
+
gctx->iv_gen = 0;
|
|
439
|
+
return 1;
|
|
440
|
+
|
|
441
|
+
case EVP_CTRL_AEAD_SET_IVLEN:
|
|
442
|
+
if (arg <= 0) {
|
|
443
|
+
return 0;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// Allocate memory for IV if needed
|
|
447
|
+
if (arg > EVP_MAX_IV_LENGTH && arg > gctx->ivlen) {
|
|
448
|
+
if (gctx->iv != c->iv) {
|
|
449
|
+
OPENSSL_free(gctx->iv);
|
|
450
|
+
}
|
|
451
|
+
gctx->iv = OPENSSL_malloc(arg);
|
|
452
|
+
if (!gctx->iv) {
|
|
453
|
+
return 0;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
gctx->ivlen = arg;
|
|
457
|
+
return 1;
|
|
458
|
+
|
|
459
|
+
case EVP_CTRL_AEAD_SET_TAG:
|
|
460
|
+
if (arg <= 0 || arg > 16 || c->encrypt) {
|
|
461
|
+
return 0;
|
|
462
|
+
}
|
|
463
|
+
OPENSSL_memcpy(c->buf, ptr, arg);
|
|
464
|
+
gctx->taglen = arg;
|
|
465
|
+
return 1;
|
|
466
|
+
|
|
467
|
+
case EVP_CTRL_AEAD_GET_TAG:
|
|
468
|
+
if (arg <= 0 || arg > 16 || !c->encrypt || gctx->taglen < 0) {
|
|
469
|
+
return 0;
|
|
470
|
+
}
|
|
471
|
+
OPENSSL_memcpy(ptr, c->buf, arg);
|
|
472
|
+
return 1;
|
|
473
|
+
|
|
474
|
+
case EVP_CTRL_AEAD_SET_IV_FIXED:
|
|
475
|
+
// Special case: -1 length restores whole IV
|
|
476
|
+
if (arg == -1) {
|
|
477
|
+
OPENSSL_memcpy(gctx->iv, ptr, gctx->ivlen);
|
|
478
|
+
gctx->iv_gen = 1;
|
|
479
|
+
return 1;
|
|
480
|
+
}
|
|
481
|
+
// Fixed field must be at least 4 bytes and invocation field
|
|
482
|
+
// at least 8.
|
|
483
|
+
if (arg < 4 || (gctx->ivlen - arg) < 8) {
|
|
484
|
+
return 0;
|
|
485
|
+
}
|
|
486
|
+
if (arg) {
|
|
487
|
+
OPENSSL_memcpy(gctx->iv, ptr, arg);
|
|
488
|
+
}
|
|
489
|
+
if (c->encrypt) {
|
|
490
|
+
// |RAND_bytes| calls within the fipsmodule should be wrapped with state
|
|
491
|
+
// lock functions to avoid updating the service indicator with the DRBG
|
|
492
|
+
// functions.
|
|
493
|
+
FIPS_service_indicator_lock_state();
|
|
494
|
+
RAND_bytes(gctx->iv + arg, gctx->ivlen - arg);
|
|
495
|
+
FIPS_service_indicator_unlock_state();
|
|
496
|
+
}
|
|
497
|
+
gctx->iv_gen = 1;
|
|
498
|
+
return 1;
|
|
499
|
+
|
|
500
|
+
case EVP_CTRL_GCM_IV_GEN:
|
|
501
|
+
if (gctx->iv_gen == 0 || gctx->key_set == 0) {
|
|
502
|
+
return 0;
|
|
503
|
+
}
|
|
504
|
+
CRYPTO_gcm128_setiv(&gctx->gcm, &gctx->ks.ks, gctx->iv, gctx->ivlen);
|
|
505
|
+
if (arg <= 0 || arg > gctx->ivlen) {
|
|
506
|
+
arg = gctx->ivlen;
|
|
507
|
+
}
|
|
508
|
+
OPENSSL_memcpy(ptr, gctx->iv + gctx->ivlen - arg, arg);
|
|
509
|
+
// Invocation field will be at least 8 bytes in size and
|
|
510
|
+
// so no need to check wrap around or increment more than
|
|
511
|
+
// last 8 bytes.
|
|
512
|
+
ctr64_inc(gctx->iv + gctx->ivlen - 8);
|
|
513
|
+
gctx->iv_set = 1;
|
|
514
|
+
return 1;
|
|
515
|
+
|
|
516
|
+
case EVP_CTRL_GCM_SET_IV_INV:
|
|
517
|
+
if (gctx->iv_gen == 0 || gctx->key_set == 0 || c->encrypt) {
|
|
518
|
+
return 0;
|
|
519
|
+
}
|
|
520
|
+
OPENSSL_memcpy(gctx->iv + gctx->ivlen - arg, ptr, arg);
|
|
521
|
+
CRYPTO_gcm128_setiv(&gctx->gcm, &gctx->ks.ks, gctx->iv, gctx->ivlen);
|
|
522
|
+
gctx->iv_set = 1;
|
|
523
|
+
return 1;
|
|
524
|
+
|
|
525
|
+
case EVP_CTRL_COPY: {
|
|
526
|
+
EVP_CIPHER_CTX *out = ptr;
|
|
527
|
+
EVP_AES_GCM_CTX *gctx_out = aes_gcm_from_cipher_ctx(out);
|
|
528
|
+
// |EVP_CIPHER_CTX_copy| copies this generically, but we must redo it in
|
|
529
|
+
// case |out->cipher_data| and |in->cipher_data| are differently aligned.
|
|
530
|
+
OPENSSL_memcpy(gctx_out, gctx, sizeof(EVP_AES_GCM_CTX));
|
|
531
|
+
if (gctx->iv == c->iv) {
|
|
532
|
+
gctx_out->iv = out->iv;
|
|
533
|
+
} else {
|
|
534
|
+
gctx_out->iv = OPENSSL_malloc(gctx->ivlen);
|
|
535
|
+
if (!gctx_out->iv) {
|
|
536
|
+
return 0;
|
|
537
|
+
}
|
|
538
|
+
OPENSSL_memcpy(gctx_out->iv, gctx->iv, gctx->ivlen);
|
|
539
|
+
}
|
|
540
|
+
return 1;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
default:
|
|
544
|
+
return -1;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
static int aes_gcm_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out, const uint8_t *in,
|
|
549
|
+
size_t len) {
|
|
550
|
+
EVP_AES_GCM_CTX *gctx = aes_gcm_from_cipher_ctx(ctx);
|
|
551
|
+
|
|
552
|
+
// If not set up, return error
|
|
553
|
+
if (!gctx->key_set) {
|
|
554
|
+
return -1;
|
|
555
|
+
}
|
|
556
|
+
if (!gctx->iv_set) {
|
|
557
|
+
return -1;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
if (in) {
|
|
561
|
+
if (out == NULL) {
|
|
562
|
+
if (!CRYPTO_gcm128_aad(&gctx->gcm, in, len)) {
|
|
563
|
+
return -1;
|
|
564
|
+
}
|
|
565
|
+
} else if (ctx->encrypt) {
|
|
566
|
+
if (gctx->ctr) {
|
|
567
|
+
if (!CRYPTO_gcm128_encrypt_ctr32(&gctx->gcm, &gctx->ks.ks, in, out, len,
|
|
568
|
+
gctx->ctr)) {
|
|
569
|
+
return -1;
|
|
570
|
+
}
|
|
571
|
+
} else {
|
|
572
|
+
if (!CRYPTO_gcm128_encrypt(&gctx->gcm, &gctx->ks.ks, in, out, len)) {
|
|
573
|
+
return -1;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
} else {
|
|
577
|
+
if (gctx->ctr) {
|
|
578
|
+
if (!CRYPTO_gcm128_decrypt_ctr32(&gctx->gcm, &gctx->ks.ks, in, out, len,
|
|
579
|
+
gctx->ctr)) {
|
|
580
|
+
return -1;
|
|
581
|
+
}
|
|
582
|
+
} else {
|
|
583
|
+
if (!CRYPTO_gcm128_decrypt(&gctx->gcm, &gctx->ks.ks, in, out, len)) {
|
|
584
|
+
return -1;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
return len;
|
|
589
|
+
} else {
|
|
590
|
+
if (!ctx->encrypt) {
|
|
591
|
+
if (gctx->taglen < 0 ||
|
|
592
|
+
!CRYPTO_gcm128_finish(&gctx->gcm, ctx->buf, gctx->taglen)) {
|
|
593
|
+
return -1;
|
|
594
|
+
}
|
|
595
|
+
gctx->iv_set = 0;
|
|
596
|
+
return 0;
|
|
597
|
+
}
|
|
598
|
+
CRYPTO_gcm128_tag(&gctx->gcm, ctx->buf, 16);
|
|
599
|
+
gctx->taglen = 16;
|
|
600
|
+
// Don't reuse the IV
|
|
601
|
+
gctx->iv_set = 0;
|
|
602
|
+
return 0;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
DEFINE_LOCAL_DATA(EVP_CIPHER, aes_128_cbc_generic) {
|
|
607
|
+
memset(out, 0, sizeof(EVP_CIPHER));
|
|
608
|
+
|
|
609
|
+
out->nid = NID_aes_128_cbc;
|
|
610
|
+
out->block_size = 16;
|
|
611
|
+
out->key_len = 16;
|
|
612
|
+
out->iv_len = 16;
|
|
613
|
+
out->ctx_size = sizeof(EVP_AES_KEY);
|
|
614
|
+
out->flags = EVP_CIPH_CBC_MODE;
|
|
615
|
+
out->init = aes_init_key;
|
|
616
|
+
out->cipher = aes_cbc_cipher;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
DEFINE_LOCAL_DATA(EVP_CIPHER, aes_128_ctr_generic) {
|
|
620
|
+
memset(out, 0, sizeof(EVP_CIPHER));
|
|
621
|
+
|
|
622
|
+
out->nid = NID_aes_128_ctr;
|
|
623
|
+
out->block_size = 1;
|
|
624
|
+
out->key_len = 16;
|
|
625
|
+
out->iv_len = 16;
|
|
626
|
+
out->ctx_size = sizeof(EVP_AES_KEY);
|
|
627
|
+
out->flags = EVP_CIPH_CTR_MODE;
|
|
628
|
+
out->init = aes_init_key;
|
|
629
|
+
out->cipher = aes_ctr_cipher;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
DEFINE_LOCAL_DATA(EVP_CIPHER, aes_128_ecb_generic) {
|
|
633
|
+
memset(out, 0, sizeof(EVP_CIPHER));
|
|
634
|
+
|
|
635
|
+
out->nid = NID_aes_128_ecb;
|
|
636
|
+
out->block_size = 16;
|
|
637
|
+
out->key_len = 16;
|
|
638
|
+
out->ctx_size = sizeof(EVP_AES_KEY);
|
|
639
|
+
out->flags = EVP_CIPH_ECB_MODE;
|
|
640
|
+
out->init = aes_init_key;
|
|
641
|
+
out->cipher = aes_ecb_cipher;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
DEFINE_LOCAL_DATA(EVP_CIPHER, aes_128_ofb_generic) {
|
|
645
|
+
memset(out, 0, sizeof(EVP_CIPHER));
|
|
646
|
+
|
|
647
|
+
out->nid = NID_aes_128_ofb128;
|
|
648
|
+
out->block_size = 1;
|
|
649
|
+
out->key_len = 16;
|
|
650
|
+
out->iv_len = 16;
|
|
651
|
+
out->ctx_size = sizeof(EVP_AES_KEY);
|
|
652
|
+
out->flags = EVP_CIPH_OFB_MODE;
|
|
653
|
+
out->init = aes_init_key;
|
|
654
|
+
out->cipher = aes_ofb_cipher;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
DEFINE_LOCAL_DATA(EVP_CIPHER, aes_128_gcm_generic) {
|
|
658
|
+
memset(out, 0, sizeof(EVP_CIPHER));
|
|
659
|
+
|
|
660
|
+
out->nid = NID_aes_128_gcm;
|
|
661
|
+
out->block_size = 1;
|
|
662
|
+
out->key_len = 16;
|
|
663
|
+
out->iv_len = AES_GCM_NONCE_LENGTH;
|
|
664
|
+
out->ctx_size = sizeof(EVP_AES_GCM_CTX) + EVP_AES_GCM_CTX_PADDING;
|
|
665
|
+
out->flags = EVP_CIPH_GCM_MODE | EVP_CIPH_CUSTOM_IV | EVP_CIPH_CUSTOM_COPY |
|
|
666
|
+
EVP_CIPH_FLAG_CUSTOM_CIPHER | EVP_CIPH_ALWAYS_CALL_INIT |
|
|
667
|
+
EVP_CIPH_CTRL_INIT | EVP_CIPH_FLAG_AEAD_CIPHER;
|
|
668
|
+
out->init = aes_gcm_init_key;
|
|
669
|
+
out->cipher = aes_gcm_cipher;
|
|
670
|
+
out->cleanup = aes_gcm_cleanup;
|
|
671
|
+
out->ctrl = aes_gcm_ctrl;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
DEFINE_LOCAL_DATA(EVP_CIPHER, aes_192_cbc_generic) {
|
|
675
|
+
memset(out, 0, sizeof(EVP_CIPHER));
|
|
676
|
+
|
|
677
|
+
out->nid = NID_aes_192_cbc;
|
|
678
|
+
out->block_size = 16;
|
|
679
|
+
out->key_len = 24;
|
|
680
|
+
out->iv_len = 16;
|
|
681
|
+
out->ctx_size = sizeof(EVP_AES_KEY);
|
|
682
|
+
out->flags = EVP_CIPH_CBC_MODE;
|
|
683
|
+
out->init = aes_init_key;
|
|
684
|
+
out->cipher = aes_cbc_cipher;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
DEFINE_LOCAL_DATA(EVP_CIPHER, aes_192_ctr_generic) {
|
|
688
|
+
memset(out, 0, sizeof(EVP_CIPHER));
|
|
689
|
+
|
|
690
|
+
out->nid = NID_aes_192_ctr;
|
|
691
|
+
out->block_size = 1;
|
|
692
|
+
out->key_len = 24;
|
|
693
|
+
out->iv_len = 16;
|
|
694
|
+
out->ctx_size = sizeof(EVP_AES_KEY);
|
|
695
|
+
out->flags = EVP_CIPH_CTR_MODE;
|
|
696
|
+
out->init = aes_init_key;
|
|
697
|
+
out->cipher = aes_ctr_cipher;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
DEFINE_LOCAL_DATA(EVP_CIPHER, aes_192_ecb_generic) {
|
|
701
|
+
memset(out, 0, sizeof(EVP_CIPHER));
|
|
702
|
+
|
|
703
|
+
out->nid = NID_aes_192_ecb;
|
|
704
|
+
out->block_size = 16;
|
|
705
|
+
out->key_len = 24;
|
|
706
|
+
out->ctx_size = sizeof(EVP_AES_KEY);
|
|
707
|
+
out->flags = EVP_CIPH_ECB_MODE;
|
|
708
|
+
out->init = aes_init_key;
|
|
709
|
+
out->cipher = aes_ecb_cipher;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
DEFINE_LOCAL_DATA(EVP_CIPHER, aes_192_ofb_generic) {
|
|
713
|
+
memset(out, 0, sizeof(EVP_CIPHER));
|
|
714
|
+
|
|
715
|
+
out->nid = NID_aes_192_ofb128;
|
|
716
|
+
out->block_size = 1;
|
|
717
|
+
out->key_len = 24;
|
|
718
|
+
out->iv_len = 16;
|
|
719
|
+
out->ctx_size = sizeof(EVP_AES_KEY);
|
|
720
|
+
out->flags = EVP_CIPH_OFB_MODE;
|
|
721
|
+
out->init = aes_init_key;
|
|
722
|
+
out->cipher = aes_ofb_cipher;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
DEFINE_LOCAL_DATA(EVP_CIPHER, aes_192_gcm_generic) {
|
|
726
|
+
memset(out, 0, sizeof(EVP_CIPHER));
|
|
727
|
+
|
|
728
|
+
out->nid = NID_aes_192_gcm;
|
|
729
|
+
out->block_size = 1;
|
|
730
|
+
out->key_len = 24;
|
|
731
|
+
out->iv_len = AES_GCM_NONCE_LENGTH;
|
|
732
|
+
out->ctx_size = sizeof(EVP_AES_GCM_CTX) + EVP_AES_GCM_CTX_PADDING;
|
|
733
|
+
out->flags = EVP_CIPH_GCM_MODE | EVP_CIPH_CUSTOM_IV | EVP_CIPH_CUSTOM_COPY |
|
|
734
|
+
EVP_CIPH_FLAG_CUSTOM_CIPHER | EVP_CIPH_ALWAYS_CALL_INIT |
|
|
735
|
+
EVP_CIPH_CTRL_INIT | EVP_CIPH_FLAG_AEAD_CIPHER;
|
|
736
|
+
out->init = aes_gcm_init_key;
|
|
737
|
+
out->cipher = aes_gcm_cipher;
|
|
738
|
+
out->cleanup = aes_gcm_cleanup;
|
|
739
|
+
out->ctrl = aes_gcm_ctrl;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
DEFINE_LOCAL_DATA(EVP_CIPHER, aes_256_cbc_generic) {
|
|
743
|
+
memset(out, 0, sizeof(EVP_CIPHER));
|
|
744
|
+
|
|
745
|
+
out->nid = NID_aes_256_cbc;
|
|
746
|
+
out->block_size = 16;
|
|
747
|
+
out->key_len = 32;
|
|
748
|
+
out->iv_len = 16;
|
|
749
|
+
out->ctx_size = sizeof(EVP_AES_KEY);
|
|
750
|
+
out->flags = EVP_CIPH_CBC_MODE;
|
|
751
|
+
out->init = aes_init_key;
|
|
752
|
+
out->cipher = aes_cbc_cipher;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
DEFINE_LOCAL_DATA(EVP_CIPHER, aes_256_ctr_generic) {
|
|
756
|
+
memset(out, 0, sizeof(EVP_CIPHER));
|
|
757
|
+
|
|
758
|
+
out->nid = NID_aes_256_ctr;
|
|
759
|
+
out->block_size = 1;
|
|
760
|
+
out->key_len = 32;
|
|
761
|
+
out->iv_len = 16;
|
|
762
|
+
out->ctx_size = sizeof(EVP_AES_KEY);
|
|
763
|
+
out->flags = EVP_CIPH_CTR_MODE;
|
|
764
|
+
out->init = aes_init_key;
|
|
765
|
+
out->cipher = aes_ctr_cipher;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
DEFINE_LOCAL_DATA(EVP_CIPHER, aes_256_ecb_generic) {
|
|
769
|
+
memset(out, 0, sizeof(EVP_CIPHER));
|
|
770
|
+
|
|
771
|
+
out->nid = NID_aes_256_ecb;
|
|
772
|
+
out->block_size = 16;
|
|
773
|
+
out->key_len = 32;
|
|
774
|
+
out->ctx_size = sizeof(EVP_AES_KEY);
|
|
775
|
+
out->flags = EVP_CIPH_ECB_MODE;
|
|
776
|
+
out->init = aes_init_key;
|
|
777
|
+
out->cipher = aes_ecb_cipher;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
DEFINE_LOCAL_DATA(EVP_CIPHER, aes_256_ofb_generic) {
|
|
781
|
+
memset(out, 0, sizeof(EVP_CIPHER));
|
|
782
|
+
|
|
783
|
+
out->nid = NID_aes_256_ofb128;
|
|
784
|
+
out->block_size = 1;
|
|
785
|
+
out->key_len = 32;
|
|
786
|
+
out->iv_len = 16;
|
|
787
|
+
out->ctx_size = sizeof(EVP_AES_KEY);
|
|
788
|
+
out->flags = EVP_CIPH_OFB_MODE;
|
|
789
|
+
out->init = aes_init_key;
|
|
790
|
+
out->cipher = aes_ofb_cipher;
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
DEFINE_LOCAL_DATA(EVP_CIPHER, aes_256_gcm_generic) {
|
|
794
|
+
memset(out, 0, sizeof(EVP_CIPHER));
|
|
795
|
+
|
|
796
|
+
out->nid = NID_aes_256_gcm;
|
|
797
|
+
out->block_size = 1;
|
|
798
|
+
out->key_len = 32;
|
|
799
|
+
out->iv_len = AES_GCM_NONCE_LENGTH;
|
|
800
|
+
out->ctx_size = sizeof(EVP_AES_GCM_CTX) + EVP_AES_GCM_CTX_PADDING;
|
|
801
|
+
out->flags = EVP_CIPH_GCM_MODE | EVP_CIPH_CUSTOM_IV | EVP_CIPH_CUSTOM_COPY |
|
|
802
|
+
EVP_CIPH_FLAG_CUSTOM_CIPHER | EVP_CIPH_ALWAYS_CALL_INIT |
|
|
803
|
+
EVP_CIPH_CTRL_INIT | EVP_CIPH_FLAG_AEAD_CIPHER;
|
|
804
|
+
out->init = aes_gcm_init_key;
|
|
805
|
+
out->cipher = aes_gcm_cipher;
|
|
806
|
+
out->cleanup = aes_gcm_cleanup;
|
|
807
|
+
out->ctrl = aes_gcm_ctrl;
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
#if defined(HWAES_ECB)
|
|
811
|
+
|
|
812
|
+
static int aes_hw_ecb_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out,
|
|
813
|
+
const uint8_t *in, size_t len) {
|
|
814
|
+
size_t bl = ctx->cipher->block_size;
|
|
815
|
+
|
|
816
|
+
if (len < bl) {
|
|
817
|
+
return 1;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
aes_hw_ecb_encrypt(in, out, len, ctx->cipher_data, ctx->encrypt);
|
|
821
|
+
|
|
822
|
+
return 1;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
DEFINE_LOCAL_DATA(EVP_CIPHER, aes_hw_128_ecb) {
|
|
826
|
+
memset(out, 0, sizeof(EVP_CIPHER));
|
|
827
|
+
|
|
828
|
+
out->nid = NID_aes_128_ecb;
|
|
829
|
+
out->block_size = 16;
|
|
830
|
+
out->key_len = 16;
|
|
831
|
+
out->ctx_size = sizeof(EVP_AES_KEY);
|
|
832
|
+
out->flags = EVP_CIPH_ECB_MODE;
|
|
833
|
+
out->init = aes_init_key;
|
|
834
|
+
out->cipher = aes_hw_ecb_cipher;
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
DEFINE_LOCAL_DATA(EVP_CIPHER, aes_hw_192_ecb) {
|
|
838
|
+
memset(out, 0, sizeof(EVP_CIPHER));
|
|
839
|
+
|
|
840
|
+
out->nid = NID_aes_192_ecb;
|
|
841
|
+
out->block_size = 16;
|
|
842
|
+
out->key_len = 24;
|
|
843
|
+
out->ctx_size = sizeof(EVP_AES_KEY);
|
|
844
|
+
out->flags = EVP_CIPH_ECB_MODE;
|
|
845
|
+
out->init = aes_init_key;
|
|
846
|
+
out->cipher = aes_hw_ecb_cipher;
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
DEFINE_LOCAL_DATA(EVP_CIPHER, aes_hw_256_ecb) {
|
|
850
|
+
memset(out, 0, sizeof(EVP_CIPHER));
|
|
851
|
+
|
|
852
|
+
out->nid = NID_aes_256_ecb;
|
|
853
|
+
out->block_size = 16;
|
|
854
|
+
out->key_len = 32;
|
|
855
|
+
out->ctx_size = sizeof(EVP_AES_KEY);
|
|
856
|
+
out->flags = EVP_CIPH_ECB_MODE;
|
|
857
|
+
out->init = aes_init_key;
|
|
858
|
+
out->cipher = aes_hw_ecb_cipher;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
#define EVP_ECB_CIPHER_FUNCTION(keybits) \
|
|
862
|
+
const EVP_CIPHER *EVP_aes_##keybits##_ecb(void) { \
|
|
863
|
+
if (hwaes_capable()) { \
|
|
864
|
+
return aes_hw_##keybits##_ecb(); \
|
|
865
|
+
} \
|
|
866
|
+
return aes_##keybits##_ecb_generic(); \
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
#else
|
|
870
|
+
|
|
871
|
+
#define EVP_ECB_CIPHER_FUNCTION(keybits) \
|
|
872
|
+
const EVP_CIPHER *EVP_aes_##keybits##_ecb(void) { \
|
|
873
|
+
return aes_##keybits##_ecb_generic(); \
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
#endif // HWAES_ECB
|
|
877
|
+
|
|
878
|
+
#define EVP_CIPHER_FUNCTION(keybits, mode) \
|
|
879
|
+
const EVP_CIPHER *EVP_aes_##keybits##_##mode(void) { \
|
|
880
|
+
return aes_##keybits##_##mode##_generic(); \
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
EVP_CIPHER_FUNCTION(128, cbc)
|
|
884
|
+
EVP_CIPHER_FUNCTION(128, ctr)
|
|
885
|
+
EVP_CIPHER_FUNCTION(128, ofb)
|
|
886
|
+
EVP_CIPHER_FUNCTION(128, gcm)
|
|
887
|
+
|
|
888
|
+
EVP_CIPHER_FUNCTION(192, cbc)
|
|
889
|
+
EVP_CIPHER_FUNCTION(192, ctr)
|
|
890
|
+
EVP_CIPHER_FUNCTION(192, ofb)
|
|
891
|
+
EVP_CIPHER_FUNCTION(192, gcm)
|
|
892
|
+
|
|
893
|
+
EVP_CIPHER_FUNCTION(256, cbc)
|
|
894
|
+
EVP_CIPHER_FUNCTION(256, ctr)
|
|
895
|
+
EVP_CIPHER_FUNCTION(256, ofb)
|
|
896
|
+
EVP_CIPHER_FUNCTION(256, gcm)
|
|
897
|
+
|
|
898
|
+
EVP_ECB_CIPHER_FUNCTION(128)
|
|
899
|
+
EVP_ECB_CIPHER_FUNCTION(192)
|
|
900
|
+
EVP_ECB_CIPHER_FUNCTION(256)
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
#define EVP_AEAD_AES_GCM_TAG_LEN 16
|
|
904
|
+
|
|
905
|
+
struct aead_aes_gcm_ctx {
|
|
906
|
+
union {
|
|
907
|
+
double align;
|
|
908
|
+
AES_KEY ks;
|
|
909
|
+
} ks;
|
|
910
|
+
GCM128_KEY gcm_key;
|
|
911
|
+
ctr128_f ctr;
|
|
912
|
+
};
|
|
913
|
+
|
|
914
|
+
static int aead_aes_gcm_init_impl(struct aead_aes_gcm_ctx *gcm_ctx,
|
|
915
|
+
size_t *out_tag_len, const uint8_t *key,
|
|
916
|
+
size_t key_len, size_t tag_len) {
|
|
917
|
+
const size_t key_bits = key_len * 8;
|
|
918
|
+
|
|
919
|
+
switch (key_bits) {
|
|
920
|
+
case 128:
|
|
921
|
+
boringssl_fips_inc_counter(fips_counter_evp_aes_128_gcm);
|
|
922
|
+
break;
|
|
923
|
+
|
|
924
|
+
case 256:
|
|
925
|
+
boringssl_fips_inc_counter(fips_counter_evp_aes_256_gcm);
|
|
926
|
+
break;
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
if (key_bits != 128 && key_bits != 192 && key_bits != 256) {
|
|
930
|
+
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BAD_KEY_LENGTH);
|
|
931
|
+
return 0; // EVP_AEAD_CTX_init should catch this.
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
if (tag_len == EVP_AEAD_DEFAULT_TAG_LENGTH) {
|
|
935
|
+
tag_len = EVP_AEAD_AES_GCM_TAG_LEN;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
if (tag_len > EVP_AEAD_AES_GCM_TAG_LEN) {
|
|
939
|
+
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_TAG_TOO_LARGE);
|
|
940
|
+
return 0;
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
gcm_ctx->ctr =
|
|
944
|
+
aes_ctr_set_key(&gcm_ctx->ks.ks, &gcm_ctx->gcm_key, NULL, key, key_len);
|
|
945
|
+
*out_tag_len = tag_len;
|
|
946
|
+
return 1;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
OPENSSL_STATIC_ASSERT(sizeof(((EVP_AEAD_CTX *)NULL)->state) >=
|
|
950
|
+
sizeof(struct aead_aes_gcm_ctx),
|
|
951
|
+
"AEAD state is too small");
|
|
952
|
+
#if defined(__GNUC__) || defined(__clang__)
|
|
953
|
+
OPENSSL_STATIC_ASSERT(alignof(union evp_aead_ctx_st_state) >=
|
|
954
|
+
alignof(struct aead_aes_gcm_ctx),
|
|
955
|
+
"AEAD state has insufficient alignment");
|
|
956
|
+
#endif
|
|
957
|
+
|
|
958
|
+
static int aead_aes_gcm_init(EVP_AEAD_CTX *ctx, const uint8_t *key,
|
|
959
|
+
size_t key_len, size_t requested_tag_len) {
|
|
960
|
+
struct aead_aes_gcm_ctx *gcm_ctx = (struct aead_aes_gcm_ctx *) &ctx->state;
|
|
961
|
+
|
|
962
|
+
size_t actual_tag_len;
|
|
963
|
+
if (!aead_aes_gcm_init_impl(gcm_ctx, &actual_tag_len, key, key_len,
|
|
964
|
+
requested_tag_len)) {
|
|
965
|
+
return 0;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
ctx->tag_len = actual_tag_len;
|
|
969
|
+
return 1;
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
static void aead_aes_gcm_cleanup(EVP_AEAD_CTX *ctx) {}
|
|
973
|
+
|
|
974
|
+
static int aead_aes_gcm_seal_scatter_impl(
|
|
975
|
+
const struct aead_aes_gcm_ctx *gcm_ctx,
|
|
976
|
+
uint8_t *out, uint8_t *out_tag, size_t *out_tag_len, size_t max_out_tag_len,
|
|
977
|
+
const uint8_t *nonce, size_t nonce_len,
|
|
978
|
+
const uint8_t *in, size_t in_len,
|
|
979
|
+
const uint8_t *extra_in, size_t extra_in_len,
|
|
980
|
+
const uint8_t *ad, size_t ad_len,
|
|
981
|
+
size_t tag_len) {
|
|
982
|
+
if (extra_in_len + tag_len < tag_len) {
|
|
983
|
+
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_TOO_LARGE);
|
|
984
|
+
return 0;
|
|
985
|
+
}
|
|
986
|
+
if (max_out_tag_len < extra_in_len + tag_len) {
|
|
987
|
+
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BUFFER_TOO_SMALL);
|
|
988
|
+
return 0;
|
|
989
|
+
}
|
|
990
|
+
if (nonce_len == 0) {
|
|
991
|
+
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_INVALID_NONCE_SIZE);
|
|
992
|
+
return 0;
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
const AES_KEY *key = &gcm_ctx->ks.ks;
|
|
996
|
+
|
|
997
|
+
GCM128_CONTEXT gcm;
|
|
998
|
+
OPENSSL_memset(&gcm, 0, sizeof(gcm));
|
|
999
|
+
OPENSSL_memcpy(&gcm.gcm_key, &gcm_ctx->gcm_key, sizeof(gcm.gcm_key));
|
|
1000
|
+
CRYPTO_gcm128_setiv(&gcm, key, nonce, nonce_len);
|
|
1001
|
+
|
|
1002
|
+
if (ad_len > 0 && !CRYPTO_gcm128_aad(&gcm, ad, ad_len)) {
|
|
1003
|
+
return 0;
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
if (gcm_ctx->ctr) {
|
|
1007
|
+
if (!CRYPTO_gcm128_encrypt_ctr32(&gcm, key, in, out, in_len,
|
|
1008
|
+
gcm_ctx->ctr)) {
|
|
1009
|
+
return 0;
|
|
1010
|
+
}
|
|
1011
|
+
} else {
|
|
1012
|
+
if (!CRYPTO_gcm128_encrypt(&gcm, key, in, out, in_len)) {
|
|
1013
|
+
return 0;
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
if (extra_in_len) {
|
|
1018
|
+
if (gcm_ctx->ctr) {
|
|
1019
|
+
if (!CRYPTO_gcm128_encrypt_ctr32(&gcm, key, extra_in, out_tag,
|
|
1020
|
+
extra_in_len, gcm_ctx->ctr)) {
|
|
1021
|
+
return 0;
|
|
1022
|
+
}
|
|
1023
|
+
} else {
|
|
1024
|
+
if (!CRYPTO_gcm128_encrypt(&gcm, key, extra_in, out_tag, extra_in_len)) {
|
|
1025
|
+
return 0;
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
CRYPTO_gcm128_tag(&gcm, out_tag + extra_in_len, tag_len);
|
|
1031
|
+
*out_tag_len = tag_len + extra_in_len;
|
|
1032
|
+
|
|
1033
|
+
return 1;
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
static int aead_aes_gcm_seal_scatter(const EVP_AEAD_CTX *ctx, uint8_t *out,
|
|
1037
|
+
uint8_t *out_tag, size_t *out_tag_len,
|
|
1038
|
+
size_t max_out_tag_len,
|
|
1039
|
+
const uint8_t *nonce, size_t nonce_len,
|
|
1040
|
+
const uint8_t *in, size_t in_len,
|
|
1041
|
+
const uint8_t *extra_in,
|
|
1042
|
+
size_t extra_in_len,
|
|
1043
|
+
const uint8_t *ad, size_t ad_len) {
|
|
1044
|
+
const struct aead_aes_gcm_ctx *gcm_ctx =
|
|
1045
|
+
(const struct aead_aes_gcm_ctx *)&ctx->state;
|
|
1046
|
+
return aead_aes_gcm_seal_scatter_impl(
|
|
1047
|
+
gcm_ctx, out, out_tag, out_tag_len, max_out_tag_len, nonce, nonce_len, in,
|
|
1048
|
+
in_len, extra_in, extra_in_len, ad, ad_len, ctx->tag_len);
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
static int aead_aes_gcm_open_gather_impl(const struct aead_aes_gcm_ctx *gcm_ctx,
|
|
1052
|
+
uint8_t *out,
|
|
1053
|
+
const uint8_t *nonce, size_t nonce_len,
|
|
1054
|
+
const uint8_t *in, size_t in_len,
|
|
1055
|
+
const uint8_t *in_tag,
|
|
1056
|
+
size_t in_tag_len,
|
|
1057
|
+
const uint8_t *ad, size_t ad_len,
|
|
1058
|
+
size_t tag_len) {
|
|
1059
|
+
uint8_t tag[EVP_AEAD_AES_GCM_TAG_LEN];
|
|
1060
|
+
|
|
1061
|
+
if (nonce_len == 0) {
|
|
1062
|
+
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_INVALID_NONCE_SIZE);
|
|
1063
|
+
return 0;
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
if (in_tag_len != tag_len) {
|
|
1067
|
+
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BAD_DECRYPT);
|
|
1068
|
+
return 0;
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
const AES_KEY *key = &gcm_ctx->ks.ks;
|
|
1072
|
+
|
|
1073
|
+
GCM128_CONTEXT gcm;
|
|
1074
|
+
OPENSSL_memset(&gcm, 0, sizeof(gcm));
|
|
1075
|
+
OPENSSL_memcpy(&gcm.gcm_key, &gcm_ctx->gcm_key, sizeof(gcm.gcm_key));
|
|
1076
|
+
CRYPTO_gcm128_setiv(&gcm, key, nonce, nonce_len);
|
|
1077
|
+
|
|
1078
|
+
if (!CRYPTO_gcm128_aad(&gcm, ad, ad_len)) {
|
|
1079
|
+
return 0;
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
if (gcm_ctx->ctr) {
|
|
1083
|
+
if (!CRYPTO_gcm128_decrypt_ctr32(&gcm, key, in, out, in_len,
|
|
1084
|
+
gcm_ctx->ctr)) {
|
|
1085
|
+
return 0;
|
|
1086
|
+
}
|
|
1087
|
+
} else {
|
|
1088
|
+
if (!CRYPTO_gcm128_decrypt(&gcm, key, in, out, in_len)) {
|
|
1089
|
+
return 0;
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
CRYPTO_gcm128_tag(&gcm, tag, tag_len);
|
|
1094
|
+
if (CRYPTO_memcmp(tag, in_tag, tag_len) != 0) {
|
|
1095
|
+
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BAD_DECRYPT);
|
|
1096
|
+
return 0;
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
return 1;
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
static int aead_aes_gcm_open_gather(const EVP_AEAD_CTX *ctx, uint8_t *out,
|
|
1103
|
+
const uint8_t *nonce, size_t nonce_len,
|
|
1104
|
+
const uint8_t *in, size_t in_len,
|
|
1105
|
+
const uint8_t *in_tag, size_t in_tag_len,
|
|
1106
|
+
const uint8_t *ad, size_t ad_len) {
|
|
1107
|
+
struct aead_aes_gcm_ctx *gcm_ctx = (struct aead_aes_gcm_ctx *)&ctx->state;
|
|
1108
|
+
if (!aead_aes_gcm_open_gather_impl(gcm_ctx, out, nonce, nonce_len, in, in_len,
|
|
1109
|
+
in_tag, in_tag_len, ad, ad_len,
|
|
1110
|
+
ctx->tag_len)) {
|
|
1111
|
+
return 0;
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
AEAD_GCM_verify_service_indicator(ctx);
|
|
1115
|
+
return 1;
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
DEFINE_METHOD_FUNCTION(EVP_AEAD, EVP_aead_aes_128_gcm) {
|
|
1119
|
+
memset(out, 0, sizeof(EVP_AEAD));
|
|
1120
|
+
|
|
1121
|
+
out->key_len = 16;
|
|
1122
|
+
out->nonce_len = AES_GCM_NONCE_LENGTH;
|
|
1123
|
+
out->overhead = EVP_AEAD_AES_GCM_TAG_LEN;
|
|
1124
|
+
out->max_tag_len = EVP_AEAD_AES_GCM_TAG_LEN;
|
|
1125
|
+
out->seal_scatter_supports_extra_in = 1;
|
|
1126
|
+
|
|
1127
|
+
out->init = aead_aes_gcm_init;
|
|
1128
|
+
out->cleanup = aead_aes_gcm_cleanup;
|
|
1129
|
+
out->seal_scatter = aead_aes_gcm_seal_scatter;
|
|
1130
|
+
out->open_gather = aead_aes_gcm_open_gather;
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
DEFINE_METHOD_FUNCTION(EVP_AEAD, EVP_aead_aes_192_gcm) {
|
|
1134
|
+
memset(out, 0, sizeof(EVP_AEAD));
|
|
1135
|
+
|
|
1136
|
+
out->key_len = 24;
|
|
1137
|
+
out->nonce_len = AES_GCM_NONCE_LENGTH;
|
|
1138
|
+
out->overhead = EVP_AEAD_AES_GCM_TAG_LEN;
|
|
1139
|
+
out->max_tag_len = EVP_AEAD_AES_GCM_TAG_LEN;
|
|
1140
|
+
out->seal_scatter_supports_extra_in = 1;
|
|
1141
|
+
|
|
1142
|
+
out->init = aead_aes_gcm_init;
|
|
1143
|
+
out->cleanup = aead_aes_gcm_cleanup;
|
|
1144
|
+
out->seal_scatter = aead_aes_gcm_seal_scatter;
|
|
1145
|
+
out->open_gather = aead_aes_gcm_open_gather;
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
DEFINE_METHOD_FUNCTION(EVP_AEAD, EVP_aead_aes_256_gcm) {
|
|
1149
|
+
memset(out, 0, sizeof(EVP_AEAD));
|
|
1150
|
+
|
|
1151
|
+
out->key_len = 32;
|
|
1152
|
+
out->nonce_len = AES_GCM_NONCE_LENGTH;
|
|
1153
|
+
out->overhead = EVP_AEAD_AES_GCM_TAG_LEN;
|
|
1154
|
+
out->max_tag_len = EVP_AEAD_AES_GCM_TAG_LEN;
|
|
1155
|
+
out->seal_scatter_supports_extra_in = 1;
|
|
1156
|
+
|
|
1157
|
+
out->init = aead_aes_gcm_init;
|
|
1158
|
+
out->cleanup = aead_aes_gcm_cleanup;
|
|
1159
|
+
out->seal_scatter = aead_aes_gcm_seal_scatter;
|
|
1160
|
+
out->open_gather = aead_aes_gcm_open_gather;
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
static int aead_aes_gcm_init_randnonce(EVP_AEAD_CTX *ctx, const uint8_t *key,
|
|
1164
|
+
size_t key_len,
|
|
1165
|
+
size_t requested_tag_len) {
|
|
1166
|
+
if (requested_tag_len != EVP_AEAD_DEFAULT_TAG_LENGTH) {
|
|
1167
|
+
if (requested_tag_len < AES_GCM_NONCE_LENGTH) {
|
|
1168
|
+
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BUFFER_TOO_SMALL);
|
|
1169
|
+
return 0;
|
|
1170
|
+
}
|
|
1171
|
+
requested_tag_len -= AES_GCM_NONCE_LENGTH;
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
if (!aead_aes_gcm_init(ctx, key, key_len, requested_tag_len)) {
|
|
1175
|
+
return 0;
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
ctx->tag_len += AES_GCM_NONCE_LENGTH;
|
|
1179
|
+
return 1;
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
static int aead_aes_gcm_seal_scatter_randnonce(
|
|
1183
|
+
const EVP_AEAD_CTX *ctx,
|
|
1184
|
+
uint8_t *out, uint8_t *out_tag, size_t *out_tag_len, size_t max_out_tag_len,
|
|
1185
|
+
const uint8_t *external_nonce, size_t external_nonce_len,
|
|
1186
|
+
const uint8_t *in, size_t in_len,
|
|
1187
|
+
const uint8_t *extra_in, size_t extra_in_len,
|
|
1188
|
+
const uint8_t *ad, size_t ad_len) {
|
|
1189
|
+
if (external_nonce_len != 0) {
|
|
1190
|
+
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_INVALID_NONCE_SIZE);
|
|
1191
|
+
return 0;
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
uint8_t nonce[AES_GCM_NONCE_LENGTH];
|
|
1195
|
+
if (max_out_tag_len < sizeof(nonce)) {
|
|
1196
|
+
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BUFFER_TOO_SMALL);
|
|
1197
|
+
return 0;
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
// |RAND_bytes| calls within the fipsmodule should be wrapped with state lock
|
|
1201
|
+
// functions to avoid updating the service indicator with the DRBG functions.
|
|
1202
|
+
FIPS_service_indicator_lock_state();
|
|
1203
|
+
RAND_bytes(nonce, sizeof(nonce));
|
|
1204
|
+
FIPS_service_indicator_unlock_state();
|
|
1205
|
+
|
|
1206
|
+
const struct aead_aes_gcm_ctx *gcm_ctx =
|
|
1207
|
+
(const struct aead_aes_gcm_ctx *)&ctx->state;
|
|
1208
|
+
if (!aead_aes_gcm_seal_scatter_impl(gcm_ctx, out, out_tag, out_tag_len,
|
|
1209
|
+
max_out_tag_len - AES_GCM_NONCE_LENGTH,
|
|
1210
|
+
nonce, sizeof(nonce), in, in_len,
|
|
1211
|
+
extra_in, extra_in_len, ad, ad_len,
|
|
1212
|
+
ctx->tag_len - AES_GCM_NONCE_LENGTH)) {
|
|
1213
|
+
return 0;
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
assert(*out_tag_len + sizeof(nonce) <= max_out_tag_len);
|
|
1217
|
+
memcpy(out_tag + *out_tag_len, nonce, sizeof(nonce));
|
|
1218
|
+
*out_tag_len += sizeof(nonce);
|
|
1219
|
+
|
|
1220
|
+
AEAD_GCM_verify_service_indicator(ctx);
|
|
1221
|
+
return 1;
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
static int aead_aes_gcm_open_gather_randnonce(
|
|
1225
|
+
const EVP_AEAD_CTX *ctx, uint8_t *out,
|
|
1226
|
+
const uint8_t *external_nonce, size_t external_nonce_len,
|
|
1227
|
+
const uint8_t *in, size_t in_len,
|
|
1228
|
+
const uint8_t *in_tag, size_t in_tag_len,
|
|
1229
|
+
const uint8_t *ad, size_t ad_len) {
|
|
1230
|
+
if (external_nonce_len != 0) {
|
|
1231
|
+
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_INVALID_NONCE_SIZE);
|
|
1232
|
+
return 0;
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
if (in_tag_len < AES_GCM_NONCE_LENGTH) {
|
|
1236
|
+
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BAD_DECRYPT);
|
|
1237
|
+
return 0;
|
|
1238
|
+
}
|
|
1239
|
+
const uint8_t *nonce = in_tag + in_tag_len - AES_GCM_NONCE_LENGTH;
|
|
1240
|
+
|
|
1241
|
+
const struct aead_aes_gcm_ctx *gcm_ctx =
|
|
1242
|
+
(const struct aead_aes_gcm_ctx *)&ctx->state;
|
|
1243
|
+
if (!aead_aes_gcm_open_gather_impl(
|
|
1244
|
+
gcm_ctx, out, nonce, AES_GCM_NONCE_LENGTH, in, in_len, in_tag,
|
|
1245
|
+
in_tag_len - AES_GCM_NONCE_LENGTH, ad, ad_len,
|
|
1246
|
+
ctx->tag_len - AES_GCM_NONCE_LENGTH)) {
|
|
1247
|
+
return 0;
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
AEAD_GCM_verify_service_indicator(ctx);
|
|
1251
|
+
return 1;
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
DEFINE_METHOD_FUNCTION(EVP_AEAD, EVP_aead_aes_128_gcm_randnonce) {
|
|
1255
|
+
memset(out, 0, sizeof(EVP_AEAD));
|
|
1256
|
+
|
|
1257
|
+
out->key_len = 16;
|
|
1258
|
+
out->nonce_len = 0;
|
|
1259
|
+
out->overhead = EVP_AEAD_AES_GCM_TAG_LEN + AES_GCM_NONCE_LENGTH;
|
|
1260
|
+
out->max_tag_len = EVP_AEAD_AES_GCM_TAG_LEN + AES_GCM_NONCE_LENGTH;
|
|
1261
|
+
out->seal_scatter_supports_extra_in = 1;
|
|
1262
|
+
|
|
1263
|
+
out->init = aead_aes_gcm_init_randnonce;
|
|
1264
|
+
out->cleanup = aead_aes_gcm_cleanup;
|
|
1265
|
+
out->seal_scatter = aead_aes_gcm_seal_scatter_randnonce;
|
|
1266
|
+
out->open_gather = aead_aes_gcm_open_gather_randnonce;
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
DEFINE_METHOD_FUNCTION(EVP_AEAD, EVP_aead_aes_256_gcm_randnonce) {
|
|
1270
|
+
memset(out, 0, sizeof(EVP_AEAD));
|
|
1271
|
+
|
|
1272
|
+
out->key_len = 32;
|
|
1273
|
+
out->nonce_len = 0;
|
|
1274
|
+
out->overhead = EVP_AEAD_AES_GCM_TAG_LEN + AES_GCM_NONCE_LENGTH;
|
|
1275
|
+
out->max_tag_len = EVP_AEAD_AES_GCM_TAG_LEN + AES_GCM_NONCE_LENGTH;
|
|
1276
|
+
out->seal_scatter_supports_extra_in = 1;
|
|
1277
|
+
|
|
1278
|
+
out->init = aead_aes_gcm_init_randnonce;
|
|
1279
|
+
out->cleanup = aead_aes_gcm_cleanup;
|
|
1280
|
+
out->seal_scatter = aead_aes_gcm_seal_scatter_randnonce;
|
|
1281
|
+
out->open_gather = aead_aes_gcm_open_gather_randnonce;
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
struct aead_aes_gcm_tls12_ctx {
|
|
1285
|
+
struct aead_aes_gcm_ctx gcm_ctx;
|
|
1286
|
+
uint64_t min_next_nonce;
|
|
1287
|
+
};
|
|
1288
|
+
|
|
1289
|
+
OPENSSL_STATIC_ASSERT(sizeof(((EVP_AEAD_CTX *)NULL)->state) >=
|
|
1290
|
+
sizeof(struct aead_aes_gcm_tls12_ctx),
|
|
1291
|
+
"AEAD state is too small");
|
|
1292
|
+
#if defined(__GNUC__) || defined(__clang__)
|
|
1293
|
+
OPENSSL_STATIC_ASSERT(alignof(union evp_aead_ctx_st_state) >=
|
|
1294
|
+
alignof(struct aead_aes_gcm_tls12_ctx),
|
|
1295
|
+
"AEAD state has insufficient alignment");
|
|
1296
|
+
#endif
|
|
1297
|
+
|
|
1298
|
+
static int aead_aes_gcm_tls12_init(EVP_AEAD_CTX *ctx, const uint8_t *key,
|
|
1299
|
+
size_t key_len, size_t requested_tag_len) {
|
|
1300
|
+
struct aead_aes_gcm_tls12_ctx *gcm_ctx =
|
|
1301
|
+
(struct aead_aes_gcm_tls12_ctx *) &ctx->state;
|
|
1302
|
+
|
|
1303
|
+
gcm_ctx->min_next_nonce = 0;
|
|
1304
|
+
|
|
1305
|
+
size_t actual_tag_len;
|
|
1306
|
+
if (!aead_aes_gcm_init_impl(&gcm_ctx->gcm_ctx, &actual_tag_len, key, key_len,
|
|
1307
|
+
requested_tag_len)) {
|
|
1308
|
+
return 0;
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
ctx->tag_len = actual_tag_len;
|
|
1312
|
+
return 1;
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
static int aead_aes_gcm_tls12_seal_scatter(
|
|
1316
|
+
const EVP_AEAD_CTX *ctx, uint8_t *out, uint8_t *out_tag,
|
|
1317
|
+
size_t *out_tag_len, size_t max_out_tag_len, const uint8_t *nonce,
|
|
1318
|
+
size_t nonce_len, const uint8_t *in, size_t in_len, const uint8_t *extra_in,
|
|
1319
|
+
size_t extra_in_len, const uint8_t *ad, size_t ad_len) {
|
|
1320
|
+
struct aead_aes_gcm_tls12_ctx *gcm_ctx =
|
|
1321
|
+
(struct aead_aes_gcm_tls12_ctx *) &ctx->state;
|
|
1322
|
+
|
|
1323
|
+
if (nonce_len != AES_GCM_NONCE_LENGTH) {
|
|
1324
|
+
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_UNSUPPORTED_NONCE_SIZE);
|
|
1325
|
+
return 0;
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
// The given nonces must be strictly monotonically increasing.
|
|
1329
|
+
uint64_t given_counter;
|
|
1330
|
+
OPENSSL_memcpy(&given_counter, nonce + nonce_len - sizeof(given_counter),
|
|
1331
|
+
sizeof(given_counter));
|
|
1332
|
+
given_counter = CRYPTO_bswap8(given_counter);
|
|
1333
|
+
if (given_counter == UINT64_MAX ||
|
|
1334
|
+
given_counter < gcm_ctx->min_next_nonce) {
|
|
1335
|
+
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_INVALID_NONCE);
|
|
1336
|
+
return 0;
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
gcm_ctx->min_next_nonce = given_counter + 1;
|
|
1340
|
+
|
|
1341
|
+
if (!aead_aes_gcm_seal_scatter(ctx, out, out_tag, out_tag_len,
|
|
1342
|
+
max_out_tag_len, nonce, nonce_len, in, in_len,
|
|
1343
|
+
extra_in, extra_in_len, ad, ad_len)) {
|
|
1344
|
+
return 0;
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
AEAD_GCM_verify_service_indicator(ctx);
|
|
1348
|
+
return 1;
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
DEFINE_METHOD_FUNCTION(EVP_AEAD, EVP_aead_aes_128_gcm_tls12) {
|
|
1352
|
+
memset(out, 0, sizeof(EVP_AEAD));
|
|
1353
|
+
|
|
1354
|
+
out->key_len = 16;
|
|
1355
|
+
out->nonce_len = AES_GCM_NONCE_LENGTH;
|
|
1356
|
+
out->overhead = EVP_AEAD_AES_GCM_TAG_LEN;
|
|
1357
|
+
out->max_tag_len = EVP_AEAD_AES_GCM_TAG_LEN;
|
|
1358
|
+
out->seal_scatter_supports_extra_in = 1;
|
|
1359
|
+
|
|
1360
|
+
out->init = aead_aes_gcm_tls12_init;
|
|
1361
|
+
out->cleanup = aead_aes_gcm_cleanup;
|
|
1362
|
+
out->seal_scatter = aead_aes_gcm_tls12_seal_scatter;
|
|
1363
|
+
out->open_gather = aead_aes_gcm_open_gather;
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
DEFINE_METHOD_FUNCTION(EVP_AEAD, EVP_aead_aes_256_gcm_tls12) {
|
|
1367
|
+
memset(out, 0, sizeof(EVP_AEAD));
|
|
1368
|
+
|
|
1369
|
+
out->key_len = 32;
|
|
1370
|
+
out->nonce_len = AES_GCM_NONCE_LENGTH;
|
|
1371
|
+
out->overhead = EVP_AEAD_AES_GCM_TAG_LEN;
|
|
1372
|
+
out->max_tag_len = EVP_AEAD_AES_GCM_TAG_LEN;
|
|
1373
|
+
out->seal_scatter_supports_extra_in = 1;
|
|
1374
|
+
|
|
1375
|
+
out->init = aead_aes_gcm_tls12_init;
|
|
1376
|
+
out->cleanup = aead_aes_gcm_cleanup;
|
|
1377
|
+
out->seal_scatter = aead_aes_gcm_tls12_seal_scatter;
|
|
1378
|
+
out->open_gather = aead_aes_gcm_open_gather;
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
struct aead_aes_gcm_tls13_ctx {
|
|
1382
|
+
struct aead_aes_gcm_ctx gcm_ctx;
|
|
1383
|
+
uint64_t min_next_nonce;
|
|
1384
|
+
uint64_t mask;
|
|
1385
|
+
uint8_t first;
|
|
1386
|
+
};
|
|
1387
|
+
|
|
1388
|
+
OPENSSL_STATIC_ASSERT(sizeof(((EVP_AEAD_CTX *)NULL)->state) >=
|
|
1389
|
+
sizeof(struct aead_aes_gcm_tls13_ctx),
|
|
1390
|
+
"AEAD state is too small");
|
|
1391
|
+
#if defined(__GNUC__) || defined(__clang__)
|
|
1392
|
+
OPENSSL_STATIC_ASSERT(alignof(union evp_aead_ctx_st_state) >=
|
|
1393
|
+
alignof(struct aead_aes_gcm_tls13_ctx),
|
|
1394
|
+
"AEAD state has insufficient alignment");
|
|
1395
|
+
#endif
|
|
1396
|
+
|
|
1397
|
+
static int aead_aes_gcm_tls13_init(EVP_AEAD_CTX *ctx, const uint8_t *key,
|
|
1398
|
+
size_t key_len, size_t requested_tag_len) {
|
|
1399
|
+
struct aead_aes_gcm_tls13_ctx *gcm_ctx =
|
|
1400
|
+
(struct aead_aes_gcm_tls13_ctx *) &ctx->state;
|
|
1401
|
+
|
|
1402
|
+
gcm_ctx->min_next_nonce = 0;
|
|
1403
|
+
gcm_ctx->first = 1;
|
|
1404
|
+
|
|
1405
|
+
size_t actual_tag_len;
|
|
1406
|
+
if (!aead_aes_gcm_init_impl(&gcm_ctx->gcm_ctx, &actual_tag_len, key, key_len,
|
|
1407
|
+
requested_tag_len)) {
|
|
1408
|
+
return 0;
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
ctx->tag_len = actual_tag_len;
|
|
1412
|
+
return 1;
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
static int aead_aes_gcm_tls13_seal_scatter(
|
|
1416
|
+
const EVP_AEAD_CTX *ctx, uint8_t *out, uint8_t *out_tag,
|
|
1417
|
+
size_t *out_tag_len, size_t max_out_tag_len, const uint8_t *nonce,
|
|
1418
|
+
size_t nonce_len, const uint8_t *in, size_t in_len, const uint8_t *extra_in,
|
|
1419
|
+
size_t extra_in_len, const uint8_t *ad, size_t ad_len) {
|
|
1420
|
+
struct aead_aes_gcm_tls13_ctx *gcm_ctx =
|
|
1421
|
+
(struct aead_aes_gcm_tls13_ctx *) &ctx->state;
|
|
1422
|
+
|
|
1423
|
+
if (nonce_len != AES_GCM_NONCE_LENGTH) {
|
|
1424
|
+
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_UNSUPPORTED_NONCE_SIZE);
|
|
1425
|
+
return 0;
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
// The given nonces must be strictly monotonically increasing. See
|
|
1429
|
+
// https://tools.ietf.org/html/rfc8446#section-5.3 for details of the TLS 1.3
|
|
1430
|
+
// nonce construction.
|
|
1431
|
+
uint64_t given_counter;
|
|
1432
|
+
OPENSSL_memcpy(&given_counter, nonce + nonce_len - sizeof(given_counter),
|
|
1433
|
+
sizeof(given_counter));
|
|
1434
|
+
given_counter = CRYPTO_bswap8(given_counter);
|
|
1435
|
+
|
|
1436
|
+
if (gcm_ctx->first) {
|
|
1437
|
+
// In the first call the sequence number will be zero and therefore the
|
|
1438
|
+
// given nonce will be 0 ^ mask = mask.
|
|
1439
|
+
gcm_ctx->mask = given_counter;
|
|
1440
|
+
gcm_ctx->first = 0;
|
|
1441
|
+
}
|
|
1442
|
+
given_counter ^= gcm_ctx->mask;
|
|
1443
|
+
|
|
1444
|
+
if (given_counter == UINT64_MAX ||
|
|
1445
|
+
given_counter < gcm_ctx->min_next_nonce) {
|
|
1446
|
+
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_INVALID_NONCE);
|
|
1447
|
+
return 0;
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
gcm_ctx->min_next_nonce = given_counter + 1;
|
|
1451
|
+
|
|
1452
|
+
if (!aead_aes_gcm_seal_scatter(ctx, out, out_tag, out_tag_len,
|
|
1453
|
+
max_out_tag_len, nonce, nonce_len, in, in_len,
|
|
1454
|
+
extra_in, extra_in_len, ad, ad_len)) {
|
|
1455
|
+
return 0;
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
AEAD_GCM_verify_service_indicator(ctx);
|
|
1459
|
+
return 1;
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
DEFINE_METHOD_FUNCTION(EVP_AEAD, EVP_aead_aes_128_gcm_tls13) {
|
|
1463
|
+
memset(out, 0, sizeof(EVP_AEAD));
|
|
1464
|
+
|
|
1465
|
+
out->key_len = 16;
|
|
1466
|
+
out->nonce_len = AES_GCM_NONCE_LENGTH;
|
|
1467
|
+
out->overhead = EVP_AEAD_AES_GCM_TAG_LEN;
|
|
1468
|
+
out->max_tag_len = EVP_AEAD_AES_GCM_TAG_LEN;
|
|
1469
|
+
out->seal_scatter_supports_extra_in = 1;
|
|
1470
|
+
|
|
1471
|
+
out->init = aead_aes_gcm_tls13_init;
|
|
1472
|
+
out->cleanup = aead_aes_gcm_cleanup;
|
|
1473
|
+
out->seal_scatter = aead_aes_gcm_tls13_seal_scatter;
|
|
1474
|
+
out->open_gather = aead_aes_gcm_open_gather;
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
DEFINE_METHOD_FUNCTION(EVP_AEAD, EVP_aead_aes_256_gcm_tls13) {
|
|
1478
|
+
memset(out, 0, sizeof(EVP_AEAD));
|
|
1479
|
+
|
|
1480
|
+
out->key_len = 32;
|
|
1481
|
+
out->nonce_len = AES_GCM_NONCE_LENGTH;
|
|
1482
|
+
out->overhead = EVP_AEAD_AES_GCM_TAG_LEN;
|
|
1483
|
+
out->max_tag_len = EVP_AEAD_AES_GCM_TAG_LEN;
|
|
1484
|
+
out->seal_scatter_supports_extra_in = 1;
|
|
1485
|
+
|
|
1486
|
+
out->init = aead_aes_gcm_tls13_init;
|
|
1487
|
+
out->cleanup = aead_aes_gcm_cleanup;
|
|
1488
|
+
out->seal_scatter = aead_aes_gcm_tls13_seal_scatter;
|
|
1489
|
+
out->open_gather = aead_aes_gcm_open_gather;
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
int EVP_has_aes_hardware(void) {
|
|
1493
|
+
#if defined(OPENSSL_X86) || defined(OPENSSL_X86_64)
|
|
1494
|
+
return hwaes_capable() && crypto_gcm_clmul_enabled();
|
|
1495
|
+
#elif defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64)
|
|
1496
|
+
return hwaes_capable() && CRYPTO_is_ARMv8_PMULL_capable();
|
|
1497
|
+
#elif defined(OPENSSL_PPC64LE)
|
|
1498
|
+
return CRYPTO_is_PPC64LE_vcrypto_capable();
|
|
1499
|
+
#else
|
|
1500
|
+
return 0;
|
|
1501
|
+
#endif
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1504
|
+
OPENSSL_MSVC_PRAGMA(warning(pop))
|