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

HDWallet: Use some kind of secure zero instead of memset that could be optimised out #34

Open
2 tasks
vincenthz opened this issue Mar 13, 2018 · 1 comment

Comments

@vincenthz
Copy link
Collaborator

  • investigate the right construction: potential candidate already suggested
  • make sure it's portable to windows
@vincenthz vincenthz changed the title Use some kind of secure zero instead of memset that could be optimised out HDWallet: Use some kind of secure zero instead of memset that could be optimised out Mar 13, 2018
mirkoAlic pushed a commit to mirkoAlic/cardano-crypto that referenced this issue Jan 9, 2019
@nalyd88
Copy link

nalyd88 commented Jan 29, 2022

How about something like this?

void clear(void *buf, uint32_t const sz)
{
#ifdef _WIN32
    SecureZeroMemory(buf, sz);
#elseif  __STDC_LIB_EXT1__
    memset_s(buf, sz, 0, sz);
#else
    volatile unsigned char *volatile pnt_ =
        (volatile unsigned char *volatile) buf;
    size_t i = (size_t) 0U;
    while (i < sz)
        pnt_[i++] = 0U;
#endif
}

References
www.cryptologie.net
libsodium

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants