Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Remove OldSetKeyFromPassphrase/OldEncrypt/OldDecrypt #11024

Merged
merged 1 commit into from Aug 22, 2017

Conversation

practicalswift
Copy link
Contributor

@practicalswift practicalswift commented Aug 10, 2017

Reduces the number of non-free:d allocs with four (Δ in use at exit = -928 bytes).

With this patch applied:

$ valgrind --leak-check=full --show-leak-kinds=all src/test/test_bitcoin --log_level=test_suite --run_test=wallet_crypto
…
==20243== HEAP SUMMARY:
==20243==     in use at exit: 72,704 bytes in 1 blocks
==20243==   total heap usage: 53,138 allocs, 53,137 frees, 49,600,420 bytes allocated
==20243==
==20243== 72,704 bytes in 1 blocks are still reachable in loss record 1 of 1
==20243==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==20243==    by 0x6AA5EFF: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
==20243==    by 0x40106B9: call_init.part.0 (dl-init.c:72)
==20243==    by 0x40107CA: call_init (dl-init.c:30)
==20243==    by 0x40107CA: _dl_init (dl-init.c:120)
==20243==    by 0x4000C69: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
==20243==    by 0x2: ???
==20243==    by 0xFFF0006A2: ???
==20243==    by 0xFFF0006B8: ???
==20243==    by 0xFFF0006CF: ???
==20243==
==20243== LEAK SUMMARY:
==20243==    definitely lost: 0 bytes in 0 blocks
==20243==    indirectly lost: 0 bytes in 0 blocks
==20243==      possibly lost: 0 bytes in 0 blocks
==20243==    still reachable: 72,704 bytes in 1 blocks
==20243==         suppressed: 0 bytes in 0 blocks

Without this patch applied:

$ valgrind --leak-check=full --show-leak-kinds=all src/test/test_bitcoin --log_level=test_suite --run_test=wallet_crypto
…
==19023== HEAP SUMMARY:
==19023==     in use at exit: 73,632 bytes in 5 blocks
==19023==   total heap usage: 52,718 allocs, 52,713 frees, 49,502,962 bytes allocated
==19023==
==19023== 24 bytes in 1 blocks are still reachable in loss record 1 of 5
==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==19023==    by 0x64E5665: lh_insert (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==19023==    by 0x64E7BB3: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==19023==    by 0x64E87AD: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
==19023==    by 0x182596: invoke<void (*)()> (callback.hpp:56)
==19023==    by 0x182596: boost::unit_test::ut_detail::callback0_impl_t<boost::unit_test::ut_detail::unused, void (*)()>::invoke() (callback.hpp:89)
==19023==
==19023== 128 bytes in 1 blocks are still reachable in loss record 2 of 5
==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==19023==    by 0x64E5331: lh_new (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==19023==    by 0x64E7862: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==19023==    by 0x64E7B7F: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==19023==    by 0x64E87AD: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
==19023==
==19023== 176 bytes in 1 blocks are still reachable in loss record 3 of 5
==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==19023==    by 0x64E530F: lh_new (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==19023==    by 0x64E7862: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==19023==    by 0x64E7B7F: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==19023==    by 0x64E87AD: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
==19023==
==19023== 600 bytes in 1 blocks are still reachable in loss record 4 of 5
==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==19023==    by 0x64E8745: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
==19023==    by 0x182596: invoke<void (*)()> (callback.hpp:56)
==19023==    by 0x182596: boost::unit_test::ut_detail::callback0_impl_t<boost::unit_test::ut_detail::unused, void (*)()>::invoke() (callback.hpp:89)
==19023==    by 0x596CCB0: ??? (in /usr/lib/x86_64-linux-gnu/libboost_unit_test_framework.so.1.58.0)
==19023==    by 0x594C995: boost::execution_monitor::catch_signals(boost::unit_test::callback0<int> const&) (in /usr/lib/x86_64-linux-gnu/libboost_unit_test_framework.so.1.58.0)
==19023==
==19023== 72,704 bytes in 1 blocks are still reachable in loss record 5 of 5
==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==19023==    by 0x6AA5EFF: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
==19023==    by 0x40106B9: call_init.part.0 (dl-init.c:72)
==19023==    by 0x40107CA: call_init (dl-init.c:30)
==19023==    by 0x40107CA: _dl_init (dl-init.c:120)
==19023==    by 0x4000C69: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
==19023==    by 0x2: ???
==19023==    by 0xFFF0006A2: ???
==19023==    by 0xFFF0006B8: ???
==19023==    by 0xFFF0006CF: ???
==19023==
==19023== LEAK SUMMARY:
==19023==    definitely lost: 0 bytes in 0 blocks
==19023==    indirectly lost: 0 bytes in 0 blocks
==19023==      possibly lost: 0 bytes in 0 blocks
==19023==    still reachable: 73,632 bytes in 5 blocks
==19023==         suppressed: 0 bytes in 0 blocks
==19023==
==19023== For counts of detected and suppressed errors, rerun with: -v
==19023== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

@practicalswift
Copy link
Contributor Author

practicalswift commented Aug 10, 2017

Note to reviewers: Let me know if this cleanup is better placed somewhere else (i.e. outside of OldDecrypt(…) to avoid doing it more than once). One alternative would be to put it in ~BasicTestingSetup(), but then it'll run for unrelated tests as well.

EVP_CIPHER_CTX_free(ctx);
ERR_remove_thread_state(nullptr);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand this. OpenSSL API is confusing, where is the symmetric "create" for this remove/free?
Surprised that this needs ERR_* just to deallocate a structure that comes out of the blue.
Is this related to cleanup in ~CInit() in util.cpp?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the OpenSSL API is full of surprises! :-)

This is my understanding:

OldDecrypt(…) (in crypto_tests.cpp) calls OpenSSL's EVP_DecryptFinal_ex(…).

If EVP_DecryptFinal_ex(…) encounters any errors then EVPerr(…) is called.

EVPerr(…) is defined as:

#define EVPerr(f,r)  ERR_PUT_error(ERR_LIB_EVP,(f),(r),OPENSSL_FILE,OPENSSL_LINE)

ERR_PUT_error(…) stores stores the errors in a thread local error queue for which the allocations are made using OPENSSL_zalloc(…) in ERR_get_state(…).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ERR_remove_thread_state(nullptr) must be run for each thread as I've understood it, so I don't think putting it in ~CInit() would be the right thing to do?

@gmaxwell
Copy link
Contributor

Alternatively we could drop this test. I think it's served its purpose now (our implementation is fine even across many systems) and hopefully OpenSSL will not be required to build without the GUI in 0.16.

@gmaxwell
Copy link
Contributor

@sipa @theuni

@sipa
Copy link
Member

sipa commented Aug 10, 2017

I'd rather just get rid of OpenSSL... we're very close to the point that it doesn't have much added benefit over our internal RNG.

@practicalswift
Copy link
Contributor Author

@gmaxwell I've now added a commit that removes Old{SetKeyFromPassphrase,Encrypt,Decrypt}. Is that in accordance with your suggestion? :-)

Let me know if it looks good and I'll squash it into one commit.

@gmaxwell
Copy link
Contributor

Looks good to me.

@maflcko maflcko changed the title tests: Free the OpenSSL error queue as part of the wallet_crypto/OldDecrypt test cleanup tests: Remove OldSetKeyFromPassphrase/OldEncrypt/OldDecrypt Aug 11, 2017
@maflcko maflcko added this to the 0.16.0 milestone Aug 11, 2017
@maflcko maflcko added the Tests label Aug 11, 2017
@practicalswift
Copy link
Contributor Author

Squashed into one commit. Please review :-)

@practicalswift
Copy link
Contributor Author

Rebased!

@theuni
Copy link
Member

theuni commented Aug 16, 2017

I have no issue with removing the old comparisons, as I think it's safe to say by now that our implementation lines up well enough with the old openssl one.

However, I don't think it'd be a terrible idea to snapshot our current implementation and compare against that. That way future changes are checked against something.

I suppose that's really not necessary until those future changes exist, though.

utACK.

@laanwj laanwj merged commit a897d0e into bitcoin:master Aug 22, 2017
laanwj added a commit that referenced this pull request Aug 22, 2017
…rypt

a897d0e tests: Remove OldSetKeyFromPassphrase/OldEncrypt/OldDecrypt (practicalswift)

Pull request description:

  Reduces the number of non-free:d allocs with four (Δ in use at exit = -928 bytes).

  With this patch applied:

  ```
  $ valgrind --leak-check=full --show-leak-kinds=all src/test/test_bitcoin --log_level=test_suite --run_test=wallet_crypto
  …
  ==20243== HEAP SUMMARY:
  ==20243==     in use at exit: 72,704 bytes in 1 blocks
  ==20243==   total heap usage: 53,138 allocs, 53,137 frees, 49,600,420 bytes allocated
  ==20243==
  ==20243== 72,704 bytes in 1 blocks are still reachable in loss record 1 of 1
  ==20243==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==20243==    by 0x6AA5EFF: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
  ==20243==    by 0x40106B9: call_init.part.0 (dl-init.c:72)
  ==20243==    by 0x40107CA: call_init (dl-init.c:30)
  ==20243==    by 0x40107CA: _dl_init (dl-init.c:120)
  ==20243==    by 0x4000C69: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
  ==20243==    by 0x2: ???
  ==20243==    by 0xFFF0006A2: ???
  ==20243==    by 0xFFF0006B8: ???
  ==20243==    by 0xFFF0006CF: ???
  ==20243==
  ==20243== LEAK SUMMARY:
  ==20243==    definitely lost: 0 bytes in 0 blocks
  ==20243==    indirectly lost: 0 bytes in 0 blocks
  ==20243==      possibly lost: 0 bytes in 0 blocks
  ==20243==    still reachable: 72,704 bytes in 1 blocks
  ==20243==         suppressed: 0 bytes in 0 blocks
  ```

  Without this patch applied:

  ```
  $ valgrind --leak-check=full --show-leak-kinds=all src/test/test_bitcoin --log_level=test_suite --run_test=wallet_crypto
  …
  ==19023== HEAP SUMMARY:
  ==19023==     in use at exit: 73,632 bytes in 5 blocks
  ==19023==   total heap usage: 52,718 allocs, 52,713 frees, 49,502,962 bytes allocated
  ==19023==
  ==19023== 24 bytes in 1 blocks are still reachable in loss record 1 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E5665: lh_insert (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7BB3: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E87AD: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
  ==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
  ==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
  ==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
  ==19023==    by 0x182596: invoke<void (*)()> (callback.hpp:56)
  ==19023==    by 0x182596: boost::unit_test::ut_detail::callback0_impl_t<boost::unit_test::ut_detail::unused, void (*)()>::invoke() (callback.hpp:89)
  ==19023==
  ==19023== 128 bytes in 1 blocks are still reachable in loss record 2 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E5331: lh_new (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7862: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7B7F: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E87AD: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
  ==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
  ==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
  ==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
  ==19023==
  ==19023== 176 bytes in 1 blocks are still reachable in loss record 3 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E530F: lh_new (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7862: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7B7F: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E87AD: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
  ==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
  ==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
  ==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
  ==19023==
  ==19023== 600 bytes in 1 blocks are still reachable in loss record 4 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E8745: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
  ==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
  ==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
  ==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
  ==19023==    by 0x182596: invoke<void (*)()> (callback.hpp:56)
  ==19023==    by 0x182596: boost::unit_test::ut_detail::callback0_impl_t<boost::unit_test::ut_detail::unused, void (*)()>::invoke() (callback.hpp:89)
  ==19023==    by 0x596CCB0: ??? (in /usr/lib/x86_64-linux-gnu/libboost_unit_test_framework.so.1.58.0)
  ==19023==    by 0x594C995: boost::execution_monitor::catch_signals(boost::unit_test::callback0<int> const&) (in /usr/lib/x86_64-linux-gnu/libboost_unit_test_framework.so.1.58.0)
  ==19023==
  ==19023== 72,704 bytes in 1 blocks are still reachable in loss record 5 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x6AA5EFF: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
  ==19023==    by 0x40106B9: call_init.part.0 (dl-init.c:72)
  ==19023==    by 0x40107CA: call_init (dl-init.c:30)
  ==19023==    by 0x40107CA: _dl_init (dl-init.c:120)
  ==19023==    by 0x4000C69: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
  ==19023==    by 0x2: ???
  ==19023==    by 0xFFF0006A2: ???
  ==19023==    by 0xFFF0006B8: ???
  ==19023==    by 0xFFF0006CF: ???
  ==19023==
  ==19023== LEAK SUMMARY:
  ==19023==    definitely lost: 0 bytes in 0 blocks
  ==19023==    indirectly lost: 0 bytes in 0 blocks
  ==19023==      possibly lost: 0 bytes in 0 blocks
  ==19023==    still reachable: 73,632 bytes in 5 blocks
  ==19023==         suppressed: 0 bytes in 0 blocks
  ==19023==
  ==19023== For counts of detected and suppressed errors, rerun with: -v
  ==19023== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
  ```

Tree-SHA512: 38b6552736a5710a42dbad770c490583cfc762acbec716f5db4cf38314f494ea99430713ea407c73b49d867676ced221a282437f3fcfd8346f8f68386f4fc74d
@maflcko
Copy link
Member

maflcko commented Aug 23, 2017

post-merge utACK a897d0e

PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Sep 19, 2019
…/OldDecrypt

a897d0e tests: Remove OldSetKeyFromPassphrase/OldEncrypt/OldDecrypt (practicalswift)

Pull request description:

  Reduces the number of non-free:d allocs with four (Δ in use at exit = -928 bytes).

  With this patch applied:

  ```
  $ valgrind --leak-check=full --show-leak-kinds=all src/test/test_bitcoin --log_level=test_suite --run_test=wallet_crypto
  …
  ==20243== HEAP SUMMARY:
  ==20243==     in use at exit: 72,704 bytes in 1 blocks
  ==20243==   total heap usage: 53,138 allocs, 53,137 frees, 49,600,420 bytes allocated
  ==20243==
  ==20243== 72,704 bytes in 1 blocks are still reachable in loss record 1 of 1
  ==20243==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==20243==    by 0x6AA5EFF: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
  ==20243==    by 0x40106B9: call_init.part.0 (dl-init.c:72)
  ==20243==    by 0x40107CA: call_init (dl-init.c:30)
  ==20243==    by 0x40107CA: _dl_init (dl-init.c:120)
  ==20243==    by 0x4000C69: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
  ==20243==    by 0x2: ???
  ==20243==    by 0xFFF0006A2: ???
  ==20243==    by 0xFFF0006B8: ???
  ==20243==    by 0xFFF0006CF: ???
  ==20243==
  ==20243== LEAK SUMMARY:
  ==20243==    definitely lost: 0 bytes in 0 blocks
  ==20243==    indirectly lost: 0 bytes in 0 blocks
  ==20243==      possibly lost: 0 bytes in 0 blocks
  ==20243==    still reachable: 72,704 bytes in 1 blocks
  ==20243==         suppressed: 0 bytes in 0 blocks
  ```

  Without this patch applied:

  ```
  $ valgrind --leak-check=full --show-leak-kinds=all src/test/test_bitcoin --log_level=test_suite --run_test=wallet_crypto
  …
  ==19023== HEAP SUMMARY:
  ==19023==     in use at exit: 73,632 bytes in 5 blocks
  ==19023==   total heap usage: 52,718 allocs, 52,713 frees, 49,502,962 bytes allocated
  ==19023==
  ==19023== 24 bytes in 1 blocks are still reachable in loss record 1 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E5665: lh_insert (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7BB3: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E87AD: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
  ==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
  ==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
  ==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
  ==19023==    by 0x182596: invoke<void (*)()> (callback.hpp:56)
  ==19023==    by 0x182596: boost::unit_test::ut_detail::callback0_impl_t<boost::unit_test::ut_detail::unused, void (*)()>::invoke() (callback.hpp:89)
  ==19023==
  ==19023== 128 bytes in 1 blocks are still reachable in loss record 2 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E5331: lh_new (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7862: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7B7F: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E87AD: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
  ==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
  ==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
  ==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
  ==19023==
  ==19023== 176 bytes in 1 blocks are still reachable in loss record 3 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E530F: lh_new (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7862: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7B7F: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E87AD: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
  ==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
  ==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
  ==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
  ==19023==
  ==19023== 600 bytes in 1 blocks are still reachable in loss record 4 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E8745: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
  ==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
  ==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
  ==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
  ==19023==    by 0x182596: invoke<void (*)()> (callback.hpp:56)
  ==19023==    by 0x182596: boost::unit_test::ut_detail::callback0_impl_t<boost::unit_test::ut_detail::unused, void (*)()>::invoke() (callback.hpp:89)
  ==19023==    by 0x596CCB0: ??? (in /usr/lib/x86_64-linux-gnu/libboost_unit_test_framework.so.1.58.0)
  ==19023==    by 0x594C995: boost::execution_monitor::catch_signals(boost::unit_test::callback0<int> const&) (in /usr/lib/x86_64-linux-gnu/libboost_unit_test_framework.so.1.58.0)
  ==19023==
  ==19023== 72,704 bytes in 1 blocks are still reachable in loss record 5 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x6AA5EFF: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
  ==19023==    by 0x40106B9: call_init.part.0 (dl-init.c:72)
  ==19023==    by 0x40107CA: call_init (dl-init.c:30)
  ==19023==    by 0x40107CA: _dl_init (dl-init.c:120)
  ==19023==    by 0x4000C69: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
  ==19023==    by 0x2: ???
  ==19023==    by 0xFFF0006A2: ???
  ==19023==    by 0xFFF0006B8: ???
  ==19023==    by 0xFFF0006CF: ???
  ==19023==
  ==19023== LEAK SUMMARY:
  ==19023==    definitely lost: 0 bytes in 0 blocks
  ==19023==    indirectly lost: 0 bytes in 0 blocks
  ==19023==      possibly lost: 0 bytes in 0 blocks
  ==19023==    still reachable: 73,632 bytes in 5 blocks
  ==19023==         suppressed: 0 bytes in 0 blocks
  ==19023==
  ==19023== For counts of detected and suppressed errors, rerun with: -v
  ==19023== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
  ```

Tree-SHA512: 38b6552736a5710a42dbad770c490583cfc762acbec716f5db4cf38314f494ea99430713ea407c73b49d867676ced221a282437f3fcfd8346f8f68386f4fc74d
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Sep 19, 2019
…/OldDecrypt

a897d0e tests: Remove OldSetKeyFromPassphrase/OldEncrypt/OldDecrypt (practicalswift)

Pull request description:

  Reduces the number of non-free:d allocs with four (Δ in use at exit = -928 bytes).

  With this patch applied:

  ```
  $ valgrind --leak-check=full --show-leak-kinds=all src/test/test_bitcoin --log_level=test_suite --run_test=wallet_crypto
  …
  ==20243== HEAP SUMMARY:
  ==20243==     in use at exit: 72,704 bytes in 1 blocks
  ==20243==   total heap usage: 53,138 allocs, 53,137 frees, 49,600,420 bytes allocated
  ==20243==
  ==20243== 72,704 bytes in 1 blocks are still reachable in loss record 1 of 1
  ==20243==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==20243==    by 0x6AA5EFF: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
  ==20243==    by 0x40106B9: call_init.part.0 (dl-init.c:72)
  ==20243==    by 0x40107CA: call_init (dl-init.c:30)
  ==20243==    by 0x40107CA: _dl_init (dl-init.c:120)
  ==20243==    by 0x4000C69: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
  ==20243==    by 0x2: ???
  ==20243==    by 0xFFF0006A2: ???
  ==20243==    by 0xFFF0006B8: ???
  ==20243==    by 0xFFF0006CF: ???
  ==20243==
  ==20243== LEAK SUMMARY:
  ==20243==    definitely lost: 0 bytes in 0 blocks
  ==20243==    indirectly lost: 0 bytes in 0 blocks
  ==20243==      possibly lost: 0 bytes in 0 blocks
  ==20243==    still reachable: 72,704 bytes in 1 blocks
  ==20243==         suppressed: 0 bytes in 0 blocks
  ```

  Without this patch applied:

  ```
  $ valgrind --leak-check=full --show-leak-kinds=all src/test/test_bitcoin --log_level=test_suite --run_test=wallet_crypto
  …
  ==19023== HEAP SUMMARY:
  ==19023==     in use at exit: 73,632 bytes in 5 blocks
  ==19023==   total heap usage: 52,718 allocs, 52,713 frees, 49,502,962 bytes allocated
  ==19023==
  ==19023== 24 bytes in 1 blocks are still reachable in loss record 1 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E5665: lh_insert (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7BB3: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E87AD: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
  ==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
  ==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
  ==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
  ==19023==    by 0x182596: invoke<void (*)()> (callback.hpp:56)
  ==19023==    by 0x182596: boost::unit_test::ut_detail::callback0_impl_t<boost::unit_test::ut_detail::unused, void (*)()>::invoke() (callback.hpp:89)
  ==19023==
  ==19023== 128 bytes in 1 blocks are still reachable in loss record 2 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E5331: lh_new (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7862: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7B7F: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E87AD: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
  ==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
  ==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
  ==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
  ==19023==
  ==19023== 176 bytes in 1 blocks are still reachable in loss record 3 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E530F: lh_new (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7862: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7B7F: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E87AD: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
  ==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
  ==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
  ==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
  ==19023==
  ==19023== 600 bytes in 1 blocks are still reachable in loss record 4 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E8745: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
  ==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
  ==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
  ==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
  ==19023==    by 0x182596: invoke<void (*)()> (callback.hpp:56)
  ==19023==    by 0x182596: boost::unit_test::ut_detail::callback0_impl_t<boost::unit_test::ut_detail::unused, void (*)()>::invoke() (callback.hpp:89)
  ==19023==    by 0x596CCB0: ??? (in /usr/lib/x86_64-linux-gnu/libboost_unit_test_framework.so.1.58.0)
  ==19023==    by 0x594C995: boost::execution_monitor::catch_signals(boost::unit_test::callback0<int> const&) (in /usr/lib/x86_64-linux-gnu/libboost_unit_test_framework.so.1.58.0)
  ==19023==
  ==19023== 72,704 bytes in 1 blocks are still reachable in loss record 5 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x6AA5EFF: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
  ==19023==    by 0x40106B9: call_init.part.0 (dl-init.c:72)
  ==19023==    by 0x40107CA: call_init (dl-init.c:30)
  ==19023==    by 0x40107CA: _dl_init (dl-init.c:120)
  ==19023==    by 0x4000C69: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
  ==19023==    by 0x2: ???
  ==19023==    by 0xFFF0006A2: ???
  ==19023==    by 0xFFF0006B8: ???
  ==19023==    by 0xFFF0006CF: ???
  ==19023==
  ==19023== LEAK SUMMARY:
  ==19023==    definitely lost: 0 bytes in 0 blocks
  ==19023==    indirectly lost: 0 bytes in 0 blocks
  ==19023==      possibly lost: 0 bytes in 0 blocks
  ==19023==    still reachable: 73,632 bytes in 5 blocks
  ==19023==         suppressed: 0 bytes in 0 blocks
  ==19023==
  ==19023== For counts of detected and suppressed errors, rerun with: -v
  ==19023== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
  ```

Tree-SHA512: 38b6552736a5710a42dbad770c490583cfc762acbec716f5db4cf38314f494ea99430713ea407c73b49d867676ced221a282437f3fcfd8346f8f68386f4fc74d
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Feb 2, 2020
…/OldDecrypt

a897d0e tests: Remove OldSetKeyFromPassphrase/OldEncrypt/OldDecrypt (practicalswift)

Pull request description:

  Reduces the number of non-free:d allocs with four (Δ in use at exit = -928 bytes).

  With this patch applied:

  ```
  $ valgrind --leak-check=full --show-leak-kinds=all src/test/test_bitcoin --log_level=test_suite --run_test=wallet_crypto
  …
  ==20243== HEAP SUMMARY:
  ==20243==     in use at exit: 72,704 bytes in 1 blocks
  ==20243==   total heap usage: 53,138 allocs, 53,137 frees, 49,600,420 bytes allocated
  ==20243==
  ==20243== 72,704 bytes in 1 blocks are still reachable in loss record 1 of 1
  ==20243==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==20243==    by 0x6AA5EFF: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
  ==20243==    by 0x40106B9: call_init.part.0 (dl-init.c:72)
  ==20243==    by 0x40107CA: call_init (dl-init.c:30)
  ==20243==    by 0x40107CA: _dl_init (dl-init.c:120)
  ==20243==    by 0x4000C69: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
  ==20243==    by 0x2: ???
  ==20243==    by 0xFFF0006A2: ???
  ==20243==    by 0xFFF0006B8: ???
  ==20243==    by 0xFFF0006CF: ???
  ==20243==
  ==20243== LEAK SUMMARY:
  ==20243==    definitely lost: 0 bytes in 0 blocks
  ==20243==    indirectly lost: 0 bytes in 0 blocks
  ==20243==      possibly lost: 0 bytes in 0 blocks
  ==20243==    still reachable: 72,704 bytes in 1 blocks
  ==20243==         suppressed: 0 bytes in 0 blocks
  ```

  Without this patch applied:

  ```
  $ valgrind --leak-check=full --show-leak-kinds=all src/test/test_bitcoin --log_level=test_suite --run_test=wallet_crypto
  …
  ==19023== HEAP SUMMARY:
  ==19023==     in use at exit: 73,632 bytes in 5 blocks
  ==19023==   total heap usage: 52,718 allocs, 52,713 frees, 49,502,962 bytes allocated
  ==19023==
  ==19023== 24 bytes in 1 blocks are still reachable in loss record 1 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E5665: lh_insert (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7BB3: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E87AD: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
  ==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
  ==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
  ==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
  ==19023==    by 0x182596: invoke<void (*)()> (callback.hpp:56)
  ==19023==    by 0x182596: boost::unit_test::ut_detail::callback0_impl_t<boost::unit_test::ut_detail::unused, void (*)()>::invoke() (callback.hpp:89)
  ==19023==
  ==19023== 128 bytes in 1 blocks are still reachable in loss record 2 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E5331: lh_new (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7862: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7B7F: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E87AD: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
  ==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
  ==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
  ==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
  ==19023==
  ==19023== 176 bytes in 1 blocks are still reachable in loss record 3 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E530F: lh_new (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7862: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7B7F: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E87AD: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
  ==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
  ==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
  ==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
  ==19023==
  ==19023== 600 bytes in 1 blocks are still reachable in loss record 4 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E8745: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
  ==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
  ==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
  ==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
  ==19023==    by 0x182596: invoke<void (*)()> (callback.hpp:56)
  ==19023==    by 0x182596: boost::unit_test::ut_detail::callback0_impl_t<boost::unit_test::ut_detail::unused, void (*)()>::invoke() (callback.hpp:89)
  ==19023==    by 0x596CCB0: ??? (in /usr/lib/x86_64-linux-gnu/libboost_unit_test_framework.so.1.58.0)
  ==19023==    by 0x594C995: boost::execution_monitor::catch_signals(boost::unit_test::callback0<int> const&) (in /usr/lib/x86_64-linux-gnu/libboost_unit_test_framework.so.1.58.0)
  ==19023==
  ==19023== 72,704 bytes in 1 blocks are still reachable in loss record 5 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x6AA5EFF: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
  ==19023==    by 0x40106B9: call_init.part.0 (dl-init.c:72)
  ==19023==    by 0x40107CA: call_init (dl-init.c:30)
  ==19023==    by 0x40107CA: _dl_init (dl-init.c:120)
  ==19023==    by 0x4000C69: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
  ==19023==    by 0x2: ???
  ==19023==    by 0xFFF0006A2: ???
  ==19023==    by 0xFFF0006B8: ???
  ==19023==    by 0xFFF0006CF: ???
  ==19023==
  ==19023== LEAK SUMMARY:
  ==19023==    definitely lost: 0 bytes in 0 blocks
  ==19023==    indirectly lost: 0 bytes in 0 blocks
  ==19023==      possibly lost: 0 bytes in 0 blocks
  ==19023==    still reachable: 73,632 bytes in 5 blocks
  ==19023==         suppressed: 0 bytes in 0 blocks
  ==19023==
  ==19023== For counts of detected and suppressed errors, rerun with: -v
  ==19023== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
  ```

Tree-SHA512: 38b6552736a5710a42dbad770c490583cfc762acbec716f5db4cf38314f494ea99430713ea407c73b49d867676ced221a282437f3fcfd8346f8f68386f4fc74d
Signed-off-by: Pasta <pasta@dashboost.org>

# Conflicts:
#	src/wallet/test/crypto_tests.cpp
UdjinM6 added a commit to dashpay/dash that referenced this pull request Feb 4, 2020
…/OldDec… (#3320)

* Merge bitcoin#11024: tests: Remove OldSetKeyFromPassphrase/OldEncrypt/OldDecrypt

a897d0e tests: Remove OldSetKeyFromPassphrase/OldEncrypt/OldDecrypt (practicalswift)

Pull request description:

  Reduces the number of non-free:d allocs with four (Δ in use at exit = -928 bytes).

  With this patch applied:

  ```
  $ valgrind --leak-check=full --show-leak-kinds=all src/test/test_bitcoin --log_level=test_suite --run_test=wallet_crypto
  …
  ==20243== HEAP SUMMARY:
  ==20243==     in use at exit: 72,704 bytes in 1 blocks
  ==20243==   total heap usage: 53,138 allocs, 53,137 frees, 49,600,420 bytes allocated
  ==20243==
  ==20243== 72,704 bytes in 1 blocks are still reachable in loss record 1 of 1
  ==20243==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==20243==    by 0x6AA5EFF: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
  ==20243==    by 0x40106B9: call_init.part.0 (dl-init.c:72)
  ==20243==    by 0x40107CA: call_init (dl-init.c:30)
  ==20243==    by 0x40107CA: _dl_init (dl-init.c:120)
  ==20243==    by 0x4000C69: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
  ==20243==    by 0x2: ???
  ==20243==    by 0xFFF0006A2: ???
  ==20243==    by 0xFFF0006B8: ???
  ==20243==    by 0xFFF0006CF: ???
  ==20243==
  ==20243== LEAK SUMMARY:
  ==20243==    definitely lost: 0 bytes in 0 blocks
  ==20243==    indirectly lost: 0 bytes in 0 blocks
  ==20243==      possibly lost: 0 bytes in 0 blocks
  ==20243==    still reachable: 72,704 bytes in 1 blocks
  ==20243==         suppressed: 0 bytes in 0 blocks
  ```

  Without this patch applied:

  ```
  $ valgrind --leak-check=full --show-leak-kinds=all src/test/test_bitcoin --log_level=test_suite --run_test=wallet_crypto
  …
  ==19023== HEAP SUMMARY:
  ==19023==     in use at exit: 73,632 bytes in 5 blocks
  ==19023==   total heap usage: 52,718 allocs, 52,713 frees, 49,502,962 bytes allocated
  ==19023==
  ==19023== 24 bytes in 1 blocks are still reachable in loss record 1 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E5665: lh_insert (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7BB3: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E87AD: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
  ==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
  ==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
  ==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
  ==19023==    by 0x182596: invoke<void (*)()> (callback.hpp:56)
  ==19023==    by 0x182596: boost::unit_test::ut_detail::callback0_impl_t<boost::unit_test::ut_detail::unused, void (*)()>::invoke() (callback.hpp:89)
  ==19023==
  ==19023== 128 bytes in 1 blocks are still reachable in loss record 2 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E5331: lh_new (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7862: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7B7F: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E87AD: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
  ==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
  ==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
  ==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
  ==19023==
  ==19023== 176 bytes in 1 blocks are still reachable in loss record 3 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E530F: lh_new (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7862: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7B7F: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E87AD: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
  ==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
  ==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
  ==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
  ==19023==
  ==19023== 600 bytes in 1 blocks are still reachable in loss record 4 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E8745: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
  ==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
  ==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
  ==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
  ==19023==    by 0x182596: invoke<void (*)()> (callback.hpp:56)
  ==19023==    by 0x182596: boost::unit_test::ut_detail::callback0_impl_t<boost::unit_test::ut_detail::unused, void (*)()>::invoke() (callback.hpp:89)
  ==19023==    by 0x596CCB0: ??? (in /usr/lib/x86_64-linux-gnu/libboost_unit_test_framework.so.1.58.0)
  ==19023==    by 0x594C995: boost::execution_monitor::catch_signals(boost::unit_test::callback0<int> const&) (in /usr/lib/x86_64-linux-gnu/libboost_unit_test_framework.so.1.58.0)
  ==19023==
  ==19023== 72,704 bytes in 1 blocks are still reachable in loss record 5 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x6AA5EFF: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
  ==19023==    by 0x40106B9: call_init.part.0 (dl-init.c:72)
  ==19023==    by 0x40107CA: call_init (dl-init.c:30)
  ==19023==    by 0x40107CA: _dl_init (dl-init.c:120)
  ==19023==    by 0x4000C69: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
  ==19023==    by 0x2: ???
  ==19023==    by 0xFFF0006A2: ???
  ==19023==    by 0xFFF0006B8: ???
  ==19023==    by 0xFFF0006CF: ???
  ==19023==
  ==19023== LEAK SUMMARY:
  ==19023==    definitely lost: 0 bytes in 0 blocks
  ==19023==    indirectly lost: 0 bytes in 0 blocks
  ==19023==      possibly lost: 0 bytes in 0 blocks
  ==19023==    still reachable: 73,632 bytes in 5 blocks
  ==19023==         suppressed: 0 bytes in 0 blocks
  ==19023==
  ==19023== For counts of detected and suppressed errors, rerun with: -v
  ==19023== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
  ```

Tree-SHA512: 38b6552736a5710a42dbad770c490583cfc762acbec716f5db4cf38314f494ea99430713ea407c73b49d867676ced221a282437f3fcfd8346f8f68386f4fc74d
Signed-off-by: Pasta <pasta@dashboost.org>

# Conflicts:
#	src/wallet/test/crypto_tests.cpp

* tests: Remove Old{En,De}cryptAES256

Co-authored-by: Wladimir J. van der Laan <laanwj@gmail.com>
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
@str4d str4d mentioned this pull request Sep 23, 2020
zkbot added a commit to zcash/zcash that referenced this pull request Oct 1, 2020
Remove OpenSSL

Includes changes cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#7095
- bitcoin/bitcoin#11024
- bitcoin/bitcoin#17165
  - Only the commit removing SSL lib detection (we have long since removed the rest).
- bitcoin/bitcoin#17265
  - We had already migrated away from OpenSSL for randomness.
- bitcoin/bitcoin#17515
  - Only the second commit.

Closes #145.
Fuzzbawls added a commit to PIVX-Project/PIVX that referenced this pull request Feb 14, 2021
84b4185 [Tests] raise minimum fee in feature_blockindexstats (random-zebra)
39d8a20 [Cleanup] Remove OldSetKeyFromPassphrase/OldEncrypt/OldDecrypt (random-zebra)
613e1da [BUG] Fix sizeof in paymentservertests (random-zebra)
0f3e961 [Cleanup] Remove useless call (random-zebra)
b1ca5e0 Remove unused fsbridge::freopen (practicalswift)
b3a1d84 Don't close old debug log file handle prematurely when trying to re-open (on SIGHUP) (practicalswift)
ecfbcfd [Cleanup] Remove unused function AddInvalidSpendsToMap (random-zebra)
15b018c [Refactor] Use InsecureRand in the unit tests (random-zebra)
81fd84c [Refactoring] Replace risky call to rand() with GetRandInt() (random-zebra)
8ba1978 [Qt] Terminate string *pszExePath after readlink and without using memset (practicalswift)
b6cd719 Remove unreachable code (g_rpcSignals.PostCommand) (practicalswift)
e4f9ab3 [BUG] Memory leak after new CNode / ConnectNode (random-zebra)
536122b Avoid rollingMinimumFeeRate never being able to decay below half (Alex Morcos)
13cad19 fix a bug if the min fee is 0 for FeeFilterRounder (Alex Morcos)
aa832d8 [Refactoring] Dereference before/after null check (random-zebra)
4630b7d [Trivial] Pass big parameters by reference, not value (random-zebra)
aa7bc7f [Refactoring] Remove unneeded CScript::IsNormalPaymentScript (random-zebra)
6cf3c8f [Trivial] Unitialized scalar fields and variables (random-zebra)

Pull request description:

  This is a collection of small fixes for the following issues/defects (discovered with the coverity tool):

  - Big parameters passed by value
  - calls to rand() function
  - Dereference before/after null-pointer check
  - Pointer to local variable out of scope
  - Resource leak with call to ConnectNode
  - Non-floating point result - unintended integer division (bitcoin#9288)
  - String not-null-terminated (bitcoin#11193)
  - Structurally dead code (bitcoin#9575)
  - Unchecked boolean return value of functions (GetOp, GetTransaction, TxOutToPublicCoin)
  - Unitialized pointers and scalar fields
  - Illegal memory access (bitcoin#13159)
  - Useless call to pubkey.IsCompressed()
  - Wrong `sizeof` argument (bitcoin#11024 + revert #494)

ACKs for top commit:
  furszy:
    Looking good, ACK 84b4185
  Fuzzbawls:
    ACK 84b4185

Tree-SHA512: 4c920a1858ccde65795c090e4becc47c50c0a78db7ab11935b4d3e2bea3f7f1f8ca3b48ce633d8112673092c35ae7cd05c444ed2b16e283a305c765874e55c1c
@practicalswift practicalswift deleted the OldDecrypt-cleanup branch April 10, 2021 19:32
gades pushed a commit to cosanta/cosanta-core that referenced this pull request Apr 21, 2022
…/OldDec… (dashpay#3320)

* Merge bitcoin#11024: tests: Remove OldSetKeyFromPassphrase/OldEncrypt/OldDecrypt

a897d0e tests: Remove OldSetKeyFromPassphrase/OldEncrypt/OldDecrypt (practicalswift)

Pull request description:

  Reduces the number of non-free:d allocs with four (Δ in use at exit = -928 bytes).

  With this patch applied:

  ```
  $ valgrind --leak-check=full --show-leak-kinds=all src/test/test_bitcoin --log_level=test_suite --run_test=wallet_crypto
  …
  ==20243== HEAP SUMMARY:
  ==20243==     in use at exit: 72,704 bytes in 1 blocks
  ==20243==   total heap usage: 53,138 allocs, 53,137 frees, 49,600,420 bytes allocated
  ==20243==
  ==20243== 72,704 bytes in 1 blocks are still reachable in loss record 1 of 1
  ==20243==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==20243==    by 0x6AA5EFF: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
  ==20243==    by 0x40106B9: call_init.part.0 (dl-init.c:72)
  ==20243==    by 0x40107CA: call_init (dl-init.c:30)
  ==20243==    by 0x40107CA: _dl_init (dl-init.c:120)
  ==20243==    by 0x4000C69: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
  ==20243==    by 0x2: ???
  ==20243==    by 0xFFF0006A2: ???
  ==20243==    by 0xFFF0006B8: ???
  ==20243==    by 0xFFF0006CF: ???
  ==20243==
  ==20243== LEAK SUMMARY:
  ==20243==    definitely lost: 0 bytes in 0 blocks
  ==20243==    indirectly lost: 0 bytes in 0 blocks
  ==20243==      possibly lost: 0 bytes in 0 blocks
  ==20243==    still reachable: 72,704 bytes in 1 blocks
  ==20243==         suppressed: 0 bytes in 0 blocks
  ```

  Without this patch applied:

  ```
  $ valgrind --leak-check=full --show-leak-kinds=all src/test/test_bitcoin --log_level=test_suite --run_test=wallet_crypto
  …
  ==19023== HEAP SUMMARY:
  ==19023==     in use at exit: 73,632 bytes in 5 blocks
  ==19023==   total heap usage: 52,718 allocs, 52,713 frees, 49,502,962 bytes allocated
  ==19023==
  ==19023== 24 bytes in 1 blocks are still reachable in loss record 1 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E5665: lh_insert (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7BB3: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E87AD: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
  ==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
  ==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
  ==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
  ==19023==    by 0x182596: invoke<void (*)()> (callback.hpp:56)
  ==19023==    by 0x182596: boost::unit_test::ut_detail::callback0_impl_t<boost::unit_test::ut_detail::unused, void (*)()>::invoke() (callback.hpp:89)
  ==19023==
  ==19023== 128 bytes in 1 blocks are still reachable in loss record 2 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E5331: lh_new (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7862: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7B7F: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E87AD: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
  ==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
  ==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
  ==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
  ==19023==
  ==19023== 176 bytes in 1 blocks are still reachable in loss record 3 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E530F: lh_new (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7862: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E7B7F: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E87AD: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
  ==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
  ==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
  ==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
  ==19023==
  ==19023== 600 bytes in 1 blocks are still reachable in loss record 4 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x642DE77: CRYPTO_malloc (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E8745: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64E883D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x64EAAE4: EVP_DecryptFinal_ex (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
  ==19023==    by 0x3AD150: wallet_crypto::OldDecrypt(std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, secure_allocator<unsigned char> >&, unsigned char const*, unsigned char const*) (crypto_tests.cpp:81)
  ==19023==    by 0x3AF892: wallet_crypto::TestCrypter::TestDecrypt(CCrypter const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&) (crypto_tests.cpp:137)
  ==19023==    by 0x3AD5E9: wallet_crypto::decrypt::test_method() (crypto_tests.cpp:223)
  ==19023==    by 0x3ADC11: wallet_crypto::decrypt_invoker() (crypto_tests.cpp:216)
  ==19023==    by 0x182596: invoke<void (*)()> (callback.hpp:56)
  ==19023==    by 0x182596: boost::unit_test::ut_detail::callback0_impl_t<boost::unit_test::ut_detail::unused, void (*)()>::invoke() (callback.hpp:89)
  ==19023==    by 0x596CCB0: ??? (in /usr/lib/x86_64-linux-gnu/libboost_unit_test_framework.so.1.58.0)
  ==19023==    by 0x594C995: boost::execution_monitor::catch_signals(boost::unit_test::callback0<int> const&) (in /usr/lib/x86_64-linux-gnu/libboost_unit_test_framework.so.1.58.0)
  ==19023==
  ==19023== 72,704 bytes in 1 blocks are still reachable in loss record 5 of 5
  ==19023==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==19023==    by 0x6AA5EFF: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
  ==19023==    by 0x40106B9: call_init.part.0 (dl-init.c:72)
  ==19023==    by 0x40107CA: call_init (dl-init.c:30)
  ==19023==    by 0x40107CA: _dl_init (dl-init.c:120)
  ==19023==    by 0x4000C69: ??? (in /lib/x86_64-linux-gnu/ld-2.23.so)
  ==19023==    by 0x2: ???
  ==19023==    by 0xFFF0006A2: ???
  ==19023==    by 0xFFF0006B8: ???
  ==19023==    by 0xFFF0006CF: ???
  ==19023==
  ==19023== LEAK SUMMARY:
  ==19023==    definitely lost: 0 bytes in 0 blocks
  ==19023==    indirectly lost: 0 bytes in 0 blocks
  ==19023==      possibly lost: 0 bytes in 0 blocks
  ==19023==    still reachable: 73,632 bytes in 5 blocks
  ==19023==         suppressed: 0 bytes in 0 blocks
  ==19023==
  ==19023== For counts of detected and suppressed errors, rerun with: -v
  ==19023== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
  ```

Tree-SHA512: 38b6552736a5710a42dbad770c490583cfc762acbec716f5db4cf38314f494ea99430713ea407c73b49d867676ced221a282437f3fcfd8346f8f68386f4fc74d
Signed-off-by: Pasta <pasta@dashboost.org>

# Conflicts:
#	src/wallet/test/crypto_tests.cpp

* tests: Remove Old{En,De}cryptAES256

Co-authored-by: Wladimir J. van der Laan <laanwj@gmail.com>
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants