@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
package/third_party/boringssl/src/crypto/fipsmodule/service_indicator/service_indicator_test.cc
ADDED
|
@@ -0,0 +1,2410 @@
|
|
|
1
|
+
/* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
*
|
|
3
|
+
* Permission to use, copy, modify, and/or distribute this software for any
|
|
4
|
+
* purpose with or without fee is hereby granted, provided that the above
|
|
5
|
+
* copyright notice and this permission notice appear in all copies.
|
|
6
|
+
*
|
|
7
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
8
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
9
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
|
10
|
+
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
11
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
|
12
|
+
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
13
|
+
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
|
14
|
+
|
|
15
|
+
#include <gtest/gtest.h>
|
|
16
|
+
|
|
17
|
+
#include <openssl/aead.h>
|
|
18
|
+
#include <openssl/aes.h>
|
|
19
|
+
#include <openssl/bn.h>
|
|
20
|
+
#include <openssl/cipher.h>
|
|
21
|
+
#include <openssl/cmac.h>
|
|
22
|
+
#include <openssl/crypto.h>
|
|
23
|
+
#include <openssl/dh.h>
|
|
24
|
+
#include <openssl/digest.h>
|
|
25
|
+
#include <openssl/ec.h>
|
|
26
|
+
#include <openssl/ecdh.h>
|
|
27
|
+
#include <openssl/err.h>
|
|
28
|
+
#include <openssl/evp.h>
|
|
29
|
+
#include <openssl/hmac.h>
|
|
30
|
+
#include <openssl/md4.h>
|
|
31
|
+
#include <openssl/md5.h>
|
|
32
|
+
#include <openssl/rand.h>
|
|
33
|
+
#include <openssl/rsa.h>
|
|
34
|
+
#include <openssl/service_indicator.h>
|
|
35
|
+
|
|
36
|
+
#include "../../test/abi_test.h"
|
|
37
|
+
#include "../../test/test_util.h"
|
|
38
|
+
#include "../bn/internal.h"
|
|
39
|
+
#include "../rand/internal.h"
|
|
40
|
+
#include "../tls/internal.h"
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
using bssl::FIPSStatus;
|
|
44
|
+
|
|
45
|
+
static const uint8_t kAESKey[16] = {'A', 'W', 'S', '-', 'L', 'C', 'C', 'r',
|
|
46
|
+
'y', 'p', 't', 'o', ' ', 'K', 'e', 'y'};
|
|
47
|
+
|
|
48
|
+
static const uint8_t kPlaintext[64] = {
|
|
49
|
+
'A', 'W', 'S', '-', 'L', 'C', 'C', 'r', 'y', 'p', 't', 'o', 'M',
|
|
50
|
+
'o', 'd', 'u', 'l', 'e', ' ', 'F', 'I', 'P', 'S', ' ', 'K', 'A',
|
|
51
|
+
'T', ' ', 'E', 'n', 'c', 'r', 'y', 'p', 't', 'i', 'o', 'n', ' ',
|
|
52
|
+
'a', 'n', 'd', ' ', 'D', 'e', 'c', 'r', 'y', 'p', 't', 'i', 'o',
|
|
53
|
+
'n', ' ', 'P', 'l', 'a', 'i', 'n', 't', 'e', 'x', 't', '!'};
|
|
54
|
+
|
|
55
|
+
#if defined(BORINGSSL_FIPS)
|
|
56
|
+
|
|
57
|
+
// kEVPKeyGenShouldCallFIPSFunctions determines whether |EVP_PKEY_keygen_*|
|
|
58
|
+
// functions should call the FIPS versions of the key-generation functions.
|
|
59
|
+
static const bool kEVPKeyGenShouldCallFIPSFunctions = false;
|
|
60
|
+
|
|
61
|
+
// kCurveSecp256k1Supported determines whether secp256k1 tests should be run.
|
|
62
|
+
static const bool kCurveSecp256k1Supported = false;
|
|
63
|
+
|
|
64
|
+
// kEVPDeriveSetsServiceIndicator is true if `EVP_PKEY_derive` should set the
|
|
65
|
+
// service indicator for some algorithms.
|
|
66
|
+
static const bool kEVPDeriveSetsServiceIndicator = false;
|
|
67
|
+
|
|
68
|
+
template <typename T>
|
|
69
|
+
class TestWithNoErrors : public testing::TestWithParam<T> {
|
|
70
|
+
void TearDown() override {
|
|
71
|
+
if (ERR_peek_error() != 0) {
|
|
72
|
+
auto f = [](const char *str, size_t len, void *unused) -> int {
|
|
73
|
+
fprintf(stderr, "%s\n", str);
|
|
74
|
+
return 1;
|
|
75
|
+
};
|
|
76
|
+
ERR_print_errors_cb(f, nullptr);
|
|
77
|
+
ADD_FAILURE();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
static const uint8_t kAESKey_192[24] = {'A', 'W', 'S', '-', 'L', 'C', 'C', 'r',
|
|
83
|
+
'y', 'p', 't', 'o', ' ', '1', '9', '2',
|
|
84
|
+
'-', 'b', 'i', 't', ' ', 'K', 'e', 'y'};
|
|
85
|
+
|
|
86
|
+
static const uint8_t kAESKey_256[32] = {'A', 'W', 'S', '-', 'L', 'C', 'C', 'r',
|
|
87
|
+
'y', 'p', 't', 'o', ' ', '2', '5', '6',
|
|
88
|
+
'-', 'b', 'i', 't', ' ', 'L', 'o', 'n',
|
|
89
|
+
'g', ' ', 'K', 'e', 'y', '!', '!', '!'};
|
|
90
|
+
|
|
91
|
+
static const uint8_t kAESIV[AES_BLOCK_SIZE] = {0};
|
|
92
|
+
|
|
93
|
+
static bssl::UniquePtr<DH> GetDH() {
|
|
94
|
+
// kFFDHE2048PrivateKeyData is a 225-bit value. (225 because that's the
|
|
95
|
+
// minimum private key size in
|
|
96
|
+
// https://tools.ietf.org/html/rfc7919#appendix-A.1.)
|
|
97
|
+
static const uint8_t kFFDHE2048PrivateKey[] = {
|
|
98
|
+
0x01, 0x91, 0x17, 0x3f, 0x2a, 0x05, 0x70, 0x18, 0x7e, 0xc4,
|
|
99
|
+
0x22, 0xee, 0xb7, 0x0a, 0x15, 0x2f, 0x39, 0x64, 0x58, 0xf3,
|
|
100
|
+
0xb8, 0x18, 0x7b, 0xe3, 0x6b, 0xd3, 0x8a, 0x4f, 0xa1};
|
|
101
|
+
bssl::UniquePtr<BIGNUM> priv(
|
|
102
|
+
BN_bin2bn(kFFDHE2048PrivateKey, sizeof(kFFDHE2048PrivateKey), nullptr));
|
|
103
|
+
if (!priv) {
|
|
104
|
+
return nullptr;
|
|
105
|
+
}
|
|
106
|
+
bssl::UniquePtr<DH> dh(DH_get_rfc7919_2048());
|
|
107
|
+
if (!dh || !DH_set0_key(dh.get(), nullptr, priv.get())) {
|
|
108
|
+
return nullptr;
|
|
109
|
+
}
|
|
110
|
+
priv.release(); // |DH_set0_key| takes ownership on success.
|
|
111
|
+
return dh;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
static void DoCipherFinal(EVP_CIPHER_CTX *ctx, std::vector<uint8_t> *out,
|
|
115
|
+
bssl::Span<const uint8_t> in,
|
|
116
|
+
FIPSStatus expect_approved) {
|
|
117
|
+
FIPSStatus approved = FIPSStatus::NOT_APPROVED;
|
|
118
|
+
size_t max_out = in.size();
|
|
119
|
+
if (EVP_CIPHER_CTX_encrypting(ctx)) {
|
|
120
|
+
unsigned block_size = EVP_CIPHER_CTX_block_size(ctx);
|
|
121
|
+
max_out += block_size - (max_out % block_size);
|
|
122
|
+
}
|
|
123
|
+
out->resize(max_out);
|
|
124
|
+
|
|
125
|
+
size_t total = 0;
|
|
126
|
+
int len;
|
|
127
|
+
ASSERT_TRUE(EVP_CipherUpdate(ctx, out->data(), &len, in.data(), in.size()));
|
|
128
|
+
total += static_cast<size_t>(len);
|
|
129
|
+
// Check if the overall service is approved by checking |EVP_CipherFinal_ex|,
|
|
130
|
+
// which should be the last part of the service.
|
|
131
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
132
|
+
approved, EVP_CipherFinal_ex(ctx, out->data() + total, &len)));
|
|
133
|
+
total += static_cast<size_t>(len);
|
|
134
|
+
ASSERT_LE(total, max_out);
|
|
135
|
+
out->resize(total);
|
|
136
|
+
|
|
137
|
+
EXPECT_EQ(approved, expect_approved);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
static const uint8_t kTDES_EDE3_CipherText[64] = {
|
|
141
|
+
0x2a, 0x17, 0x79, 0x5a, 0x9b, 0x1d, 0xd8, 0x72, 0x06, 0xc6, 0xe7,
|
|
142
|
+
0x55, 0x14, 0xaa, 0x7b, 0x2a, 0x6e, 0xfc, 0x71, 0x29, 0xff, 0x9b,
|
|
143
|
+
0x67, 0x73, 0x7c, 0x9e, 0x15, 0x74, 0x80, 0xc8, 0x2f, 0xca, 0x93,
|
|
144
|
+
0xaa, 0x8e, 0xba, 0x2c, 0x48, 0x88, 0x51, 0xc7, 0xa4, 0xf4, 0xe3,
|
|
145
|
+
0x2b, 0x33, 0xe5, 0xa1, 0x58, 0x0a, 0x08, 0x3c, 0xb9, 0xf6, 0xf1,
|
|
146
|
+
0x20, 0x67, 0x02, 0x49, 0xa0, 0x92, 0x18, 0xde, 0x2b};
|
|
147
|
+
|
|
148
|
+
static const uint8_t kTDES_EDE3_CBCCipherText[64] = {
|
|
149
|
+
0x2a, 0x17, 0x79, 0x5a, 0x9b, 0x1d, 0xd8, 0x72, 0xbf, 0x3f, 0xfd,
|
|
150
|
+
0xe4, 0x0d, 0x66, 0x33, 0x49, 0x3b, 0x8c, 0xa6, 0xd0, 0x0a, 0x66,
|
|
151
|
+
0xae, 0xf1, 0xd9, 0xa7, 0xd6, 0xfb, 0xa2, 0x39, 0x6f, 0xf6, 0x1b,
|
|
152
|
+
0x8f, 0x67, 0xe1, 0x2b, 0x58, 0x1c, 0xb6, 0xa2, 0xec, 0xb3, 0xc2,
|
|
153
|
+
0xe6, 0xd1, 0xcc, 0x11, 0x05, 0xdd, 0xee, 0x9d, 0x87, 0x95, 0xe9,
|
|
154
|
+
0x58, 0xc7, 0xef, 0xa4, 0x6d, 0x5e, 0xd6, 0x57, 0x01};
|
|
155
|
+
|
|
156
|
+
// AES-OFB is not an approved service, and is only used to test we are not
|
|
157
|
+
// validating un-approved services correctly.
|
|
158
|
+
static const uint8_t kAESOFBCiphertext[64] = {
|
|
159
|
+
0x49, 0xf5, 0x6a, 0x7d, 0x3e, 0xd7, 0xb2, 0x47, 0x35, 0xca, 0x54,
|
|
160
|
+
0xf5, 0xf1, 0xb8, 0xd1, 0x48, 0x8e, 0x47, 0x09, 0x95, 0xd5, 0xa0,
|
|
161
|
+
0xc6, 0xa3, 0xe4, 0x94, 0xaf, 0xd4, 0x1b, 0x64, 0x25, 0x65, 0x28,
|
|
162
|
+
0x9e, 0x82, 0xba, 0x92, 0xca, 0x75, 0xb3, 0xf3, 0x78, 0x44, 0x87,
|
|
163
|
+
0xd6, 0x11, 0xf9, 0x22, 0xa3, 0xf3, 0xc6, 0x1d, 0x30, 0x00, 0x5b,
|
|
164
|
+
0x77, 0x18, 0x38, 0x39, 0x08, 0x5e, 0x0a, 0x56, 0x6b};
|
|
165
|
+
|
|
166
|
+
static const uint8_t kAESECBCiphertext[64] = {
|
|
167
|
+
0xa4, 0xc1, 0x5c, 0x51, 0x2a, 0x2e, 0x2a, 0xda, 0xd9, 0x02, 0x23,
|
|
168
|
+
0xe7, 0xa9, 0x34, 0x9d, 0xd8, 0x15, 0xc5, 0xf5, 0x55, 0x8e, 0xb0,
|
|
169
|
+
0x29, 0x95, 0x48, 0x6c, 0x7f, 0xa9, 0x47, 0x19, 0x0b, 0x54, 0xe5,
|
|
170
|
+
0x0f, 0x05, 0x76, 0xbb, 0xd0, 0x1a, 0x6c, 0xab, 0xe9, 0xfd, 0x5b,
|
|
171
|
+
0xd8, 0x0b, 0x0a, 0xbd, 0x7f, 0xea, 0xda, 0x52, 0x07, 0x65, 0x13,
|
|
172
|
+
0x6c, 0xbe, 0xfc, 0x36, 0x82, 0x4b, 0x6a, 0xc3, 0xd5};
|
|
173
|
+
|
|
174
|
+
static const uint8_t kAESECBCiphertext_192[64] = {
|
|
175
|
+
0x1d, 0xc8, 0xaa, 0xa7, 0x29, 0x01, 0x17, 0x09, 0x72, 0xc6, 0xe9,
|
|
176
|
+
0x63, 0x02, 0x9d, 0xeb, 0x01, 0xeb, 0xc0, 0xda, 0x82, 0x6c, 0x30,
|
|
177
|
+
0x7d, 0x60, 0x1b, 0x3e, 0xc7, 0x7b, 0xe3, 0x18, 0xa2, 0x43, 0x59,
|
|
178
|
+
0x15, 0x4a, 0xe4, 0x8a, 0x84, 0xda, 0x16, 0x90, 0x7b, 0xfa, 0x64,
|
|
179
|
+
0x37, 0x62, 0x19, 0xf1, 0x95, 0x11, 0x61, 0x84, 0xb0, 0x70, 0x49,
|
|
180
|
+
0x72, 0x9f, 0xe7, 0x3a, 0x18, 0x99, 0x01, 0xba, 0xb0};
|
|
181
|
+
|
|
182
|
+
static const uint8_t kAESECBCiphertext_256[64] = {
|
|
183
|
+
0x6f, 0x2d, 0x6d, 0x7a, 0xc1, 0x8f, 0x00, 0x9f, 0x2d, 0xcf, 0xba,
|
|
184
|
+
0xe6, 0x4f, 0xdd, 0xe0, 0x09, 0x5b, 0xf3, 0xa4, 0xaf, 0xce, 0x45,
|
|
185
|
+
0x49, 0x6e, 0x28, 0x7b, 0x48, 0x57, 0xb5, 0xf5, 0xd8, 0x05, 0x16,
|
|
186
|
+
0x0f, 0xea, 0x21, 0x0c, 0x39, 0x78, 0xee, 0x9e, 0x57, 0x3c, 0x40,
|
|
187
|
+
0x11, 0x9c, 0xd9, 0x34, 0x97, 0xb9, 0xa6, 0x06, 0x40, 0x60, 0xa2,
|
|
188
|
+
0x0c, 0x01, 0xe3, 0x9c, 0xda, 0x3e, 0xad, 0x99, 0x3d};
|
|
189
|
+
|
|
190
|
+
static const uint8_t kAESCBCCiphertext[64] = {
|
|
191
|
+
0xa4, 0xc1, 0x5c, 0x51, 0x2a, 0x2e, 0x2a, 0xda, 0xd9, 0x02, 0x23,
|
|
192
|
+
0xe7, 0xa9, 0x34, 0x9d, 0xd8, 0x5c, 0xb3, 0x65, 0x54, 0x72, 0xc8,
|
|
193
|
+
0x06, 0xf1, 0x36, 0xc3, 0x97, 0x73, 0x87, 0xca, 0x44, 0x99, 0x21,
|
|
194
|
+
0xb8, 0xdb, 0x93, 0x22, 0x00, 0x89, 0x7c, 0x1c, 0xea, 0x36, 0x23,
|
|
195
|
+
0x18, 0xdb, 0xc1, 0x52, 0x8c, 0x23, 0x66, 0x11, 0x0d, 0xa8, 0xe9,
|
|
196
|
+
0xb8, 0x08, 0x8b, 0xaa, 0x81, 0x47, 0x01, 0xa4, 0x4f};
|
|
197
|
+
|
|
198
|
+
static const uint8_t kAESCBCCiphertext_192[64] = {
|
|
199
|
+
0x1d, 0xc8, 0xaa, 0xa7, 0x29, 0x01, 0x17, 0x09, 0x72, 0xc6, 0xe9,
|
|
200
|
+
0x63, 0x02, 0x9d, 0xeb, 0x01, 0xb4, 0x48, 0xa8, 0x00, 0x94, 0x46,
|
|
201
|
+
0x7f, 0xe3, 0xc1, 0x24, 0xea, 0x41, 0xa0, 0x2b, 0x47, 0x2f, 0xae,
|
|
202
|
+
0x19, 0xce, 0x0d, 0xfa, 0x90, 0x45, 0x85, 0xce, 0xc4, 0x21, 0x0c,
|
|
203
|
+
0x74, 0x38, 0x13, 0xfd, 0x64, 0xba, 0x58, 0x10, 0x37, 0x53, 0x48,
|
|
204
|
+
0x66, 0x02, 0x76, 0xfb, 0xb1, 0x3a, 0x19, 0xce, 0x61};
|
|
205
|
+
|
|
206
|
+
static const uint8_t kAESCBCCiphertext_256[64] = {
|
|
207
|
+
0x6f, 0x2d, 0x6d, 0x7a, 0xc1, 0x8f, 0x00, 0x9f, 0x2d, 0xcf, 0xba,
|
|
208
|
+
0xe6, 0x4f, 0xdd, 0xe0, 0x09, 0x9e, 0xa8, 0x28, 0xdc, 0x27, 0xde,
|
|
209
|
+
0x89, 0x26, 0xc7, 0x94, 0x6a, 0xbf, 0xb6, 0x94, 0x05, 0x08, 0x6c,
|
|
210
|
+
0x39, 0x07, 0x52, 0xfa, 0x7b, 0xca, 0x7d, 0x9b, 0xbf, 0xb2, 0x43,
|
|
211
|
+
0x2b, 0x69, 0xee, 0xc5, 0x68, 0x4c, 0xdd, 0x62, 0xae, 0x8d, 0x7e,
|
|
212
|
+
0x71, 0x0c, 0x8f, 0x11, 0xce, 0x1d, 0x8b, 0xee, 0x94};
|
|
213
|
+
|
|
214
|
+
static const uint8_t kAESCTRCiphertext[64] = {
|
|
215
|
+
0x49, 0xf5, 0x6a, 0x7d, 0x3e, 0xd7, 0xb2, 0x47, 0x35, 0xca, 0x54,
|
|
216
|
+
0xf5, 0xf1, 0xb8, 0xd1, 0x48, 0xb0, 0x18, 0xc4, 0x5e, 0xeb, 0x42,
|
|
217
|
+
0xfd, 0x10, 0x49, 0x1f, 0x2b, 0x11, 0xe9, 0xb0, 0x07, 0xa4, 0x00,
|
|
218
|
+
0x56, 0xec, 0x25, 0x53, 0x4d, 0x70, 0x98, 0x38, 0x85, 0x5d, 0x54,
|
|
219
|
+
0xab, 0x2c, 0x19, 0x13, 0x6d, 0xf3, 0x0e, 0x6f, 0x48, 0x2f, 0xab,
|
|
220
|
+
0xe1, 0x82, 0xd4, 0x30, 0xa9, 0x16, 0x73, 0x93, 0xc3};
|
|
221
|
+
|
|
222
|
+
static const uint8_t kAESCTRCiphertext_192[64] = {
|
|
223
|
+
0x72, 0x7d, 0xbb, 0xd4, 0x8b, 0x16, 0x8b, 0x19, 0xa4, 0xeb, 0xa6,
|
|
224
|
+
0xfa, 0xa0, 0xd0, 0x2b, 0xbb, 0x9b, 0x1f, 0xbf, 0x4d, 0x67, 0xfb,
|
|
225
|
+
0xea, 0x89, 0x16, 0xd7, 0xa4, 0xb6, 0xbe, 0x1a, 0x78, 0x1c, 0x3d,
|
|
226
|
+
0x44, 0x49, 0xa0, 0xf2, 0xb2, 0xb3, 0x82, 0x0f, 0xdd, 0xac, 0xd6,
|
|
227
|
+
0xea, 0x6e, 0x1f, 0x09, 0x8d, 0xa5, 0xdb, 0x4f, 0x3f, 0x97, 0x90,
|
|
228
|
+
0x26, 0xed, 0xf6, 0xbb, 0x62, 0xb3, 0x6f, 0x52, 0x67};
|
|
229
|
+
|
|
230
|
+
static const uint8_t kAESCTRCiphertext_256[64] = {
|
|
231
|
+
0x4a, 0x87, 0x44, 0x09, 0xf4, 0x1d, 0x80, 0x94, 0x51, 0x9a, 0xe4,
|
|
232
|
+
0x89, 0x49, 0xcb, 0x98, 0x0d, 0x27, 0xc5, 0xba, 0x20, 0x00, 0x45,
|
|
233
|
+
0xbb, 0x29, 0x75, 0xc0, 0xb7, 0x23, 0x0d, 0x81, 0x9f, 0x43, 0xaa,
|
|
234
|
+
0x78, 0x89, 0xc0, 0xc4, 0x6d, 0x99, 0x0d, 0xb8, 0x9b, 0xc3, 0x25,
|
|
235
|
+
0xa6, 0xd1, 0x7c, 0x98, 0x3e, 0xff, 0x06, 0x59, 0x41, 0xcf, 0xb2,
|
|
236
|
+
0xd5, 0x2f, 0x95, 0xea, 0x83, 0xb1, 0x42, 0xb8, 0xb2};
|
|
237
|
+
|
|
238
|
+
static const uint8_t kAESCFBCiphertext[64] = {
|
|
239
|
+
0x49, 0xf5, 0x6a, 0x7d, 0x3e, 0xd7, 0xb2, 0x47, 0x35, 0xca, 0x54,
|
|
240
|
+
0xf5, 0xf1, 0xb8, 0xd1, 0x48, 0x01, 0xdc, 0xba, 0x43, 0x3a, 0x7b,
|
|
241
|
+
0xbf, 0x84, 0x91, 0x49, 0xc5, 0xc9, 0xd6, 0xcf, 0x6a, 0x2c, 0x3a,
|
|
242
|
+
0x66, 0x99, 0x68, 0xe3, 0xd0, 0x56, 0x05, 0xe7, 0x99, 0x7f, 0xc3,
|
|
243
|
+
0xbc, 0x09, 0x13, 0xa6, 0xf0, 0xde, 0x17, 0xf4, 0x85, 0x9a, 0xee,
|
|
244
|
+
0x29, 0xc3, 0x77, 0xab, 0xc4, 0xf6, 0xdb, 0xae, 0x24};
|
|
245
|
+
|
|
246
|
+
static const uint8_t kAESCCMCiphertext[64 + 4] = {
|
|
247
|
+
0x7a, 0x02, 0x5d, 0x48, 0x02, 0x44, 0x78, 0x7f, 0xb4, 0x71, 0x74, 0x7b,
|
|
248
|
+
0xec, 0x4d, 0x90, 0x29, 0x7b, 0xa7, 0x65, 0xbb, 0x3e, 0x80, 0x41, 0x7e,
|
|
249
|
+
0xab, 0xb4, 0x58, 0x22, 0x4f, 0x86, 0xcd, 0xcc, 0xc2, 0x12, 0xeb, 0x36,
|
|
250
|
+
0x39, 0x89, 0xe3, 0x66, 0x2a, 0xbf, 0xe3, 0x6c, 0x95, 0x60, 0x13, 0x9e,
|
|
251
|
+
0x93, 0xcc, 0xb4, 0x06, 0xbe, 0xaf, 0x3f, 0xba, 0x13, 0x73, 0x09, 0x92,
|
|
252
|
+
0xd1, 0x80, 0x73, 0xb3, 0xc3, 0xa3, 0xa4, 0x8b,
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
static const uint8_t kAESKWCiphertext[72] = {
|
|
256
|
+
0x44, 0xec, 0x7d, 0x92, 0x2c, 0x9f, 0xf3, 0xe8, 0xac, 0xb1, 0xea, 0x3d,
|
|
257
|
+
0x0a, 0xc7, 0x51, 0x27, 0xe8, 0x03, 0x11, 0x78, 0xe5, 0xaf, 0x8d, 0xb1,
|
|
258
|
+
0x70, 0x96, 0x2e, 0xfa, 0x05, 0x48, 0x48, 0x99, 0x1a, 0x58, 0xcc, 0xfe,
|
|
259
|
+
0x11, 0x36, 0x5d, 0x49, 0x98, 0x1e, 0xbb, 0xd6, 0x0b, 0xf5, 0xb9, 0x64,
|
|
260
|
+
0xa4, 0x30, 0x3e, 0x60, 0xf6, 0xc5, 0xff, 0x82, 0x30, 0x9a, 0xa7, 0x48,
|
|
261
|
+
0x82, 0xe2, 0x00, 0xc1, 0xe9, 0xc2, 0x73, 0x6f, 0xbc, 0x89, 0x66, 0x9d};
|
|
262
|
+
|
|
263
|
+
static const uint8_t kAESKWPCiphertext[72] = {
|
|
264
|
+
0x29, 0x5e, 0xb9, 0xea, 0x96, 0xa7, 0xa5, 0xca, 0xfa, 0xeb, 0xda, 0x78,
|
|
265
|
+
0x13, 0xea, 0x83, 0xca, 0x41, 0xdb, 0x4d, 0x36, 0x7d, 0x39, 0x8a, 0xd6,
|
|
266
|
+
0xef, 0xd3, 0xd2, 0x2d, 0x3a, 0xc8, 0x55, 0xc8, 0x73, 0xd7, 0x79, 0x55,
|
|
267
|
+
0xad, 0xc0, 0xce, 0xad, 0x12, 0x54, 0x51, 0xf0, 0x70, 0x76, 0xff, 0xe7,
|
|
268
|
+
0x0c, 0xb2, 0x8e, 0xdd, 0xb6, 0x9a, 0x27, 0x74, 0x98, 0x28, 0xe0, 0xfa,
|
|
269
|
+
0x11, 0xe6, 0x3f, 0x86, 0x93, 0x23, 0xf8, 0x0d, 0xcb, 0xaf, 0x2b, 0xb7};
|
|
270
|
+
|
|
271
|
+
static const uint8_t kAESCMACOutput[16] = {0xe7, 0x32, 0x43, 0xb4, 0xae, 0x79,
|
|
272
|
+
0x08, 0x86, 0xe7, 0x9f, 0x0d, 0x3f,
|
|
273
|
+
0x88, 0x3f, 0x1a, 0xfd};
|
|
274
|
+
|
|
275
|
+
const uint8_t kDHOutput[2048 / 8] = {
|
|
276
|
+
0x83, 0xf0, 0xd8, 0x4f, 0xdb, 0xe7, 0x65, 0xb6, 0x80, 0x6f, 0xa3, 0x22,
|
|
277
|
+
0x9b, 0x33, 0x1c, 0x87, 0x89, 0xc8, 0x1d, 0x2c, 0xa1, 0xba, 0xa3, 0xb8,
|
|
278
|
+
0xdf, 0xad, 0x42, 0xea, 0x9a, 0x75, 0xfe, 0xbf, 0xc1, 0xa8, 0xf6, 0xda,
|
|
279
|
+
0xec, 0xdf, 0x48, 0x61, 0x7d, 0x7f, 0x3d, 0xab, 0xbd, 0xda, 0xd1, 0xd3,
|
|
280
|
+
0xd8, 0xaf, 0x44, 0x4a, 0xba, 0x3f, 0x0e, 0x99, 0x8d, 0x11, 0xdc, 0x63,
|
|
281
|
+
0xb1, 0xe0, 0x65, 0xf2, 0xb9, 0x82, 0x81, 0x8c, 0x88, 0x75, 0x8f, 0xa0,
|
|
282
|
+
0x94, 0x52, 0x2a, 0x2f, 0x2d, 0x10, 0xb1, 0xf4, 0xd2, 0xdd, 0x0f, 0x8a,
|
|
283
|
+
0x7e, 0x49, 0x7b, 0x1e, 0xfd, 0x8c, 0x78, 0xf9, 0x11, 0xdf, 0x80, 0x8b,
|
|
284
|
+
0x2e, 0x86, 0x34, 0xbf, 0x4b, 0xca, 0x13, 0x3e, 0x85, 0x63, 0xeb, 0xe4,
|
|
285
|
+
0xff, 0xec, 0xb0, 0xe8, 0x83, 0xf6, 0x2c, 0x45, 0x21, 0x90, 0x34, 0x9c,
|
|
286
|
+
0x9d, 0x9d, 0xfe, 0x1a, 0x48, 0x53, 0xef, 0x97, 0xd5, 0xea, 0x6a, 0x65,
|
|
287
|
+
0xf5, 0xe9, 0x9f, 0x91, 0x4f, 0xb4, 0x43, 0xe7, 0x1f, 0x0a, 0x2e, 0xdb,
|
|
288
|
+
0xe6, 0x84, 0x30, 0xdb, 0xad, 0xe4, 0xaf, 0x2c, 0xf9, 0x93, 0xe8, 0x0a,
|
|
289
|
+
0xab, 0x7f, 0x1c, 0xde, 0xb3, 0x80, 0xb6, 0x02, 0x42, 0xba, 0x18, 0x0d,
|
|
290
|
+
0x0f, 0xc2, 0x1d, 0xa4, 0x4b, 0x2b, 0x84, 0x74, 0x10, 0x97, 0x6d, 0xdc,
|
|
291
|
+
0xfa, 0x99, 0xdc, 0xba, 0xf2, 0xcb, 0x1b, 0xe8, 0x1a, 0xba, 0x0c, 0x67,
|
|
292
|
+
0x60, 0x07, 0x87, 0xcc, 0xc6, 0x0d, 0xef, 0x56, 0x07, 0x80, 0x55, 0xae,
|
|
293
|
+
0x03, 0xa3, 0x62, 0x31, 0x4c, 0x50, 0xf7, 0xf6, 0x87, 0xb3, 0x8d, 0xe2,
|
|
294
|
+
0x11, 0x86, 0xe7, 0x9d, 0x98, 0x3c, 0x2a, 0x6c, 0x8a, 0xf0, 0xa7, 0x73,
|
|
295
|
+
0x33, 0x07, 0x4e, 0x70, 0xee, 0x14, 0x4b, 0xa3, 0xf7, 0x4f, 0x8f, 0x1a,
|
|
296
|
+
0xa2, 0xf6, 0xd1, 0xeb, 0x4d, 0x04, 0xf9, 0x4c, 0x07, 0x36, 0xb1, 0x46,
|
|
297
|
+
0x53, 0x55, 0xb1, 0x23};
|
|
298
|
+
|
|
299
|
+
static const uint8_t kOutput_md4[MD4_DIGEST_LENGTH] = {
|
|
300
|
+
0xab, 0x6b, 0xda, 0x84, 0xc0, 0x6b, 0xd0, 0x1d,
|
|
301
|
+
0x19, 0xc0, 0x08, 0x11, 0x07, 0x8d, 0xce, 0x0e};
|
|
302
|
+
|
|
303
|
+
static const uint8_t kOutput_md5[MD5_DIGEST_LENGTH] = {
|
|
304
|
+
0xe9, 0x70, 0xa2, 0xf7, 0x9c, 0x55, 0x57, 0xac,
|
|
305
|
+
0x4e, 0x7f, 0x6b, 0xbc, 0xa3, 0xb9, 0xb7, 0xdb};
|
|
306
|
+
|
|
307
|
+
static const uint8_t kOutput_sha1[SHA_DIGEST_LENGTH] = {
|
|
308
|
+
0xaa, 0x18, 0x71, 0x34, 0x00, 0x71, 0x67, 0x9f, 0xa1, 0x6d,
|
|
309
|
+
0x20, 0x82, 0x91, 0x0f, 0x53, 0x0a, 0xcd, 0x6e, 0xa4, 0x34};
|
|
310
|
+
|
|
311
|
+
static const uint8_t kOutput_sha224[SHA224_DIGEST_LENGTH] = {
|
|
312
|
+
0x5f, 0x1a, 0x9e, 0x68, 0x4c, 0xb7, 0x42, 0x68, 0xa0, 0x8b,
|
|
313
|
+
0x87, 0xd7, 0x96, 0xb6, 0xcf, 0x1e, 0x4f, 0x85, 0x1c, 0x47,
|
|
314
|
+
0xe9, 0x29, 0xb3, 0xb2, 0x73, 0x72, 0xd2, 0x69};
|
|
315
|
+
|
|
316
|
+
static const uint8_t kOutput_sha256[SHA256_DIGEST_LENGTH] = {
|
|
317
|
+
0xe7, 0x63, 0x1c, 0xbb, 0x12, 0xb5, 0xbf, 0x4f, 0x99, 0x05, 0x9d,
|
|
318
|
+
0x40, 0x15, 0x55, 0x34, 0x9c, 0x26, 0x36, 0xd2, 0xfe, 0x6a, 0xd6,
|
|
319
|
+
0x26, 0xb4, 0x9d, 0x33, 0x07, 0xf5, 0xe6, 0x29, 0x13, 0x92};
|
|
320
|
+
|
|
321
|
+
static const uint8_t kOutput_sha384[SHA384_DIGEST_LENGTH] = {
|
|
322
|
+
0x15, 0x81, 0x48, 0x8d, 0x95, 0xf2, 0x66, 0x84, 0x65, 0x94, 0x3e, 0xb9,
|
|
323
|
+
0x8c, 0xda, 0x36, 0x30, 0x2a, 0x85, 0xc0, 0xcd, 0xec, 0x38, 0xa0, 0x1f,
|
|
324
|
+
0x72, 0xe2, 0x68, 0xfe, 0x4e, 0xdb, 0x27, 0x8b, 0x50, 0x15, 0xe0, 0x24,
|
|
325
|
+
0xc3, 0x65, 0xd1, 0x66, 0x2a, 0x3e, 0xe7, 0x00, 0x16, 0x51, 0xf5, 0x18};
|
|
326
|
+
|
|
327
|
+
static const uint8_t kOutput_sha512[SHA512_DIGEST_LENGTH] = {
|
|
328
|
+
0x71, 0xcc, 0xec, 0x03, 0xf8, 0x76, 0xf4, 0x0b, 0xf1, 0x1b, 0x89,
|
|
329
|
+
0x27, 0x83, 0xa1, 0x70, 0x02, 0x00, 0x2b, 0xe9, 0x3c, 0x3c, 0x65,
|
|
330
|
+
0x12, 0xb9, 0xa8, 0x8c, 0xc5, 0x9d, 0xae, 0x3c, 0x73, 0x43, 0x76,
|
|
331
|
+
0x4d, 0x98, 0xed, 0xd0, 0xbe, 0xb4, 0xf9, 0x0b, 0x5c, 0x5d, 0x34,
|
|
332
|
+
0x46, 0x30, 0x18, 0xc2, 0x05, 0x88, 0x8a, 0x3c, 0x25, 0xcc, 0x06,
|
|
333
|
+
0xf8, 0x73, 0xb9, 0xe4, 0x18, 0xa8, 0xc2, 0xf0, 0xe5};
|
|
334
|
+
|
|
335
|
+
static const uint8_t kOutput_sha512_256[SHA512_256_DIGEST_LENGTH] = {
|
|
336
|
+
0x1a, 0x78, 0x68, 0x6b, 0x69, 0x6d, 0x28, 0x14, 0x6b, 0x37, 0x11,
|
|
337
|
+
0x2d, 0xfb, 0x72, 0x35, 0xfa, 0xc1, 0xc4, 0x5f, 0x5c, 0x49, 0x91,
|
|
338
|
+
0x08, 0x95, 0x0b, 0x0f, 0xc9, 0x88, 0x44, 0x12, 0x01, 0x6a};
|
|
339
|
+
|
|
340
|
+
static const uint8_t kHMACOutput_sha1[SHA_DIGEST_LENGTH] = {
|
|
341
|
+
0x34, 0xac, 0x50, 0x9b, 0xa9, 0x4c, 0x39, 0xef, 0x45, 0xa0,
|
|
342
|
+
0x6b, 0xdc, 0xfc, 0xbd, 0x3d, 0x42, 0xe8, 0x0a, 0x97, 0x86};
|
|
343
|
+
|
|
344
|
+
static const uint8_t kHMACOutput_sha224[SHA224_DIGEST_LENGTH] = {
|
|
345
|
+
0x30, 0x62, 0x97, 0x45, 0x9e, 0xea, 0x62, 0xe4, 0x5d, 0xbb,
|
|
346
|
+
0x7d, 0x25, 0x3f, 0x77, 0x0f, 0x9d, 0xa4, 0xbd, 0x17, 0x96,
|
|
347
|
+
0x23, 0x53, 0xe1, 0x76, 0xf3, 0xf8, 0x9b, 0x74};
|
|
348
|
+
|
|
349
|
+
static const uint8_t kHMACOutput_sha256[SHA256_DIGEST_LENGTH] = {
|
|
350
|
+
0x68, 0x33, 0x3e, 0x74, 0x9a, 0x49, 0xab, 0x77, 0xb4, 0x1a, 0x40,
|
|
351
|
+
0xd8, 0x55, 0x07, 0xa7, 0xb6, 0x48, 0xa1, 0xa5, 0xa9, 0xd1, 0x7b,
|
|
352
|
+
0x85, 0xe9, 0x33, 0x09, 0x16, 0x79, 0xcc, 0xe9, 0x29, 0x97};
|
|
353
|
+
|
|
354
|
+
static const uint8_t kHMACOutput_sha384[SHA384_DIGEST_LENGTH] = {
|
|
355
|
+
0xcc, 0x39, 0x22, 0x0e, 0x9f, 0x2e, 0x26, 0x4a, 0xb5, 0xf8, 0x4a, 0x0f,
|
|
356
|
+
0x73, 0x51, 0x26, 0x1a, 0xf2, 0xef, 0x15, 0xf3, 0x5f, 0x77, 0xce, 0xbb,
|
|
357
|
+
0x4c, 0x69, 0x86, 0x0e, 0x1f, 0x5c, 0x4d, 0xc9, 0x96, 0xd9, 0xed, 0x74,
|
|
358
|
+
0x6c, 0x45, 0x05, 0x7a, 0x0e, 0x3f, 0x36, 0x8a, 0xda, 0x2a, 0x35, 0xf9};
|
|
359
|
+
|
|
360
|
+
static const uint8_t kHMACOutput_sha512[SHA512_DIGEST_LENGTH] = {
|
|
361
|
+
0x4c, 0x09, 0x46, 0x50, 0x7c, 0xb3, 0xa1, 0xfa, 0xbc, 0xf2, 0xc4,
|
|
362
|
+
0x4f, 0x1e, 0x3d, 0xa9, 0x0b, 0x29, 0x4e, 0x12, 0x09, 0x09, 0x32,
|
|
363
|
+
0xde, 0x82, 0xa0, 0xab, 0xf6, 0x5e, 0x66, 0x19, 0xd0, 0x86, 0x9a,
|
|
364
|
+
0x92, 0xe3, 0xf9, 0x13, 0xa7, 0xe6, 0xfc, 0x1a, 0x2e, 0x50, 0xda,
|
|
365
|
+
0xf6, 0x8f, 0xb2, 0xd5, 0xb2, 0x6e, 0x97, 0x82, 0x25, 0x5a, 0x1e,
|
|
366
|
+
0xbf, 0x9b, 0x99, 0x8c, 0xf0, 0x37, 0xe6, 0x3d, 0x40};
|
|
367
|
+
|
|
368
|
+
static const uint8_t kHMACOutput_sha512_256[SHA512_256_DIGEST_LENGTH] = {
|
|
369
|
+
0x9c, 0x95, 0x9c, 0x03, 0xc9, 0x8c, 0x90, 0xee, 0x7a, 0xff, 0xed,
|
|
370
|
+
0x26, 0xba, 0x75, 0x90, 0xd0, 0xb9, 0xd4, 0x09, 0xf5, 0x22, 0xd6,
|
|
371
|
+
0xb6, 0xab, 0xa8, 0xb9, 0xae, 0x01, 0x06, 0x37, 0x8f, 0xd1};
|
|
372
|
+
|
|
373
|
+
static const uint8_t kDRBGEntropy[48] = {
|
|
374
|
+
'B', 'C', 'M', ' ', 'K', 'n', 'o', 'w', 'n', ' ', 'A', 'n',
|
|
375
|
+
's', 'w', 'e', 'r', ' ', 'T', 'e', 's', 't', ' ', 'D', 'B',
|
|
376
|
+
'R', 'G', ' ', 'I', 'n', 'i', 't', 'i', 'a', 'l', ' ', 'E',
|
|
377
|
+
'n', 't', 'r', 'o', 'p', 'y', ' ', ' ', ' ', ' ', ' ', ' '};
|
|
378
|
+
|
|
379
|
+
static const uint8_t kDRBGPersonalization[18] = {'B', 'C', 'M', 'P', 'e', 'r',
|
|
380
|
+
's', 'o', 'n', 'a', 'l', 'i',
|
|
381
|
+
'z', 'a', 't', 'i', 'o', 'n'};
|
|
382
|
+
|
|
383
|
+
static const uint8_t kDRBGAD[16] = {'B', 'C', 'M', ' ', 'D', 'R', 'B', 'G',
|
|
384
|
+
' ', 'K', 'A', 'T', ' ', 'A', 'D', ' '};
|
|
385
|
+
|
|
386
|
+
const uint8_t kDRBGOutput[64] = {
|
|
387
|
+
0x1d, 0x63, 0xdf, 0x05, 0x51, 0x49, 0x22, 0x46, 0xcd, 0x9b, 0xc5,
|
|
388
|
+
0xbb, 0xf1, 0x5d, 0x44, 0xae, 0x13, 0x78, 0xb1, 0xe4, 0x7c, 0xf1,
|
|
389
|
+
0x96, 0x33, 0x3d, 0x60, 0xb6, 0x29, 0xd4, 0xbb, 0x6b, 0x44, 0xf9,
|
|
390
|
+
0xef, 0xd9, 0xf4, 0xa2, 0xba, 0x48, 0xea, 0x39, 0x75, 0x59, 0x32,
|
|
391
|
+
0xf7, 0x31, 0x2c, 0x98, 0x14, 0x2b, 0x49, 0xdf, 0x02, 0xb6, 0x5d,
|
|
392
|
+
0x71, 0x09, 0x50, 0xdb, 0x23, 0xdb, 0xe5, 0x22, 0x95};
|
|
393
|
+
|
|
394
|
+
static const uint8_t kDRBGEntropy2[48] = {
|
|
395
|
+
'B', 'C', 'M', ' ', 'K', 'n', 'o', 'w', 'n', ' ', 'A', 'n',
|
|
396
|
+
's', 'w', 'e', 'r', ' ', 'T', 'e', 's', 't', ' ', 'D', 'B',
|
|
397
|
+
'R', 'G', ' ', 'R', 'e', 's', 'e', 'e', 'd', ' ', 'E', 'n',
|
|
398
|
+
't', 'r', 'o', 'p', 'y', ' ', ' ', ' ', ' ', ' ', ' ', ' '};
|
|
399
|
+
|
|
400
|
+
static const uint8_t kDRBGReseedOutput[64] = {
|
|
401
|
+
0xa4, 0x77, 0x05, 0xdb, 0x14, 0x11, 0x76, 0x71, 0x42, 0x5b, 0xd8,
|
|
402
|
+
0xd7, 0xa5, 0x4f, 0x8b, 0x39, 0xf2, 0x10, 0x4a, 0x50, 0x5b, 0xa2,
|
|
403
|
+
0xc8, 0xf0, 0xbb, 0x3e, 0xa1, 0xa5, 0x90, 0x7d, 0x54, 0xd9, 0xc6,
|
|
404
|
+
0xb0, 0x96, 0xc0, 0x2b, 0x7e, 0x9b, 0xc9, 0xa1, 0xdd, 0x78, 0x2e,
|
|
405
|
+
0xd5, 0xa8, 0x66, 0x16, 0xbd, 0x18, 0x3c, 0xf2, 0xaa, 0x7a, 0x2b,
|
|
406
|
+
0x37, 0xf9, 0xab, 0x35, 0x64, 0x15, 0x01, 0x3f, 0xc4,
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
static const uint8_t kTLSSecret[32] = {
|
|
410
|
+
0xbf, 0xe4, 0xb7, 0xe0, 0x26, 0x55, 0x5f, 0x6a, 0xdf, 0x5d, 0x27,
|
|
411
|
+
0xd6, 0x89, 0x99, 0x2a, 0xd6, 0xf7, 0x65, 0x66, 0x07, 0x4b, 0x55,
|
|
412
|
+
0x5f, 0x64, 0x55, 0xcd, 0xd5, 0x77, 0xa4, 0xc7, 0x09, 0x61,
|
|
413
|
+
};
|
|
414
|
+
static const char kTLSLabel[] = "FIPS self test";
|
|
415
|
+
static const uint8_t kTLSSeed1[16] = {
|
|
416
|
+
0x8f, 0x0d, 0xe8, 0xb6, 0x90, 0x8f, 0xb1, 0xd2,
|
|
417
|
+
0x6d, 0x51, 0xf4, 0x79, 0x18, 0x63, 0x51, 0x65,
|
|
418
|
+
};
|
|
419
|
+
static const uint8_t kTLSSeed2[16] = {
|
|
420
|
+
0x7d, 0x24, 0x1a, 0x9d, 0x3c, 0x59, 0xbf, 0x3c,
|
|
421
|
+
0x31, 0x1e, 0x2b, 0x21, 0x41, 0x8d, 0x32, 0x81,
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
static const uint8_t kTLSOutput_mdsha1[32] = {
|
|
425
|
+
0x36, 0xa9, 0x31, 0xb0, 0x43, 0xe3, 0x64, 0x72, 0xb9, 0x47, 0x54,
|
|
426
|
+
0x0d, 0x8a, 0xfc, 0xe3, 0x5c, 0x1c, 0x15, 0x67, 0x7e, 0xa3, 0x5d,
|
|
427
|
+
0xf2, 0x3a, 0x57, 0xfd, 0x50, 0x16, 0xe1, 0xa4, 0xa6, 0x37,
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
static const uint8_t kTLSOutput_md[32] = {
|
|
431
|
+
0x79, 0xef, 0x46, 0xc4, 0x35, 0xbc, 0xe5, 0xda, 0xd3, 0x66, 0x91,
|
|
432
|
+
0xdc, 0x86, 0x09, 0x41, 0x66, 0xf2, 0x0c, 0xeb, 0xe6, 0xab, 0x5c,
|
|
433
|
+
0x58, 0xf4, 0x65, 0xce, 0x2f, 0x5f, 0x4b, 0x34, 0x1e, 0xa1,
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
static const uint8_t kTLSOutput_sha1[32] = {
|
|
437
|
+
0xbb, 0x0a, 0x73, 0x52, 0xf8, 0x85, 0xd7, 0xbd, 0x12, 0x34, 0x78,
|
|
438
|
+
0x3b, 0x54, 0x4c, 0x75, 0xfe, 0xd7, 0x23, 0x6e, 0x22, 0x3f, 0x42,
|
|
439
|
+
0x34, 0x99, 0x57, 0x6b, 0x14, 0xc4, 0xc8, 0xae, 0x9f, 0x4c,
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
static const uint8_t kTLSOutput_sha224[32] = {
|
|
443
|
+
0xdd, 0xaf, 0x6f, 0xaa, 0xd9, 0x2b, 0x3d, 0xb9, 0x46, 0x4c, 0x55,
|
|
444
|
+
0x8a, 0xf7, 0xa6, 0x9b, 0x0b, 0x35, 0xcc, 0x07, 0xa7, 0x55, 0x5b,
|
|
445
|
+
0x5e, 0x39, 0x12, 0xc0, 0xd4, 0x30, 0xdf, 0x0c, 0xdf, 0x6b,
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
static const uint8_t kTLSOutput_sha256[32] = {
|
|
449
|
+
0x67, 0x85, 0xde, 0x60, 0xfc, 0x0a, 0x83, 0xe9, 0xa2, 0x2a, 0xb3,
|
|
450
|
+
0xf0, 0x27, 0x0c, 0xba, 0xf7, 0xfa, 0x82, 0x3d, 0x14, 0x77, 0x1d,
|
|
451
|
+
0x86, 0x29, 0x79, 0x39, 0x77, 0x8a, 0xd5, 0x0e, 0x9d, 0x32,
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
static const uint8_t kTLSOutput_sha384[32] = {
|
|
455
|
+
0x75, 0x15, 0x3f, 0x44, 0x7a, 0xfd, 0x34, 0xed, 0x2b, 0x67, 0xbc,
|
|
456
|
+
0xd8, 0x57, 0x96, 0xab, 0xff, 0xf4, 0x0c, 0x05, 0x94, 0x02, 0x23,
|
|
457
|
+
0x81, 0xbf, 0x0e, 0xd2, 0xec, 0x7c, 0xe0, 0xa7, 0xc3, 0x7d,
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
static const uint8_t kTLSOutput_sha512[32] = {
|
|
461
|
+
0x68, 0xb9, 0xc8, 0x4c, 0xf5, 0x51, 0xfc, 0x7a, 0x1f, 0x6c, 0xe5,
|
|
462
|
+
0x43, 0x73, 0x80, 0x53, 0x7c, 0xae, 0x76, 0x55, 0x67, 0xe0, 0x79,
|
|
463
|
+
0xbf, 0x3a, 0x53, 0x71, 0xb7, 0x9c, 0xb5, 0x03, 0x15, 0x3f,
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
static const uint8_t kAESGCMCiphertext_128[64 + 16] = {
|
|
467
|
+
0x38, 0x71, 0xcb, 0x61, 0x70, 0x60, 0x13, 0x8b, 0x2f, 0x91, 0x09, 0x7f,
|
|
468
|
+
0x83, 0x20, 0x0f, 0x1f, 0x71, 0xe2, 0x47, 0x46, 0x6f, 0x5f, 0xa8, 0xad,
|
|
469
|
+
0xa8, 0xfc, 0x0a, 0xfd, 0x36, 0x65, 0x84, 0x90, 0x28, 0x2b, 0xcb, 0x4f,
|
|
470
|
+
0x68, 0xae, 0x09, 0xba, 0xae, 0xdd, 0xdb, 0x91, 0xcc, 0x38, 0xb3, 0xad,
|
|
471
|
+
0x10, 0x84, 0xb8, 0x45, 0x36, 0xf3, 0x96, 0xb4, 0xef, 0xba, 0xda, 0x10,
|
|
472
|
+
0xf8, 0x8b, 0xf3, 0xda, 0x91, 0x1f, 0x8c, 0xd8, 0x39, 0x7b, 0x1c, 0xfd,
|
|
473
|
+
0xe7, 0x99, 0x7d, 0xb7, 0x22, 0x69, 0x67, 0xbd,
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
static const uint8_t kAESGCMCiphertext_192[64 + 16] = {
|
|
477
|
+
0x05, 0x63, 0x6e, 0xe4, 0xd1, 0x9f, 0xd0, 0x91, 0x18, 0xc9, 0xf8, 0xfd,
|
|
478
|
+
0xc2, 0x62, 0x09, 0x05, 0x91, 0xb4, 0x92, 0x66, 0x18, 0xe7, 0x93, 0x6a,
|
|
479
|
+
0xc7, 0xde, 0x81, 0x36, 0x93, 0x79, 0x45, 0x34, 0xc0, 0x6d, 0x14, 0x94,
|
|
480
|
+
0x93, 0x39, 0x2b, 0x7f, 0x4f, 0x10, 0x1c, 0xa5, 0xfe, 0x3b, 0x37, 0xd7,
|
|
481
|
+
0x0a, 0x98, 0xd7, 0xb5, 0xe0, 0xdc, 0xe4, 0x9f, 0x36, 0x40, 0xad, 0x03,
|
|
482
|
+
0xbf, 0x53, 0xe0, 0x7c, 0x3f, 0x57, 0x4f, 0x80, 0x99, 0xe6, 0x90, 0x4e,
|
|
483
|
+
0x59, 0x2e, 0xe0, 0x76, 0x53, 0x09, 0xc3, 0xd3,
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
static const uint8_t kAESGCMCiphertext_256[64 + 16] = {
|
|
487
|
+
0x92, 0x5f, 0xae, 0x84, 0xe7, 0x40, 0xfa, 0x1e, 0xaf, 0x8f, 0x97, 0x0e,
|
|
488
|
+
0x8e, 0xdd, 0x6a, 0x94, 0x22, 0xee, 0x4f, 0x70, 0x66, 0xbf, 0xb1, 0x99,
|
|
489
|
+
0x05, 0xbd, 0xd0, 0xd7, 0x91, 0x54, 0xaf, 0xe1, 0x52, 0xc9, 0x4e, 0x55,
|
|
490
|
+
0xa5, 0x23, 0x62, 0x8b, 0x23, 0x40, 0x90, 0x56, 0xe0, 0x68, 0x63, 0xe5,
|
|
491
|
+
0x7e, 0x5b, 0xbe, 0x96, 0x7b, 0xc4, 0x16, 0xf9, 0xbe, 0x18, 0x06, 0x79,
|
|
492
|
+
0x8f, 0x99, 0x35, 0xe3, 0x2a, 0x82, 0xb5, 0x5e, 0x8a, 0x06, 0xbe, 0x99,
|
|
493
|
+
0x57, 0xb1, 0x76, 0xe1, 0xc5, 0xaa, 0x82, 0xe7,
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
static const struct AEADTestVector {
|
|
497
|
+
const char *name;
|
|
498
|
+
const EVP_AEAD *aead;
|
|
499
|
+
const uint8_t *key;
|
|
500
|
+
const int key_length;
|
|
501
|
+
const uint8_t *expected_ciphertext;
|
|
502
|
+
const int cipher_text_length;
|
|
503
|
+
const FIPSStatus expect_approved;
|
|
504
|
+
const bool test_repeat_nonce;
|
|
505
|
+
} kAEADTestVectors[] = {
|
|
506
|
+
// Internal IV usage of AES-GCM is approved.
|
|
507
|
+
{
|
|
508
|
+
"AES-GCM 128-bit key internal iv test",
|
|
509
|
+
EVP_aead_aes_128_gcm_randnonce(),
|
|
510
|
+
kAESKey,
|
|
511
|
+
sizeof(kAESKey),
|
|
512
|
+
nullptr,
|
|
513
|
+
0,
|
|
514
|
+
FIPSStatus::APPROVED,
|
|
515
|
+
false,
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
"AES-GCM 256-bit key internal iv test",
|
|
519
|
+
EVP_aead_aes_256_gcm_randnonce(),
|
|
520
|
+
kAESKey_256,
|
|
521
|
+
sizeof(kAESKey_256),
|
|
522
|
+
nullptr,
|
|
523
|
+
0,
|
|
524
|
+
FIPSStatus::APPROVED,
|
|
525
|
+
false,
|
|
526
|
+
},
|
|
527
|
+
// External IV usage of AES-GCM is not approved unless used within a TLS
|
|
528
|
+
// context.
|
|
529
|
+
{
|
|
530
|
+
"Generic AES-GCM 128-bit key external iv test",
|
|
531
|
+
EVP_aead_aes_128_gcm(),
|
|
532
|
+
kAESKey,
|
|
533
|
+
sizeof(kAESKey),
|
|
534
|
+
kAESGCMCiphertext_128,
|
|
535
|
+
sizeof(kAESGCMCiphertext_128),
|
|
536
|
+
FIPSStatus::NOT_APPROVED,
|
|
537
|
+
false,
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
"Generic AES-GCM 192-bit key external iv test",
|
|
541
|
+
EVP_aead_aes_192_gcm(),
|
|
542
|
+
kAESKey_192,
|
|
543
|
+
24,
|
|
544
|
+
kAESGCMCiphertext_192,
|
|
545
|
+
sizeof(kAESGCMCiphertext_192),
|
|
546
|
+
FIPSStatus::NOT_APPROVED,
|
|
547
|
+
false,
|
|
548
|
+
},
|
|
549
|
+
{
|
|
550
|
+
"Generic AES-GCM 256-bit key external iv test",
|
|
551
|
+
EVP_aead_aes_256_gcm(),
|
|
552
|
+
kAESKey_256,
|
|
553
|
+
sizeof(kAESKey_256),
|
|
554
|
+
kAESGCMCiphertext_256,
|
|
555
|
+
sizeof(kAESGCMCiphertext_256),
|
|
556
|
+
FIPSStatus::NOT_APPROVED,
|
|
557
|
+
false,
|
|
558
|
+
},
|
|
559
|
+
// External IV usage of AEAD AES-GCM APIs specific for TLS is approved.
|
|
560
|
+
{
|
|
561
|
+
"TLS1.2 AES-GCM 128-bit key external iv test",
|
|
562
|
+
EVP_aead_aes_128_gcm_tls12(),
|
|
563
|
+
kAESKey,
|
|
564
|
+
sizeof(kAESKey),
|
|
565
|
+
kAESGCMCiphertext_128,
|
|
566
|
+
sizeof(kAESGCMCiphertext_128),
|
|
567
|
+
FIPSStatus::APPROVED,
|
|
568
|
+
true,
|
|
569
|
+
},
|
|
570
|
+
{
|
|
571
|
+
"TLS1.2 AES-GCM 256-bit key external iv test",
|
|
572
|
+
EVP_aead_aes_256_gcm_tls12(),
|
|
573
|
+
kAESKey_256,
|
|
574
|
+
sizeof(kAESKey_256),
|
|
575
|
+
kAESGCMCiphertext_256,
|
|
576
|
+
sizeof(kAESGCMCiphertext_256),
|
|
577
|
+
FIPSStatus::APPROVED,
|
|
578
|
+
true,
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
"TLS1.3 AES-GCM 128-bit key external iv test",
|
|
582
|
+
EVP_aead_aes_128_gcm_tls13(),
|
|
583
|
+
kAESKey,
|
|
584
|
+
sizeof(kAESKey),
|
|
585
|
+
kAESGCMCiphertext_128,
|
|
586
|
+
sizeof(kAESGCMCiphertext_128),
|
|
587
|
+
FIPSStatus::APPROVED,
|
|
588
|
+
true,
|
|
589
|
+
},
|
|
590
|
+
{
|
|
591
|
+
"TLS1.3 AES-GCM 256-bit key external iv test",
|
|
592
|
+
EVP_aead_aes_256_gcm_tls13(),
|
|
593
|
+
kAESKey_256,
|
|
594
|
+
sizeof(kAESKey_256),
|
|
595
|
+
kAESGCMCiphertext_256,
|
|
596
|
+
sizeof(kAESGCMCiphertext_256),
|
|
597
|
+
FIPSStatus::APPROVED,
|
|
598
|
+
true,
|
|
599
|
+
},
|
|
600
|
+
// 128 bit keys with 32 bit tag lengths are approved for AES-CCM.
|
|
601
|
+
{
|
|
602
|
+
"AES-CCM 128-bit key test",
|
|
603
|
+
EVP_aead_aes_128_ccm_bluetooth(),
|
|
604
|
+
kAESKey,
|
|
605
|
+
sizeof(kAESKey),
|
|
606
|
+
kAESCCMCiphertext,
|
|
607
|
+
sizeof(kAESCCMCiphertext),
|
|
608
|
+
FIPSStatus::APPROVED,
|
|
609
|
+
false,
|
|
610
|
+
},
|
|
611
|
+
};
|
|
612
|
+
|
|
613
|
+
class AEADServiceIndicatorTest : public TestWithNoErrors<AEADTestVector> {};
|
|
614
|
+
|
|
615
|
+
INSTANTIATE_TEST_SUITE_P(All, AEADServiceIndicatorTest,
|
|
616
|
+
testing::ValuesIn(kAEADTestVectors));
|
|
617
|
+
|
|
618
|
+
TEST_P(AEADServiceIndicatorTest, EVP_AEAD) {
|
|
619
|
+
const AEADTestVector &test = GetParam();
|
|
620
|
+
SCOPED_TRACE(test.name);
|
|
621
|
+
|
|
622
|
+
FIPSStatus approved = FIPSStatus::NOT_APPROVED;
|
|
623
|
+
|
|
624
|
+
bssl::ScopedEVP_AEAD_CTX aead_ctx;
|
|
625
|
+
std::vector<uint8_t> nonce(EVP_AEAD_nonce_length(test.aead), 0);
|
|
626
|
+
std::vector<uint8_t> encrypt_output(256);
|
|
627
|
+
std::vector<uint8_t> decrypt_output(256);
|
|
628
|
+
size_t out_len;
|
|
629
|
+
|
|
630
|
+
// Test running the EVP_AEAD_CTX interfaces one by one directly, and check
|
|
631
|
+
// |EVP_AEAD_CTX_seal| and |EVP_AEAD_CTX_open| for approval at the end.
|
|
632
|
+
// |EVP_AEAD_CTX_init| should not be approved because the function does not
|
|
633
|
+
// indicate that a service has been fully completed yet.
|
|
634
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
635
|
+
approved, EVP_AEAD_CTX_init(aead_ctx.get(), test.aead, test.key,
|
|
636
|
+
test.key_length, 0, nullptr)));
|
|
637
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
638
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
639
|
+
approved, EVP_AEAD_CTX_seal(aead_ctx.get(), encrypt_output.data(),
|
|
640
|
+
&out_len, encrypt_output.size(), nonce.data(),
|
|
641
|
+
EVP_AEAD_nonce_length(test.aead), kPlaintext,
|
|
642
|
+
sizeof(kPlaintext), nullptr, 0)));
|
|
643
|
+
EXPECT_EQ(approved, test.expect_approved);
|
|
644
|
+
encrypt_output.resize(out_len);
|
|
645
|
+
if (test.expected_ciphertext) {
|
|
646
|
+
EXPECT_EQ(Bytes(test.expected_ciphertext, test.cipher_text_length),
|
|
647
|
+
Bytes(encrypt_output));
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
651
|
+
approved,
|
|
652
|
+
EVP_AEAD_CTX_open(aead_ctx.get(), decrypt_output.data(), &out_len,
|
|
653
|
+
decrypt_output.size(), nonce.data(), nonce.size(),
|
|
654
|
+
encrypt_output.data(), out_len, nullptr, 0)));
|
|
655
|
+
// Decryption doesn't have nonce uniqueness requirements and so is always
|
|
656
|
+
// approved for approved key lengths.
|
|
657
|
+
EXPECT_EQ(approved, test.key_length != 24 ? FIPSStatus::APPROVED
|
|
658
|
+
: FIPSStatus::NOT_APPROVED);
|
|
659
|
+
decrypt_output.resize(out_len);
|
|
660
|
+
EXPECT_EQ(Bytes(kPlaintext), Bytes(decrypt_output));
|
|
661
|
+
|
|
662
|
+
// Second call when encrypting using the same nonce for AES-GCM TLS specific
|
|
663
|
+
// functions should fail and return |FIPSStatus::NOT_APPROVED|.
|
|
664
|
+
if (test.test_repeat_nonce) {
|
|
665
|
+
ASSERT_FALSE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
666
|
+
approved,
|
|
667
|
+
EVP_AEAD_CTX_seal(aead_ctx.get(), encrypt_output.data(), &out_len,
|
|
668
|
+
encrypt_output.size(), nonce.data(), nonce.size(),
|
|
669
|
+
kPlaintext, sizeof(kPlaintext), nullptr, 0)));
|
|
670
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
671
|
+
EXPECT_EQ(ERR_GET_REASON(ERR_get_error()), CIPHER_R_INVALID_NONCE);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
static const struct CipherTestVector {
|
|
676
|
+
const EVP_CIPHER *cipher;
|
|
677
|
+
const uint8_t *key;
|
|
678
|
+
const int key_length;
|
|
679
|
+
const uint8_t *expected_ciphertext;
|
|
680
|
+
const int cipher_text_length;
|
|
681
|
+
const bool has_iv;
|
|
682
|
+
const FIPSStatus expect_approved;
|
|
683
|
+
} kTestVectors[] = {
|
|
684
|
+
{
|
|
685
|
+
EVP_aes_128_ecb(),
|
|
686
|
+
kAESKey,
|
|
687
|
+
sizeof(kAESKey),
|
|
688
|
+
kAESECBCiphertext,
|
|
689
|
+
sizeof(kAESECBCiphertext),
|
|
690
|
+
false,
|
|
691
|
+
FIPSStatus::APPROVED,
|
|
692
|
+
},
|
|
693
|
+
{
|
|
694
|
+
EVP_aes_192_ecb(),
|
|
695
|
+
kAESKey_192,
|
|
696
|
+
sizeof(kAESKey_192),
|
|
697
|
+
kAESECBCiphertext_192,
|
|
698
|
+
sizeof(kAESECBCiphertext_192),
|
|
699
|
+
false,
|
|
700
|
+
FIPSStatus::APPROVED,
|
|
701
|
+
},
|
|
702
|
+
{
|
|
703
|
+
EVP_aes_256_ecb(),
|
|
704
|
+
kAESKey_256,
|
|
705
|
+
sizeof(kAESKey_256),
|
|
706
|
+
kAESECBCiphertext_256,
|
|
707
|
+
sizeof(kAESECBCiphertext_256),
|
|
708
|
+
false,
|
|
709
|
+
FIPSStatus::APPROVED,
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
EVP_aes_128_cbc(),
|
|
713
|
+
kAESKey,
|
|
714
|
+
sizeof(kAESKey),
|
|
715
|
+
kAESCBCCiphertext,
|
|
716
|
+
sizeof(kAESCBCCiphertext),
|
|
717
|
+
true,
|
|
718
|
+
FIPSStatus::APPROVED,
|
|
719
|
+
},
|
|
720
|
+
{
|
|
721
|
+
EVP_aes_192_cbc(),
|
|
722
|
+
kAESKey_192,
|
|
723
|
+
sizeof(kAESKey_192),
|
|
724
|
+
kAESCBCCiphertext_192,
|
|
725
|
+
sizeof(kAESCBCCiphertext_192),
|
|
726
|
+
true,
|
|
727
|
+
FIPSStatus::APPROVED,
|
|
728
|
+
},
|
|
729
|
+
{
|
|
730
|
+
EVP_aes_256_cbc(),
|
|
731
|
+
kAESKey_256,
|
|
732
|
+
sizeof(kAESKey_256),
|
|
733
|
+
kAESCBCCiphertext_256,
|
|
734
|
+
sizeof(kAESCBCCiphertext_256),
|
|
735
|
+
true,
|
|
736
|
+
FIPSStatus::APPROVED,
|
|
737
|
+
},
|
|
738
|
+
{
|
|
739
|
+
EVP_aes_128_ctr(),
|
|
740
|
+
kAESKey,
|
|
741
|
+
sizeof(kAESKey),
|
|
742
|
+
kAESCTRCiphertext,
|
|
743
|
+
sizeof(kAESCTRCiphertext),
|
|
744
|
+
true,
|
|
745
|
+
FIPSStatus::APPROVED,
|
|
746
|
+
},
|
|
747
|
+
{
|
|
748
|
+
EVP_aes_192_ctr(),
|
|
749
|
+
kAESKey_192,
|
|
750
|
+
sizeof(kAESKey_192),
|
|
751
|
+
kAESCTRCiphertext_192,
|
|
752
|
+
sizeof(kAESCTRCiphertext_192),
|
|
753
|
+
true,
|
|
754
|
+
FIPSStatus::APPROVED,
|
|
755
|
+
},
|
|
756
|
+
{
|
|
757
|
+
EVP_aes_256_ctr(),
|
|
758
|
+
kAESKey_256,
|
|
759
|
+
sizeof(kAESKey_256),
|
|
760
|
+
kAESCTRCiphertext_256,
|
|
761
|
+
sizeof(kAESCTRCiphertext_256),
|
|
762
|
+
true,
|
|
763
|
+
FIPSStatus::APPROVED,
|
|
764
|
+
},
|
|
765
|
+
{
|
|
766
|
+
EVP_aes_128_ofb(),
|
|
767
|
+
kAESKey,
|
|
768
|
+
sizeof(kAESKey),
|
|
769
|
+
kAESOFBCiphertext,
|
|
770
|
+
sizeof(kAESOFBCiphertext),
|
|
771
|
+
true,
|
|
772
|
+
FIPSStatus::NOT_APPROVED,
|
|
773
|
+
},
|
|
774
|
+
{
|
|
775
|
+
EVP_des_ede3(),
|
|
776
|
+
kAESKey_192,
|
|
777
|
+
sizeof(kAESKey_192),
|
|
778
|
+
kTDES_EDE3_CipherText,
|
|
779
|
+
sizeof(kTDES_EDE3_CipherText),
|
|
780
|
+
false,
|
|
781
|
+
FIPSStatus::NOT_APPROVED,
|
|
782
|
+
},
|
|
783
|
+
{
|
|
784
|
+
EVP_des_ede3_cbc(),
|
|
785
|
+
kAESKey_192,
|
|
786
|
+
sizeof(kAESKey_192),
|
|
787
|
+
kTDES_EDE3_CBCCipherText,
|
|
788
|
+
sizeof(kTDES_EDE3_CBCCipherText),
|
|
789
|
+
false,
|
|
790
|
+
FIPSStatus::NOT_APPROVED,
|
|
791
|
+
},
|
|
792
|
+
};
|
|
793
|
+
|
|
794
|
+
class EVPServiceIndicatorTest : public TestWithNoErrors<CipherTestVector> {};
|
|
795
|
+
|
|
796
|
+
static void TestOperation(const EVP_CIPHER *cipher, bool encrypt,
|
|
797
|
+
const bssl::Span<const uint8_t> key,
|
|
798
|
+
const bssl::Span<const uint8_t> plaintext,
|
|
799
|
+
const bssl::Span<const uint8_t> ciphertext,
|
|
800
|
+
FIPSStatus expect_approved) {
|
|
801
|
+
FIPSStatus approved = FIPSStatus::NOT_APPROVED;
|
|
802
|
+
bssl::Span<const uint8_t> in, out;
|
|
803
|
+
if (encrypt) {
|
|
804
|
+
in = plaintext;
|
|
805
|
+
out = ciphertext;
|
|
806
|
+
} else {
|
|
807
|
+
in = ciphertext;
|
|
808
|
+
out = plaintext;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
bssl::ScopedEVP_CIPHER_CTX ctx;
|
|
812
|
+
// Test running the EVP_Cipher interfaces one by one directly, and check
|
|
813
|
+
// |EVP_EncryptFinal_ex| and |EVP_DecryptFinal_ex| for approval at the end.
|
|
814
|
+
ASSERT_TRUE(EVP_CipherInit_ex(ctx.get(), cipher, nullptr, nullptr, nullptr,
|
|
815
|
+
encrypt ? 1 : 0));
|
|
816
|
+
ASSERT_LE(EVP_CIPHER_CTX_iv_length(ctx.get()), sizeof(kAESIV));
|
|
817
|
+
|
|
818
|
+
ASSERT_TRUE(EVP_CIPHER_CTX_set_key_length(ctx.get(), key.size()));
|
|
819
|
+
ASSERT_TRUE(EVP_CipherInit_ex(ctx.get(), cipher, nullptr, key.data(), kAESIV,
|
|
820
|
+
encrypt ? 1 : 0));
|
|
821
|
+
ASSERT_TRUE(EVP_CIPHER_CTX_set_padding(ctx.get(), 0));
|
|
822
|
+
std::vector<uint8_t> encrypt_result;
|
|
823
|
+
DoCipherFinal(ctx.get(), &encrypt_result, in, expect_approved);
|
|
824
|
+
EXPECT_EQ(Bytes(out), Bytes(encrypt_result));
|
|
825
|
+
|
|
826
|
+
// Test using the one-shot |EVP_Cipher| function for approval.
|
|
827
|
+
bssl::ScopedEVP_CIPHER_CTX ctx2;
|
|
828
|
+
uint8_t output[256];
|
|
829
|
+
ASSERT_TRUE(EVP_CipherInit_ex(ctx2.get(), cipher, nullptr, key.data(), kAESIV,
|
|
830
|
+
encrypt ? 1 : 0));
|
|
831
|
+
CALL_SERVICE_AND_CHECK_APPROVED(
|
|
832
|
+
approved, EVP_Cipher(ctx2.get(), output, in.data(), in.size()));
|
|
833
|
+
EXPECT_EQ(approved, expect_approved);
|
|
834
|
+
EXPECT_EQ(Bytes(out), Bytes(output, in.size()));
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
INSTANTIATE_TEST_SUITE_P(All, EVPServiceIndicatorTest,
|
|
838
|
+
testing::ValuesIn(kTestVectors));
|
|
839
|
+
|
|
840
|
+
TEST_P(EVPServiceIndicatorTest, EVP_Ciphers) {
|
|
841
|
+
const CipherTestVector &test = GetParam();
|
|
842
|
+
|
|
843
|
+
const EVP_CIPHER *cipher = test.cipher;
|
|
844
|
+
std::vector<uint8_t> key(test.key, test.key + test.key_length);
|
|
845
|
+
std::vector<uint8_t> plaintext(kPlaintext, kPlaintext + sizeof(kPlaintext));
|
|
846
|
+
std::vector<uint8_t> ciphertext(
|
|
847
|
+
test.expected_ciphertext,
|
|
848
|
+
test.expected_ciphertext + test.cipher_text_length);
|
|
849
|
+
|
|
850
|
+
TestOperation(cipher, true /* encrypt */, key, plaintext, ciphertext,
|
|
851
|
+
test.expect_approved);
|
|
852
|
+
TestOperation(cipher, false /* decrypt */, key, plaintext, ciphertext,
|
|
853
|
+
test.expect_approved);
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
static const struct DigestTestVector {
|
|
857
|
+
// name is the name of the digest test.
|
|
858
|
+
const char *name;
|
|
859
|
+
// length of digest.
|
|
860
|
+
const int length;
|
|
861
|
+
// func is the digest to test.
|
|
862
|
+
const EVP_MD *(*func)();
|
|
863
|
+
// one_shot_func is the convenience one-shot version of the digest.
|
|
864
|
+
uint8_t *(*one_shot_func)(const uint8_t *, size_t, uint8_t *);
|
|
865
|
+
// expected_digest is the expected digest.
|
|
866
|
+
const uint8_t *expected_digest;
|
|
867
|
+
// expected to be approved or not.
|
|
868
|
+
const FIPSStatus expect_approved;
|
|
869
|
+
} kDigestTestVectors[] = {
|
|
870
|
+
{
|
|
871
|
+
"MD4",
|
|
872
|
+
MD4_DIGEST_LENGTH,
|
|
873
|
+
&EVP_md4,
|
|
874
|
+
&MD4,
|
|
875
|
+
kOutput_md4,
|
|
876
|
+
FIPSStatus::NOT_APPROVED,
|
|
877
|
+
},
|
|
878
|
+
{
|
|
879
|
+
"MD5",
|
|
880
|
+
MD5_DIGEST_LENGTH,
|
|
881
|
+
&EVP_md5,
|
|
882
|
+
&MD5,
|
|
883
|
+
kOutput_md5,
|
|
884
|
+
FIPSStatus::NOT_APPROVED,
|
|
885
|
+
},
|
|
886
|
+
{
|
|
887
|
+
"SHA-1",
|
|
888
|
+
SHA_DIGEST_LENGTH,
|
|
889
|
+
&EVP_sha1,
|
|
890
|
+
&SHA1,
|
|
891
|
+
kOutput_sha1,
|
|
892
|
+
FIPSStatus::APPROVED,
|
|
893
|
+
},
|
|
894
|
+
{
|
|
895
|
+
"SHA-224",
|
|
896
|
+
SHA224_DIGEST_LENGTH,
|
|
897
|
+
&EVP_sha224,
|
|
898
|
+
&SHA224,
|
|
899
|
+
kOutput_sha224,
|
|
900
|
+
FIPSStatus::APPROVED,
|
|
901
|
+
},
|
|
902
|
+
{
|
|
903
|
+
"SHA-256",
|
|
904
|
+
SHA256_DIGEST_LENGTH,
|
|
905
|
+
&EVP_sha256,
|
|
906
|
+
&SHA256,
|
|
907
|
+
kOutput_sha256,
|
|
908
|
+
FIPSStatus::APPROVED,
|
|
909
|
+
},
|
|
910
|
+
{
|
|
911
|
+
"SHA-384",
|
|
912
|
+
SHA384_DIGEST_LENGTH,
|
|
913
|
+
&EVP_sha384,
|
|
914
|
+
&SHA384,
|
|
915
|
+
kOutput_sha384,
|
|
916
|
+
FIPSStatus::APPROVED,
|
|
917
|
+
},
|
|
918
|
+
{
|
|
919
|
+
"SHA-512",
|
|
920
|
+
SHA512_DIGEST_LENGTH,
|
|
921
|
+
&EVP_sha512,
|
|
922
|
+
&SHA512,
|
|
923
|
+
kOutput_sha512,
|
|
924
|
+
FIPSStatus::APPROVED,
|
|
925
|
+
},
|
|
926
|
+
{
|
|
927
|
+
"SHA-512/256",
|
|
928
|
+
SHA512_256_DIGEST_LENGTH,
|
|
929
|
+
&EVP_sha512_256,
|
|
930
|
+
&SHA512_256,
|
|
931
|
+
kOutput_sha512_256,
|
|
932
|
+
FIPSStatus::APPROVED,
|
|
933
|
+
},
|
|
934
|
+
};
|
|
935
|
+
|
|
936
|
+
class EVPMDServiceIndicatorTest : public TestWithNoErrors<DigestTestVector> {};
|
|
937
|
+
|
|
938
|
+
INSTANTIATE_TEST_SUITE_P(All, EVPMDServiceIndicatorTest,
|
|
939
|
+
testing::ValuesIn(kDigestTestVectors));
|
|
940
|
+
|
|
941
|
+
TEST_P(EVPMDServiceIndicatorTest, EVP_Digests) {
|
|
942
|
+
const DigestTestVector &test = GetParam();
|
|
943
|
+
SCOPED_TRACE(test.name);
|
|
944
|
+
|
|
945
|
+
FIPSStatus approved = FIPSStatus::NOT_APPROVED;
|
|
946
|
+
bssl::ScopedEVP_MD_CTX ctx;
|
|
947
|
+
std::vector<uint8_t> digest(test.length);
|
|
948
|
+
unsigned digest_len;
|
|
949
|
+
|
|
950
|
+
// Test running the EVP_Digest interfaces one by one directly, and check
|
|
951
|
+
// |EVP_DigestFinal_ex| for approval at the end. |EVP_DigestInit_ex| and
|
|
952
|
+
// |EVP_DigestUpdate| should not be approved, because the functions do not
|
|
953
|
+
// indicate that a service has been fully completed yet.
|
|
954
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
955
|
+
approved, EVP_DigestInit_ex(ctx.get(), test.func(), nullptr)));
|
|
956
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
957
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
958
|
+
approved, EVP_DigestUpdate(ctx.get(), kPlaintext, sizeof(kPlaintext))));
|
|
959
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
960
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
961
|
+
approved, EVP_DigestFinal_ex(ctx.get(), digest.data(), &digest_len)));
|
|
962
|
+
EXPECT_EQ(approved, test.expect_approved);
|
|
963
|
+
EXPECT_EQ(Bytes(test.expected_digest, digest_len), Bytes(digest));
|
|
964
|
+
|
|
965
|
+
// Test using the one-shot |EVP_Digest| function for approval.
|
|
966
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
967
|
+
approved, EVP_Digest(kPlaintext, sizeof(kPlaintext), digest.data(),
|
|
968
|
+
&digest_len, test.func(), nullptr)));
|
|
969
|
+
EXPECT_EQ(approved, test.expect_approved);
|
|
970
|
+
EXPECT_EQ(Bytes(test.expected_digest, test.length), Bytes(digest));
|
|
971
|
+
|
|
972
|
+
// Test using the one-shot API for approval.
|
|
973
|
+
CALL_SERVICE_AND_CHECK_APPROVED(
|
|
974
|
+
approved,
|
|
975
|
+
test.one_shot_func(kPlaintext, sizeof(kPlaintext), digest.data()));
|
|
976
|
+
EXPECT_EQ(approved, test.expect_approved);
|
|
977
|
+
EXPECT_EQ(Bytes(test.expected_digest, test.length), Bytes(digest));
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
static const struct HMACTestVector {
|
|
981
|
+
// func is the hash function for HMAC to test.
|
|
982
|
+
const EVP_MD *(*func)(void);
|
|
983
|
+
// expected_digest is the expected digest.
|
|
984
|
+
const uint8_t *expected_digest;
|
|
985
|
+
// expected to be approved or not.
|
|
986
|
+
const FIPSStatus expect_approved;
|
|
987
|
+
} kHMACTestVectors[] = {
|
|
988
|
+
{EVP_sha1, kHMACOutput_sha1, FIPSStatus::APPROVED},
|
|
989
|
+
{EVP_sha224, kHMACOutput_sha224, FIPSStatus::APPROVED},
|
|
990
|
+
{EVP_sha256, kHMACOutput_sha256, FIPSStatus::APPROVED},
|
|
991
|
+
{EVP_sha384, kHMACOutput_sha384, FIPSStatus::APPROVED},
|
|
992
|
+
{EVP_sha512, kHMACOutput_sha512, FIPSStatus::APPROVED},
|
|
993
|
+
{EVP_sha512_256, kHMACOutput_sha512_256, FIPSStatus::APPROVED},
|
|
994
|
+
};
|
|
995
|
+
|
|
996
|
+
class HMACServiceIndicatorTest : public TestWithNoErrors<HMACTestVector> {};
|
|
997
|
+
|
|
998
|
+
INSTANTIATE_TEST_SUITE_P(All, HMACServiceIndicatorTest,
|
|
999
|
+
testing::ValuesIn(kHMACTestVectors));
|
|
1000
|
+
|
|
1001
|
+
TEST_P(HMACServiceIndicatorTest, HMACTest) {
|
|
1002
|
+
const HMACTestVector &test = GetParam();
|
|
1003
|
+
|
|
1004
|
+
FIPSStatus approved = FIPSStatus::NOT_APPROVED;
|
|
1005
|
+
// The key is deliberately long in order to trigger digesting it down to a
|
|
1006
|
+
// block size. This tests that doing so does not cause the indicator to be
|
|
1007
|
+
// mistakenly set in |HMAC_Init_ex|.
|
|
1008
|
+
const uint8_t kHMACKey[512] = {0};
|
|
1009
|
+
const EVP_MD *const digest = test.func();
|
|
1010
|
+
const unsigned expected_mac_len = EVP_MD_size(digest);
|
|
1011
|
+
std::vector<uint8_t> mac(expected_mac_len);
|
|
1012
|
+
|
|
1013
|
+
// Test running the HMAC interfaces one by one directly, and check
|
|
1014
|
+
// |HMAC_Final| for approval at the end. |HMAC_Init_ex| and |HMAC_Update|
|
|
1015
|
+
// should not be approved, because the functions do not indicate that a
|
|
1016
|
+
// service has been fully completed yet.
|
|
1017
|
+
unsigned mac_len;
|
|
1018
|
+
bssl::ScopedHMAC_CTX ctx;
|
|
1019
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1020
|
+
approved,
|
|
1021
|
+
HMAC_Init_ex(ctx.get(), kHMACKey, sizeof(kHMACKey), digest, nullptr)));
|
|
1022
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1023
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1024
|
+
approved, HMAC_Update(ctx.get(), kPlaintext, sizeof(kPlaintext))));
|
|
1025
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1026
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1027
|
+
approved, HMAC_Final(ctx.get(), mac.data(), &mac_len)));
|
|
1028
|
+
EXPECT_EQ(approved, test.expect_approved);
|
|
1029
|
+
EXPECT_EQ(Bytes(test.expected_digest, expected_mac_len),
|
|
1030
|
+
Bytes(mac.data(), mac_len));
|
|
1031
|
+
|
|
1032
|
+
// Test using the one-shot API for approval.
|
|
1033
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1034
|
+
approved, HMAC(digest, kHMACKey, sizeof(kHMACKey), kPlaintext,
|
|
1035
|
+
sizeof(kPlaintext), mac.data(), &mac_len)));
|
|
1036
|
+
EXPECT_EQ(approved, test.expect_approved);
|
|
1037
|
+
EXPECT_EQ(Bytes(test.expected_digest, expected_mac_len),
|
|
1038
|
+
Bytes(mac.data(), mac_len));
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
// RSA tests are not parameterized with the |kRSATestVectors| as key
|
|
1042
|
+
// generation for RSA is time consuming.
|
|
1043
|
+
TEST(ServiceIndicatorTest, RSAKeyGen) {
|
|
1044
|
+
FIPSStatus approved = FIPSStatus::NOT_APPROVED;
|
|
1045
|
+
bssl::UniquePtr<RSA> rsa(RSA_new());
|
|
1046
|
+
ASSERT_TRUE(rsa);
|
|
1047
|
+
|
|
1048
|
+
// |RSA_generate_key_fips| may only be used for 2048-, 3072-, and 4096-bit
|
|
1049
|
+
// keys.
|
|
1050
|
+
for (const size_t bits : {512, 1024, 3071, 4095}) {
|
|
1051
|
+
SCOPED_TRACE(bits);
|
|
1052
|
+
|
|
1053
|
+
rsa.reset(RSA_new());
|
|
1054
|
+
EXPECT_FALSE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1055
|
+
approved, RSA_generate_key_fips(rsa.get(), bits, nullptr)));
|
|
1056
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
// Test that we can generate keys of the supported lengths:
|
|
1060
|
+
for (const size_t bits : {2048, 3072, 4096}) {
|
|
1061
|
+
SCOPED_TRACE(bits);
|
|
1062
|
+
|
|
1063
|
+
rsa.reset(RSA_new());
|
|
1064
|
+
EXPECT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1065
|
+
approved, RSA_generate_key_fips(rsa.get(), bits, nullptr)));
|
|
1066
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
1067
|
+
EXPECT_EQ(bits, BN_num_bits(rsa->n));
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
// Test running the EVP_PKEY_keygen interfaces one by one directly, and check
|
|
1071
|
+
// |EVP_PKEY_keygen| for approval at the end. |EVP_PKEY_keygen_init| should
|
|
1072
|
+
// not be approved because it does not indicate an entire service has been
|
|
1073
|
+
// completed.
|
|
1074
|
+
bssl::UniquePtr<EVP_PKEY_CTX> ctx(EVP_PKEY_CTX_new_id(EVP_PKEY_RSA, nullptr));
|
|
1075
|
+
EVP_PKEY *raw = nullptr;
|
|
1076
|
+
bssl::UniquePtr<EVP_PKEY> pkey(raw);
|
|
1077
|
+
ASSERT_TRUE(ctx);
|
|
1078
|
+
|
|
1079
|
+
if (kEVPKeyGenShouldCallFIPSFunctions) {
|
|
1080
|
+
// Test unapproved key sizes of RSA.
|
|
1081
|
+
for (const size_t bits : {512, 1024, 3071, 4095}) {
|
|
1082
|
+
SCOPED_TRACE(bits);
|
|
1083
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1084
|
+
approved, EVP_PKEY_keygen_init(ctx.get())));
|
|
1085
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1086
|
+
ASSERT_TRUE(EVP_PKEY_CTX_set_rsa_keygen_bits(ctx.get(), bits));
|
|
1087
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1088
|
+
approved, EVP_PKEY_keygen(ctx.get(), &raw)));
|
|
1089
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1090
|
+
pkey.reset(raw);
|
|
1091
|
+
raw = nullptr;
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
// Test approved key sizes of RSA.
|
|
1095
|
+
for (const size_t bits : {2048, 3072, 4096}) {
|
|
1096
|
+
SCOPED_TRACE(bits);
|
|
1097
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1098
|
+
approved, EVP_PKEY_keygen_init(ctx.get())));
|
|
1099
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1100
|
+
ASSERT_TRUE(EVP_PKEY_CTX_set_rsa_keygen_bits(ctx.get(), bits));
|
|
1101
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1102
|
+
approved, EVP_PKEY_keygen(ctx.get(), &raw)));
|
|
1103
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
1104
|
+
pkey.reset(raw);
|
|
1105
|
+
raw = nullptr;
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
struct RSATestVector {
|
|
1111
|
+
// key_size is the input rsa key size.
|
|
1112
|
+
int key_size;
|
|
1113
|
+
// md_func is the digest to test.
|
|
1114
|
+
const EVP_MD *(*func)();
|
|
1115
|
+
// whether to use pss testing or not.
|
|
1116
|
+
bool use_pss;
|
|
1117
|
+
// expected to be approved or not for signature generation.
|
|
1118
|
+
FIPSStatus sig_gen_expect_approved;
|
|
1119
|
+
// expected to be approved or not for signature verification.
|
|
1120
|
+
FIPSStatus sig_ver_expect_approved;
|
|
1121
|
+
};
|
|
1122
|
+
|
|
1123
|
+
static const struct RSATestVector kRSATestVectors[] = {
|
|
1124
|
+
// RSA test cases that are not approved in any case.
|
|
1125
|
+
{512, &EVP_sha1, false, FIPSStatus::NOT_APPROVED, FIPSStatus::NOT_APPROVED},
|
|
1126
|
+
// PSS with hashLen == saltLen is not possible for 512-bit modulus.
|
|
1127
|
+
{1024, &EVP_md5, false, FIPSStatus::NOT_APPROVED, FIPSStatus::NOT_APPROVED},
|
|
1128
|
+
{1536, &EVP_sha256, false, FIPSStatus::NOT_APPROVED,
|
|
1129
|
+
FIPSStatus::NOT_APPROVED},
|
|
1130
|
+
{1536, &EVP_sha512, true, FIPSStatus::NOT_APPROVED,
|
|
1131
|
+
FIPSStatus::NOT_APPROVED},
|
|
1132
|
+
{2048, &EVP_md5, false, FIPSStatus::NOT_APPROVED, FIPSStatus::NOT_APPROVED},
|
|
1133
|
+
{3071, &EVP_md5, true, FIPSStatus::NOT_APPROVED, FIPSStatus::NOT_APPROVED},
|
|
1134
|
+
{3071, &EVP_sha256, false, FIPSStatus::NOT_APPROVED,
|
|
1135
|
+
FIPSStatus::NOT_APPROVED},
|
|
1136
|
+
{3071, &EVP_sha512, true, FIPSStatus::NOT_APPROVED,
|
|
1137
|
+
FIPSStatus::NOT_APPROVED},
|
|
1138
|
+
{4096, &EVP_md5, false, FIPSStatus::NOT_APPROVED, FIPSStatus::NOT_APPROVED},
|
|
1139
|
+
|
|
1140
|
+
// RSA test cases that are approved.
|
|
1141
|
+
{1024, &EVP_sha1, false, FIPSStatus::NOT_APPROVED, FIPSStatus::APPROVED},
|
|
1142
|
+
{1024, &EVP_sha256, false, FIPSStatus::NOT_APPROVED, FIPSStatus::APPROVED},
|
|
1143
|
+
{1024, &EVP_sha512, false, FIPSStatus::NOT_APPROVED, FIPSStatus::APPROVED},
|
|
1144
|
+
{1024, &EVP_sha1, true, FIPSStatus::NOT_APPROVED, FIPSStatus::APPROVED},
|
|
1145
|
+
{1024, &EVP_sha256, true, FIPSStatus::NOT_APPROVED, FIPSStatus::APPROVED},
|
|
1146
|
+
// PSS with hashLen == saltLen is not possible for 1024-bit modulus and
|
|
1147
|
+
// SHA-512.
|
|
1148
|
+
|
|
1149
|
+
{2048, &EVP_sha1, false, FIPSStatus::NOT_APPROVED, FIPSStatus::APPROVED},
|
|
1150
|
+
{2048, &EVP_sha224, false, FIPSStatus::APPROVED, FIPSStatus::APPROVED},
|
|
1151
|
+
{2048, &EVP_sha256, false, FIPSStatus::APPROVED, FIPSStatus::APPROVED},
|
|
1152
|
+
{2048, &EVP_sha384, false, FIPSStatus::APPROVED, FIPSStatus::APPROVED},
|
|
1153
|
+
{2048, &EVP_sha512, false, FIPSStatus::APPROVED, FIPSStatus::APPROVED},
|
|
1154
|
+
{2048, &EVP_sha1, true, FIPSStatus::NOT_APPROVED, FIPSStatus::APPROVED},
|
|
1155
|
+
{2048, &EVP_sha224, true, FIPSStatus::APPROVED, FIPSStatus::APPROVED},
|
|
1156
|
+
{2048, &EVP_sha256, true, FIPSStatus::APPROVED, FIPSStatus::APPROVED},
|
|
1157
|
+
{2048, &EVP_sha384, true, FIPSStatus::APPROVED, FIPSStatus::APPROVED},
|
|
1158
|
+
{2048, &EVP_sha512, true, FIPSStatus::APPROVED, FIPSStatus::APPROVED},
|
|
1159
|
+
|
|
1160
|
+
{3072, &EVP_sha1, false, FIPSStatus::NOT_APPROVED, FIPSStatus::APPROVED},
|
|
1161
|
+
{3072, &EVP_sha224, false, FIPSStatus::APPROVED, FIPSStatus::APPROVED},
|
|
1162
|
+
{3072, &EVP_sha256, false, FIPSStatus::APPROVED, FIPSStatus::APPROVED},
|
|
1163
|
+
{3072, &EVP_sha384, false, FIPSStatus::APPROVED, FIPSStatus::APPROVED},
|
|
1164
|
+
{3072, &EVP_sha512, false, FIPSStatus::APPROVED, FIPSStatus::APPROVED},
|
|
1165
|
+
{3072, &EVP_sha1, true, FIPSStatus::NOT_APPROVED, FIPSStatus::APPROVED},
|
|
1166
|
+
{3072, &EVP_sha224, true, FIPSStatus::APPROVED, FIPSStatus::APPROVED},
|
|
1167
|
+
{3072, &EVP_sha256, true, FIPSStatus::APPROVED, FIPSStatus::APPROVED},
|
|
1168
|
+
{3072, &EVP_sha384, true, FIPSStatus::APPROVED, FIPSStatus::APPROVED},
|
|
1169
|
+
{3072, &EVP_sha512, true, FIPSStatus::APPROVED, FIPSStatus::APPROVED},
|
|
1170
|
+
|
|
1171
|
+
{4096, &EVP_sha1, false, FIPSStatus::NOT_APPROVED, FIPSStatus::APPROVED},
|
|
1172
|
+
{4096, &EVP_sha224, false, FIPSStatus::APPROVED, FIPSStatus::APPROVED},
|
|
1173
|
+
{4096, &EVP_sha256, false, FIPSStatus::APPROVED, FIPSStatus::APPROVED},
|
|
1174
|
+
{4096, &EVP_sha384, false, FIPSStatus::APPROVED, FIPSStatus::APPROVED},
|
|
1175
|
+
{4096, &EVP_sha512, false, FIPSStatus::APPROVED, FIPSStatus::APPROVED},
|
|
1176
|
+
{4096, &EVP_sha1, true, FIPSStatus::NOT_APPROVED, FIPSStatus::APPROVED},
|
|
1177
|
+
{4096, &EVP_sha224, true, FIPSStatus::APPROVED, FIPSStatus::APPROVED},
|
|
1178
|
+
{4096, &EVP_sha256, true, FIPSStatus::APPROVED, FIPSStatus::APPROVED},
|
|
1179
|
+
{4096, &EVP_sha384, true, FIPSStatus::APPROVED, FIPSStatus::APPROVED},
|
|
1180
|
+
{4096, &EVP_sha512, true, FIPSStatus::APPROVED, FIPSStatus::APPROVED},
|
|
1181
|
+
};
|
|
1182
|
+
|
|
1183
|
+
class RSAServiceIndicatorTest : public TestWithNoErrors<RSATestVector> {};
|
|
1184
|
+
|
|
1185
|
+
INSTANTIATE_TEST_SUITE_P(All, RSAServiceIndicatorTest,
|
|
1186
|
+
testing::ValuesIn(kRSATestVectors));
|
|
1187
|
+
|
|
1188
|
+
static std::map<unsigned, bssl::UniquePtr<RSA>> &CachedRSAKeys() {
|
|
1189
|
+
static std::map<unsigned, bssl::UniquePtr<RSA>> keys;
|
|
1190
|
+
return keys;
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
static RSA *GetRSAKey(unsigned bits) {
|
|
1194
|
+
auto it = CachedRSAKeys().find(bits);
|
|
1195
|
+
if (it != CachedRSAKeys().end()) {
|
|
1196
|
+
return it->second.get();
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
bssl::UniquePtr<BIGNUM> e(BN_new());
|
|
1200
|
+
if (!e || !BN_set_word(e.get(), RSA_F4)) {
|
|
1201
|
+
abort();
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
bssl::UniquePtr<RSA> key(RSA_new());
|
|
1205
|
+
if (!key || !RSA_generate_key_ex(key.get(), bits, e.get(), nullptr)) {
|
|
1206
|
+
abort();
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
RSA *const ret = key.get();
|
|
1210
|
+
CachedRSAKeys().emplace(static_cast<unsigned>(bits), std::move(key));
|
|
1211
|
+
|
|
1212
|
+
return ret;
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
TEST_P(RSAServiceIndicatorTest, RSASigGen) {
|
|
1216
|
+
const RSATestVector &test = GetParam();
|
|
1217
|
+
SCOPED_TRACE(test.key_size);
|
|
1218
|
+
|
|
1219
|
+
bssl::UniquePtr<EVP_PKEY> pkey(EVP_PKEY_new());
|
|
1220
|
+
ASSERT_TRUE(pkey);
|
|
1221
|
+
|
|
1222
|
+
RSA *const rsa = GetRSAKey(test.key_size);
|
|
1223
|
+
ASSERT_TRUE(EVP_PKEY_set1_RSA(pkey.get(), rsa));
|
|
1224
|
+
|
|
1225
|
+
// Test running the EVP_DigestSign interfaces one by one directly, and check
|
|
1226
|
+
// |EVP_DigestSignFinal| for approval at the end. |EVP_DigestSignInit|, and
|
|
1227
|
+
// |EVP_DigestSignUpdate| should not be approved because they do not indicate
|
|
1228
|
+
// an entire service has been completed.
|
|
1229
|
+
FIPSStatus approved = FIPSStatus::NOT_APPROVED;
|
|
1230
|
+
bssl::ScopedEVP_MD_CTX md_ctx;
|
|
1231
|
+
EVP_PKEY_CTX *pctx = nullptr;
|
|
1232
|
+
size_t sig_len;
|
|
1233
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1234
|
+
approved, EVP_DigestSignInit(md_ctx.get(), &pctx, test.func(), nullptr,
|
|
1235
|
+
pkey.get())));
|
|
1236
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1237
|
+
if (test.use_pss) {
|
|
1238
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1239
|
+
approved, EVP_PKEY_CTX_set_rsa_padding(pctx, RSA_PKCS1_PSS_PADDING)));
|
|
1240
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1241
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1242
|
+
approved, EVP_PKEY_CTX_set_rsa_pss_saltlen(pctx, -1)));
|
|
1243
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1244
|
+
}
|
|
1245
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1246
|
+
approved,
|
|
1247
|
+
EVP_DigestSignUpdate(md_ctx.get(), kPlaintext, sizeof(kPlaintext))));
|
|
1248
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1249
|
+
// Determine the size of the signature. The first call of
|
|
1250
|
+
// |EVP_DigestSignFinal| should not return an approval check because no crypto
|
|
1251
|
+
// is being done when |nullptr| is inputted in the |*out_sig| field.
|
|
1252
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1253
|
+
approved, EVP_DigestSignFinal(md_ctx.get(), nullptr, &sig_len)));
|
|
1254
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1255
|
+
std::vector<uint8_t> signature(sig_len);
|
|
1256
|
+
// The second call performs the actual operation.
|
|
1257
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1258
|
+
approved, EVP_DigestSignFinal(md_ctx.get(), signature.data(), &sig_len)));
|
|
1259
|
+
EXPECT_EQ(approved, test.sig_gen_expect_approved);
|
|
1260
|
+
|
|
1261
|
+
// Test using the one-shot |EVP_DigestSign| function for approval.
|
|
1262
|
+
md_ctx.Reset();
|
|
1263
|
+
std::vector<uint8_t> oneshot_output(sig_len);
|
|
1264
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1265
|
+
approved, EVP_DigestSignInit(md_ctx.get(), &pctx, test.func(), nullptr,
|
|
1266
|
+
pkey.get())));
|
|
1267
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1268
|
+
if (test.use_pss) {
|
|
1269
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1270
|
+
approved, EVP_PKEY_CTX_set_rsa_padding(pctx, RSA_PKCS1_PSS_PADDING)));
|
|
1271
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1272
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1273
|
+
approved, EVP_PKEY_CTX_set_rsa_pss_saltlen(pctx, -1)));
|
|
1274
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1275
|
+
}
|
|
1276
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1277
|
+
approved, EVP_DigestSign(md_ctx.get(), oneshot_output.data(), &sig_len,
|
|
1278
|
+
kPlaintext, sizeof(kPlaintext))));
|
|
1279
|
+
EXPECT_EQ(approved, test.sig_gen_expect_approved);
|
|
1280
|
+
|
|
1281
|
+
if (test.use_pss) {
|
|
1282
|
+
// Odd configurations of PSS, for example where the salt length is not equal
|
|
1283
|
+
// to the hash length, are not approved.
|
|
1284
|
+
md_ctx.Reset();
|
|
1285
|
+
ASSERT_TRUE(EVP_DigestSignInit(md_ctx.get(), &pctx, test.func(), nullptr,
|
|
1286
|
+
pkey.get()));
|
|
1287
|
+
ASSERT_TRUE(EVP_PKEY_CTX_set_rsa_padding(pctx, RSA_PKCS1_PSS_PADDING));
|
|
1288
|
+
ASSERT_TRUE(EVP_PKEY_CTX_set_rsa_pss_saltlen(pctx, 10));
|
|
1289
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1290
|
+
approved, EVP_DigestSign(md_ctx.get(), oneshot_output.data(), &sig_len,
|
|
1291
|
+
kPlaintext, sizeof(kPlaintext))));
|
|
1292
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
TEST_P(RSAServiceIndicatorTest, RSASigVer) {
|
|
1297
|
+
const RSATestVector &test = GetParam();
|
|
1298
|
+
|
|
1299
|
+
bssl::UniquePtr<EVP_PKEY> pkey(EVP_PKEY_new());
|
|
1300
|
+
RSA *const rsa = GetRSAKey(test.key_size);
|
|
1301
|
+
|
|
1302
|
+
ASSERT_TRUE(pkey);
|
|
1303
|
+
ASSERT_TRUE(EVP_PKEY_set1_RSA(pkey.get(), rsa));
|
|
1304
|
+
|
|
1305
|
+
std::vector<uint8_t> signature;
|
|
1306
|
+
size_t sig_len;
|
|
1307
|
+
bssl::ScopedEVP_MD_CTX md_ctx;
|
|
1308
|
+
EVP_PKEY_CTX *pctx = nullptr;
|
|
1309
|
+
ASSERT_TRUE(EVP_DigestSignInit(md_ctx.get(), &pctx, test.func(), nullptr,
|
|
1310
|
+
pkey.get()));
|
|
1311
|
+
if (test.use_pss) {
|
|
1312
|
+
ASSERT_TRUE(EVP_PKEY_CTX_set_rsa_padding(pctx, RSA_PKCS1_PSS_PADDING));
|
|
1313
|
+
ASSERT_TRUE(EVP_PKEY_CTX_set_rsa_pss_saltlen(pctx, -1));
|
|
1314
|
+
}
|
|
1315
|
+
ASSERT_TRUE(EVP_DigestSign(md_ctx.get(), nullptr, &sig_len, nullptr, 0));
|
|
1316
|
+
signature.resize(sig_len);
|
|
1317
|
+
ASSERT_TRUE(EVP_DigestSign(md_ctx.get(), signature.data(), &sig_len,
|
|
1318
|
+
kPlaintext, sizeof(kPlaintext)));
|
|
1319
|
+
signature.resize(sig_len);
|
|
1320
|
+
|
|
1321
|
+
// Service Indicator approval checks for RSA signature verification.
|
|
1322
|
+
|
|
1323
|
+
// Test running the EVP_DigestVerify interfaces one by one directly, and check
|
|
1324
|
+
// |EVP_DigestVerifyFinal| for approval at the end. |EVP_DigestVerifyInit|,
|
|
1325
|
+
// |EVP_DigestVerifyUpdate| should not be approved because they do not
|
|
1326
|
+
// indicate an entire service has been done.
|
|
1327
|
+
FIPSStatus approved = FIPSStatus::NOT_APPROVED;
|
|
1328
|
+
md_ctx.Reset();
|
|
1329
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1330
|
+
approved, EVP_DigestVerifyInit(md_ctx.get(), &pctx, test.func(), nullptr,
|
|
1331
|
+
pkey.get())));
|
|
1332
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1333
|
+
if (test.use_pss) {
|
|
1334
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1335
|
+
approved, EVP_PKEY_CTX_set_rsa_padding(pctx, RSA_PKCS1_PSS_PADDING)));
|
|
1336
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1337
|
+
ASSERT_TRUE(EVP_PKEY_CTX_set_rsa_pss_saltlen(pctx, -1));
|
|
1338
|
+
}
|
|
1339
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1340
|
+
approved,
|
|
1341
|
+
EVP_DigestVerifyUpdate(md_ctx.get(), kPlaintext, sizeof(kPlaintext))));
|
|
1342
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1343
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1344
|
+
approved,
|
|
1345
|
+
EVP_DigestVerifyFinal(md_ctx.get(), signature.data(), signature.size())));
|
|
1346
|
+
EXPECT_EQ(approved, test.sig_ver_expect_approved);
|
|
1347
|
+
|
|
1348
|
+
// Test using the one-shot |EVP_DigestVerify| function for approval.
|
|
1349
|
+
md_ctx.Reset();
|
|
1350
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1351
|
+
approved, EVP_DigestVerifyInit(md_ctx.get(), &pctx, test.func(), nullptr,
|
|
1352
|
+
pkey.get())));
|
|
1353
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1354
|
+
if (test.use_pss) {
|
|
1355
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1356
|
+
approved, EVP_PKEY_CTX_set_rsa_padding(pctx, RSA_PKCS1_PSS_PADDING)));
|
|
1357
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1358
|
+
ASSERT_TRUE(EVP_PKEY_CTX_set_rsa_pss_saltlen(pctx, -1));
|
|
1359
|
+
}
|
|
1360
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1361
|
+
approved,
|
|
1362
|
+
EVP_DigestVerify(md_ctx.get(), signature.data(), signature.size(),
|
|
1363
|
+
kPlaintext, sizeof(kPlaintext))));
|
|
1364
|
+
EXPECT_EQ(approved, test.sig_ver_expect_approved);
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
struct ECDSATestVector {
|
|
1368
|
+
// nid is the input curve nid.
|
|
1369
|
+
int nid;
|
|
1370
|
+
// md_func is the digest to test.
|
|
1371
|
+
const EVP_MD *(*func)();
|
|
1372
|
+
// expected to be approved or not for signature generation.
|
|
1373
|
+
FIPSStatus key_check_expect_approved;
|
|
1374
|
+
// expected to be approved or not for signature generation.
|
|
1375
|
+
FIPSStatus sig_gen_expect_approved;
|
|
1376
|
+
// expected to be approved or not for signature verification.
|
|
1377
|
+
FIPSStatus sig_ver_expect_approved;
|
|
1378
|
+
};
|
|
1379
|
+
|
|
1380
|
+
static const struct ECDSATestVector kECDSATestVectors[] = {
|
|
1381
|
+
// Only the following NIDs for |EC_GROUP| are creatable with
|
|
1382
|
+
// |EC_GROUP_new_by_curve_name|, and |NID_secp256k1| will only work if
|
|
1383
|
+
// |kCurveSecp256k1Supported| is true.
|
|
1384
|
+
{NID_secp224r1, &EVP_sha1, FIPSStatus::APPROVED, FIPSStatus::NOT_APPROVED,
|
|
1385
|
+
FIPSStatus::APPROVED},
|
|
1386
|
+
{NID_secp224r1, &EVP_sha224, FIPSStatus::APPROVED, FIPSStatus::APPROVED,
|
|
1387
|
+
FIPSStatus::APPROVED},
|
|
1388
|
+
{NID_secp224r1, &EVP_sha256, FIPSStatus::APPROVED, FIPSStatus::APPROVED,
|
|
1389
|
+
FIPSStatus::APPROVED},
|
|
1390
|
+
{NID_secp224r1, &EVP_sha384, FIPSStatus::APPROVED, FIPSStatus::APPROVED,
|
|
1391
|
+
FIPSStatus::APPROVED},
|
|
1392
|
+
{NID_secp224r1, &EVP_sha512, FIPSStatus::APPROVED, FIPSStatus::APPROVED,
|
|
1393
|
+
FIPSStatus::APPROVED},
|
|
1394
|
+
|
|
1395
|
+
{NID_X9_62_prime256v1, &EVP_sha1, FIPSStatus::APPROVED,
|
|
1396
|
+
FIPSStatus::NOT_APPROVED, FIPSStatus::APPROVED},
|
|
1397
|
+
{NID_X9_62_prime256v1, &EVP_sha224, FIPSStatus::APPROVED,
|
|
1398
|
+
FIPSStatus::APPROVED, FIPSStatus::APPROVED},
|
|
1399
|
+
{NID_X9_62_prime256v1, &EVP_sha256, FIPSStatus::APPROVED,
|
|
1400
|
+
FIPSStatus::APPROVED, FIPSStatus::APPROVED},
|
|
1401
|
+
{NID_X9_62_prime256v1, &EVP_sha384, FIPSStatus::APPROVED,
|
|
1402
|
+
FIPSStatus::APPROVED, FIPSStatus::APPROVED},
|
|
1403
|
+
{NID_X9_62_prime256v1, &EVP_sha512, FIPSStatus::APPROVED,
|
|
1404
|
+
FIPSStatus::APPROVED, FIPSStatus::APPROVED},
|
|
1405
|
+
|
|
1406
|
+
{NID_secp384r1, &EVP_sha1, FIPSStatus::APPROVED, FIPSStatus::NOT_APPROVED,
|
|
1407
|
+
FIPSStatus::APPROVED},
|
|
1408
|
+
{NID_secp384r1, &EVP_sha224, FIPSStatus::APPROVED, FIPSStatus::APPROVED,
|
|
1409
|
+
FIPSStatus::APPROVED},
|
|
1410
|
+
{NID_secp384r1, &EVP_sha256, FIPSStatus::APPROVED, FIPSStatus::APPROVED,
|
|
1411
|
+
FIPSStatus::APPROVED},
|
|
1412
|
+
{NID_secp384r1, &EVP_sha384, FIPSStatus::APPROVED, FIPSStatus::APPROVED,
|
|
1413
|
+
FIPSStatus::APPROVED},
|
|
1414
|
+
{NID_secp384r1, &EVP_sha512, FIPSStatus::APPROVED, FIPSStatus::APPROVED,
|
|
1415
|
+
FIPSStatus::APPROVED},
|
|
1416
|
+
|
|
1417
|
+
{NID_secp521r1, &EVP_sha1, FIPSStatus::APPROVED, FIPSStatus::NOT_APPROVED,
|
|
1418
|
+
FIPSStatus::APPROVED},
|
|
1419
|
+
{NID_secp521r1, &EVP_sha224, FIPSStatus::APPROVED, FIPSStatus::APPROVED,
|
|
1420
|
+
FIPSStatus::APPROVED},
|
|
1421
|
+
{NID_secp521r1, &EVP_sha256, FIPSStatus::APPROVED, FIPSStatus::APPROVED,
|
|
1422
|
+
FIPSStatus::APPROVED},
|
|
1423
|
+
{NID_secp521r1, &EVP_sha384, FIPSStatus::APPROVED, FIPSStatus::APPROVED,
|
|
1424
|
+
FIPSStatus::APPROVED},
|
|
1425
|
+
{NID_secp521r1, &EVP_sha512, FIPSStatus::APPROVED, FIPSStatus::APPROVED,
|
|
1426
|
+
FIPSStatus::APPROVED},
|
|
1427
|
+
|
|
1428
|
+
{NID_secp256k1, &EVP_sha1, FIPSStatus::NOT_APPROVED,
|
|
1429
|
+
FIPSStatus::NOT_APPROVED, FIPSStatus::NOT_APPROVED},
|
|
1430
|
+
{NID_secp256k1, &EVP_sha224, FIPSStatus::NOT_APPROVED,
|
|
1431
|
+
FIPSStatus::NOT_APPROVED, FIPSStatus::NOT_APPROVED},
|
|
1432
|
+
{NID_secp256k1, &EVP_sha256, FIPSStatus::NOT_APPROVED,
|
|
1433
|
+
FIPSStatus::NOT_APPROVED, FIPSStatus::NOT_APPROVED},
|
|
1434
|
+
{NID_secp256k1, &EVP_sha384, FIPSStatus::NOT_APPROVED,
|
|
1435
|
+
FIPSStatus::NOT_APPROVED, FIPSStatus::NOT_APPROVED},
|
|
1436
|
+
{NID_secp256k1, &EVP_sha512, FIPSStatus::NOT_APPROVED,
|
|
1437
|
+
FIPSStatus::NOT_APPROVED, FIPSStatus::NOT_APPROVED},
|
|
1438
|
+
};
|
|
1439
|
+
|
|
1440
|
+
class ECDSAServiceIndicatorTest : public TestWithNoErrors<ECDSATestVector> {};
|
|
1441
|
+
|
|
1442
|
+
INSTANTIATE_TEST_SUITE_P(All, ECDSAServiceIndicatorTest,
|
|
1443
|
+
testing::ValuesIn(kECDSATestVectors));
|
|
1444
|
+
|
|
1445
|
+
TEST_P(ECDSAServiceIndicatorTest, ECDSAKeyCheck) {
|
|
1446
|
+
const ECDSATestVector &test = GetParam();
|
|
1447
|
+
if (test.nid == NID_secp256k1 && !kCurveSecp256k1Supported) {
|
|
1448
|
+
GTEST_SKIP();
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
FIPSStatus approved = FIPSStatus::NOT_APPROVED;
|
|
1452
|
+
|
|
1453
|
+
// Test service indicator approval for |EC_KEY_generate_key_fips| and
|
|
1454
|
+
// |EC_KEY_check_fips|.
|
|
1455
|
+
bssl::UniquePtr<EC_KEY> key(EC_KEY_new_by_curve_name(test.nid));
|
|
1456
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1457
|
+
approved, EC_KEY_generate_key_fips(key.get())));
|
|
1458
|
+
EXPECT_EQ(approved, test.key_check_expect_approved);
|
|
1459
|
+
ASSERT_TRUE(
|
|
1460
|
+
CALL_SERVICE_AND_CHECK_APPROVED(approved, EC_KEY_check_fips(key.get())));
|
|
1461
|
+
EXPECT_EQ(approved, test.key_check_expect_approved);
|
|
1462
|
+
|
|
1463
|
+
// See if |EC_KEY_check_fips| still returns approval with only the public
|
|
1464
|
+
// component.
|
|
1465
|
+
bssl::UniquePtr<EC_KEY> key_only_public(EC_KEY_new_by_curve_name(test.nid));
|
|
1466
|
+
ASSERT_TRUE(EC_KEY_set_public_key(key_only_public.get(),
|
|
1467
|
+
EC_KEY_get0_public_key(key.get())));
|
|
1468
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1469
|
+
approved, EC_KEY_check_fips(key_only_public.get())));
|
|
1470
|
+
EXPECT_EQ(approved, test.key_check_expect_approved);
|
|
1471
|
+
|
|
1472
|
+
if (kEVPKeyGenShouldCallFIPSFunctions) {
|
|
1473
|
+
// Test running the EVP_PKEY_keygen interfaces one by one directly, and
|
|
1474
|
+
// check |EVP_PKEY_keygen| for approval at the end. |EVP_PKEY_keygen_init|
|
|
1475
|
+
// should not be approved because it does not indicate that an entire
|
|
1476
|
+
// service has been completed.
|
|
1477
|
+
bssl::UniquePtr<EVP_PKEY_CTX> ctx(
|
|
1478
|
+
EVP_PKEY_CTX_new_id(EVP_PKEY_EC, nullptr));
|
|
1479
|
+
EVP_PKEY *raw = nullptr;
|
|
1480
|
+
ASSERT_TRUE(ctx);
|
|
1481
|
+
ASSERT_TRUE(EVP_PKEY_keygen_init(ctx.get()));
|
|
1482
|
+
ASSERT_TRUE(EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx.get(), test.nid));
|
|
1483
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1484
|
+
approved, EVP_PKEY_keygen(ctx.get(), &raw)));
|
|
1485
|
+
EXPECT_EQ(approved, test.key_check_expect_approved);
|
|
1486
|
+
|
|
1487
|
+
EVP_PKEY_free(raw);
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
TEST_P(ECDSAServiceIndicatorTest, ECDSASigGen) {
|
|
1492
|
+
const ECDSATestVector &test = GetParam();
|
|
1493
|
+
if (test.nid == NID_secp256k1 && !kCurveSecp256k1Supported) {
|
|
1494
|
+
GTEST_SKIP();
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
FIPSStatus approved = FIPSStatus::NOT_APPROVED;
|
|
1498
|
+
|
|
1499
|
+
bssl::UniquePtr<EC_GROUP> group(EC_GROUP_new_by_curve_name(test.nid));
|
|
1500
|
+
bssl::UniquePtr<EC_KEY> eckey(EC_KEY_new());
|
|
1501
|
+
bssl::UniquePtr<EVP_PKEY> pkey(EVP_PKEY_new());
|
|
1502
|
+
bssl::ScopedEVP_MD_CTX md_ctx;
|
|
1503
|
+
ASSERT_TRUE(eckey);
|
|
1504
|
+
ASSERT_TRUE(EC_KEY_set_group(eckey.get(), group.get()));
|
|
1505
|
+
|
|
1506
|
+
// Generate a generic EC key.
|
|
1507
|
+
ASSERT_TRUE(EC_KEY_generate_key(eckey.get()));
|
|
1508
|
+
ASSERT_TRUE(EVP_PKEY_set1_EC_KEY(pkey.get(), eckey.get()));
|
|
1509
|
+
|
|
1510
|
+
// Test running the EVP_DigestSign interfaces one by one directly, and check
|
|
1511
|
+
// |EVP_DigestSignFinal| for approval at the end. |EVP_DigestSignInit|,
|
|
1512
|
+
// |EVP_DigestSignUpdate| should not be approved because they do not indicate
|
|
1513
|
+
// an entire service has been done.
|
|
1514
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1515
|
+
approved, EVP_DigestSignInit(md_ctx.get(), nullptr, test.func(), nullptr,
|
|
1516
|
+
pkey.get())));
|
|
1517
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1518
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1519
|
+
approved,
|
|
1520
|
+
EVP_DigestSignUpdate(md_ctx.get(), kPlaintext, sizeof(kPlaintext))));
|
|
1521
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1522
|
+
// Determine the size of the signature. The first call of
|
|
1523
|
+
// |EVP_DigestSignFinal| should not return an approval check because no crypto
|
|
1524
|
+
// is being done when |nullptr| is given as the |out_sig| field.
|
|
1525
|
+
size_t max_sig_len;
|
|
1526
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1527
|
+
approved, EVP_DigestSignFinal(md_ctx.get(), nullptr, &max_sig_len)));
|
|
1528
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1529
|
+
std::vector<uint8_t> signature(max_sig_len);
|
|
1530
|
+
// The second call performs the actual operation.
|
|
1531
|
+
size_t sig_len = max_sig_len;
|
|
1532
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1533
|
+
approved, EVP_DigestSignFinal(md_ctx.get(), signature.data(), &sig_len)));
|
|
1534
|
+
ASSERT_LE(sig_len, signature.size());
|
|
1535
|
+
EXPECT_EQ(approved, test.sig_gen_expect_approved);
|
|
1536
|
+
|
|
1537
|
+
// Test using the one-shot |EVP_DigestSign| function for approval.
|
|
1538
|
+
md_ctx.Reset();
|
|
1539
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1540
|
+
approved, EVP_DigestSignInit(md_ctx.get(), nullptr, test.func(), nullptr,
|
|
1541
|
+
pkey.get())));
|
|
1542
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1543
|
+
sig_len = max_sig_len;
|
|
1544
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1545
|
+
approved, EVP_DigestSign(md_ctx.get(), signature.data(), &sig_len,
|
|
1546
|
+
kPlaintext, sizeof(kPlaintext))));
|
|
1547
|
+
ASSERT_LE(sig_len, signature.size());
|
|
1548
|
+
EXPECT_EQ(approved, test.sig_gen_expect_approved);
|
|
1549
|
+
}
|
|
1550
|
+
|
|
1551
|
+
TEST_P(ECDSAServiceIndicatorTest, ECDSASigVer) {
|
|
1552
|
+
const ECDSATestVector &test = GetParam();
|
|
1553
|
+
if (test.nid == NID_secp256k1 && !kCurveSecp256k1Supported) {
|
|
1554
|
+
GTEST_SKIP();
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
FIPSStatus approved = FIPSStatus::NOT_APPROVED;
|
|
1558
|
+
|
|
1559
|
+
bssl::UniquePtr<EC_GROUP> group(EC_GROUP_new_by_curve_name(test.nid));
|
|
1560
|
+
bssl::UniquePtr<EC_KEY> eckey(EC_KEY_new());
|
|
1561
|
+
bssl::UniquePtr<EVP_PKEY> pkey(EVP_PKEY_new());
|
|
1562
|
+
bssl::ScopedEVP_MD_CTX md_ctx;
|
|
1563
|
+
ASSERT_TRUE(eckey);
|
|
1564
|
+
ASSERT_TRUE(EC_KEY_set_group(eckey.get(), group.get()));
|
|
1565
|
+
|
|
1566
|
+
// Generate ECDSA signatures for ECDSA verification.
|
|
1567
|
+
ASSERT_TRUE(EC_KEY_generate_key(eckey.get()));
|
|
1568
|
+
ASSERT_TRUE(EVP_PKEY_set1_EC_KEY(pkey.get(), eckey.get()));
|
|
1569
|
+
std::vector<uint8_t> signature;
|
|
1570
|
+
size_t sig_len = 0;
|
|
1571
|
+
ASSERT_TRUE(EVP_DigestSignInit(md_ctx.get(), nullptr, test.func(), nullptr,
|
|
1572
|
+
pkey.get()));
|
|
1573
|
+
ASSERT_TRUE(EVP_DigestSignFinal(md_ctx.get(), nullptr, &sig_len));
|
|
1574
|
+
signature.resize(sig_len);
|
|
1575
|
+
ASSERT_TRUE(EVP_DigestSign(md_ctx.get(), signature.data(), &sig_len,
|
|
1576
|
+
kPlaintext, sizeof(kPlaintext)));
|
|
1577
|
+
signature.resize(sig_len);
|
|
1578
|
+
|
|
1579
|
+
// Service Indicator approval checks for ECDSA signature verification.
|
|
1580
|
+
|
|
1581
|
+
// Test running the EVP_DigestVerify interfaces one by one directly, and check
|
|
1582
|
+
// |EVP_DigestVerifyFinal| for approval at the end. |EVP_DigestVerifyInit|,
|
|
1583
|
+
// |EVP_DigestVerifyUpdate| should not be approved because they do not
|
|
1584
|
+
// indicate an entire service has been done.
|
|
1585
|
+
md_ctx.Reset();
|
|
1586
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1587
|
+
approved, EVP_DigestVerifyInit(md_ctx.get(), nullptr, test.func(),
|
|
1588
|
+
nullptr, pkey.get())));
|
|
1589
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1590
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1591
|
+
approved,
|
|
1592
|
+
EVP_DigestVerifyUpdate(md_ctx.get(), kPlaintext, sizeof(kPlaintext))));
|
|
1593
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1594
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1595
|
+
approved,
|
|
1596
|
+
EVP_DigestVerifyFinal(md_ctx.get(), signature.data(), signature.size())));
|
|
1597
|
+
EXPECT_EQ(approved, test.sig_ver_expect_approved);
|
|
1598
|
+
|
|
1599
|
+
// Test using the one-shot |EVP_DigestVerify| function for approval.
|
|
1600
|
+
md_ctx.Reset();
|
|
1601
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1602
|
+
approved, EVP_DigestVerifyInit(md_ctx.get(), nullptr, test.func(),
|
|
1603
|
+
nullptr, pkey.get())));
|
|
1604
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1605
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1606
|
+
approved,
|
|
1607
|
+
EVP_DigestVerify(md_ctx.get(), signature.data(), signature.size(),
|
|
1608
|
+
kPlaintext, sizeof(kPlaintext))));
|
|
1609
|
+
EXPECT_EQ(approved, test.sig_ver_expect_approved);
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
#if defined(AWSLC_FIPS)
|
|
1613
|
+
|
|
1614
|
+
// Test that |EVP_DigestSignFinal| and |EVP_DigestSignVerify| are approved with
|
|
1615
|
+
// manually constructing using the context setting functions.
|
|
1616
|
+
TEST_P(ECDSAServiceIndicatorTest, ManualECDSASignVerify) {
|
|
1617
|
+
const ECDSATestVector &test = GetParam();
|
|
1618
|
+
|
|
1619
|
+
FIPSStatus approved = FIPSStatus::NOT_APPROVED;
|
|
1620
|
+
|
|
1621
|
+
bssl::ScopedEVP_MD_CTX ctx;
|
|
1622
|
+
ASSERT_TRUE(EVP_DigestInit(ctx.get(), test.func()));
|
|
1623
|
+
ASSERT_TRUE(EVP_DigestUpdate(ctx.get(), kPlaintext, sizeof(kPlaintext)));
|
|
1624
|
+
|
|
1625
|
+
bssl::UniquePtr<EC_GROUP> group(EC_GROUP_new_by_curve_name(test.nid));
|
|
1626
|
+
bssl::UniquePtr<EC_KEY> eckey(EC_KEY_new());
|
|
1627
|
+
bssl::UniquePtr<EVP_PKEY> pkey(EVP_PKEY_new());
|
|
1628
|
+
bssl::ScopedEVP_MD_CTX md_ctx;
|
|
1629
|
+
ASSERT_TRUE(eckey);
|
|
1630
|
+
ASSERT_TRUE(EC_KEY_set_group(eckey.get(), group.get()));
|
|
1631
|
+
|
|
1632
|
+
// Generate a generic ec key.
|
|
1633
|
+
EC_KEY_generate_key(eckey.get());
|
|
1634
|
+
ASSERT_TRUE(EVP_PKEY_set1_EC_KEY(pkey.get(), eckey.get()));
|
|
1635
|
+
|
|
1636
|
+
// Manual construction for signing.
|
|
1637
|
+
bssl::UniquePtr<EVP_PKEY_CTX> pctx(EVP_PKEY_CTX_new(pkey.get(), nullptr));
|
|
1638
|
+
ASSERT_TRUE(EVP_PKEY_sign_init(pctx.get()));
|
|
1639
|
+
ASSERT_TRUE(EVP_PKEY_CTX_set_signature_md(pctx.get(), test.func()));
|
|
1640
|
+
EVP_MD_CTX_set_pkey_ctx(ctx.get(), pctx.get());
|
|
1641
|
+
// Determine the size of the signature.
|
|
1642
|
+
size_t sig_len = 0;
|
|
1643
|
+
CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1644
|
+
approved, ASSERT_TRUE(EVP_DigestSignFinal(ctx.get(), nullptr, &sig_len)));
|
|
1645
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1646
|
+
|
|
1647
|
+
std::vector<uint8_t> sig;
|
|
1648
|
+
sig.resize(sig_len);
|
|
1649
|
+
CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1650
|
+
approved,
|
|
1651
|
+
ASSERT_TRUE(EVP_DigestSignFinal(ctx.get(), sig.data(), &sig_len)));
|
|
1652
|
+
EXPECT_EQ(approved, test.sig_gen_expect_approved);
|
|
1653
|
+
sig.resize(sig_len);
|
|
1654
|
+
|
|
1655
|
+
// Manual construction for verification.
|
|
1656
|
+
ASSERT_TRUE(EVP_PKEY_verify_init(pctx.get()));
|
|
1657
|
+
ASSERT_TRUE(EVP_PKEY_CTX_set_signature_md(pctx.get(), test.func()));
|
|
1658
|
+
EVP_MD_CTX_set_pkey_ctx(ctx.get(), pctx.get());
|
|
1659
|
+
|
|
1660
|
+
CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1661
|
+
approved,
|
|
1662
|
+
ASSERT_TRUE(EVP_DigestVerifyFinal(ctx.get(), sig.data(), sig_len)));
|
|
1663
|
+
EXPECT_EQ(approved, test.sig_ver_expect_approved);
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
#endif // AWSLC_FIPS
|
|
1667
|
+
|
|
1668
|
+
struct ECDHTestVector {
|
|
1669
|
+
// nid is the input curve nid.
|
|
1670
|
+
const int nid;
|
|
1671
|
+
// digest_length is the length of the hash output to test with.
|
|
1672
|
+
const int digest_length;
|
|
1673
|
+
// expect_approved to be approved or not.
|
|
1674
|
+
const FIPSStatus expect_approved;
|
|
1675
|
+
};
|
|
1676
|
+
|
|
1677
|
+
static const struct ECDHTestVector kECDHTestVectors[] = {
|
|
1678
|
+
// Only the following NIDs for |EC_GROUP| are creatable with
|
|
1679
|
+
// |EC_GROUP_new_by_curve_name|.
|
|
1680
|
+
// |ECDH_compute_key_fips| fails directly when an invalid hash length is
|
|
1681
|
+
// inputted.
|
|
1682
|
+
{NID_secp224r1, SHA224_DIGEST_LENGTH, FIPSStatus::APPROVED},
|
|
1683
|
+
{NID_secp224r1, SHA256_DIGEST_LENGTH, FIPSStatus::APPROVED},
|
|
1684
|
+
{NID_secp224r1, SHA384_DIGEST_LENGTH, FIPSStatus::APPROVED},
|
|
1685
|
+
{NID_secp224r1, SHA512_DIGEST_LENGTH, FIPSStatus::APPROVED},
|
|
1686
|
+
|
|
1687
|
+
{NID_X9_62_prime256v1, SHA224_DIGEST_LENGTH, FIPSStatus::APPROVED},
|
|
1688
|
+
{NID_X9_62_prime256v1, SHA256_DIGEST_LENGTH, FIPSStatus::APPROVED},
|
|
1689
|
+
{NID_X9_62_prime256v1, SHA384_DIGEST_LENGTH, FIPSStatus::APPROVED},
|
|
1690
|
+
{NID_X9_62_prime256v1, SHA512_DIGEST_LENGTH, FIPSStatus::APPROVED},
|
|
1691
|
+
|
|
1692
|
+
{NID_secp384r1, SHA224_DIGEST_LENGTH, FIPSStatus::APPROVED},
|
|
1693
|
+
{NID_secp384r1, SHA256_DIGEST_LENGTH, FIPSStatus::APPROVED},
|
|
1694
|
+
{NID_secp384r1, SHA384_DIGEST_LENGTH, FIPSStatus::APPROVED},
|
|
1695
|
+
{NID_secp384r1, SHA512_DIGEST_LENGTH, FIPSStatus::APPROVED},
|
|
1696
|
+
|
|
1697
|
+
{NID_secp521r1, SHA224_DIGEST_LENGTH, FIPSStatus::APPROVED},
|
|
1698
|
+
{NID_secp521r1, SHA256_DIGEST_LENGTH, FIPSStatus::APPROVED},
|
|
1699
|
+
{NID_secp521r1, SHA384_DIGEST_LENGTH, FIPSStatus::APPROVED},
|
|
1700
|
+
{NID_secp521r1, SHA512_DIGEST_LENGTH, FIPSStatus::APPROVED},
|
|
1701
|
+
|
|
1702
|
+
{NID_secp256k1, SHA224_DIGEST_LENGTH, FIPSStatus::NOT_APPROVED},
|
|
1703
|
+
{NID_secp256k1, SHA256_DIGEST_LENGTH, FIPSStatus::NOT_APPROVED},
|
|
1704
|
+
{NID_secp256k1, SHA384_DIGEST_LENGTH, FIPSStatus::NOT_APPROVED},
|
|
1705
|
+
{NID_secp256k1, SHA512_DIGEST_LENGTH, FIPSStatus::NOT_APPROVED},
|
|
1706
|
+
};
|
|
1707
|
+
|
|
1708
|
+
class ECDH_ServiceIndicatorTest : public TestWithNoErrors<ECDHTestVector> {};
|
|
1709
|
+
|
|
1710
|
+
INSTANTIATE_TEST_SUITE_P(All, ECDH_ServiceIndicatorTest,
|
|
1711
|
+
testing::ValuesIn(kECDHTestVectors));
|
|
1712
|
+
|
|
1713
|
+
TEST_P(ECDH_ServiceIndicatorTest, ECDH) {
|
|
1714
|
+
const ECDHTestVector &test = GetParam();
|
|
1715
|
+
if (test.nid == NID_secp256k1 && !kCurveSecp256k1Supported) {
|
|
1716
|
+
GTEST_SKIP();
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1719
|
+
FIPSStatus approved = FIPSStatus::NOT_APPROVED;
|
|
1720
|
+
|
|
1721
|
+
bssl::UniquePtr<EC_GROUP> group(EC_GROUP_new_by_curve_name(test.nid));
|
|
1722
|
+
bssl::UniquePtr<EC_KEY> our_key(EC_KEY_new());
|
|
1723
|
+
bssl::UniquePtr<EC_KEY> peer_key(EC_KEY_new());
|
|
1724
|
+
bssl::ScopedEVP_MD_CTX md_ctx;
|
|
1725
|
+
ASSERT_TRUE(our_key);
|
|
1726
|
+
ASSERT_TRUE(peer_key);
|
|
1727
|
+
|
|
1728
|
+
// Generate two generic ec key pairs.
|
|
1729
|
+
ASSERT_TRUE(EC_KEY_set_group(our_key.get(), group.get()));
|
|
1730
|
+
ASSERT_TRUE(EC_KEY_generate_key(our_key.get()));
|
|
1731
|
+
ASSERT_TRUE(EC_KEY_check_key(our_key.get()));
|
|
1732
|
+
|
|
1733
|
+
ASSERT_TRUE(EC_KEY_set_group(peer_key.get(), group.get()));
|
|
1734
|
+
ASSERT_TRUE(EC_KEY_generate_key(peer_key.get()));
|
|
1735
|
+
ASSERT_TRUE(EC_KEY_check_key(peer_key.get()));
|
|
1736
|
+
|
|
1737
|
+
// Test that |ECDH_compute_key_fips| has service indicator approval as
|
|
1738
|
+
// expected.
|
|
1739
|
+
std::vector<uint8_t> digest(test.digest_length);
|
|
1740
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1741
|
+
approved, ECDH_compute_key_fips(digest.data(), digest.size(),
|
|
1742
|
+
EC_KEY_get0_public_key(peer_key.get()),
|
|
1743
|
+
our_key.get())));
|
|
1744
|
+
EXPECT_EQ(approved, test.expect_approved);
|
|
1745
|
+
|
|
1746
|
+
// Test running the EVP_PKEY_derive interfaces one by one directly, and check
|
|
1747
|
+
// |EVP_PKEY_derive| for approval at the end. |EVP_PKEY_derive_init| and
|
|
1748
|
+
// |EVP_PKEY_derive_set_peer| should not be approved because they do not
|
|
1749
|
+
// indicate an entire service has been done.
|
|
1750
|
+
bssl::UniquePtr<EVP_PKEY> our_pkey(EVP_PKEY_new());
|
|
1751
|
+
ASSERT_TRUE(EVP_PKEY_set1_EC_KEY(our_pkey.get(), our_key.get()));
|
|
1752
|
+
bssl::UniquePtr<EVP_PKEY_CTX> our_ctx(
|
|
1753
|
+
EVP_PKEY_CTX_new(our_pkey.get(), nullptr));
|
|
1754
|
+
bssl::UniquePtr<EVP_PKEY> peer_pkey(EVP_PKEY_new());
|
|
1755
|
+
ASSERT_TRUE(EVP_PKEY_set1_EC_KEY(peer_pkey.get(), peer_key.get()));
|
|
1756
|
+
|
|
1757
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1758
|
+
approved, EVP_PKEY_derive_init(our_ctx.get())));
|
|
1759
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1760
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1761
|
+
approved, EVP_PKEY_derive_set_peer(our_ctx.get(), peer_pkey.get())));
|
|
1762
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1763
|
+
// Determine the size of the output key. The first call of |EVP_PKEY_derive|
|
|
1764
|
+
// should not return an approval check because no crypto is being done when
|
|
1765
|
+
// |nullptr| is inputted in the |*key| field
|
|
1766
|
+
size_t out_len = 0;
|
|
1767
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1768
|
+
approved, EVP_PKEY_derive(our_ctx.get(), nullptr, &out_len)));
|
|
1769
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1770
|
+
std::vector<uint8_t> derive_output(out_len);
|
|
1771
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1772
|
+
approved,
|
|
1773
|
+
EVP_PKEY_derive(our_ctx.get(), derive_output.data(), &out_len)));
|
|
1774
|
+
EXPECT_EQ(approved, kEVPDeriveSetsServiceIndicator
|
|
1775
|
+
? test.expect_approved
|
|
1776
|
+
: FIPSStatus::NOT_APPROVED);
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
static const struct KDFTestVector {
|
|
1780
|
+
// func is the hash function for KDF to test.
|
|
1781
|
+
const EVP_MD *(*func)();
|
|
1782
|
+
const uint8_t *expected_output;
|
|
1783
|
+
const FIPSStatus expect_approved;
|
|
1784
|
+
} kKDFTestVectors[] = {
|
|
1785
|
+
{EVP_md5, kTLSOutput_md, FIPSStatus::APPROVED},
|
|
1786
|
+
{EVP_sha1, kTLSOutput_sha1, FIPSStatus::APPROVED},
|
|
1787
|
+
{EVP_md5_sha1, kTLSOutput_mdsha1, FIPSStatus::APPROVED},
|
|
1788
|
+
{EVP_sha224, kTLSOutput_sha224, FIPSStatus::NOT_APPROVED},
|
|
1789
|
+
{EVP_sha256, kTLSOutput_sha256, FIPSStatus::APPROVED},
|
|
1790
|
+
{EVP_sha384, kTLSOutput_sha384, FIPSStatus::APPROVED},
|
|
1791
|
+
{EVP_sha512, kTLSOutput_sha512, FIPSStatus::APPROVED},
|
|
1792
|
+
};
|
|
1793
|
+
|
|
1794
|
+
class KDF_ServiceIndicatorTest : public TestWithNoErrors<KDFTestVector> {};
|
|
1795
|
+
|
|
1796
|
+
INSTANTIATE_TEST_SUITE_P(All, KDF_ServiceIndicatorTest,
|
|
1797
|
+
testing::ValuesIn(kKDFTestVectors));
|
|
1798
|
+
|
|
1799
|
+
TEST_P(KDF_ServiceIndicatorTest, TLSKDF) {
|
|
1800
|
+
const KDFTestVector &test = GetParam();
|
|
1801
|
+
|
|
1802
|
+
FIPSStatus approved = FIPSStatus::NOT_APPROVED;
|
|
1803
|
+
|
|
1804
|
+
uint8_t output[32];
|
|
1805
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1806
|
+
approved, CRYPTO_tls1_prf(test.func(), output, sizeof(output), kTLSSecret,
|
|
1807
|
+
sizeof(kTLSSecret), kTLSLabel,
|
|
1808
|
+
sizeof(kTLSLabel), kTLSSeed1, sizeof(kTLSSeed1),
|
|
1809
|
+
kTLSSeed2, sizeof(kTLSSeed2))));
|
|
1810
|
+
EXPECT_EQ(Bytes(test.expected_output, sizeof(output)),
|
|
1811
|
+
Bytes(output, sizeof(output)));
|
|
1812
|
+
EXPECT_EQ(approved, test.expect_approved);
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
TEST(ServiceIndicatorTest, CMAC) {
|
|
1816
|
+
FIPSStatus approved = FIPSStatus::NOT_APPROVED;
|
|
1817
|
+
|
|
1818
|
+
bssl::UniquePtr<CMAC_CTX> ctx(CMAC_CTX_new());
|
|
1819
|
+
ASSERT_TRUE(ctx);
|
|
1820
|
+
|
|
1821
|
+
// Test running the CMAC interfaces one by one directly, and check
|
|
1822
|
+
// |CMAC_Final| for approval at the end. |CMAC_Init| and |CMAC_Update|
|
|
1823
|
+
// should not be approved, because the functions do not indicate that a
|
|
1824
|
+
// service has been fully completed yet.
|
|
1825
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1826
|
+
approved, CMAC_Init(ctx.get(), kAESKey, sizeof(kAESKey),
|
|
1827
|
+
EVP_aes_128_cbc(), nullptr)));
|
|
1828
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1829
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1830
|
+
approved, CMAC_Update(ctx.get(), kPlaintext, sizeof(kPlaintext))));
|
|
1831
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1832
|
+
|
|
1833
|
+
uint8_t mac[16];
|
|
1834
|
+
size_t out_len;
|
|
1835
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1836
|
+
approved, CMAC_Final(ctx.get(), mac, &out_len)));
|
|
1837
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
1838
|
+
EXPECT_EQ(Bytes(kAESCMACOutput), Bytes(mac));
|
|
1839
|
+
|
|
1840
|
+
// Test using the one-shot API for approval.
|
|
1841
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1842
|
+
approved,
|
|
1843
|
+
AES_CMAC(mac, kAESKey, sizeof(kAESKey), kPlaintext, sizeof(kPlaintext))));
|
|
1844
|
+
EXPECT_EQ(Bytes(kAESCMACOutput), Bytes(mac));
|
|
1845
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1848
|
+
TEST(ServiceIndicatorTest, BasicTest) {
|
|
1849
|
+
FIPSStatus approved = FIPSStatus::NOT_APPROVED;
|
|
1850
|
+
|
|
1851
|
+
bssl::ScopedEVP_AEAD_CTX aead_ctx;
|
|
1852
|
+
ASSERT_TRUE(EVP_AEAD_CTX_init(aead_ctx.get(),
|
|
1853
|
+
EVP_aead_aes_128_gcm_randnonce(), kAESKey,
|
|
1854
|
+
sizeof(kAESKey), 0, nullptr));
|
|
1855
|
+
// This test ensures that the counter gets incremented once, i.e. it was
|
|
1856
|
+
// locked through the internal calls.
|
|
1857
|
+
const int counter_before = FIPS_service_indicator_after_call();
|
|
1858
|
+
size_t out_len;
|
|
1859
|
+
uint8_t output[256];
|
|
1860
|
+
EVP_AEAD_CTX_seal(aead_ctx.get(), output, &out_len, sizeof(output), nullptr,
|
|
1861
|
+
0, kPlaintext, sizeof(kPlaintext), nullptr, 0);
|
|
1862
|
+
const int counter_after = FIPS_service_indicator_after_call();
|
|
1863
|
+
EXPECT_EQ(counter_after, counter_before + 1);
|
|
1864
|
+
|
|
1865
|
+
// Call an approved service.
|
|
1866
|
+
CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1867
|
+
approved, EVP_AEAD_CTX_seal(aead_ctx.get(), output, &out_len,
|
|
1868
|
+
sizeof(output), nullptr, 0, kPlaintext,
|
|
1869
|
+
sizeof(kPlaintext), nullptr, 0));
|
|
1870
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
1871
|
+
|
|
1872
|
+
// Fail an approved service on purpose.
|
|
1873
|
+
ASSERT_FALSE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1874
|
+
approved,
|
|
1875
|
+
EVP_AEAD_CTX_seal(aead_ctx.get(), output, &out_len, 0, nullptr, 0,
|
|
1876
|
+
kPlaintext, sizeof(kPlaintext), nullptr, 0)));
|
|
1877
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1878
|
+
|
|
1879
|
+
// Call a non-approved service.
|
|
1880
|
+
uint8_t aes_iv[sizeof(kAESIV)];
|
|
1881
|
+
memcpy(aes_iv, kAESIV, sizeof(aes_iv));
|
|
1882
|
+
AES_KEY aes_key;
|
|
1883
|
+
ASSERT_TRUE(AES_set_encrypt_key(kAESKey, 8 * sizeof(kAESKey), &aes_key) == 0);
|
|
1884
|
+
int num = 0;
|
|
1885
|
+
CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1886
|
+
approved, AES_ofb128_encrypt(kPlaintext, output, sizeof(kPlaintext),
|
|
1887
|
+
&aes_key, aes_iv, &num));
|
|
1888
|
+
EXPECT_EQ(Bytes(kAESOFBCiphertext), Bytes(output, sizeof(kAESOFBCiphertext)));
|
|
1889
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1892
|
+
// Test the SHA interfaces one by one and check that only |*_Final| does the
|
|
1893
|
+
// approval at the end.
|
|
1894
|
+
TEST(ServiceIndicatorTest, SHA) {
|
|
1895
|
+
FIPSStatus approved = FIPSStatus::NOT_APPROVED;
|
|
1896
|
+
|
|
1897
|
+
std::vector<uint8_t> digest;
|
|
1898
|
+
|
|
1899
|
+
digest.resize(MD4_DIGEST_LENGTH);
|
|
1900
|
+
MD4_CTX md4_ctx;
|
|
1901
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(approved, MD4_Init(&md4_ctx)));
|
|
1902
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1903
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1904
|
+
approved, MD4_Update(&md4_ctx, kPlaintext, sizeof(kPlaintext))));
|
|
1905
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1906
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1907
|
+
approved, MD4_Final(digest.data(), &md4_ctx)));
|
|
1908
|
+
EXPECT_EQ(Bytes(kOutput_md4), Bytes(digest));
|
|
1909
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1910
|
+
|
|
1911
|
+
digest.resize(MD5_DIGEST_LENGTH);
|
|
1912
|
+
MD5_CTX md5_ctx;
|
|
1913
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(approved, MD5_Init(&md5_ctx)));
|
|
1914
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1915
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1916
|
+
approved, MD5_Update(&md5_ctx, kPlaintext, sizeof(kPlaintext))));
|
|
1917
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1918
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1919
|
+
approved, MD5_Final(digest.data(), &md5_ctx)));
|
|
1920
|
+
EXPECT_EQ(Bytes(kOutput_md5), Bytes(digest));
|
|
1921
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1922
|
+
|
|
1923
|
+
digest.resize(SHA_DIGEST_LENGTH);
|
|
1924
|
+
SHA_CTX sha_ctx;
|
|
1925
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(approved, SHA1_Init(&sha_ctx)));
|
|
1926
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1927
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1928
|
+
approved, SHA1_Update(&sha_ctx, kPlaintext, sizeof(kPlaintext))));
|
|
1929
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1930
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1931
|
+
approved, SHA1_Final(digest.data(), &sha_ctx)));
|
|
1932
|
+
EXPECT_EQ(Bytes(kOutput_sha1), Bytes(digest));
|
|
1933
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
1934
|
+
|
|
1935
|
+
digest.resize(SHA224_DIGEST_LENGTH);
|
|
1936
|
+
SHA256_CTX sha224_ctx;
|
|
1937
|
+
ASSERT_TRUE(
|
|
1938
|
+
CALL_SERVICE_AND_CHECK_APPROVED(approved, SHA224_Init(&sha224_ctx)));
|
|
1939
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1940
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1941
|
+
approved, SHA224_Update(&sha224_ctx, kPlaintext, sizeof(kPlaintext))));
|
|
1942
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1943
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1944
|
+
approved, SHA224_Final(digest.data(), &sha224_ctx)));
|
|
1945
|
+
EXPECT_EQ(Bytes(kOutput_sha224), Bytes(digest));
|
|
1946
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
1947
|
+
|
|
1948
|
+
digest.resize(SHA256_DIGEST_LENGTH);
|
|
1949
|
+
SHA256_CTX sha256_ctx;
|
|
1950
|
+
ASSERT_TRUE(
|
|
1951
|
+
CALL_SERVICE_AND_CHECK_APPROVED(approved, SHA256_Init(&sha256_ctx)));
|
|
1952
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1953
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1954
|
+
approved, SHA256_Update(&sha256_ctx, kPlaintext, sizeof(kPlaintext))));
|
|
1955
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1956
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1957
|
+
approved, SHA256_Final(digest.data(), &sha256_ctx)));
|
|
1958
|
+
EXPECT_EQ(Bytes(kOutput_sha256), Bytes(digest));
|
|
1959
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
1960
|
+
|
|
1961
|
+
digest.resize(SHA384_DIGEST_LENGTH);
|
|
1962
|
+
SHA512_CTX sha384_ctx;
|
|
1963
|
+
ASSERT_TRUE(
|
|
1964
|
+
CALL_SERVICE_AND_CHECK_APPROVED(approved, SHA384_Init(&sha384_ctx)));
|
|
1965
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1966
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1967
|
+
approved, SHA384_Update(&sha384_ctx, kPlaintext, sizeof(kPlaintext))));
|
|
1968
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1969
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1970
|
+
approved, SHA384_Final(digest.data(), &sha384_ctx)));
|
|
1971
|
+
EXPECT_EQ(Bytes(kOutput_sha384), Bytes(digest));
|
|
1972
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
1973
|
+
|
|
1974
|
+
digest.resize(SHA512_DIGEST_LENGTH);
|
|
1975
|
+
SHA512_CTX sha512_ctx;
|
|
1976
|
+
ASSERT_TRUE(
|
|
1977
|
+
CALL_SERVICE_AND_CHECK_APPROVED(approved, SHA512_Init(&sha512_ctx)));
|
|
1978
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1979
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1980
|
+
approved, SHA512_Update(&sha512_ctx, kPlaintext, sizeof(kPlaintext))));
|
|
1981
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1982
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1983
|
+
approved, SHA512_Final(digest.data(), &sha512_ctx)));
|
|
1984
|
+
EXPECT_EQ(Bytes(kOutput_sha512), Bytes(digest));
|
|
1985
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
1986
|
+
|
|
1987
|
+
digest.resize(SHA512_256_DIGEST_LENGTH);
|
|
1988
|
+
SHA512_CTX sha512_256_ctx;
|
|
1989
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1990
|
+
approved, SHA512_256_Init(&sha512_256_ctx)));
|
|
1991
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1992
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1993
|
+
approved,
|
|
1994
|
+
SHA512_256_Update(&sha512_256_ctx, kPlaintext, sizeof(kPlaintext))));
|
|
1995
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
1996
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
1997
|
+
approved, SHA512_256_Final(digest.data(), &sha512_256_ctx)));
|
|
1998
|
+
EXPECT_EQ(Bytes(kOutput_sha512_256), Bytes(digest));
|
|
1999
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
TEST(ServiceIndicatorTest, AESECB) {
|
|
2003
|
+
FIPSStatus approved = FIPSStatus::NOT_APPROVED;
|
|
2004
|
+
|
|
2005
|
+
AES_KEY aes_key;
|
|
2006
|
+
uint8_t output[256];
|
|
2007
|
+
|
|
2008
|
+
// AES-ECB Encryption KAT for 128 bit key.
|
|
2009
|
+
ASSERT_TRUE(AES_set_encrypt_key(kAESKey, 8 * sizeof(kAESKey), &aes_key) == 0);
|
|
2010
|
+
// AES_ecb_encrypt encrypts (or decrypts) a single, 16 byte block from in to
|
|
2011
|
+
// out.
|
|
2012
|
+
for (size_t i = 0; i < sizeof(kPlaintext) / AES_BLOCK_SIZE; i++) {
|
|
2013
|
+
CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2014
|
+
approved,
|
|
2015
|
+
AES_ecb_encrypt(&kPlaintext[i * AES_BLOCK_SIZE],
|
|
2016
|
+
&output[i * AES_BLOCK_SIZE], &aes_key, AES_ENCRYPT));
|
|
2017
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
2018
|
+
}
|
|
2019
|
+
EXPECT_EQ(Bytes(kAESECBCiphertext), Bytes(output, sizeof(kAESECBCiphertext)));
|
|
2020
|
+
|
|
2021
|
+
// AES-ECB Decryption KAT for 128 bit key.
|
|
2022
|
+
ASSERT_TRUE(AES_set_decrypt_key(kAESKey, 8 * sizeof(kAESKey), &aes_key) == 0);
|
|
2023
|
+
for (size_t i = 0; i < sizeof(kPlaintext) / AES_BLOCK_SIZE; i++) {
|
|
2024
|
+
CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2025
|
+
approved,
|
|
2026
|
+
AES_ecb_encrypt(&kAESECBCiphertext[i * AES_BLOCK_SIZE],
|
|
2027
|
+
&output[i * AES_BLOCK_SIZE], &aes_key, AES_DECRYPT));
|
|
2028
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
2029
|
+
}
|
|
2030
|
+
EXPECT_EQ(Bytes(kPlaintext), Bytes(output, sizeof(kPlaintext)));
|
|
2031
|
+
|
|
2032
|
+
// AES-ECB Encryption KAT for 192 bit key.
|
|
2033
|
+
ASSERT_TRUE(
|
|
2034
|
+
AES_set_encrypt_key(kAESKey_192, 8 * sizeof(kAESKey_192), &aes_key) == 0);
|
|
2035
|
+
for (size_t i = 0; i < sizeof(kPlaintext) / AES_BLOCK_SIZE; i++) {
|
|
2036
|
+
CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2037
|
+
approved,
|
|
2038
|
+
AES_ecb_encrypt(&kPlaintext[i * AES_BLOCK_SIZE],
|
|
2039
|
+
&output[i * AES_BLOCK_SIZE], &aes_key, AES_ENCRYPT));
|
|
2040
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
2041
|
+
}
|
|
2042
|
+
EXPECT_EQ(Bytes(kAESECBCiphertext_192),
|
|
2043
|
+
Bytes(output, sizeof(kAESECBCiphertext_192)));
|
|
2044
|
+
|
|
2045
|
+
// AES-ECB Decryption KAT for 192 bit key.
|
|
2046
|
+
ASSERT_TRUE(
|
|
2047
|
+
AES_set_decrypt_key(kAESKey_192, 8 * sizeof(kAESKey_192), &aes_key) == 0);
|
|
2048
|
+
for (size_t i = 0; i < sizeof(kPlaintext) / AES_BLOCK_SIZE; i++) {
|
|
2049
|
+
CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2050
|
+
approved,
|
|
2051
|
+
AES_ecb_encrypt(&kAESECBCiphertext_192[i * AES_BLOCK_SIZE],
|
|
2052
|
+
&output[i * AES_BLOCK_SIZE], &aes_key, AES_DECRYPT));
|
|
2053
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
2054
|
+
}
|
|
2055
|
+
EXPECT_EQ(Bytes(kPlaintext), Bytes(output, sizeof(kPlaintext)));
|
|
2056
|
+
|
|
2057
|
+
// AES-ECB Encryption KAT for 256 bit key.
|
|
2058
|
+
ASSERT_TRUE(
|
|
2059
|
+
AES_set_encrypt_key(kAESKey_256, 8 * sizeof(kAESKey_256), &aes_key) == 0);
|
|
2060
|
+
for (size_t i = 0; i < sizeof(kPlaintext) / AES_BLOCK_SIZE; i++) {
|
|
2061
|
+
CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2062
|
+
approved,
|
|
2063
|
+
AES_ecb_encrypt(&kPlaintext[i * AES_BLOCK_SIZE],
|
|
2064
|
+
&output[i * AES_BLOCK_SIZE], &aes_key, AES_ENCRYPT));
|
|
2065
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
2066
|
+
}
|
|
2067
|
+
EXPECT_EQ(Bytes(kAESECBCiphertext_256),
|
|
2068
|
+
Bytes(output, sizeof(kAESECBCiphertext_256)));
|
|
2069
|
+
|
|
2070
|
+
// AES-ECB Decryption KAT for 256 bit key.
|
|
2071
|
+
ASSERT_TRUE(
|
|
2072
|
+
AES_set_decrypt_key(kAESKey_256, 8 * sizeof(kAESKey_256), &aes_key) == 0);
|
|
2073
|
+
for (size_t i = 0; i < sizeof(kPlaintext) / AES_BLOCK_SIZE; i++) {
|
|
2074
|
+
CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2075
|
+
approved,
|
|
2076
|
+
AES_ecb_encrypt(&kAESECBCiphertext_256[i * AES_BLOCK_SIZE],
|
|
2077
|
+
&output[i * AES_BLOCK_SIZE], &aes_key, AES_DECRYPT));
|
|
2078
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
2079
|
+
}
|
|
2080
|
+
EXPECT_EQ(Bytes(kPlaintext), Bytes(output, sizeof(kPlaintext)));
|
|
2081
|
+
}
|
|
2082
|
+
|
|
2083
|
+
TEST(ServiceIndicatorTest, AESCBC) {
|
|
2084
|
+
FIPSStatus approved = FIPSStatus::NOT_APPROVED;
|
|
2085
|
+
|
|
2086
|
+
AES_KEY aes_key;
|
|
2087
|
+
uint8_t aes_iv[sizeof(kAESIV)];
|
|
2088
|
+
uint8_t output[sizeof(kPlaintext)];
|
|
2089
|
+
|
|
2090
|
+
// AES-CBC Encryption KAT for 128 bit key.
|
|
2091
|
+
memcpy(aes_iv, kAESIV, sizeof(aes_iv));
|
|
2092
|
+
ASSERT_TRUE(AES_set_encrypt_key(kAESKey, 8 * sizeof(kAESKey), &aes_key) == 0);
|
|
2093
|
+
CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2094
|
+
approved, AES_cbc_encrypt(kPlaintext, output, sizeof(kPlaintext),
|
|
2095
|
+
&aes_key, aes_iv, AES_ENCRYPT));
|
|
2096
|
+
EXPECT_EQ(Bytes(kAESCBCCiphertext), Bytes(output));
|
|
2097
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
2098
|
+
|
|
2099
|
+
// AES-CBC Decryption KAT for 128 bit key.
|
|
2100
|
+
memcpy(aes_iv, kAESIV, sizeof(aes_iv));
|
|
2101
|
+
ASSERT_TRUE(AES_set_decrypt_key(kAESKey, 8 * sizeof(kAESKey), &aes_key) == 0);
|
|
2102
|
+
CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2103
|
+
approved,
|
|
2104
|
+
AES_cbc_encrypt(kAESCBCCiphertext, output, sizeof(kAESCBCCiphertext),
|
|
2105
|
+
&aes_key, aes_iv, AES_DECRYPT));
|
|
2106
|
+
EXPECT_EQ(Bytes(kPlaintext), Bytes(output));
|
|
2107
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
2108
|
+
|
|
2109
|
+
// AES-CBC Encryption KAT for 192 bit key.
|
|
2110
|
+
memcpy(aes_iv, kAESIV, sizeof(aes_iv));
|
|
2111
|
+
ASSERT_TRUE(
|
|
2112
|
+
AES_set_encrypt_key(kAESKey_192, 8 * sizeof(kAESKey_192), &aes_key) == 0);
|
|
2113
|
+
CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2114
|
+
approved, AES_cbc_encrypt(kPlaintext, output, sizeof(kPlaintext),
|
|
2115
|
+
&aes_key, aes_iv, AES_ENCRYPT));
|
|
2116
|
+
EXPECT_EQ(Bytes(kAESCBCCiphertext_192), Bytes(output));
|
|
2117
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
2118
|
+
|
|
2119
|
+
// AES-CBC Decryption KAT for 192 bit key.
|
|
2120
|
+
memcpy(aes_iv, kAESIV, sizeof(aes_iv));
|
|
2121
|
+
ASSERT_TRUE(
|
|
2122
|
+
AES_set_decrypt_key(kAESKey_192, 8 * sizeof(kAESKey_192), &aes_key) == 0);
|
|
2123
|
+
CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2124
|
+
approved, AES_cbc_encrypt(kAESCBCCiphertext_192, output,
|
|
2125
|
+
sizeof(kAESCBCCiphertext_192), &aes_key, aes_iv,
|
|
2126
|
+
AES_DECRYPT));
|
|
2127
|
+
EXPECT_EQ(Bytes(kPlaintext), Bytes(output));
|
|
2128
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
2129
|
+
|
|
2130
|
+
// AES-CBC Encryption KAT for 256 bit key.
|
|
2131
|
+
memcpy(aes_iv, kAESIV, sizeof(aes_iv));
|
|
2132
|
+
ASSERT_TRUE(
|
|
2133
|
+
AES_set_encrypt_key(kAESKey_256, 8 * sizeof(kAESKey_256), &aes_key) == 0);
|
|
2134
|
+
CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2135
|
+
approved, AES_cbc_encrypt(kPlaintext, output, sizeof(kPlaintext),
|
|
2136
|
+
&aes_key, aes_iv, AES_ENCRYPT));
|
|
2137
|
+
EXPECT_EQ(Bytes(kAESCBCCiphertext_256), Bytes(output));
|
|
2138
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
2139
|
+
|
|
2140
|
+
// AES-CBC Decryption KAT for 256 bit key.
|
|
2141
|
+
memcpy(aes_iv, kAESIV, sizeof(aes_iv));
|
|
2142
|
+
ASSERT_TRUE(
|
|
2143
|
+
AES_set_decrypt_key(kAESKey_256, 8 * sizeof(kAESKey_256), &aes_key) == 0);
|
|
2144
|
+
CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2145
|
+
approved, AES_cbc_encrypt(kAESCBCCiphertext_256, output,
|
|
2146
|
+
sizeof(kAESCBCCiphertext_256), &aes_key, aes_iv,
|
|
2147
|
+
AES_DECRYPT));
|
|
2148
|
+
EXPECT_EQ(Bytes(kPlaintext), Bytes(output));
|
|
2149
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2152
|
+
TEST(ServiceIndicatorTest, AESCTR) {
|
|
2153
|
+
FIPSStatus approved = FIPSStatus::NOT_APPROVED;
|
|
2154
|
+
|
|
2155
|
+
AES_KEY aes_key;
|
|
2156
|
+
uint8_t aes_iv[sizeof(kAESIV)];
|
|
2157
|
+
uint8_t output[sizeof(kPlaintext)];
|
|
2158
|
+
unsigned num = 0;
|
|
2159
|
+
uint8_t ecount_buf[AES_BLOCK_SIZE];
|
|
2160
|
+
|
|
2161
|
+
// AES-CTR Encryption KAT
|
|
2162
|
+
memcpy(aes_iv, kAESIV, sizeof(aes_iv));
|
|
2163
|
+
ASSERT_TRUE(AES_set_encrypt_key(kAESKey, 8 * sizeof(kAESKey), &aes_key) == 0);
|
|
2164
|
+
CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2165
|
+
approved, AES_ctr128_encrypt(kPlaintext, output, sizeof(kPlaintext),
|
|
2166
|
+
&aes_key, aes_iv, ecount_buf, &num));
|
|
2167
|
+
EXPECT_EQ(Bytes(kAESCTRCiphertext), Bytes(output));
|
|
2168
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
2169
|
+
|
|
2170
|
+
// AES-CTR Decryption KAT
|
|
2171
|
+
memcpy(aes_iv, kAESIV, sizeof(aes_iv));
|
|
2172
|
+
CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2173
|
+
approved,
|
|
2174
|
+
AES_ctr128_encrypt(kAESCTRCiphertext, output, sizeof(kAESCTRCiphertext),
|
|
2175
|
+
&aes_key, aes_iv, ecount_buf, &num));
|
|
2176
|
+
EXPECT_EQ(Bytes(kPlaintext), Bytes(output));
|
|
2177
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
2178
|
+
|
|
2179
|
+
// AES-CTR Encryption KAT for 192 bit key.
|
|
2180
|
+
memcpy(aes_iv, kAESIV, sizeof(aes_iv));
|
|
2181
|
+
ASSERT_TRUE(
|
|
2182
|
+
AES_set_encrypt_key(kAESKey_192, 8 * sizeof(kAESKey_192), &aes_key) == 0);
|
|
2183
|
+
CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2184
|
+
approved, AES_ctr128_encrypt(kPlaintext, output, sizeof(kPlaintext),
|
|
2185
|
+
&aes_key, aes_iv, ecount_buf, &num));
|
|
2186
|
+
EXPECT_EQ(Bytes(kAESCTRCiphertext_192), Bytes(output));
|
|
2187
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
2188
|
+
|
|
2189
|
+
// AES-CTR Decryption KAT for 192 bit key.
|
|
2190
|
+
memcpy(aes_iv, kAESIV, sizeof(aes_iv));
|
|
2191
|
+
CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2192
|
+
approved, AES_ctr128_encrypt(kAESCTRCiphertext_192, output,
|
|
2193
|
+
sizeof(kAESCTRCiphertext_192), &aes_key,
|
|
2194
|
+
aes_iv, ecount_buf, &num));
|
|
2195
|
+
EXPECT_EQ(Bytes(kPlaintext), Bytes(output));
|
|
2196
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
2197
|
+
|
|
2198
|
+
// AES-CTR Encryption KAT for 256 bit key.
|
|
2199
|
+
memcpy(aes_iv, kAESIV, sizeof(aes_iv));
|
|
2200
|
+
ASSERT_TRUE(
|
|
2201
|
+
AES_set_encrypt_key(kAESKey_256, 8 * sizeof(kAESKey_256), &aes_key) == 0);
|
|
2202
|
+
CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2203
|
+
approved, AES_ctr128_encrypt(kPlaintext, output, sizeof(kPlaintext),
|
|
2204
|
+
&aes_key, aes_iv, ecount_buf, &num));
|
|
2205
|
+
EXPECT_EQ(Bytes(kAESCTRCiphertext_256), Bytes(output));
|
|
2206
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
2207
|
+
|
|
2208
|
+
// AES-CTR Decryption KAT for 256 bit key.
|
|
2209
|
+
memcpy(aes_iv, kAESIV, sizeof(aes_iv));
|
|
2210
|
+
CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2211
|
+
approved, AES_ctr128_encrypt(kAESCTRCiphertext_256, output,
|
|
2212
|
+
sizeof(kAESCTRCiphertext_256), &aes_key,
|
|
2213
|
+
aes_iv, ecount_buf, &num));
|
|
2214
|
+
EXPECT_EQ(Bytes(kPlaintext), Bytes(output));
|
|
2215
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
2216
|
+
}
|
|
2217
|
+
|
|
2218
|
+
TEST(ServiceIndicatorTest, AESOFB) {
|
|
2219
|
+
FIPSStatus approved = FIPSStatus::NOT_APPROVED;
|
|
2220
|
+
|
|
2221
|
+
AES_KEY aes_key;
|
|
2222
|
+
uint8_t aes_iv[sizeof(kAESIV)];
|
|
2223
|
+
uint8_t output[sizeof(kPlaintext)];
|
|
2224
|
+
int num = 0;
|
|
2225
|
+
|
|
2226
|
+
// AES-OFB Encryption KAT
|
|
2227
|
+
memcpy(aes_iv, kAESIV, sizeof(aes_iv));
|
|
2228
|
+
ASSERT_TRUE(AES_set_encrypt_key(kAESKey, 8 * sizeof(kAESKey), &aes_key) == 0);
|
|
2229
|
+
CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2230
|
+
approved, AES_ofb128_encrypt(kPlaintext, output, sizeof(kPlaintext),
|
|
2231
|
+
&aes_key, aes_iv, &num));
|
|
2232
|
+
EXPECT_EQ(Bytes(kAESOFBCiphertext), Bytes(output));
|
|
2233
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
2234
|
+
|
|
2235
|
+
// AES-OFB Decryption KAT
|
|
2236
|
+
memcpy(aes_iv, kAESIV, sizeof(aes_iv));
|
|
2237
|
+
CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2238
|
+
approved,
|
|
2239
|
+
AES_ofb128_encrypt(kAESOFBCiphertext, output, sizeof(kAESOFBCiphertext),
|
|
2240
|
+
&aes_key, aes_iv, &num));
|
|
2241
|
+
EXPECT_EQ(Bytes(kPlaintext), Bytes(output));
|
|
2242
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
2243
|
+
}
|
|
2244
|
+
|
|
2245
|
+
TEST(ServiceIndicatorTest, AESCFB) {
|
|
2246
|
+
FIPSStatus approved = FIPSStatus::NOT_APPROVED;
|
|
2247
|
+
|
|
2248
|
+
AES_KEY aes_key;
|
|
2249
|
+
uint8_t aes_iv[sizeof(kAESIV)];
|
|
2250
|
+
uint8_t output[sizeof(kPlaintext)];
|
|
2251
|
+
int num = 0;
|
|
2252
|
+
|
|
2253
|
+
// AES-CFB Encryption KAT
|
|
2254
|
+
memcpy(aes_iv, kAESIV, sizeof(aes_iv));
|
|
2255
|
+
ASSERT_TRUE(AES_set_encrypt_key(kAESKey, 8 * sizeof(kAESKey), &aes_key) == 0);
|
|
2256
|
+
CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2257
|
+
approved, AES_cfb128_encrypt(kPlaintext, output, sizeof(kPlaintext),
|
|
2258
|
+
&aes_key, aes_iv, &num, AES_ENCRYPT));
|
|
2259
|
+
EXPECT_EQ(Bytes(kAESCFBCiphertext), Bytes(output));
|
|
2260
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
2261
|
+
|
|
2262
|
+
// AES-CFB Decryption KAT
|
|
2263
|
+
memcpy(aes_iv, kAESIV, sizeof(aes_iv));
|
|
2264
|
+
CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2265
|
+
approved,
|
|
2266
|
+
AES_cfb128_encrypt(kAESCFBCiphertext, output, sizeof(kAESCFBCiphertext),
|
|
2267
|
+
&aes_key, aes_iv, &num, AES_DECRYPT));
|
|
2268
|
+
EXPECT_EQ(Bytes(kPlaintext), Bytes(output));
|
|
2269
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
2270
|
+
}
|
|
2271
|
+
|
|
2272
|
+
TEST(ServiceIndicatorTest, AESKW) {
|
|
2273
|
+
FIPSStatus approved = FIPSStatus::NOT_APPROVED;
|
|
2274
|
+
|
|
2275
|
+
AES_KEY aes_key;
|
|
2276
|
+
uint8_t output[sizeof(kPlaintext) + 8];
|
|
2277
|
+
size_t outlen;
|
|
2278
|
+
|
|
2279
|
+
// AES-KW Encryption KAT
|
|
2280
|
+
ASSERT_TRUE(AES_set_encrypt_key(kAESKey, 8 * sizeof(kAESKey), &aes_key) == 0);
|
|
2281
|
+
outlen = CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2282
|
+
approved,
|
|
2283
|
+
AES_wrap_key(&aes_key, nullptr, output, kPlaintext, sizeof(kPlaintext)));
|
|
2284
|
+
ASSERT_EQ(outlen, sizeof(kAESKWCiphertext));
|
|
2285
|
+
EXPECT_EQ(Bytes(kAESKWCiphertext), Bytes(output));
|
|
2286
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
2287
|
+
|
|
2288
|
+
// AES-KW Decryption KAT
|
|
2289
|
+
ASSERT_TRUE(AES_set_decrypt_key(kAESKey, 8 * sizeof(kAESKey), &aes_key) == 0);
|
|
2290
|
+
outlen = CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2291
|
+
approved, AES_unwrap_key(&aes_key, nullptr, output, kAESKWCiphertext,
|
|
2292
|
+
sizeof(kAESKWCiphertext)));
|
|
2293
|
+
ASSERT_EQ(outlen, sizeof(kPlaintext));
|
|
2294
|
+
EXPECT_EQ(Bytes(kPlaintext), Bytes(output, sizeof(kPlaintext)));
|
|
2295
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
2296
|
+
}
|
|
2297
|
+
|
|
2298
|
+
TEST(ServiceIndicatorTest, AESKWP) {
|
|
2299
|
+
FIPSStatus approved = FIPSStatus::NOT_APPROVED;
|
|
2300
|
+
|
|
2301
|
+
AES_KEY aes_key;
|
|
2302
|
+
uint8_t output[sizeof(kPlaintext) + 15];
|
|
2303
|
+
size_t outlen;
|
|
2304
|
+
|
|
2305
|
+
// AES-KWP Encryption KAT
|
|
2306
|
+
ASSERT_TRUE(AES_set_encrypt_key(kAESKey, 8 * sizeof(kAESKey), &aes_key) == 0);
|
|
2307
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2308
|
+
approved, AES_wrap_key_padded(&aes_key, output, &outlen, sizeof(output),
|
|
2309
|
+
kPlaintext, sizeof(kPlaintext))));
|
|
2310
|
+
EXPECT_EQ(Bytes(kAESKWPCiphertext), Bytes(output, outlen));
|
|
2311
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
2312
|
+
|
|
2313
|
+
// AES-KWP Decryption KAT
|
|
2314
|
+
ASSERT_TRUE(AES_set_decrypt_key(kAESKey, 8 * sizeof(kAESKey), &aes_key) == 0);
|
|
2315
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2316
|
+
approved,
|
|
2317
|
+
AES_unwrap_key_padded(&aes_key, output, &outlen, sizeof(output),
|
|
2318
|
+
kAESKWPCiphertext, sizeof(kAESKWPCiphertext))));
|
|
2319
|
+
EXPECT_EQ(Bytes(kPlaintext), Bytes(output, outlen));
|
|
2320
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
2321
|
+
}
|
|
2322
|
+
|
|
2323
|
+
TEST(ServiceIndicatorTest, FFDH) {
|
|
2324
|
+
FIPSStatus approved = FIPSStatus::NOT_APPROVED;
|
|
2325
|
+
|
|
2326
|
+
// |DH_compute_key_padded| should be a non-approved service.
|
|
2327
|
+
bssl::UniquePtr<DH> dh(GetDH());
|
|
2328
|
+
uint8_t dh_out[sizeof(kDHOutput)];
|
|
2329
|
+
ASSERT_EQ(DH_size(dh.get()), static_cast<int>(sizeof(dh_out)));
|
|
2330
|
+
ASSERT_EQ(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2331
|
+
approved, DH_compute_key_padded(
|
|
2332
|
+
dh_out, DH_get0_priv_key(dh.get()), dh.get())),
|
|
2333
|
+
static_cast<int>(sizeof(dh_out)));
|
|
2334
|
+
EXPECT_EQ(Bytes(kDHOutput), Bytes(dh_out));
|
|
2335
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
2336
|
+
}
|
|
2337
|
+
|
|
2338
|
+
TEST(ServiceIndicatorTest, DRBG) {
|
|
2339
|
+
FIPSStatus approved = FIPSStatus::NOT_APPROVED;
|
|
2340
|
+
CTR_DRBG_STATE drbg;
|
|
2341
|
+
uint8_t output[sizeof(kDRBGOutput)];
|
|
2342
|
+
|
|
2343
|
+
// Test running the DRBG interfaces and check |CTR_DRBG_generate| for approval
|
|
2344
|
+
// at the end since it indicates a service is being done. |CTR_DRBG_init| and
|
|
2345
|
+
// |CTR_DRBG_reseed| should not be approved, because the functions do not
|
|
2346
|
+
// indicate that a service has been fully completed yet.
|
|
2347
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2348
|
+
approved, CTR_DRBG_init(&drbg, kDRBGEntropy, kDRBGPersonalization,
|
|
2349
|
+
sizeof(kDRBGPersonalization))));
|
|
2350
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
2351
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2352
|
+
approved, CTR_DRBG_generate(&drbg, output, sizeof(kDRBGOutput), kDRBGAD,
|
|
2353
|
+
sizeof(kDRBGAD))));
|
|
2354
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
2355
|
+
EXPECT_EQ(Bytes(kDRBGOutput), Bytes(output));
|
|
2356
|
+
|
|
2357
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2358
|
+
approved,
|
|
2359
|
+
CTR_DRBG_reseed(&drbg, kDRBGEntropy2, kDRBGAD, sizeof(kDRBGAD))));
|
|
2360
|
+
EXPECT_EQ(approved, FIPSStatus::NOT_APPROVED);
|
|
2361
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2362
|
+
approved, CTR_DRBG_generate(&drbg, output, sizeof(kDRBGReseedOutput),
|
|
2363
|
+
kDRBGAD, sizeof(kDRBGAD))));
|
|
2364
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
2365
|
+
EXPECT_EQ(Bytes(kDRBGReseedOutput), Bytes(output));
|
|
2366
|
+
|
|
2367
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2368
|
+
approved, RAND_bytes(output, sizeof(output))));
|
|
2369
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
2370
|
+
}
|
|
2371
|
+
|
|
2372
|
+
#else // !BORINGSSL_FIPS
|
|
2373
|
+
|
|
2374
|
+
// Service indicator calls should not be used in non-FIPS builds. However, if
|
|
2375
|
+
// used, the macro |CALL_SERVICE_AND_CHECK_APPROVED| will return
|
|
2376
|
+
// |FIPSStatus::APPROVED|, but the direct calls to
|
|
2377
|
+
// |FIPS_service_indicator_xxx| will not indicate an approved state.
|
|
2378
|
+
TEST(ServiceIndicatorTest, BasicTest) {
|
|
2379
|
+
// Reset and check the initial state and counter.
|
|
2380
|
+
FIPSStatus approved = FIPSStatus::NOT_APPROVED;
|
|
2381
|
+
uint64_t before = FIPS_service_indicator_before_call();
|
|
2382
|
+
ASSERT_EQ(before, (uint64_t)0);
|
|
2383
|
+
|
|
2384
|
+
// Call an approved service.
|
|
2385
|
+
bssl::ScopedEVP_AEAD_CTX aead_ctx;
|
|
2386
|
+
uint8_t nonce[EVP_AEAD_MAX_NONCE_LENGTH] = {0};
|
|
2387
|
+
uint8_t output[256];
|
|
2388
|
+
size_t out_len;
|
|
2389
|
+
ASSERT_TRUE(EVP_AEAD_CTX_init(aead_ctx.get(),
|
|
2390
|
+
EVP_aead_aes_128_gcm_randnonce(), kAESKey,
|
|
2391
|
+
sizeof(kAESKey), 0, nullptr));
|
|
2392
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2393
|
+
approved, EVP_AEAD_CTX_seal(aead_ctx.get(), output, &out_len,
|
|
2394
|
+
sizeof(output), nullptr, 0, kPlaintext,
|
|
2395
|
+
sizeof(kPlaintext), nullptr, 0)));
|
|
2396
|
+
// Macro should return true, to ensure FIPS/non-FIPS compatibility.
|
|
2397
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
2398
|
+
|
|
2399
|
+
// Call a non-approved service.
|
|
2400
|
+
ASSERT_TRUE(EVP_AEAD_CTX_init(aead_ctx.get(), EVP_aead_aes_128_gcm(), kAESKey,
|
|
2401
|
+
sizeof(kAESKey), 0, nullptr));
|
|
2402
|
+
ASSERT_TRUE(CALL_SERVICE_AND_CHECK_APPROVED(
|
|
2403
|
+
approved,
|
|
2404
|
+
EVP_AEAD_CTX_seal(aead_ctx.get(), output, &out_len, sizeof(output), nonce,
|
|
2405
|
+
EVP_AEAD_nonce_length(EVP_aead_aes_128_gcm()),
|
|
2406
|
+
kPlaintext, sizeof(kPlaintext), nullptr, 0)));
|
|
2407
|
+
EXPECT_EQ(approved, FIPSStatus::APPROVED);
|
|
2408
|
+
}
|
|
2409
|
+
|
|
2410
|
+
#endif // BORINGSSL_FIPS
|