grpc 1.38.0 → 1.39.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +50 -19
- data/include/grpc/event_engine/endpoint_config.h +48 -0
- data/include/grpc/event_engine/event_engine.h +13 -15
- data/include/grpc/event_engine/port.h +2 -0
- data/include/grpc/event_engine/slice_allocator.h +17 -7
- data/include/grpc/grpc.h +9 -2
- data/include/grpc/grpc_security.h +32 -0
- data/include/grpc/grpc_security_constants.h +1 -0
- data/include/grpc/impl/codegen/grpc_types.h +17 -13
- data/include/grpc/impl/codegen/port_platform.h +17 -0
- data/src/core/ext/filters/client_channel/client_channel.cc +2 -2
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +2 -0
- data/src/core/ext/filters/client_channel/health/health_check_client.h +3 -3
- data/src/core/ext/filters/client_channel/http_proxy.cc +16 -1
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +755 -0
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +10 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +10 -24
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +63 -95
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +1 -3
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_event_engine.cc +31 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_event_engine.cc +28 -0
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +1 -3
- data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +7 -2
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +15 -3
- data/src/core/ext/filters/client_channel/retry_filter.cc +665 -404
- data/src/core/ext/filters/client_channel/retry_service_config.cc +43 -24
- data/src/core/ext/filters/client_channel/retry_service_config.h +8 -2
- data/src/core/ext/filters/client_idle/client_idle_filter.cc +1 -1
- data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +6 -0
- data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +2 -1
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +3 -2
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +10 -4
- data/src/core/ext/transport/chttp2/transport/internal.h +1 -0
- data/src/core/ext/transport/chttp2/transport/parsing.cc +2 -2
- data/src/core/ext/transport/inproc/inproc_transport.cc +42 -31
- data/src/core/ext/xds/xds_api.cc +247 -106
- data/src/core/ext/xds/xds_api.h +15 -6
- data/src/core/lib/address_utils/sockaddr_utils.cc +13 -0
- data/src/core/lib/address_utils/sockaddr_utils.h +10 -0
- data/src/core/lib/channel/channelz.h +3 -0
- data/src/core/lib/event_engine/endpoint_config.cc +46 -0
- data/src/core/lib/event_engine/endpoint_config_internal.h +42 -0
- data/src/core/lib/event_engine/event_engine.cc +50 -0
- data/src/core/lib/event_engine/slice_allocator.cc +33 -3
- data/src/core/lib/event_engine/sockaddr.cc +14 -12
- data/src/core/lib/event_engine/sockaddr.h +44 -0
- data/src/core/lib/gpr/wrap_memcpy.cc +2 -1
- data/src/core/lib/gprpp/status_helper.h +3 -0
- data/src/core/lib/iomgr/endpoint_pair_event_engine.cc +33 -0
- data/src/core/lib/iomgr/error.cc +5 -4
- data/src/core/lib/iomgr/error.h +1 -1
- data/src/core/lib/iomgr/event_engine/closure.cc +54 -0
- data/src/core/lib/iomgr/event_engine/closure.h +33 -0
- data/src/core/lib/iomgr/event_engine/endpoint.cc +194 -0
- data/src/core/lib/iomgr/event_engine/endpoint.h +53 -0
- data/src/core/lib/iomgr/event_engine/iomgr.cc +105 -0
- data/src/core/lib/iomgr/event_engine/iomgr.h +24 -0
- data/src/core/lib/iomgr/event_engine/pollset.cc +87 -0
- data/{include/grpc/event_engine/channel_args.h → src/core/lib/iomgr/event_engine/pollset.h} +7 -10
- data/src/core/lib/iomgr/event_engine/promise.h +51 -0
- data/src/core/lib/iomgr/event_engine/resolved_address_internal.cc +41 -0
- data/src/core/lib/iomgr/event_engine/resolved_address_internal.h +35 -0
- data/src/core/lib/iomgr/event_engine/resolver.cc +110 -0
- data/src/core/lib/iomgr/event_engine/tcp.cc +243 -0
- data/src/core/lib/iomgr/event_engine/timer.cc +57 -0
- data/src/core/lib/iomgr/exec_ctx.cc +8 -0
- data/src/core/lib/iomgr/exec_ctx.h +3 -4
- data/src/core/lib/iomgr/executor/threadpool.cc +2 -3
- data/src/core/lib/iomgr/executor/threadpool.h +2 -2
- data/src/core/lib/iomgr/iomgr.cc +1 -1
- data/src/core/lib/iomgr/iomgr_posix.cc +2 -0
- data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +40 -10
- data/src/core/lib/iomgr/pollset_custom.cc +2 -2
- data/src/core/lib/iomgr/pollset_custom.h +3 -1
- data/src/core/lib/iomgr/pollset_uv.cc +3 -1
- data/src/core/lib/iomgr/pollset_uv.h +5 -1
- data/src/core/lib/iomgr/port.h +7 -5
- data/src/core/lib/iomgr/resolve_address.cc +5 -1
- data/src/core/lib/iomgr/resolve_address.h +6 -0
- data/src/core/lib/iomgr/sockaddr.h +1 -0
- data/src/core/lib/iomgr/socket_mutator.cc +15 -2
- data/src/core/lib/iomgr/socket_mutator.h +26 -2
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +4 -4
- data/src/core/lib/iomgr/socket_utils_posix.h +2 -2
- data/src/core/lib/iomgr/tcp_client_posix.cc +7 -2
- data/src/core/lib/iomgr/tcp_posix.cc +42 -39
- data/src/core/lib/iomgr/tcp_posix.h +8 -0
- data/src/core/lib/iomgr/tcp_server_custom.cc +3 -4
- data/src/core/lib/iomgr/tcp_server_posix.cc +6 -0
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +2 -1
- data/src/core/lib/iomgr/timer.h +6 -1
- data/src/core/lib/security/authorization/authorization_engine.h +44 -0
- data/src/core/lib/security/authorization/authorization_policy_provider.h +32 -0
- data/src/core/lib/security/authorization/authorization_policy_provider_vtable.cc +46 -0
- data/src/core/lib/security/authorization/evaluate_args.cc +209 -0
- data/src/core/lib/security/authorization/evaluate_args.h +91 -0
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +3 -1
- data/src/core/lib/security/credentials/tls/tls_utils.cc +32 -0
- data/src/core/lib/security/credentials/tls/tls_utils.h +13 -0
- data/src/core/lib/security/security_connector/local/local_security_connector.cc +9 -6
- data/src/core/lib/security/security_connector/ssl_utils.cc +5 -0
- data/src/core/lib/surface/call.cc +21 -1
- data/src/core/lib/surface/call.h +11 -0
- data/src/core/lib/surface/completion_queue.cc +22 -22
- data/src/core/lib/surface/completion_queue.h +1 -1
- data/src/core/lib/surface/completion_queue_factory.cc +1 -2
- data/src/core/lib/surface/init.cc +1 -3
- data/src/core/lib/surface/init.h +10 -1
- data/src/core/lib/surface/version.cc +1 -1
- data/src/core/lib/transport/error_utils.cc +2 -2
- data/src/core/lib/transport/transport.h +2 -0
- data/src/core/lib/transport/transport_op_string.cc +1 -1
- data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -0
- data/src/core/tsi/alts/crypt/gsec.h +2 -0
- data/src/ruby/ext/grpc/extconf.rb +2 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +6 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +10 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/third_party/boringssl-with-bazel/err_data.c +269 -263
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +8 -6
- data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/cipher_extra.c +4 -0
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/curve25519/internal.h +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/evp/evp.c +9 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/prime.c +0 -4
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digest.c +7 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/md32_common.h +87 -121
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md4/md4.c +20 -30
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md5/md5.c +19 -30
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +1 -4
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +0 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +26 -24
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +10 -7
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha1.c +28 -39
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha256.c +48 -66
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha512.c +4 -5
- data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +362 -371
- data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7_x509.c +4 -2
- data/third_party/boringssl-with-bazel/src/crypto/rand_extra/passive.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/rsa_asn1.c +1 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509/internal.h +101 -11
- data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509a.c +3 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +3 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +2 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +14 -15
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vpm.c +53 -73
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +31 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509rset.c +3 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_all.c +3 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_req.c +5 -8
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_sig.c +5 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509a.c +3 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +7 -0
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +5 -8
- data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +1 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +66 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/base.h +40 -9
- data/third_party/boringssl-with-bazel/src/include/openssl/bytestring.h +1 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/chacha.h +1 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +6 -2
- data/third_party/boringssl-with-bazel/src/include/openssl/ecdsa.h +14 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +19 -11
- data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +325 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/pkcs7.h +23 -7
- data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +99 -63
- data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +139 -109
- data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +12 -19
- data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +48 -50
- data/third_party/boringssl-with-bazel/src/include/openssl/x509_vfy.h +451 -435
- data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +0 -1
- data/third_party/boringssl-with-bazel/src/ssl/d1_both.cc +2 -2
- data/third_party/boringssl-with-bazel/src/ssl/d1_srtp.cc +1 -1
- data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +773 -84
- data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +80 -47
- data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +24 -19
- data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +189 -86
- data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +45 -56
- data/third_party/boringssl-with-bazel/src/ssl/internal.h +272 -167
- data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +2 -2
- data/third_party/boringssl-with-bazel/src/ssl/s3_lib.cc +2 -2
- data/third_party/boringssl-with-bazel/src/ssl/s3_pkt.cc +14 -19
- data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +34 -102
- data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +2 -0
- data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +8 -31
- data/third_party/boringssl-with-bazel/src/ssl/ssl_stat.cc +3 -0
- data/third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc +4 -3
- data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +7 -3
- data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +576 -648
- data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +31 -3
- data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +98 -39
- data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +141 -94
- data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +58 -68
- metadata +65 -40
- data/third_party/boringssl-with-bazel/src/crypto/hpke/internal.h +0 -267
- data/third_party/boringssl-with-bazel/src/crypto/x509/vpm_int.h +0 -71
@@ -60,8 +60,9 @@
|
|
60
60
|
|
61
61
|
#include <openssl/mem.h>
|
62
62
|
|
63
|
-
#include "internal.h"
|
64
63
|
#include "../../internal.h"
|
64
|
+
#include "../digest/md32_common.h"
|
65
|
+
#include "internal.h"
|
65
66
|
|
66
67
|
|
67
68
|
uint8_t *MD5(const uint8_t *data, size_t len, uint8_t out[MD5_DIGEST_LENGTH]) {
|
@@ -89,29 +90,26 @@ static void md5_block_data_order(uint32_t *state, const uint8_t *data,
|
|
89
90
|
size_t num);
|
90
91
|
#endif
|
91
92
|
|
93
|
+
void MD5_Transform(MD5_CTX *c, const uint8_t data[MD5_CBLOCK]) {
|
94
|
+
md5_block_data_order(c->h, data, 1);
|
95
|
+
}
|
92
96
|
|
93
|
-
|
97
|
+
int MD5_Update(MD5_CTX *c, const void *data, size_t len) {
|
98
|
+
crypto_md32_update(&md5_block_data_order, c->h, c->data, MD5_CBLOCK, &c->num,
|
99
|
+
&c->Nh, &c->Nl, data, len);
|
100
|
+
return 1;
|
101
|
+
}
|
94
102
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
#define HASH_UPDATE MD5_Update
|
99
|
-
#define HASH_TRANSFORM MD5_Transform
|
100
|
-
#define HASH_FINAL MD5_Final
|
101
|
-
#define HASH_MAKE_STRING(c, s) \
|
102
|
-
do { \
|
103
|
-
CRYPTO_store_u32_le((s), (c)->h[0]); \
|
104
|
-
(s) += 4; \
|
105
|
-
CRYPTO_store_u32_le((s), (c)->h[1]); \
|
106
|
-
(s) += 4; \
|
107
|
-
CRYPTO_store_u32_le((s), (c)->h[2]); \
|
108
|
-
(s) += 4; \
|
109
|
-
CRYPTO_store_u32_le((s), (c)->h[3]); \
|
110
|
-
(s) += 4; \
|
111
|
-
} while (0)
|
112
|
-
#define HASH_BLOCK_DATA_ORDER md5_block_data_order
|
103
|
+
int MD5_Final(uint8_t out[MD5_DIGEST_LENGTH], MD5_CTX *c) {
|
104
|
+
crypto_md32_final(&md5_block_data_order, c->h, c->data, MD5_CBLOCK, &c->num,
|
105
|
+
c->Nh, c->Nl, /*is_big_endian=*/0);
|
113
106
|
|
114
|
-
|
107
|
+
CRYPTO_store_u32_le(out, c->h[0]);
|
108
|
+
CRYPTO_store_u32_le(out + 4, c->h[1]);
|
109
|
+
CRYPTO_store_u32_le(out + 8, c->h[2]);
|
110
|
+
CRYPTO_store_u32_le(out + 12, c->h[3]);
|
111
|
+
return 1;
|
112
|
+
}
|
115
113
|
|
116
114
|
// As pointed out by Wei Dai <weidai@eskimo.com>, the above can be
|
117
115
|
// simplified to the code below. Wei attributes these optimizations
|
@@ -278,15 +276,6 @@ static void md5_block_data_order(uint32_t *state, const uint8_t *data,
|
|
278
276
|
#undef X
|
279
277
|
#endif
|
280
278
|
|
281
|
-
#undef DATA_ORDER_IS_LITTLE_ENDIAN
|
282
|
-
#undef HASH_CTX
|
283
|
-
#undef HASH_CBLOCK
|
284
|
-
#undef HASH_DIGEST_LENGTH
|
285
|
-
#undef HASH_UPDATE
|
286
|
-
#undef HASH_TRANSFORM
|
287
|
-
#undef HASH_FINAL
|
288
|
-
#undef HASH_MAKE_STRING
|
289
|
-
#undef HASH_BLOCK_DATA_ORDER
|
290
279
|
#undef F
|
291
280
|
#undef G
|
292
281
|
#undef H
|
@@ -45,12 +45,10 @@ void RAND_bytes_with_additional_data(uint8_t *out, size_t out_len,
|
|
45
45
|
// for seeding a DRBG, to |out_entropy|. It sets |*out_used_cpu| to one if the
|
46
46
|
// entropy came directly from the CPU and zero if it came from the OS. It
|
47
47
|
// actively obtains entropy from the CPU/OS and so should not be called from
|
48
|
-
// within the FIPS module
|
48
|
+
// within the FIPS module.
|
49
49
|
void CRYPTO_get_seed_entropy(uint8_t *out_entropy, size_t out_entropy_len,
|
50
50
|
int *out_used_cpu);
|
51
51
|
|
52
|
-
#if defined(BORINGSSL_FIPS_PASSIVE_ENTROPY)
|
53
|
-
|
54
52
|
// RAND_load_entropy supplies |entropy_len| bytes of entropy to the module. The
|
55
53
|
// |from_cpu| parameter is true iff the entropy was obtained directly from the
|
56
54
|
// CPU.
|
@@ -61,7 +59,6 @@ void RAND_load_entropy(const uint8_t *entropy, size_t entropy_len,
|
|
61
59
|
// when the module has stopped because it has run out of entropy.
|
62
60
|
void RAND_need_entropy(size_t bytes_needed);
|
63
61
|
|
64
|
-
#endif // BORINGSSL_FIPS_PASSIVE_ENTROPY
|
65
62
|
#endif // BORINGSSL_FIPS
|
66
63
|
|
67
64
|
// CRYPTO_sysrand fills |len| bytes at |buf| with entropy from the operating
|
@@ -178,8 +178,6 @@ void CRYPTO_get_seed_entropy(uint8_t *out_entropy, size_t out_entropy_len,
|
|
178
178
|
#endif
|
179
179
|
}
|
180
180
|
|
181
|
-
#if defined(BORINGSSL_FIPS_PASSIVE_ENTROPY)
|
182
|
-
|
183
181
|
// In passive entropy mode, entropy is supplied from outside of the module via
|
184
182
|
// |RAND_load_entropy| and is stored in global instance of the following
|
185
183
|
// structure.
|
@@ -242,17 +240,6 @@ static void get_seed_entropy(uint8_t *out_entropy, size_t out_entropy_len,
|
|
242
240
|
CRYPTO_STATIC_MUTEX_unlock_write(entropy_buffer_lock_bss_get());
|
243
241
|
}
|
244
242
|
|
245
|
-
#else
|
246
|
-
|
247
|
-
// In the active case, |get_seed_entropy| simply calls |CRYPTO_get_seed_entropy|
|
248
|
-
// in order to obtain entropy from the CPU or OS.
|
249
|
-
static void get_seed_entropy(uint8_t *out_entropy, size_t out_entropy_len,
|
250
|
-
int *out_used_cpu) {
|
251
|
-
CRYPTO_get_seed_entropy(out_entropy, out_entropy_len, out_used_cpu);
|
252
|
-
}
|
253
|
-
|
254
|
-
#endif // !BORINGSSL_FIPS_PASSIVE_ENTROPY
|
255
|
-
|
256
243
|
// rand_get_seed fills |seed| with entropy and sets |*out_used_cpu| to one if
|
257
244
|
// that entropy came directly from the CPU and zero otherwise.
|
258
245
|
static void rand_get_seed(struct rand_thread_state *state,
|
@@ -458,18 +458,18 @@ static const struct pkcs1_sig_prefix kPKCS1SigPrefixes[] = {
|
|
458
458
|
};
|
459
459
|
|
460
460
|
int RSA_add_pkcs1_prefix(uint8_t **out_msg, size_t *out_msg_len,
|
461
|
-
int *is_alloced, int hash_nid, const uint8_t *
|
462
|
-
size_t
|
461
|
+
int *is_alloced, int hash_nid, const uint8_t *digest,
|
462
|
+
size_t digest_len) {
|
463
463
|
unsigned i;
|
464
464
|
|
465
465
|
if (hash_nid == NID_md5_sha1) {
|
466
466
|
// Special case: SSL signature, just check the length.
|
467
|
-
if (
|
467
|
+
if (digest_len != SSL_SIG_LENGTH) {
|
468
468
|
OPENSSL_PUT_ERROR(RSA, RSA_R_INVALID_MESSAGE_LENGTH);
|
469
469
|
return 0;
|
470
470
|
}
|
471
471
|
|
472
|
-
*out_msg = (uint8_t*)
|
472
|
+
*out_msg = (uint8_t *)digest;
|
473
473
|
*out_msg_len = SSL_SIG_LENGTH;
|
474
474
|
*is_alloced = 0;
|
475
475
|
return 1;
|
@@ -481,7 +481,7 @@ int RSA_add_pkcs1_prefix(uint8_t **out_msg, size_t *out_msg_len,
|
|
481
481
|
continue;
|
482
482
|
}
|
483
483
|
|
484
|
-
if (
|
484
|
+
if (digest_len != sig_prefix->hash_len) {
|
485
485
|
OPENSSL_PUT_ERROR(RSA, RSA_R_INVALID_MESSAGE_LENGTH);
|
486
486
|
return 0;
|
487
487
|
}
|
@@ -491,7 +491,7 @@ int RSA_add_pkcs1_prefix(uint8_t **out_msg, size_t *out_msg_len,
|
|
491
491
|
unsigned signed_msg_len;
|
492
492
|
uint8_t *signed_msg;
|
493
493
|
|
494
|
-
signed_msg_len = prefix_len +
|
494
|
+
signed_msg_len = prefix_len + digest_len;
|
495
495
|
if (signed_msg_len < prefix_len) {
|
496
496
|
OPENSSL_PUT_ERROR(RSA, RSA_R_TOO_LONG);
|
497
497
|
return 0;
|
@@ -504,7 +504,7 @@ int RSA_add_pkcs1_prefix(uint8_t **out_msg, size_t *out_msg_len,
|
|
504
504
|
}
|
505
505
|
|
506
506
|
OPENSSL_memcpy(signed_msg, prefix, prefix_len);
|
507
|
-
OPENSSL_memcpy(signed_msg + prefix_len,
|
507
|
+
OPENSSL_memcpy(signed_msg + prefix_len, digest, digest_len);
|
508
508
|
|
509
509
|
*out_msg = signed_msg;
|
510
510
|
*out_msg_len = signed_msg_len;
|
@@ -517,8 +517,8 @@ int RSA_add_pkcs1_prefix(uint8_t **out_msg, size_t *out_msg_len,
|
|
517
517
|
return 0;
|
518
518
|
}
|
519
519
|
|
520
|
-
int RSA_sign(int hash_nid, const uint8_t *
|
521
|
-
unsigned *out_len, RSA *rsa) {
|
520
|
+
int RSA_sign(int hash_nid, const uint8_t *digest, unsigned digest_len,
|
521
|
+
uint8_t *out, unsigned *out_len, RSA *rsa) {
|
522
522
|
const unsigned rsa_size = RSA_size(rsa);
|
523
523
|
int ret = 0;
|
524
524
|
uint8_t *signed_msg = NULL;
|
@@ -527,11 +527,12 @@ int RSA_sign(int hash_nid, const uint8_t *in, unsigned in_len, uint8_t *out,
|
|
527
527
|
size_t size_t_out_len;
|
528
528
|
|
529
529
|
if (rsa->meth->sign) {
|
530
|
-
return rsa->meth->sign(hash_nid,
|
530
|
+
return rsa->meth->sign(hash_nid, digest, digest_len, out, out_len, rsa);
|
531
531
|
}
|
532
532
|
|
533
533
|
if (!RSA_add_pkcs1_prefix(&signed_msg, &signed_msg_len,
|
534
|
-
&signed_msg_is_alloced, hash_nid,
|
534
|
+
&signed_msg_is_alloced, hash_nid, digest,
|
535
|
+
digest_len) ||
|
535
536
|
!RSA_sign_raw(rsa, &size_t_out_len, out, rsa_size, signed_msg,
|
536
537
|
signed_msg_len, RSA_PKCS1_PADDING)) {
|
537
538
|
goto err;
|
@@ -548,9 +549,9 @@ err:
|
|
548
549
|
}
|
549
550
|
|
550
551
|
int RSA_sign_pss_mgf1(RSA *rsa, size_t *out_len, uint8_t *out, size_t max_out,
|
551
|
-
const uint8_t *
|
552
|
-
const EVP_MD *mgf1_md, int salt_len) {
|
553
|
-
if (
|
552
|
+
const uint8_t *digest, size_t digest_len,
|
553
|
+
const EVP_MD *md, const EVP_MD *mgf1_md, int salt_len) {
|
554
|
+
if (digest_len != EVP_MD_size(md)) {
|
554
555
|
OPENSSL_PUT_ERROR(RSA, RSA_R_INVALID_MESSAGE_LENGTH);
|
555
556
|
return 0;
|
556
557
|
}
|
@@ -562,15 +563,15 @@ int RSA_sign_pss_mgf1(RSA *rsa, size_t *out_len, uint8_t *out, size_t max_out,
|
|
562
563
|
return 0;
|
563
564
|
}
|
564
565
|
|
565
|
-
int ret =
|
566
|
-
|
567
|
-
|
568
|
-
|
566
|
+
int ret = RSA_padding_add_PKCS1_PSS_mgf1(rsa, padded, digest, md, mgf1_md,
|
567
|
+
salt_len) &&
|
568
|
+
RSA_sign_raw(rsa, out_len, out, max_out, padded, padded_len,
|
569
|
+
RSA_NO_PADDING);
|
569
570
|
OPENSSL_free(padded);
|
570
571
|
return ret;
|
571
572
|
}
|
572
573
|
|
573
|
-
int RSA_verify(int hash_nid, const uint8_t *
|
574
|
+
int RSA_verify(int hash_nid, const uint8_t *digest, size_t digest_len,
|
574
575
|
const uint8_t *sig, size_t sig_len, RSA *rsa) {
|
575
576
|
if (rsa->n == NULL || rsa->e == NULL) {
|
576
577
|
OPENSSL_PUT_ERROR(RSA, RSA_R_VALUE_MISSING);
|
@@ -584,7 +585,7 @@ int RSA_verify(int hash_nid, const uint8_t *msg, size_t msg_len,
|
|
584
585
|
size_t signed_msg_len = 0, len;
|
585
586
|
int signed_msg_is_alloced = 0;
|
586
587
|
|
587
|
-
if (hash_nid == NID_md5_sha1 &&
|
588
|
+
if (hash_nid == NID_md5_sha1 && digest_len != SSL_SIG_LENGTH) {
|
588
589
|
OPENSSL_PUT_ERROR(RSA, RSA_R_INVALID_MESSAGE_LENGTH);
|
589
590
|
return 0;
|
590
591
|
}
|
@@ -601,7 +602,8 @@ int RSA_verify(int hash_nid, const uint8_t *msg, size_t msg_len,
|
|
601
602
|
}
|
602
603
|
|
603
604
|
if (!RSA_add_pkcs1_prefix(&signed_msg, &signed_msg_len,
|
604
|
-
&signed_msg_is_alloced, hash_nid,
|
605
|
+
&signed_msg_is_alloced, hash_nid, digest,
|
606
|
+
digest_len)) {
|
605
607
|
goto out;
|
606
608
|
}
|
607
609
|
|
@@ -622,10 +624,10 @@ out:
|
|
622
624
|
return ret;
|
623
625
|
}
|
624
626
|
|
625
|
-
int RSA_verify_pss_mgf1(RSA *rsa, const uint8_t *
|
627
|
+
int RSA_verify_pss_mgf1(RSA *rsa, const uint8_t *digest, size_t digest_len,
|
626
628
|
const EVP_MD *md, const EVP_MD *mgf1_md, int salt_len,
|
627
629
|
const uint8_t *sig, size_t sig_len) {
|
628
|
-
if (
|
630
|
+
if (digest_len != EVP_MD_size(md)) {
|
629
631
|
OPENSSL_PUT_ERROR(RSA, RSA_R_INVALID_MESSAGE_LENGTH);
|
630
632
|
return 0;
|
631
633
|
}
|
@@ -647,7 +649,7 @@ int RSA_verify_pss_mgf1(RSA *rsa, const uint8_t *msg, size_t msg_len,
|
|
647
649
|
goto err;
|
648
650
|
}
|
649
651
|
|
650
|
-
ret = RSA_verify_PKCS1_PSS_mgf1(rsa,
|
652
|
+
ret = RSA_verify_PKCS1_PSS_mgf1(rsa, digest, md, mgf1_md, em, salt_len);
|
651
653
|
|
652
654
|
err:
|
653
655
|
OPENSSL_free(em);
|
@@ -79,9 +79,8 @@ int rsa_check_public_key(const RSA *rsa) {
|
|
79
79
|
return 0;
|
80
80
|
}
|
81
81
|
|
82
|
-
unsigned
|
83
|
-
|
84
|
-
if (rsa_bits > 16 * 1024) {
|
82
|
+
unsigned n_bits = BN_num_bits(rsa->n);
|
83
|
+
if (n_bits > 16 * 1024) {
|
85
84
|
OPENSSL_PUT_ERROR(RSA, RSA_R_MODULUS_TOO_LARGE);
|
86
85
|
return 0;
|
87
86
|
}
|
@@ -96,17 +95,21 @@ int rsa_check_public_key(const RSA *rsa) {
|
|
96
95
|
// [2] https://www.imperialviolet.org/2012/03/17/rsados.html
|
97
96
|
// [3] https://msdn.microsoft.com/en-us/library/aa387685(VS.85).aspx
|
98
97
|
static const unsigned kMaxExponentBits = 33;
|
99
|
-
|
100
|
-
if (
|
98
|
+
unsigned e_bits = BN_num_bits(rsa->e);
|
99
|
+
if (e_bits > kMaxExponentBits ||
|
100
|
+
// Additionally reject e = 1 or even e. e must be odd to be relatively
|
101
|
+
// prime with phi(n).
|
102
|
+
e_bits < 2 ||
|
103
|
+
!BN_is_odd(rsa->e)) {
|
101
104
|
OPENSSL_PUT_ERROR(RSA, RSA_R_BAD_E_VALUE);
|
102
105
|
return 0;
|
103
106
|
}
|
104
107
|
|
105
|
-
// Verify |n > e|. Comparing |
|
108
|
+
// Verify |n > e|. Comparing |n_bits| to |kMaxExponentBits| is a small
|
106
109
|
// shortcut to comparing |n| and |e| directly. In reality, |kMaxExponentBits|
|
107
110
|
// is much smaller than the minimum RSA key size that any application should
|
108
111
|
// accept.
|
109
|
-
if (
|
112
|
+
if (n_bits <= kMaxExponentBits) {
|
110
113
|
OPENSSL_PUT_ERROR(RSA, RSA_R_KEY_SIZE_TOO_SMALL);
|
111
114
|
return 0;
|
112
115
|
}
|
@@ -60,8 +60,9 @@
|
|
60
60
|
|
61
61
|
#include <openssl/mem.h>
|
62
62
|
|
63
|
-
#include "internal.h"
|
64
63
|
#include "../../internal.h"
|
64
|
+
#include "../digest/md32_common.h"
|
65
|
+
#include "internal.h"
|
65
66
|
|
66
67
|
|
67
68
|
int SHA1_Init(SHA_CTX *sha) {
|
@@ -83,29 +84,33 @@ uint8_t *SHA1(const uint8_t *data, size_t len, uint8_t out[SHA_DIGEST_LENGTH]) {
|
|
83
84
|
return out;
|
84
85
|
}
|
85
86
|
|
86
|
-
#
|
87
|
-
|
88
|
-
|
89
|
-
#
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
87
|
+
#if !defined(SHA1_ASM)
|
88
|
+
static void sha1_block_data_order(uint32_t *state, const uint8_t *data,
|
89
|
+
size_t num);
|
90
|
+
#endif
|
91
|
+
|
92
|
+
void SHA1_Transform(SHA_CTX *c, const uint8_t data[SHA_CBLOCK]) {
|
93
|
+
sha1_block_data_order(c->h, data, 1);
|
94
|
+
}
|
95
|
+
|
96
|
+
int SHA1_Update(SHA_CTX *c, const void *data, size_t len) {
|
97
|
+
crypto_md32_update(&sha1_block_data_order, c->h, c->data, SHA_CBLOCK, &c->num,
|
98
|
+
&c->Nh, &c->Nl, data, len);
|
99
|
+
return 1;
|
100
|
+
}
|
101
|
+
|
102
|
+
int SHA1_Final(uint8_t out[SHA_DIGEST_LENGTH], SHA_CTX *c) {
|
103
|
+
crypto_md32_final(&sha1_block_data_order, c->h, c->data, SHA_CBLOCK, &c->num,
|
104
|
+
c->Nh, c->Nl, /*is_big_endian=*/1);
|
105
|
+
|
106
|
+
CRYPTO_store_u32_be(out, c->h[0]);
|
107
|
+
CRYPTO_store_u32_be(out + 4, c->h[1]);
|
108
|
+
CRYPTO_store_u32_be(out + 8, c->h[2]);
|
109
|
+
CRYPTO_store_u32_be(out + 12, c->h[3]);
|
110
|
+
CRYPTO_store_u32_be(out + 16, c->h[4]);
|
111
|
+
return 1;
|
112
|
+
}
|
104
113
|
|
105
|
-
#define HASH_UPDATE SHA1_Update
|
106
|
-
#define HASH_TRANSFORM SHA1_Transform
|
107
|
-
#define HASH_FINAL SHA1_Final
|
108
|
-
#define HASH_BLOCK_DATA_ORDER sha1_block_data_order
|
109
114
|
#define ROTATE(a, n) (((a) << (n)) | ((a) >> (32 - (n))))
|
110
115
|
#define Xupdate(a, ix, ia, ib, ic, id) \
|
111
116
|
do { \
|
@@ -113,13 +118,6 @@ uint8_t *SHA1(const uint8_t *data, size_t len, uint8_t out[SHA_DIGEST_LENGTH]) {
|
|
113
118
|
(ix) = (a) = ROTATE((a), 1); \
|
114
119
|
} while (0)
|
115
120
|
|
116
|
-
#if !defined(SHA1_ASM)
|
117
|
-
static void sha1_block_data_order(uint32_t *state, const uint8_t *data,
|
118
|
-
size_t num);
|
119
|
-
#endif
|
120
|
-
|
121
|
-
#include "../digest/md32_common.h"
|
122
|
-
|
123
121
|
#define K_00_19 0x5a827999UL
|
124
122
|
#define K_20_39 0x6ed9eba1UL
|
125
123
|
#define K_40_59 0x8f1bbcdcUL
|
@@ -340,15 +338,6 @@ static void sha1_block_data_order(uint32_t *state, const uint8_t *data,
|
|
340
338
|
}
|
341
339
|
#endif
|
342
340
|
|
343
|
-
#undef DATA_ORDER_IS_BIG_ENDIAN
|
344
|
-
#undef HASH_CTX
|
345
|
-
#undef HASH_CBLOCK
|
346
|
-
#undef HASH_DIGEST_LENGTH
|
347
|
-
#undef HASH_MAKE_STRING
|
348
|
-
#undef HASH_UPDATE
|
349
|
-
#undef HASH_TRANSFORM
|
350
|
-
#undef HASH_FINAL
|
351
|
-
#undef HASH_BLOCK_DATA_ORDER
|
352
341
|
#undef ROTATE
|
353
342
|
#undef Xupdate
|
354
343
|
#undef K_00_19
|
@@ -60,8 +60,9 @@
|
|
60
60
|
|
61
61
|
#include <openssl/mem.h>
|
62
62
|
|
63
|
-
#include "internal.h"
|
64
63
|
#include "../../internal.h"
|
64
|
+
#include "../digest/md32_common.h"
|
65
|
+
#include "internal.h"
|
65
66
|
|
66
67
|
|
67
68
|
int SHA224_Init(SHA256_CTX *sha) {
|
@@ -112,70 +113,60 @@ uint8_t *SHA256(const uint8_t *data, size_t len,
|
|
112
113
|
return out;
|
113
114
|
}
|
114
115
|
|
115
|
-
|
116
|
-
|
117
|
-
|
116
|
+
#ifndef SHA256_ASM
|
117
|
+
static void sha256_block_data_order(uint32_t *state, const uint8_t *in,
|
118
|
+
size_t num);
|
119
|
+
#endif
|
118
120
|
|
119
|
-
|
120
|
-
|
121
|
-
// smaller output.
|
122
|
-
return SHA256_Final(out, ctx);
|
121
|
+
void SHA256_Transform(SHA256_CTX *c, const uint8_t data[SHA256_CBLOCK]) {
|
122
|
+
sha256_block_data_order(c->h, data, 1);
|
123
123
|
}
|
124
124
|
|
125
|
-
|
125
|
+
int SHA256_Update(SHA256_CTX *c, const void *data, size_t len) {
|
126
|
+
crypto_md32_update(&sha256_block_data_order, c->h, c->data, SHA256_CBLOCK,
|
127
|
+
&c->num, &c->Nh, &c->Nl, data, len);
|
128
|
+
return 1;
|
129
|
+
}
|
126
130
|
|
127
|
-
|
128
|
-
|
129
|
-
|
131
|
+
int SHA224_Update(SHA256_CTX *ctx, const void *data, size_t len) {
|
132
|
+
return SHA256_Update(ctx, data, len);
|
133
|
+
}
|
130
134
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
// then default: case shall be extended. For reference. Idea behind separate
|
135
|
-
// cases for pre-defined lenghts is to let the compiler decide if it's
|
136
|
-
// appropriate to unroll small loops.
|
137
|
-
//
|
138
|
-
// TODO(davidben): The small |md_len| case is one of the few places a low-level
|
139
|
-
// hash 'final' function can fail. This should never happen.
|
140
|
-
#define HASH_MAKE_STRING(c, s) \
|
141
|
-
do { \
|
142
|
-
unsigned int nn; \
|
143
|
-
switch ((c)->md_len) { \
|
144
|
-
case SHA224_DIGEST_LENGTH: \
|
145
|
-
for (nn = 0; nn < SHA224_DIGEST_LENGTH / 4; nn++) { \
|
146
|
-
CRYPTO_store_u32_be((s), (c)->h[nn]); \
|
147
|
-
(s) += 4; \
|
148
|
-
} \
|
149
|
-
break; \
|
150
|
-
case SHA256_DIGEST_LENGTH: \
|
151
|
-
for (nn = 0; nn < SHA256_DIGEST_LENGTH / 4; nn++) { \
|
152
|
-
CRYPTO_store_u32_be((s), (c)->h[nn]); \
|
153
|
-
(s) += 4; \
|
154
|
-
} \
|
155
|
-
break; \
|
156
|
-
default: \
|
157
|
-
if ((c)->md_len > SHA256_DIGEST_LENGTH) { \
|
158
|
-
return 0; \
|
159
|
-
} \
|
160
|
-
for (nn = 0; nn < (c)->md_len / 4; nn++) { \
|
161
|
-
CRYPTO_store_u32_be((s), (c)->h[nn]); \
|
162
|
-
(s) += 4; \
|
163
|
-
} \
|
164
|
-
break; \
|
165
|
-
} \
|
166
|
-
} while (0)
|
135
|
+
static int sha256_final_impl(uint8_t *out, SHA256_CTX *c) {
|
136
|
+
crypto_md32_final(&sha256_block_data_order, c->h, c->data, SHA256_CBLOCK,
|
137
|
+
&c->num, c->Nh, c->Nl, /*is_big_endian=*/1);
|
167
138
|
|
139
|
+
// TODO(davidben): This overflow check one of the few places a low-level hash
|
140
|
+
// 'final' function can fail. SHA-512 does not have a corresponding check.
|
141
|
+
// These functions already misbehave if the caller arbitrarily mutates |c|, so
|
142
|
+
// can we assume one of |SHA256_Init| or |SHA224_Init| was used?
|
143
|
+
if (c->md_len > SHA256_DIGEST_LENGTH) {
|
144
|
+
return 0;
|
145
|
+
}
|
168
146
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
147
|
+
assert(c->md_len % 4 == 0);
|
148
|
+
const size_t out_words = c->md_len / 4;
|
149
|
+
for (size_t i = 0; i < out_words; i++) {
|
150
|
+
CRYPTO_store_u32_be(out, c->h[i]);
|
151
|
+
out += 4;
|
152
|
+
}
|
153
|
+
return 1;
|
154
|
+
}
|
177
155
|
|
178
|
-
|
156
|
+
int SHA256_Final(uint8_t out[SHA256_DIGEST_LENGTH], SHA256_CTX *c) {
|
157
|
+
// Ideally we would assert |sha->md_len| is |SHA256_DIGEST_LENGTH| to match
|
158
|
+
// the size hint, but calling code often pairs |SHA224_Init| with
|
159
|
+
// |SHA256_Final| and expects |sha->md_len| to carry the size over.
|
160
|
+
//
|
161
|
+
// TODO(davidben): Add an assert and fix code to match them up.
|
162
|
+
return sha256_final_impl(out, c);
|
163
|
+
}
|
164
|
+
int SHA224_Final(uint8_t out[SHA224_DIGEST_LENGTH], SHA256_CTX *ctx) {
|
165
|
+
// SHA224_Init sets |ctx->md_len| to |SHA224_DIGEST_LENGTH|, so this has a
|
166
|
+
// smaller output.
|
167
|
+
assert(ctx->md_len == SHA224_DIGEST_LENGTH);
|
168
|
+
return sha256_final_impl(out, ctx);
|
169
|
+
}
|
179
170
|
|
180
171
|
#ifndef SHA256_ASM
|
181
172
|
static const uint32_t K256[64] = {
|
@@ -318,15 +309,6 @@ void SHA256_TransformBlocks(uint32_t state[8], const uint8_t *data,
|
|
318
309
|
sha256_block_data_order(state, data, num_blocks);
|
319
310
|
}
|
320
311
|
|
321
|
-
#undef DATA_ORDER_IS_BIG_ENDIAN
|
322
|
-
#undef HASH_CTX
|
323
|
-
#undef HASH_CBLOCK
|
324
|
-
#undef HASH_DIGEST_LENGTH
|
325
|
-
#undef HASH_MAKE_STRING
|
326
|
-
#undef HASH_UPDATE
|
327
|
-
#undef HASH_TRANSFORM
|
328
|
-
#undef HASH_FINAL
|
329
|
-
#undef HASH_BLOCK_DATA_ORDER
|
330
312
|
#undef ROTATE
|
331
313
|
#undef Sigma0
|
332
314
|
#undef Sigma1
|