openssl: abstract out OPENSSL_cleanse #5689

pull theuni wants to merge 1 commits into bitcoin:master from theuni:cleanse changing 13 files +44 −17
  1. theuni commented at 12:28 AM on January 21, 2015: member

    This makes it easier for us to replace it if desired, since it's now only in one spot. Also, it avoids the openssl include from allocators.h, which essentially forced openssl to be included from every compilation unit.

    Also a few minor header cleanups.

    I'm not a big fan of putting a single function in this object, but we use it at such low levels (allocators.h) that i don't want to stick it somewhere that would pull in other headers. Suggestions welcome.

  2. theuni force-pushed on Jan 21, 2015
  3. laanwj commented at 8:14 AM on January 21, 2015: member

    Concept ACK.

    I'm not against one function per object if that makes sense but let's not put all of these at the top level. For organizational purposes could put it in a subdirectory below src, e.g. support or util.

  4. laanwj added the label Improvement on Jan 21, 2015
  5. theuni commented at 5:42 PM on January 29, 2015: member

    Sorry for the lack of response. I've been putting this off because this is part of a larger reorganization, and I figured I'd wait until it took shape before moving it somewhere since I'm not sure how it will end up looking. Right now, it'd make sense to move this along with the string/time/etc utils to some utils/ dir, but I'd also like to keep the consensus/app-specific stuff segregated in some way.

  6. theuni commented at 10:22 PM on February 6, 2015: member

    @laanwj After looking working on a refactor including this for a while, I still don't really have a good place for it. How about leaving it at the top for now and moving it to support/util when there's more stuff that can go there? For ex, we may consider moving random.o and other remaining openssl users into there, so that we have a more straightforward path to removal.

    Otherwise, I'm happy to move it to whereever you prefer.

  7. laanwj commented at 11:37 AM on February 9, 2015: member

    Well we are in the process of moving source files from the top level, so I'm not that happy to create more there. As for "let's move it later". If we know we are going to move it I prefer to create it in the right place (this avoids extra rebases as well as diff noise). I don't mind if this is the only file in support/ for now.

  8. theuni commented at 6:19 PM on February 9, 2015: member

    Ok, will do.

  9. theuni force-pushed on Feb 9, 2015
  10. theuni commented at 8:58 PM on February 9, 2015: member

    moved and rebased.

  11. in src/support/cleanse.cpp:None in c5e5ff2c97 outdated
       6 | +#include "cleanse.h"
       7 | +#include <openssl/crypto.h> // for OPENSSL_cleanse()
       8 | +
       9 | +void memory_cleanse(void *ptr, size_t len)
      10 | +{
      11 | +  OPENSSL_cleanse(ptr, len);
    


    sipa commented at 6:20 AM on February 14, 2015:

    4 spaces indentation, pretty please?


    theuni commented at 4:21 PM on February 15, 2015:

    Grr.. still haven't managed to completely break this habit. Will fix.

  12. sipa commented at 6:21 AM on February 14, 2015: member

    utACK

  13. in src/support/cleanse.cpp:None in c5e5ff2c97 outdated
       0 | @@ -0,0 +1,12 @@
       1 | +// Copyright (c) 2009-2010 Satoshi Nakamoto
       2 | +// Copyright (c) 2009-2015 The Bitcoin Core developers
       3 | +// Distributed under the MIT software license, see the accompanying
       4 | +// file COPYING or http://www.opensource.org/licenses/mit-license.php.
       5 | +
       6 | +#include "cleanse.h"
       7 | +#include <openssl/crypto.h> // for OPENSSL_cleanse()
    


    Diapolo commented at 1:49 PM on February 14, 2015:

    Nit: Can you add a new-line here please?

  14. in src/support/cleanse.h:None in c5e5ff2c97 outdated
       0 | @@ -0,0 +1,12 @@
       1 | +// Copyright (c) 2009-2010 Satoshi Nakamoto
       2 | +// Copyright (c) 2009-2015 The Bitcoin Core developers
       3 | +// Distributed under the MIT software license, see the accompanying
       4 | +// file COPYING or http://www.opensource.org/licenses/mit-license.php.
       5 | +
       6 | +#ifndef BITCOIN_CLEANSE_H
       7 | +#define BITCOIN_CLEANSE_H
       8 | +#include <stdlib.h>
    


    Diapolo commented at 1:49 PM on February 14, 2015:

    Nit: Same here, new-line is missing.

  15. in src/support/cleanse.h:None in c5e5ff2c97 outdated
       0 | @@ -0,0 +1,12 @@
       1 | +// Copyright (c) 2009-2010 Satoshi Nakamoto
       2 | +// Copyright (c) 2009-2015 The Bitcoin Core developers
       3 | +// Distributed under the MIT software license, see the accompanying
       4 | +// file COPYING or http://www.opensource.org/licenses/mit-license.php.
       5 | +
       6 | +#ifndef BITCOIN_CLEANSE_H
    


    Diapolo commented at 1:49 PM on February 14, 2015:

    This should be BITCOIN_SUPPORT_CLEANSE_H and you are currently missing the header end comment :).

  16. Diapolo commented at 1:50 PM on February 14, 2015: none

    utACK after fixing the comments.

  17. theuni force-pushed on Feb 15, 2015
  18. theuni commented at 4:25 PM on February 15, 2015: member

    Nits addressed.

  19. openssl: abstract out OPENSSL_cleanse
    This makes it easier for us to replace it if desired, since it's now only in
    one spot. Also, it avoids the openssl include from allocators.h, which
    essentially forced openssl to be included from every compilation unit.
    1630219d90
  20. Diapolo commented at 4:38 PM on February 15, 2015: none

    Thanks, utACK!

  21. sipa commented at 8:03 PM on February 16, 2015: member

    utACK

  22. laanwj commented at 11:00 AM on February 19, 2015: member

    utACK

  23. laanwj merged this on Feb 19, 2015
  24. laanwj closed this on Feb 19, 2015

  25. laanwj referenced this in commit 07f4386b38 on Feb 19, 2015
  26. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-18 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me