fix_comment_out_incompatible_crypto_modules.patch 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Shelley Vohr <[email protected]>
  3. Date: Wed, 27 May 2020 13:02:13 -0700
  4. Subject: fix: comment out incompatible crypto modules
  5. Node.js introduced some functionality in https://github.com/nodejs/node/pull/32739
  6. and https://github.com/nodejs/node/pull/31178 that is not currently compatible
  7. with what's exposed through BoringSSL. I plan to upstream parts of this or
  8. otherwise introduce shims to reduce friction.
  9. diff --git a/src/node_crypto.cc b/src/node_crypto.cc
  10. index 91cb94d8dbe9db0adbee5e005649188e1ccbcbf9..2000c789d9daac835c0ecc1e4144179575c9b502 100644
  11. --- a/src/node_crypto.cc
  12. +++ b/src/node_crypto.cc
  13. @@ -5192,11 +5192,11 @@ bool DiffieHellman::Init(int primeLength, int g) {
  14. bool DiffieHellman::Init(const char* p, int p_len, int g) {
  15. dh_.reset(DH_new());
  16. if (p_len <= 0) {
  17. - BNerr(BN_F_BN_GENERATE_PRIME_EX, BN_R_BITS_TOO_SMALL);
  18. + OPENSSL_PUT_ERROR(BN, BN_R_BITS_TOO_SMALL);
  19. return false;
  20. }
  21. if (g <= 1) {
  22. - DHerr(DH_F_DH_BUILTIN_GENPARAMS, DH_R_BAD_GENERATOR);
  23. + OPENSSL_PUT_ERROR(DH, DH_R_BAD_GENERATOR);
  24. return false;
  25. }
  26. BIGNUM* bn_p =
  27. @@ -5215,18 +5215,18 @@ bool DiffieHellman::Init(const char* p, int p_len, int g) {
  28. bool DiffieHellman::Init(const char* p, int p_len, const char* g, int g_len) {
  29. dh_.reset(DH_new());
  30. if (p_len <= 0) {
  31. - BNerr(BN_F_BN_GENERATE_PRIME_EX, BN_R_BITS_TOO_SMALL);
  32. + OPENSSL_PUT_ERROR(BN, BN_R_BITS_TOO_SMALL);
  33. return false;
  34. }
  35. if (g_len <= 0) {
  36. - DHerr(DH_F_DH_BUILTIN_GENPARAMS, DH_R_BAD_GENERATOR);
  37. + OPENSSL_PUT_ERROR(DH, DH_R_BAD_GENERATOR);
  38. return false;
  39. }
  40. BIGNUM* bn_g =
  41. BN_bin2bn(reinterpret_cast<const unsigned char*>(g), g_len, nullptr);
  42. if (BN_is_zero(bn_g) || BN_is_one(bn_g)) {
  43. BN_free(bn_g);
  44. - DHerr(DH_F_DH_BUILTIN_GENPARAMS, DH_R_BAD_GENERATOR);
  45. + OPENSSL_PUT_ERROR(DH, DH_R_BAD_GENERATOR);
  46. return false;
  47. }
  48. BIGNUM* bn_p =
  49. @@ -5719,7 +5719,7 @@ void ECDH::SetPrivateKey(const FunctionCallbackInfo<Value>& args) {
  50. if (!EC_KEY_set_public_key(new_key.get(), pub.get()))
  51. return env->ThrowError("Failed to set generated public key");
  52. - EC_KEY_copy(ecdh->key_.get(), new_key.get());
  53. + ecdh->key_.reset(EC_KEY_dup(new_key.get()));
  54. ecdh->group_ = EC_KEY_get0_group(ecdh->key_.get());
  55. }
  56. @@ -6207,6 +6207,7 @@ class DHKeyPairGenerationConfig : public KeyPairGenerationConfig {
  57. EVPKeyCtxPointer Setup() override {
  58. EVPKeyPointer params;
  59. if (prime_info_.fixed_value_) {
  60. +#if 0
  61. DHPointer dh(DH_new());
  62. if (!dh)
  63. return nullptr;
  64. @@ -6223,6 +6224,7 @@ class DHKeyPairGenerationConfig : public KeyPairGenerationConfig {
  65. params = EVPKeyPointer(EVP_PKEY_new());
  66. CHECK(params);
  67. EVP_PKEY_assign_DH(params.get(), dh.release());
  68. +#endif
  69. } else {
  70. EVPKeyCtxPointer param_ctx(EVP_PKEY_CTX_new_id(EVP_PKEY_DH, nullptr));
  71. if (!param_ctx)
  72. @@ -6230,7 +6232,7 @@ class DHKeyPairGenerationConfig : public KeyPairGenerationConfig {
  73. if (EVP_PKEY_paramgen_init(param_ctx.get()) <= 0)
  74. return nullptr;
  75. -
  76. +#if 0
  77. if (EVP_PKEY_CTX_set_dh_paramgen_prime_len(param_ctx.get(),
  78. prime_info_.prime_size_) <= 0)
  79. return nullptr;
  80. @@ -6238,7 +6240,7 @@ class DHKeyPairGenerationConfig : public KeyPairGenerationConfig {
  81. if (EVP_PKEY_CTX_set_dh_paramgen_generator(param_ctx.get(),
  82. generator_) <= 0)
  83. return nullptr;
  84. -
  85. +#endif
  86. EVP_PKEY* raw_params = nullptr;
  87. if (EVP_PKEY_paramgen(param_ctx.get(), &raw_params) <= 0)
  88. return nullptr;