@fails-components/webtransport 0.0.1 → 0.0.2
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/package.json +1 -1
- package/readme.md +1 -3
- package/src/http3eventloop.cc +83 -9
- package/src/http3eventloop.h +13 -3
- package/src/http3server.cc +22 -22
- package/src/http3server.h +7 -20
- package/src/http3wtstreamvisitor.cc +31 -10
- package/src/http3wtstreamvisitor.h +38 -11
- package/src/webtransport.js +91 -23
- package/test/echoserver.js +29 -5
- package/test/testsuite.js +242 -220
- package/third_party/boringssl/src/CMakeLists.txt +2 -0
- package/third_party/boringssl/src/crypto/CMakeLists.txt +1 -0
- package/third_party/boringssl/src/crypto/asn1/a_bitstr.c +174 -177
- package/third_party/boringssl/src/crypto/asn1/a_bool.c +46 -48
- package/third_party/boringssl/src/crypto/asn1/a_d2i_fp.c +21 -23
- package/third_party/boringssl/src/crypto/asn1/a_dup.c +21 -23
- package/third_party/boringssl/src/crypto/asn1/a_gentm.c +84 -187
- package/third_party/boringssl/src/crypto/asn1/a_i2d_fp.c +19 -21
- package/third_party/boringssl/src/crypto/asn1/a_int.c +305 -329
- package/third_party/boringssl/src/crypto/asn1/a_mbstr.c +190 -195
- package/third_party/boringssl/src/crypto/asn1/a_object.c +182 -189
- package/third_party/boringssl/src/crypto/asn1/a_octet.c +6 -9
- package/third_party/boringssl/src/crypto/asn1/a_print.c +15 -16
- package/third_party/boringssl/src/crypto/asn1/a_strex.c +386 -399
- package/third_party/boringssl/src/crypto/asn1/a_strnid.c +110 -131
- package/third_party/boringssl/src/crypto/asn1/a_time.c +118 -111
- package/third_party/boringssl/src/crypto/asn1/a_type.c +59 -60
- package/third_party/boringssl/src/crypto/asn1/a_utctm.c +114 -186
- package/third_party/boringssl/src/crypto/asn1/a_utf8.c +171 -159
- package/third_party/boringssl/src/crypto/asn1/asn1_lib.c +245 -260
- package/third_party/boringssl/src/crypto/asn1/asn1_par.c +41 -40
- package/third_party/boringssl/src/crypto/asn1/asn1_test.cc +31 -0
- package/third_party/boringssl/src/crypto/asn1/asn_pack.c +31 -33
- package/third_party/boringssl/src/crypto/asn1/f_int.c +36 -33
- package/third_party/boringssl/src/crypto/asn1/f_string.c +29 -26
- package/third_party/boringssl/src/crypto/asn1/internal.h +62 -61
- package/third_party/boringssl/src/crypto/asn1/tasn_dec.c +706 -702
- package/third_party/boringssl/src/crypto/asn1/tasn_enc.c +507 -524
- package/third_party/boringssl/src/crypto/asn1/tasn_fre.c +141 -133
- package/third_party/boringssl/src/crypto/asn1/tasn_new.c +207 -199
- package/third_party/boringssl/src/crypto/asn1/tasn_typ.c +19 -22
- package/third_party/boringssl/src/crypto/asn1/tasn_utl.c +24 -24
- package/third_party/boringssl/src/crypto/asn1/time_support.c +13 -13
- package/third_party/boringssl/src/crypto/bio/connect.c +9 -3
- package/third_party/boringssl/src/crypto/bytestring/bytestring_test.cc +125 -1
- package/third_party/boringssl/src/crypto/bytestring/cbb.c +4 -7
- package/third_party/boringssl/src/crypto/bytestring/cbs.c +167 -9
- package/third_party/boringssl/src/crypto/cipher_extra/e_aesctrhmac.c +0 -2
- package/third_party/boringssl/src/crypto/cipher_extra/e_aesgcmsiv.c +23 -54
- package/third_party/boringssl/src/crypto/cipher_extra/e_chacha20poly1305.c +0 -2
- package/third_party/boringssl/src/crypto/cipher_extra/e_tls.c +0 -2
- package/third_party/boringssl/src/crypto/curve25519/curve25519.c +6 -8
- package/third_party/boringssl/src/crypto/evp/evp_ctx.c +25 -22
- package/third_party/boringssl/src/crypto/evp/internal.h +15 -9
- package/third_party/boringssl/src/crypto/evp/p_dsa_asn1.c +2 -0
- package/third_party/boringssl/src/crypto/evp/p_ec_asn1.c +2 -0
- package/third_party/boringssl/src/crypto/evp/p_ed25519.c +3 -3
- package/third_party/boringssl/src/crypto/evp/p_ed25519_asn1.c +10 -7
- package/third_party/boringssl/src/crypto/evp/p_hkdf.c +241 -0
- package/third_party/boringssl/src/crypto/evp/p_rsa_asn1.c +2 -0
- package/third_party/boringssl/src/crypto/evp/p_x25519_asn1.c +1 -0
- package/third_party/boringssl/src/crypto/fipsmodule/aes/aes_nohw.c +9 -10
- package/third_party/boringssl/src/crypto/fipsmodule/aes/key_wrap.c +2 -6
- package/third_party/boringssl/src/crypto/fipsmodule/bn/exponentiation.c +5 -11
- package/third_party/boringssl/src/crypto/fipsmodule/bn/internal.h +1 -1
- package/third_party/boringssl/src/crypto/fipsmodule/bn/prime.c +2 -0
- package/third_party/boringssl/src/crypto/fipsmodule/cipher/e_aes.c +10 -26
- package/third_party/boringssl/src/crypto/fipsmodule/cipher/e_aesccm.c +2 -3
- package/third_party/boringssl/src/crypto/fipsmodule/digestsign/digestsign.c +1 -0
- package/third_party/boringssl/src/crypto/fipsmodule/ec/p256-nistz.c +44 -43
- package/third_party/boringssl/src/crypto/fipsmodule/modes/cbc.c +5 -9
- package/third_party/boringssl/src/crypto/fipsmodule/modes/gcm.c +14 -21
- package/third_party/boringssl/src/crypto/fipsmodule/rand/ctrdrbg.c +8 -8
- package/third_party/boringssl/src/crypto/fipsmodule/rand/internal.h +1 -4
- package/third_party/boringssl/src/crypto/hkdf/hkdf_test.cc +104 -0
- package/third_party/boringssl/src/crypto/internal.h +18 -4
- package/third_party/boringssl/src/crypto/lhash/internal.h +13 -1
- package/third_party/boringssl/src/crypto/obj/obj_dat.h +4 -1
- package/third_party/boringssl/src/crypto/obj/obj_mac.num +1 -0
- package/third_party/boringssl/src/crypto/obj/objects.txt +2 -0
- package/third_party/boringssl/src/crypto/pem/pem_all.c +77 -86
- package/third_party/boringssl/src/crypto/pem/pem_info.c +221 -233
- package/third_party/boringssl/src/crypto/pem/pem_lib.c +639 -608
- package/third_party/boringssl/src/crypto/pem/pem_oth.c +17 -16
- package/third_party/boringssl/src/crypto/pem/pem_pk8.c +133 -142
- package/third_party/boringssl/src/crypto/pem/pem_pkey.c +96 -92
- package/third_party/boringssl/src/crypto/poly1305/poly1305_vec.c +12 -28
- package/third_party/boringssl/src/crypto/siphash/siphash.c +8 -11
- package/third_party/boringssl/src/crypto/siphash/siphash_test.cc +5 -7
- package/third_party/boringssl/src/crypto/stack/stack.c +33 -16
- package/third_party/boringssl/src/crypto/thread_pthread.c +0 -2
- package/third_party/boringssl/src/crypto/thread_win.c +0 -2
- package/third_party/boringssl/src/crypto/trust_token/internal.h +14 -0
- package/third_party/boringssl/src/crypto/trust_token/pmbtoken.c +127 -30
- package/third_party/boringssl/src/crypto/trust_token/trust_token.c +40 -0
- package/third_party/boringssl/src/crypto/trust_token/trust_token_test.cc +165 -0
- package/third_party/boringssl/src/crypto/trust_token/voprf.c +55 -6
- package/third_party/boringssl/src/crypto/x509/a_digest.c +23 -24
- package/third_party/boringssl/src/crypto/x509/a_sign.c +52 -55
- package/third_party/boringssl/src/crypto/x509/a_verify.c +33 -34
- package/third_party/boringssl/src/crypto/x509/algorithm.c +17 -18
- package/third_party/boringssl/src/crypto/x509/asn1_gen.c +618 -612
- package/third_party/boringssl/src/crypto/x509/by_dir.c +320 -337
- package/third_party/boringssl/src/crypto/x509/by_file.c +186 -186
- package/third_party/boringssl/src/crypto/x509/i2d_pr.c +11 -14
- package/third_party/boringssl/src/crypto/x509/internal.h +22 -22
- package/third_party/boringssl/src/crypto/x509/name_print.c +155 -150
- package/third_party/boringssl/src/crypto/x509/rsa_pss.c +27 -29
- package/third_party/boringssl/src/crypto/x509/t_crl.c +67 -70
- package/third_party/boringssl/src/crypto/x509/t_req.c +3 -5
- package/third_party/boringssl/src/crypto/x509/t_x509.c +280 -251
- package/third_party/boringssl/src/crypto/x509/t_x509a.c +52 -47
- package/third_party/boringssl/src/crypto/x509/x509.c +3 -4
- package/third_party/boringssl/src/crypto/x509/x509_att.c +234 -223
- package/third_party/boringssl/src/crypto/x509/x509_cmp.c +286 -296
- package/third_party/boringssl/src/crypto/x509/x509_d2.c +37 -32
- package/third_party/boringssl/src/crypto/x509/x509_def.c +14 -30
- package/third_party/boringssl/src/crypto/x509/x509_ext.c +55 -84
- package/third_party/boringssl/src/crypto/x509/x509_lu.c +545 -581
- package/third_party/boringssl/src/crypto/x509/x509_obj.c +131 -121
- package/third_party/boringssl/src/crypto/x509/x509_req.c +120 -139
- package/third_party/boringssl/src/crypto/x509/x509_set.c +128 -142
- package/third_party/boringssl/src/crypto/x509/x509_trs.c +185 -193
- package/third_party/boringssl/src/crypto/x509/x509_txt.c +70 -72
- package/third_party/boringssl/src/crypto/x509/x509_v3.c +172 -161
- package/third_party/boringssl/src/crypto/x509/x509_vfy.c +2041 -2053
- package/third_party/boringssl/src/crypto/x509/x509_vpm.c +441 -461
- package/third_party/boringssl/src/crypto/x509/x509cset.c +152 -170
- package/third_party/boringssl/src/crypto/x509/x509name.c +274 -260
- package/third_party/boringssl/src/crypto/x509/x509rset.c +43 -20
- package/third_party/boringssl/src/crypto/x509/x509spki.c +62 -63
- package/third_party/boringssl/src/crypto/x509/x_algor.c +64 -62
- package/third_party/boringssl/src/crypto/x509/x_all.c +103 -133
- package/third_party/boringssl/src/crypto/x509/x_attrib.c +23 -24
- package/third_party/boringssl/src/crypto/x509/x_crl.c +310 -321
- package/third_party/boringssl/src/crypto/x509/x_exten.c +6 -5
- package/third_party/boringssl/src/crypto/x509/x_info.c +31 -28
- package/third_party/boringssl/src/crypto/x509/x_name.c +361 -365
- package/third_party/boringssl/src/crypto/x509/x_pkey.c +38 -32
- package/third_party/boringssl/src/crypto/x509/x_pubkey.c +114 -117
- package/third_party/boringssl/src/crypto/x509/x_req.c +27 -29
- package/third_party/boringssl/src/crypto/x509/x_sig.c +2 -2
- package/third_party/boringssl/src/crypto/x509/x_spki.c +8 -10
- package/third_party/boringssl/src/crypto/x509/x_val.c +2 -2
- package/third_party/boringssl/src/crypto/x509/x_x509.c +212 -226
- package/third_party/boringssl/src/crypto/x509/x_x509a.c +112 -109
- package/third_party/boringssl/src/crypto/x509v3/ext_dat.h +10 -13
- package/third_party/boringssl/src/crypto/x509v3/internal.h +72 -87
- package/third_party/boringssl/src/crypto/x509v3/pcy_cache.c +184 -176
- package/third_party/boringssl/src/crypto/x509v3/pcy_data.c +58 -56
- package/third_party/boringssl/src/crypto/x509v3/pcy_lib.c +71 -70
- package/third_party/boringssl/src/crypto/x509v3/pcy_map.c +56 -58
- package/third_party/boringssl/src/crypto/x509v3/pcy_node.c +89 -91
- package/third_party/boringssl/src/crypto/x509v3/pcy_tree.c +585 -590
- package/third_party/boringssl/src/crypto/x509v3/v3_akey.c +118 -112
- package/third_party/boringssl/src/crypto/x509v3/v3_akeya.c +3 -3
- package/third_party/boringssl/src/crypto/x509v3/v3_alt.c +447 -451
- package/third_party/boringssl/src/crypto/x509v3/v3_bcons.c +44 -38
- package/third_party/boringssl/src/crypto/x509v3/v3_bitst.c +39 -43
- package/third_party/boringssl/src/crypto/x509v3/v3_conf.c +321 -320
- package/third_party/boringssl/src/crypto/x509v3/v3_cpols.c +352 -327
- package/third_party/boringssl/src/crypto/x509v3/v3_crld.c +437 -383
- package/third_party/boringssl/src/crypto/x509v3/v3_enum.c +23 -16
- package/third_party/boringssl/src/crypto/x509v3/v3_extku.c +62 -53
- package/third_party/boringssl/src/crypto/x509v3/v3_genn.c +118 -115
- package/third_party/boringssl/src/crypto/x509v3/v3_ia5.c +30 -31
- package/third_party/boringssl/src/crypto/x509v3/v3_info.c +112 -98
- package/third_party/boringssl/src/crypto/x509v3/v3_int.c +40 -15
- package/third_party/boringssl/src/crypto/x509v3/v3_lib.c +248 -252
- package/third_party/boringssl/src/crypto/x509v3/v3_ncons.c +390 -386
- package/third_party/boringssl/src/crypto/x509v3/v3_ocsp.c +45 -32
- package/third_party/boringssl/src/crypto/x509v3/v3_pci.c +206 -209
- package/third_party/boringssl/src/crypto/x509v3/v3_pcia.c +6 -8
- package/third_party/boringssl/src/crypto/x509v3/v3_pcons.c +54 -50
- package/third_party/boringssl/src/crypto/x509v3/v3_pmaps.c +66 -65
- package/third_party/boringssl/src/crypto/x509v3/v3_prn.c +144 -133
- package/third_party/boringssl/src/crypto/x509v3/v3_purp.c +695 -709
- package/third_party/boringssl/src/crypto/x509v3/v3_skey.c +75 -69
- package/third_party/boringssl/src/crypto/x509v3/v3_utl.c +1102 -1082
- package/third_party/boringssl/src/include/openssl/base.h +3 -1
- package/third_party/boringssl/src/include/openssl/bn.h +3 -0
- package/third_party/boringssl/src/include/openssl/bytestring.h +20 -0
- package/third_party/boringssl/src/include/openssl/evp.h +6 -5
- package/third_party/boringssl/src/include/openssl/kdf.h +91 -0
- package/third_party/boringssl/src/include/openssl/nid.h +4 -0
- package/third_party/boringssl/src/include/openssl/ssl.h +6 -1
- package/third_party/boringssl/src/include/openssl/stack.h +47 -32
- package/third_party/boringssl/src/include/openssl/trust_token.h +18 -3
- package/third_party/boringssl/src/include/openssl/x509.h +18 -0
- package/third_party/boringssl/src/ssl/ssl_file.cc +61 -99
- package/third_party/boringssl/src/ssl/ssl_test.cc +101 -0
- package/third_party/boringssl/src/util/doc.config +2 -1
- package/third_party/boringssl/src/util/fipstools/acvp/acvptool/subprocess/subprocess.go +8 -0
- package/third_party/googleurl/AUTHORS +16 -2
- package/third_party/googleurl/base/BUILD +1 -0
- package/third_party/googleurl/base/compiler_specific.h +16 -17
- package/third_party/googleurl/base/containers/contiguous_iterator.h +13 -9
- package/third_party/googleurl/base/containers/span.h +23 -8
- package/third_party/googleurl/base/memory/raw_ptr.h +17 -25
- package/third_party/googleurl/base/memory/raw_ptr_exclusion.h +21 -0
- package/third_party/googleurl/base/strings/escape.cc +14 -2
- package/third_party/googleurl/base/strings/safe_sprintf.h +1 -1
- package/third_party/googleurl/base/strings/string_number_conversions.cc +5 -3
- package/third_party/googleurl/base/strings/string_number_conversions_internal.h +5 -5
- package/third_party/googleurl/base/strings/string_piece.h +3 -3
- package/third_party/googleurl/base/strings/string_util.cc +4 -27
- package/third_party/googleurl/base/strings/string_util.h +43 -8
- package/third_party/googleurl/base/strings/string_util_internal.h +11 -12
- package/third_party/googleurl/base/strings/string_util_unittest.cc +33 -0
- package/third_party/googleurl/base/strings/string_util_win.cc +0 -5
- package/third_party/googleurl/base/strings/string_util_win.h +9 -1
- package/third_party/googleurl/base/strings/utf_offset_string_conversions.cc +1 -1
- package/third_party/googleurl/base/strings/utf_string_conversion_utils.cc +5 -8
- package/third_party/googleurl/base/strings/utf_string_conversion_utils.h +13 -10
- package/third_party/googleurl/base/strings/utf_string_conversions.cc +32 -25
- package/third_party/googleurl/base/template_util.h +23 -35
- package/third_party/googleurl/build/build_config.h +14 -3
- package/third_party/googleurl/copy.bara.sky +1 -1
- package/third_party/googleurl/url/gurl.cc +8 -4
- package/third_party/googleurl/url/gurl.h +1 -0
- package/third_party/googleurl/url/gurl_unittest.cc +1 -0
- package/third_party/googleurl/url/origin.h +36 -26
- package/third_party/googleurl/url/scheme_host_port.h +4 -1
- package/third_party/googleurl/url/url_canon.h +2 -1
- package/third_party/googleurl/url/url_canon_internal.cc +9 -7
- package/third_party/googleurl/url/url_canon_internal.h +16 -16
- package/third_party/googleurl/url/url_canon_stdstring.h +2 -1
- package/third_party/googleurl/url/url_util.cc +9 -8
- package/third_party/quiche/build/source_list.bzl +7 -0
- package/third_party/quiche/build/source_list.gni +7 -0
- package/third_party/quiche/build/source_list.json +7 -0
- package/third_party/quiche/quiche/common/platform/api/quiche_mem_slice.h +7 -3
- package/third_party/quiche/quiche/http2/adapter/nghttp2_adapter_test.cc +86 -2
- package/third_party/quiche/quiche/http2/adapter/oghttp2_adapter_test.cc +104 -2
- package/third_party/quiche/quiche/http2/adapter/oghttp2_session.cc +23 -0
- package/third_party/quiche/quiche/http2/adapter/oghttp2_session.h +6 -1
- package/third_party/quiche/quiche/quic/core/congestion_control/send_algorithm_test.cc +0 -16
- package/third_party/quiche/quiche/quic/core/crypto/crypto_protocol.h +1 -1
- package/third_party/quiche/quiche/quic/core/http/end_to_end_test.cc +56 -2
- package/third_party/quiche/quiche/quic/core/http/http_constants.cc +1 -0
- package/third_party/quiche/quiche/quic/core/http/http_constants.h +1 -0
- package/third_party/quiche/quiche/quic/core/http/http_encoder.cc +28 -17
- package/third_party/quiche/quiche/quic/core/http/http_encoder.h +5 -0
- package/third_party/quiche/quiche/quic/core/http/http_encoder_test.cc +26 -30
- package/third_party/quiche/quiche/quic/core/http/http_frames.h +1 -0
- package/third_party/quiche/quiche/quic/core/http/quic_server_session_base.cc +4 -4
- package/third_party/quiche/quiche/quic/core/http/quic_server_session_base_test.cc +1 -1
- package/third_party/quiche/quiche/quic/core/http/quic_spdy_client_session.cc +5 -1
- package/third_party/quiche/quiche/quic/core/http/quic_spdy_stream.cc +6 -33
- package/third_party/quiche/quiche/quic/core/http/quic_spdy_stream.h +0 -17
- package/third_party/quiche/quiche/quic/core/http/quic_spdy_stream_test.cc +5 -20
- package/third_party/quiche/quiche/quic/core/io/quic_event_loop.h +81 -0
- package/third_party/quiche/quiche/quic/core/io/quic_poll_event_loop.cc +265 -0
- package/third_party/quiche/quiche/quic/core/io/quic_poll_event_loop.h +152 -0
- package/third_party/quiche/quiche/quic/core/io/quic_poll_event_loop_test.cc +341 -0
- package/third_party/quiche/quiche/quic/core/quic_buffered_packet_store.cc +3 -1
- package/third_party/quiche/quiche/quic/core/quic_buffered_packet_store.h +7 -7
- package/third_party/quiche/quiche/quic/core/quic_buffered_packet_store_test.cc +4 -3
- package/third_party/quiche/quiche/quic/core/quic_connection.cc +69 -19
- package/third_party/quiche/quiche/quic/core/quic_connection.h +9 -3
- package/third_party/quiche/quiche/quic/core/quic_connection_id_manager.cc +29 -10
- package/third_party/quiche/quiche/quic/core/quic_connection_id_manager.h +5 -3
- package/third_party/quiche/quiche/quic/core/quic_connection_id_manager_test.cc +85 -22
- package/third_party/quiche/quiche/quic/core/quic_connection_test.cc +186 -30
- package/third_party/quiche/quiche/quic/core/quic_crypto_stream.cc +2 -1
- package/third_party/quiche/quiche/quic/core/quic_default_clock.cc +31 -0
- package/third_party/quiche/quiche/quic/core/quic_default_clock.h +34 -0
- package/third_party/quiche/quiche/quic/core/quic_default_connection_helper.h +49 -0
- package/third_party/quiche/quiche/quic/core/quic_dispatcher.cc +53 -37
- package/third_party/quiche/quiche/quic/core/quic_dispatcher.h +19 -11
- package/third_party/quiche/quiche/quic/core/quic_dispatcher_test.cc +15 -2
- package/third_party/quiche/quiche/quic/core/quic_flags_list.h +10 -4
- package/third_party/quiche/quiche/quic/core/quic_idle_network_detector.cc +2 -2
- package/third_party/quiche/quiche/quic/core/quic_idle_network_detector_test.cc +4 -4
- package/third_party/quiche/quiche/quic/core/quic_packet_creator.cc +14 -3
- package/third_party/quiche/quiche/quic/core/quic_packet_creator_test.cc +145 -2
- package/third_party/quiche/quiche/quic/core/quic_packets.cc +3 -1
- package/third_party/quiche/quiche/quic/core/quic_packets.h +4 -0
- package/third_party/quiche/quiche/quic/core/quic_sent_packet_manager.cc +13 -11
- package/third_party/quiche/quiche/quic/core/quic_sent_packet_manager.h +9 -0
- package/third_party/quiche/quiche/quic/core/quic_sent_packet_manager_test.cc +6 -0
- package/third_party/quiche/quiche/quic/core/quic_session.cc +3 -2
- package/third_party/quiche/quiche/quic/core/quic_session.h +8 -3
- package/third_party/quiche/quiche/quic/core/quic_types.cc +18 -0
- package/third_party/quiche/quiche/quic/core/quic_types.h +3 -0
- package/third_party/quiche/quiche/quic/core/tls_chlo_extractor.cc +3 -0
- package/third_party/quiche/quiche/quic/core/tls_chlo_extractor.h +10 -0
- package/third_party/quiche/quiche/quic/test_tools/mock_quic_session_visitor.h +1 -1
- package/third_party/quiche/quiche/quic/test_tools/quic_test_utils.h +1 -1
- package/third_party/quiche/quiche/quic/test_tools/server_thread.cc +3 -2
- package/third_party/quiche/quiche/quic/test_tools/simple_session_notifier.cc +7 -1
- package/third_party/quiche/quiche/quic/test_tools/simple_session_notifier.h +3 -0
- package/third_party/quiche/quiche/quic/test_tools/simulator/quic_endpoint.h +4 -2
- package/certs/ca.cnf +0 -69
- package/certs/generate_certs.sh +0 -53
- package/certs/generate_certs_leaf.sh +0 -53
- package/certs/leaf.cnf +0 -24
- package/certs/readme.txt +0 -2
- package/third_party/quiche/build/BUILD.bazel +0 -7
|
@@ -1936,11 +1936,8 @@ int ED25519_verify(const uint8_t *message, size_t message_len,
|
|
|
1936
1936
|
OPENSSL_memcpy(pkcopy, public_key, 32);
|
|
1937
1937
|
uint8_t rcopy[32];
|
|
1938
1938
|
OPENSSL_memcpy(rcopy, signature, 32);
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
uint8_t u8[32];
|
|
1942
|
-
} scopy;
|
|
1943
|
-
OPENSSL_memcpy(&scopy.u8[0], signature + 32, 32);
|
|
1939
|
+
uint8_t scopy[32];
|
|
1940
|
+
OPENSSL_memcpy(scopy, signature + 32, 32);
|
|
1944
1941
|
|
|
1945
1942
|
// https://tools.ietf.org/html/rfc8032#section-5.1.7 requires that s be in
|
|
1946
1943
|
// the range [0, order) in order to prevent signature malleability.
|
|
@@ -1953,9 +1950,10 @@ int ED25519_verify(const uint8_t *message, size_t message_len,
|
|
|
1953
1950
|
UINT64_C(0x1000000000000000),
|
|
1954
1951
|
};
|
|
1955
1952
|
for (size_t i = 3;; i--) {
|
|
1956
|
-
|
|
1953
|
+
uint64_t word = CRYPTO_load_u64_le(scopy + i * 8);
|
|
1954
|
+
if (word > kOrder[i]) {
|
|
1957
1955
|
return 0;
|
|
1958
|
-
} else if (
|
|
1956
|
+
} else if (word < kOrder[i]) {
|
|
1959
1957
|
break;
|
|
1960
1958
|
} else if (i == 0) {
|
|
1961
1959
|
return 0;
|
|
@@ -1973,7 +1971,7 @@ int ED25519_verify(const uint8_t *message, size_t message_len,
|
|
|
1973
1971
|
x25519_sc_reduce(h);
|
|
1974
1972
|
|
|
1975
1973
|
ge_p2 R;
|
|
1976
|
-
ge_double_scalarmult_vartime(&R, h, &A, scopy
|
|
1974
|
+
ge_double_scalarmult_vartime(&R, h, &A, scopy);
|
|
1977
1975
|
|
|
1978
1976
|
uint8_t rcheck[32];
|
|
1979
1977
|
x25519_ge_tobytes(rcheck, &R);
|
|
@@ -71,6 +71,7 @@ static const EVP_PKEY_METHOD *const evp_methods[] = {
|
|
|
71
71
|
&ec_pkey_meth,
|
|
72
72
|
&ed25519_pkey_meth,
|
|
73
73
|
&x25519_pkey_meth,
|
|
74
|
+
&hkdf_pkey_meth,
|
|
74
75
|
};
|
|
75
76
|
|
|
76
77
|
static const EVP_PKEY_METHOD *evp_pkey_meth_find(int type) {
|
|
@@ -83,26 +84,9 @@ static const EVP_PKEY_METHOD *evp_pkey_meth_find(int type) {
|
|
|
83
84
|
return NULL;
|
|
84
85
|
}
|
|
85
86
|
|
|
86
|
-
static EVP_PKEY_CTX *evp_pkey_ctx_new(EVP_PKEY *pkey, ENGINE *e,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (id == -1) {
|
|
91
|
-
if (!pkey || !pkey->ameth) {
|
|
92
|
-
return NULL;
|
|
93
|
-
}
|
|
94
|
-
id = pkey->ameth->pkey_id;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
pmeth = evp_pkey_meth_find(id);
|
|
98
|
-
|
|
99
|
-
if (pmeth == NULL) {
|
|
100
|
-
OPENSSL_PUT_ERROR(EVP, EVP_R_UNSUPPORTED_ALGORITHM);
|
|
101
|
-
ERR_add_error_dataf("algorithm %d", id);
|
|
102
|
-
return NULL;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
ret = OPENSSL_malloc(sizeof(EVP_PKEY_CTX));
|
|
87
|
+
static EVP_PKEY_CTX *evp_pkey_ctx_new(EVP_PKEY *pkey, ENGINE *e,
|
|
88
|
+
const EVP_PKEY_METHOD *pmeth) {
|
|
89
|
+
EVP_PKEY_CTX *ret = OPENSSL_malloc(sizeof(EVP_PKEY_CTX));
|
|
106
90
|
if (!ret) {
|
|
107
91
|
OPENSSL_PUT_ERROR(EVP, ERR_R_MALLOC_FAILURE);
|
|
108
92
|
return NULL;
|
|
@@ -130,11 +114,30 @@ static EVP_PKEY_CTX *evp_pkey_ctx_new(EVP_PKEY *pkey, ENGINE *e, int id) {
|
|
|
130
114
|
}
|
|
131
115
|
|
|
132
116
|
EVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e) {
|
|
133
|
-
|
|
117
|
+
if (pkey == NULL || pkey->ameth == NULL) {
|
|
118
|
+
OPENSSL_PUT_ERROR(EVP, ERR_R_PASSED_NULL_PARAMETER);
|
|
119
|
+
return NULL;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const EVP_PKEY_METHOD *pkey_method = pkey->ameth->pkey_method;
|
|
123
|
+
if (pkey_method == NULL) {
|
|
124
|
+
OPENSSL_PUT_ERROR(EVP, EVP_R_UNSUPPORTED_ALGORITHM);
|
|
125
|
+
ERR_add_error_dataf("algorithm %d", pkey->ameth->pkey_id);
|
|
126
|
+
return NULL;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return evp_pkey_ctx_new(pkey, e, pkey_method);
|
|
134
130
|
}
|
|
135
131
|
|
|
136
132
|
EVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e) {
|
|
137
|
-
|
|
133
|
+
const EVP_PKEY_METHOD *pkey_method = evp_pkey_meth_find(id);
|
|
134
|
+
if (pkey_method == NULL) {
|
|
135
|
+
OPENSSL_PUT_ERROR(EVP, EVP_R_UNSUPPORTED_ALGORITHM);
|
|
136
|
+
ERR_add_error_dataf("algorithm %d", id);
|
|
137
|
+
return NULL;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return evp_pkey_ctx_new(NULL, e, pkey_method);
|
|
138
141
|
}
|
|
139
142
|
|
|
140
143
|
void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx) {
|
|
@@ -71,6 +71,8 @@ struct evp_pkey_asn1_method_st {
|
|
|
71
71
|
uint8_t oid[9];
|
|
72
72
|
uint8_t oid_len;
|
|
73
73
|
|
|
74
|
+
const EVP_PKEY_METHOD *pkey_method;
|
|
75
|
+
|
|
74
76
|
// pub_decode decodes |params| and |key| as a SubjectPublicKeyInfo
|
|
75
77
|
// and writes the result into |out|. It returns one on success and zero on
|
|
76
78
|
// error. |params| is the AlgorithmIdentifier after the OBJECT IDENTIFIER
|
|
@@ -178,6 +180,11 @@ OPENSSL_EXPORT int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype,
|
|
|
178
180
|
#define EVP_PKEY_CTRL_RSA_OAEP_LABEL (EVP_PKEY_ALG_CTRL + 11)
|
|
179
181
|
#define EVP_PKEY_CTRL_GET_RSA_OAEP_LABEL (EVP_PKEY_ALG_CTRL + 12)
|
|
180
182
|
#define EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID (EVP_PKEY_ALG_CTRL + 13)
|
|
183
|
+
#define EVP_PKEY_CTRL_HKDF_MODE (EVP_PKEY_ALG_CTRL + 14)
|
|
184
|
+
#define EVP_PKEY_CTRL_HKDF_MD (EVP_PKEY_ALG_CTRL + 15)
|
|
185
|
+
#define EVP_PKEY_CTRL_HKDF_KEY (EVP_PKEY_ALG_CTRL + 16)
|
|
186
|
+
#define EVP_PKEY_CTRL_HKDF_SALT (EVP_PKEY_ALG_CTRL + 17)
|
|
187
|
+
#define EVP_PKEY_CTRL_HKDF_INFO (EVP_PKEY_ALG_CTRL + 18)
|
|
181
188
|
|
|
182
189
|
struct evp_pkey_ctx_st {
|
|
183
190
|
// Method associated with this operation
|
|
@@ -232,18 +239,16 @@ struct evp_pkey_method_st {
|
|
|
232
239
|
} /* EVP_PKEY_METHOD */;
|
|
233
240
|
|
|
234
241
|
typedef struct {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
uint8_t pad[32];
|
|
241
|
-
uint8_t value[32];
|
|
242
|
-
} pub;
|
|
243
|
-
} key;
|
|
242
|
+
// key is the concatenation of the private seed and public key. It is stored
|
|
243
|
+
// as a single 64-bit array to allow passing to |ED25519_sign|. If
|
|
244
|
+
// |has_private| is false, the first 32 bytes are uninitialized and the public
|
|
245
|
+
// key is in the last 32 bytes.
|
|
246
|
+
uint8_t key[64];
|
|
244
247
|
char has_private;
|
|
245
248
|
} ED25519_KEY;
|
|
246
249
|
|
|
250
|
+
#define ED25519_PUBLIC_KEY_OFFSET 32
|
|
251
|
+
|
|
247
252
|
typedef struct {
|
|
248
253
|
uint8_t pub[32];
|
|
249
254
|
uint8_t priv[32];
|
|
@@ -260,6 +265,7 @@ extern const EVP_PKEY_METHOD rsa_pkey_meth;
|
|
|
260
265
|
extern const EVP_PKEY_METHOD ec_pkey_meth;
|
|
261
266
|
extern const EVP_PKEY_METHOD ed25519_pkey_meth;
|
|
262
267
|
extern const EVP_PKEY_METHOD x25519_pkey_meth;
|
|
268
|
+
extern const EVP_PKEY_METHOD hkdf_pkey_meth;
|
|
263
269
|
|
|
264
270
|
|
|
265
271
|
#if defined(__cplusplus)
|
|
@@ -37,7 +37,7 @@ static int pkey_ed25519_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
uint8_t pubkey_unused[32];
|
|
40
|
-
ED25519_keypair(pubkey_unused, key->key
|
|
40
|
+
ED25519_keypair(pubkey_unused, key->key);
|
|
41
41
|
key->has_private = 1;
|
|
42
42
|
|
|
43
43
|
OPENSSL_free(pkey->pkey.ptr);
|
|
@@ -64,7 +64,7 @@ static int pkey_ed25519_sign_message(EVP_PKEY_CTX *ctx, uint8_t *sig,
|
|
|
64
64
|
return 0;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
if (!ED25519_sign(sig, tbs, tbslen, key->key
|
|
67
|
+
if (!ED25519_sign(sig, tbs, tbslen, key->key)) {
|
|
68
68
|
return 0;
|
|
69
69
|
}
|
|
70
70
|
|
|
@@ -77,7 +77,7 @@ static int pkey_ed25519_verify_message(EVP_PKEY_CTX *ctx, const uint8_t *sig,
|
|
|
77
77
|
size_t tbslen) {
|
|
78
78
|
ED25519_KEY *key = ctx->pkey->pkey.ptr;
|
|
79
79
|
if (siglen != 64 ||
|
|
80
|
-
!ED25519_verify(tbs, tbslen, sig, key->key
|
|
80
|
+
!ED25519_verify(tbs, tbslen, sig, key->key + ED25519_PUBLIC_KEY_OFFSET)) {
|
|
81
81
|
OPENSSL_PUT_ERROR(EVP, EVP_R_INVALID_SIGNATURE);
|
|
82
82
|
return 0;
|
|
83
83
|
}
|
|
@@ -43,7 +43,7 @@ static int ed25519_set_priv_raw(EVP_PKEY *pkey, const uint8_t *in, size_t len) {
|
|
|
43
43
|
// The RFC 8032 encoding stores only the 32-byte seed, so we must recover the
|
|
44
44
|
// full representation which we use from it.
|
|
45
45
|
uint8_t pubkey_unused[32];
|
|
46
|
-
ED25519_keypair_from_seed(pubkey_unused, key->key
|
|
46
|
+
ED25519_keypair_from_seed(pubkey_unused, key->key, in);
|
|
47
47
|
key->has_private = 1;
|
|
48
48
|
|
|
49
49
|
ed25519_free(pkey);
|
|
@@ -63,7 +63,7 @@ static int ed25519_set_pub_raw(EVP_PKEY *pkey, const uint8_t *in, size_t len) {
|
|
|
63
63
|
return 0;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
OPENSSL_memcpy(key->key
|
|
66
|
+
OPENSSL_memcpy(key->key + ED25519_PUBLIC_KEY_OFFSET, in, 32);
|
|
67
67
|
key->has_private = 0;
|
|
68
68
|
|
|
69
69
|
ed25519_free(pkey);
|
|
@@ -90,7 +90,7 @@ static int ed25519_get_priv_raw(const EVP_PKEY *pkey, uint8_t *out,
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
// The raw private key format is the first 32 bytes of the private key.
|
|
93
|
-
OPENSSL_memcpy(out, key->key
|
|
93
|
+
OPENSSL_memcpy(out, key->key, 32);
|
|
94
94
|
*out_len = 32;
|
|
95
95
|
return 1;
|
|
96
96
|
}
|
|
@@ -108,7 +108,7 @@ static int ed25519_get_pub_raw(const EVP_PKEY *pkey, uint8_t *out,
|
|
|
108
108
|
return 0;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
OPENSSL_memcpy(out, key->key
|
|
111
|
+
OPENSSL_memcpy(out, key->key + ED25519_PUBLIC_KEY_OFFSET, 32);
|
|
112
112
|
*out_len = 32;
|
|
113
113
|
return 1;
|
|
114
114
|
}
|
|
@@ -136,7 +136,8 @@ static int ed25519_pub_encode(CBB *out, const EVP_PKEY *pkey) {
|
|
|
136
136
|
!CBB_add_bytes(&oid, ed25519_asn1_meth.oid, ed25519_asn1_meth.oid_len) ||
|
|
137
137
|
!CBB_add_asn1(&spki, &key_bitstring, CBS_ASN1_BITSTRING) ||
|
|
138
138
|
!CBB_add_u8(&key_bitstring, 0 /* padding */) ||
|
|
139
|
-
!CBB_add_bytes(&key_bitstring, key->key
|
|
139
|
+
!CBB_add_bytes(&key_bitstring, key->key + ED25519_PUBLIC_KEY_OFFSET,
|
|
140
|
+
32) ||
|
|
140
141
|
!CBB_flush(out)) {
|
|
141
142
|
OPENSSL_PUT_ERROR(EVP, EVP_R_ENCODE_ERROR);
|
|
142
143
|
return 0;
|
|
@@ -148,7 +149,8 @@ static int ed25519_pub_encode(CBB *out, const EVP_PKEY *pkey) {
|
|
|
148
149
|
static int ed25519_pub_cmp(const EVP_PKEY *a, const EVP_PKEY *b) {
|
|
149
150
|
const ED25519_KEY *a_key = a->pkey.ptr;
|
|
150
151
|
const ED25519_KEY *b_key = b->pkey.ptr;
|
|
151
|
-
return OPENSSL_memcmp(a_key->key
|
|
152
|
+
return OPENSSL_memcmp(a_key->key + ED25519_PUBLIC_KEY_OFFSET,
|
|
153
|
+
b_key->key + ED25519_PUBLIC_KEY_OFFSET, 32) == 0;
|
|
152
154
|
}
|
|
153
155
|
|
|
154
156
|
static int ed25519_priv_decode(EVP_PKEY *out, CBS *params, CBS *key) {
|
|
@@ -185,7 +187,7 @@ static int ed25519_priv_encode(CBB *out, const EVP_PKEY *pkey) {
|
|
|
185
187
|
!CBB_add_asn1(&private_key, &inner, CBS_ASN1_OCTETSTRING) ||
|
|
186
188
|
// The PKCS#8 encoding stores only the 32-byte seed which is the first 32
|
|
187
189
|
// bytes of the private key.
|
|
188
|
-
!CBB_add_bytes(&inner, key->key
|
|
190
|
+
!CBB_add_bytes(&inner, key->key, 32) ||
|
|
189
191
|
!CBB_flush(out)) {
|
|
190
192
|
OPENSSL_PUT_ERROR(EVP, EVP_R_ENCODE_ERROR);
|
|
191
193
|
return 0;
|
|
@@ -202,6 +204,7 @@ const EVP_PKEY_ASN1_METHOD ed25519_asn1_meth = {
|
|
|
202
204
|
EVP_PKEY_ED25519,
|
|
203
205
|
{0x2b, 0x65, 0x70},
|
|
204
206
|
3,
|
|
207
|
+
&ed25519_pkey_meth,
|
|
205
208
|
ed25519_pub_decode,
|
|
206
209
|
ed25519_pub_encode,
|
|
207
210
|
ed25519_pub_cmp,
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/* Copyright (c) 2022, Google Inc.
|
|
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 <openssl/evp.h>
|
|
16
|
+
|
|
17
|
+
#include <openssl/bytestring.h>
|
|
18
|
+
#include <openssl/err.h>
|
|
19
|
+
#include <openssl/hkdf.h>
|
|
20
|
+
#include <openssl/kdf.h>
|
|
21
|
+
#include <openssl/mem.h>
|
|
22
|
+
|
|
23
|
+
#include "../internal.h"
|
|
24
|
+
#include "internal.h"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
typedef struct {
|
|
28
|
+
int mode;
|
|
29
|
+
const EVP_MD *md;
|
|
30
|
+
uint8_t *key;
|
|
31
|
+
size_t key_len;
|
|
32
|
+
uint8_t *salt;
|
|
33
|
+
size_t salt_len;
|
|
34
|
+
CBB info;
|
|
35
|
+
} HKDF_PKEY_CTX;
|
|
36
|
+
|
|
37
|
+
static int pkey_hkdf_init(EVP_PKEY_CTX *ctx) {
|
|
38
|
+
HKDF_PKEY_CTX *hctx = OPENSSL_malloc(sizeof(HKDF_PKEY_CTX));
|
|
39
|
+
if (hctx == NULL) {
|
|
40
|
+
OPENSSL_PUT_ERROR(EVP, ERR_R_MALLOC_FAILURE);
|
|
41
|
+
return 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
OPENSSL_memset(hctx, 0, sizeof(HKDF_PKEY_CTX));
|
|
45
|
+
if (!CBB_init(&hctx->info, 0)) {
|
|
46
|
+
OPENSSL_PUT_ERROR(EVP, ERR_R_MALLOC_FAILURE);
|
|
47
|
+
OPENSSL_free(hctx);
|
|
48
|
+
return 0;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
ctx->data = hctx;
|
|
52
|
+
return 1;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static int pkey_hkdf_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src) {
|
|
56
|
+
if (!pkey_hkdf_init(dst)) {
|
|
57
|
+
return 0;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
HKDF_PKEY_CTX *hctx_dst = dst->data;
|
|
61
|
+
const HKDF_PKEY_CTX *hctx_src = src->data;
|
|
62
|
+
hctx_dst->mode = hctx_src->mode;
|
|
63
|
+
hctx_dst->md = hctx_src->md;
|
|
64
|
+
|
|
65
|
+
if (hctx_src->key_len != 0) {
|
|
66
|
+
hctx_dst->key = OPENSSL_memdup(hctx_src->key, hctx_src->key_len);
|
|
67
|
+
if (hctx_src->key == NULL) {
|
|
68
|
+
OPENSSL_PUT_ERROR(EVP, ERR_R_MALLOC_FAILURE);
|
|
69
|
+
return 0;
|
|
70
|
+
}
|
|
71
|
+
hctx_dst->key_len = hctx_src->key_len;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (hctx_src->salt_len != 0) {
|
|
75
|
+
hctx_dst->salt = OPENSSL_memdup(hctx_src->salt, hctx_src->salt_len);
|
|
76
|
+
if (hctx_src->salt == NULL) {
|
|
77
|
+
OPENSSL_PUT_ERROR(EVP, ERR_R_MALLOC_FAILURE);
|
|
78
|
+
return 0;
|
|
79
|
+
}
|
|
80
|
+
hctx_dst->salt_len = hctx_src->salt_len;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (!CBB_add_bytes(&hctx_dst->info, CBB_data(&hctx_src->info),
|
|
84
|
+
CBB_len(&hctx_src->info))) {
|
|
85
|
+
OPENSSL_PUT_ERROR(EVP, ERR_R_MALLOC_FAILURE);
|
|
86
|
+
return 0;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return 1;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
static void pkey_hkdf_cleanup(EVP_PKEY_CTX *ctx) {
|
|
93
|
+
HKDF_PKEY_CTX *hctx = ctx->data;
|
|
94
|
+
if (hctx != NULL) {
|
|
95
|
+
OPENSSL_free(hctx->key);
|
|
96
|
+
OPENSSL_free(hctx->salt);
|
|
97
|
+
CBB_cleanup(&hctx->info);
|
|
98
|
+
OPENSSL_free(hctx);
|
|
99
|
+
ctx->data = NULL;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
static int pkey_hkdf_derive(EVP_PKEY_CTX *ctx, uint8_t *out, size_t *out_len) {
|
|
104
|
+
HKDF_PKEY_CTX *hctx = ctx->data;
|
|
105
|
+
if (hctx->md == NULL) {
|
|
106
|
+
OPENSSL_PUT_ERROR(EVP, EVP_R_MISSING_PARAMETERS);
|
|
107
|
+
return 0;
|
|
108
|
+
}
|
|
109
|
+
if (hctx->key_len == 0) {
|
|
110
|
+
OPENSSL_PUT_ERROR(EVP, EVP_R_NO_KEY_SET);
|
|
111
|
+
return 0;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (out == NULL) {
|
|
115
|
+
if (hctx->mode == EVP_PKEY_HKDEF_MODE_EXTRACT_ONLY) {
|
|
116
|
+
*out_len = EVP_MD_size(hctx->md);
|
|
117
|
+
}
|
|
118
|
+
// HKDF-Expand is variable-length and returns |*out_len| bytes. "Output" the
|
|
119
|
+
// input length by leaving it alone.
|
|
120
|
+
return 1;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
switch (hctx->mode) {
|
|
124
|
+
case EVP_PKEY_HKDEF_MODE_EXTRACT_AND_EXPAND:
|
|
125
|
+
return HKDF(out, *out_len, hctx->md, hctx->key, hctx->key_len, hctx->salt,
|
|
126
|
+
hctx->salt_len, CBB_data(&hctx->info), CBB_len(&hctx->info));
|
|
127
|
+
|
|
128
|
+
case EVP_PKEY_HKDEF_MODE_EXTRACT_ONLY:
|
|
129
|
+
if (*out_len < EVP_MD_size(hctx->md)) {
|
|
130
|
+
OPENSSL_PUT_ERROR(EVP, EVP_R_BUFFER_TOO_SMALL);
|
|
131
|
+
return 0;
|
|
132
|
+
}
|
|
133
|
+
return HKDF_extract(out, out_len, hctx->md, hctx->key, hctx->key_len,
|
|
134
|
+
hctx->salt, hctx->salt_len);
|
|
135
|
+
|
|
136
|
+
case EVP_PKEY_HKDEF_MODE_EXPAND_ONLY:
|
|
137
|
+
return HKDF_expand(out, *out_len, hctx->md, hctx->key, hctx->key_len,
|
|
138
|
+
CBB_data(&hctx->info), CBB_len(&hctx->info));
|
|
139
|
+
}
|
|
140
|
+
OPENSSL_PUT_ERROR(EVP, ERR_R_INTERNAL_ERROR);
|
|
141
|
+
return 0;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
static int pkey_hkdf_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) {
|
|
145
|
+
HKDF_PKEY_CTX *hctx = ctx->data;
|
|
146
|
+
switch (type) {
|
|
147
|
+
case EVP_PKEY_CTRL_HKDF_MODE:
|
|
148
|
+
if (p1 != EVP_PKEY_HKDEF_MODE_EXTRACT_AND_EXPAND &&
|
|
149
|
+
p1 != EVP_PKEY_HKDEF_MODE_EXTRACT_ONLY &&
|
|
150
|
+
p1 != EVP_PKEY_HKDEF_MODE_EXPAND_ONLY) {
|
|
151
|
+
OPENSSL_PUT_ERROR(EVP, EVP_R_INVALID_OPERATION);
|
|
152
|
+
return 0;
|
|
153
|
+
}
|
|
154
|
+
hctx->mode = p1;
|
|
155
|
+
return 1;
|
|
156
|
+
case EVP_PKEY_CTRL_HKDF_MD:
|
|
157
|
+
hctx->md = p2;
|
|
158
|
+
return 1;
|
|
159
|
+
case EVP_PKEY_CTRL_HKDF_KEY: {
|
|
160
|
+
const CBS *key = p2;
|
|
161
|
+
if (!CBS_stow(key, &hctx->key, &hctx->key_len)) {
|
|
162
|
+
OPENSSL_PUT_ERROR(EVP, ERR_R_MALLOC_FAILURE);
|
|
163
|
+
return 0;
|
|
164
|
+
}
|
|
165
|
+
return 1;
|
|
166
|
+
}
|
|
167
|
+
case EVP_PKEY_CTRL_HKDF_SALT: {
|
|
168
|
+
const CBS *salt = p2;
|
|
169
|
+
if (!CBS_stow(salt, &hctx->salt, &hctx->salt_len)) {
|
|
170
|
+
OPENSSL_PUT_ERROR(EVP, ERR_R_MALLOC_FAILURE);
|
|
171
|
+
return 0;
|
|
172
|
+
}
|
|
173
|
+
return 1;
|
|
174
|
+
}
|
|
175
|
+
case EVP_PKEY_CTRL_HKDF_INFO: {
|
|
176
|
+
const CBS *info = p2;
|
|
177
|
+
// |EVP_PKEY_CTX_add1_hkdf_info| appends to the info string, rather than
|
|
178
|
+
// replacing it.
|
|
179
|
+
if (!CBB_add_bytes(&hctx->info, CBS_data(info), CBS_len(info))) {
|
|
180
|
+
OPENSSL_PUT_ERROR(EVP, ERR_R_MALLOC_FAILURE);
|
|
181
|
+
return 0;
|
|
182
|
+
}
|
|
183
|
+
return 1;
|
|
184
|
+
}
|
|
185
|
+
default:
|
|
186
|
+
OPENSSL_PUT_ERROR(EVP, EVP_R_COMMAND_NOT_SUPPORTED);
|
|
187
|
+
return 0;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const EVP_PKEY_METHOD hkdf_pkey_meth = {
|
|
192
|
+
EVP_PKEY_HKDF,
|
|
193
|
+
pkey_hkdf_init,
|
|
194
|
+
pkey_hkdf_copy,
|
|
195
|
+
pkey_hkdf_cleanup,
|
|
196
|
+
/*keygen=*/NULL,
|
|
197
|
+
/*sign=*/NULL,
|
|
198
|
+
/*sign_message=*/NULL,
|
|
199
|
+
/*verify=*/NULL,
|
|
200
|
+
/*verify_message=*/NULL,
|
|
201
|
+
/*verify_recover=*/NULL,
|
|
202
|
+
/*encrypt=*/NULL,
|
|
203
|
+
/*decrypt=*/NULL,
|
|
204
|
+
pkey_hkdf_derive,
|
|
205
|
+
/*paramgen=*/NULL,
|
|
206
|
+
pkey_hkdf_ctrl,
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
int EVP_PKEY_CTX_hkdf_mode(EVP_PKEY_CTX *ctx, int mode) {
|
|
210
|
+
return EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_HKDF, EVP_PKEY_OP_DERIVE,
|
|
211
|
+
EVP_PKEY_CTRL_HKDF_MODE, mode, NULL);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
int EVP_PKEY_CTX_set_hkdf_md(EVP_PKEY_CTX *ctx, const EVP_MD *md) {
|
|
215
|
+
return EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_HKDF, EVP_PKEY_OP_DERIVE,
|
|
216
|
+
EVP_PKEY_CTRL_HKDF_MD, 0, (void *)md);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
int EVP_PKEY_CTX_set1_hkdf_key(EVP_PKEY_CTX *ctx, const uint8_t *key,
|
|
220
|
+
size_t key_len) {
|
|
221
|
+
CBS cbs;
|
|
222
|
+
CBS_init(&cbs, key, key_len);
|
|
223
|
+
return EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_HKDF, EVP_PKEY_OP_DERIVE,
|
|
224
|
+
EVP_PKEY_CTRL_HKDF_KEY, 0, &cbs);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
int EVP_PKEY_CTX_set1_hkdf_salt(EVP_PKEY_CTX *ctx, const uint8_t *salt,
|
|
228
|
+
size_t salt_len) {
|
|
229
|
+
CBS cbs;
|
|
230
|
+
CBS_init(&cbs, salt, salt_len);
|
|
231
|
+
return EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_HKDF, EVP_PKEY_OP_DERIVE,
|
|
232
|
+
EVP_PKEY_CTRL_HKDF_SALT, 0, &cbs);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
int EVP_PKEY_CTX_add1_hkdf_info(EVP_PKEY_CTX *ctx, const uint8_t *info,
|
|
236
|
+
size_t info_len) {
|
|
237
|
+
CBS cbs;
|
|
238
|
+
CBS_init(&cbs, info, info_len);
|
|
239
|
+
return EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_HKDF, EVP_PKEY_OP_DERIVE,
|
|
240
|
+
EVP_PKEY_CTRL_HKDF_INFO, 0, &cbs);
|
|
241
|
+
}
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
#include <string.h>
|
|
19
19
|
|
|
20
20
|
#include "../../internal.h"
|
|
21
|
+
#include "internal.h"
|
|
21
22
|
|
|
22
23
|
#if defined(OPENSSL_SSE2)
|
|
23
24
|
#include <emmintrin.h>
|
|
@@ -1181,29 +1182,27 @@ void aes_nohw_ctr32_encrypt_blocks(const uint8_t *in, uint8_t *out,
|
|
|
1181
1182
|
aes_nohw_expand_round_keys(&sched, key);
|
|
1182
1183
|
|
|
1183
1184
|
// Make |AES_NOHW_BATCH_SIZE| copies of |ivec|.
|
|
1184
|
-
alignas(AES_NOHW_WORD_SIZE)
|
|
1185
|
-
|
|
1186
|
-
uint8_t u8[AES_NOHW_BATCH_SIZE * 16];
|
|
1187
|
-
} ivs, enc_ivs;
|
|
1185
|
+
alignas(AES_NOHW_WORD_SIZE) uint8_t ivs[AES_NOHW_BATCH_SIZE * 16];
|
|
1186
|
+
alignas(AES_NOHW_WORD_SIZE) uint8_t enc_ivs[AES_NOHW_BATCH_SIZE * 16];
|
|
1188
1187
|
for (size_t i = 0; i < AES_NOHW_BATCH_SIZE; i++) {
|
|
1189
|
-
memcpy(ivs
|
|
1188
|
+
memcpy(ivs + 16 * i, ivec, 16);
|
|
1190
1189
|
}
|
|
1191
1190
|
|
|
1192
|
-
uint32_t ctr =
|
|
1191
|
+
uint32_t ctr = CRYPTO_load_u32_be(ivs + 12);
|
|
1193
1192
|
for (;;) {
|
|
1194
1193
|
// Update counters.
|
|
1195
1194
|
for (size_t i = 0; i < AES_NOHW_BATCH_SIZE; i++) {
|
|
1196
|
-
ivs
|
|
1195
|
+
CRYPTO_store_u32_be(ivs + 16 * i + 12, ctr + i);
|
|
1197
1196
|
}
|
|
1198
1197
|
|
|
1199
1198
|
size_t todo = blocks >= AES_NOHW_BATCH_SIZE ? AES_NOHW_BATCH_SIZE : blocks;
|
|
1200
1199
|
AES_NOHW_BATCH batch;
|
|
1201
|
-
aes_nohw_to_batch(&batch, ivs
|
|
1200
|
+
aes_nohw_to_batch(&batch, ivs, todo);
|
|
1202
1201
|
aes_nohw_encrypt_batch(&sched, key->rounds, &batch);
|
|
1203
|
-
aes_nohw_from_batch(enc_ivs
|
|
1202
|
+
aes_nohw_from_batch(enc_ivs, todo, &batch);
|
|
1204
1203
|
|
|
1205
1204
|
for (size_t i = 0; i < todo; i++) {
|
|
1206
|
-
aes_nohw_xor_block(out + 16 * i, in + 16 * i, enc_ivs
|
|
1205
|
+
aes_nohw_xor_block(out + 16 * i, in + 16 * i, enc_ivs + 16 * i);
|
|
1207
1206
|
}
|
|
1208
1207
|
|
|
1209
1208
|
blocks -= todo;
|
|
@@ -164,10 +164,8 @@ static const uint8_t kPaddingConstant[4] = {0xa6, 0x59, 0x59, 0xa6};
|
|
|
164
164
|
int AES_wrap_key_padded(const AES_KEY *key, uint8_t *out, size_t *out_len,
|
|
165
165
|
size_t max_out, const uint8_t *in, size_t in_len) {
|
|
166
166
|
// See https://tools.ietf.org/html/rfc5649#section-4.1
|
|
167
|
-
const uint32_t in_len32_be = CRYPTO_bswap4(in_len);
|
|
168
167
|
const uint64_t in_len64 = in_len;
|
|
169
168
|
const size_t padded_len = (in_len + 7) & ~7;
|
|
170
|
-
|
|
171
169
|
*out_len = 0;
|
|
172
170
|
if (in_len == 0 || in_len64 > 0xffffffffu || in_len + 7 < in_len ||
|
|
173
171
|
padded_len + 8 < padded_len || max_out < padded_len + 8) {
|
|
@@ -176,7 +174,7 @@ int AES_wrap_key_padded(const AES_KEY *key, uint8_t *out, size_t *out_len,
|
|
|
176
174
|
|
|
177
175
|
uint8_t block[AES_BLOCK_SIZE];
|
|
178
176
|
memcpy(block, kPaddingConstant, sizeof(kPaddingConstant));
|
|
179
|
-
|
|
177
|
+
CRYPTO_store_u32_be(block + 4, (uint32_t)in_len);
|
|
180
178
|
|
|
181
179
|
if (in_len <= 8) {
|
|
182
180
|
memset(block + 8, 0, 8);
|
|
@@ -226,9 +224,7 @@ int AES_unwrap_key_padded(const AES_KEY *key, uint8_t *out, size_t *out_len,
|
|
|
226
224
|
crypto_word_t ok = constant_time_eq_int(
|
|
227
225
|
CRYPTO_memcmp(iv, kPaddingConstant, sizeof(kPaddingConstant)), 0);
|
|
228
226
|
|
|
229
|
-
|
|
230
|
-
memcpy(&claimed_len32, iv + 4, sizeof(claimed_len32));
|
|
231
|
-
const size_t claimed_len = CRYPTO_bswap4(claimed_len32);
|
|
227
|
+
const size_t claimed_len = CRYPTO_load_u32_be(iv + 4);
|
|
232
228
|
ok &= ~constant_time_is_zero_w(claimed_len);
|
|
233
229
|
ok &= constant_time_eq_w((claimed_len - 1) >> 3, (in_len - 9) >> 3);
|
|
234
230
|
|
|
@@ -1016,14 +1016,16 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
|
|
1016
1016
|
tmp.neg = am.neg = 0;
|
|
1017
1017
|
tmp.flags = am.flags = BN_FLG_STATIC_DATA;
|
|
1018
1018
|
|
|
1019
|
-
if (!bn_one_to_montgomery(&tmp, mont, ctx)
|
|
1019
|
+
if (!bn_one_to_montgomery(&tmp, mont, ctx) ||
|
|
1020
|
+
!bn_resize_words(&tmp, top)) {
|
|
1020
1021
|
goto err;
|
|
1021
1022
|
}
|
|
1022
1023
|
|
|
1023
|
-
//
|
|
1024
|
+
// Prepare a^1 in the Montgomery domain.
|
|
1024
1025
|
assert(!a->neg);
|
|
1025
1026
|
assert(BN_ucmp(a, m) < 0);
|
|
1026
|
-
if (!BN_to_montgomery(&am, a, mont, ctx)
|
|
1027
|
+
if (!BN_to_montgomery(&am, a, mont, ctx) ||
|
|
1028
|
+
!bn_resize_words(&am, top)) {
|
|
1027
1029
|
goto err;
|
|
1028
1030
|
}
|
|
1029
1031
|
|
|
@@ -1047,14 +1049,6 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
|
|
1047
1049
|
// and its interaction with other parts of the project. Determine whether this
|
|
1048
1050
|
// is actually necessary for performance.
|
|
1049
1051
|
if (window == 5 && top > 1) {
|
|
1050
|
-
// Ensure |am| and |tmp| are padded to the right width.
|
|
1051
|
-
for (i = am.width; i < top; i++) {
|
|
1052
|
-
am.d[i] = 0;
|
|
1053
|
-
}
|
|
1054
|
-
for (i = tmp.width; i < top; i++) {
|
|
1055
|
-
tmp.d[i] = 0;
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1058
1052
|
// Copy |mont->N| to improve cache locality.
|
|
1059
1053
|
BN_ULONG *np = am.d + top;
|
|
1060
1054
|
for (i = 0; i < top; i++) {
|
|
@@ -391,7 +391,7 @@ void bn_scatter5(const BN_ULONG *inp, size_t num, BN_ULONG *table,
|
|
|
391
391
|
|
|
392
392
|
// bn_gather5 loads index |power| of |table| and stores it in |out|. |out| and
|
|
393
393
|
// each entry of |table| are |num| words long. |power| must be less than 32.
|
|
394
|
-
void bn_gather5(BN_ULONG *out, size_t num, BN_ULONG *table, size_t power);
|
|
394
|
+
void bn_gather5(BN_ULONG *out, size_t num, const BN_ULONG *table, size_t power);
|
|
395
395
|
|
|
396
396
|
// bn_power5 squares |ap| five times and multiplies it by the value stored at
|
|
397
397
|
// index |power| of |table|, modulo |np|. It stores the result in |rp|. The
|
|
@@ -386,6 +386,8 @@ int BN_GENCB_call(BN_GENCB *callback, int event, int n) {
|
|
|
386
386
|
return callback->callback(event, n, callback);
|
|
387
387
|
}
|
|
388
388
|
|
|
389
|
+
void *BN_GENCB_get_arg(const BN_GENCB *callback) { return callback->arg; }
|
|
390
|
+
|
|
389
391
|
int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add,
|
|
390
392
|
const BIGNUM *rem, BN_GENCB *cb) {
|
|
391
393
|
BIGNUM *t;
|