• Cryptographic zero initialization (was: Re: Initialization Of Static Pointer Variables)

    From Johann 'Myrkraverk' Oskarsson@johann@myrkraverk.invalid to comp.lang.c,alt.lang.asm,comp.lang.asm on Mon Aug 24 19:26:26 2026
    From Newsgroup: alt.lang.asm

    On 24/08/2026 4:01 AM, steve g wrote:
    David Brown <david.brown@hesbynett.no> writes:

    On 21/08/2026 21:12, Chris M. Thomasson wrote:
    On 8/20/2026 4:42 PM, Richard Tobin wrote:
    In article <11681np$3s8jk$4@dont-email.me>,
    Lawrence D;Oliveiro-a <ldo@nz.invalid> wrote:

    The spec also says that all static variables are initialized to zero >>>>> at program start time. Are pointer variables allowed to be given an
    all-zero bit pattern at this time? Or are they supposed to be
    initialized to the NULL value (if that's different) instead?

    ISO C 1999, 6.7.8:

    If an object that has automatic storage duration is not initialized
    explicitly, its value is indeterminate. If an object that has static
    storage duration is not initialized explicitly, then:

    rCo if it has pointer type, it is initialized to a null pointer;
    Oh. I must have missed that one.
    so:
    static void* g_ptr;
    is guaranteed to be nullptr? Just to clarify...

    Yes.

    I would still recomend memset or bzero. You never know what is complient
    or not - better to be safe then sorry.

    And if your need is cryptographic security, you should be using Micro-
    soft's SecureZeroMemory() or its equivalent,


    https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/aa366877(v=vs.85)

    and never mind the legacy warning, it's still there in the header files,
    and it's just a fancy way to write STOSB, so I'm including alt.lang.asm,
    and comp.lang.asm in this discussion; this is to annoy the trolls in comp.lang.c.

    Of course, many of the trolls in comp.lang.c are Linux supremacists, so
    they're going to have to figure out what GCC offers for the equivalent functionality.

    After all, /SecureZeroMemory()/ cannot be optimized out, or it wouldn't
    be secure.

    I'm actually curious about the equivalent function in GCC, since one of
    my many hobbies is cryptographic programming.


    Happy programming cryptography in assembly!
    --
    Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
    I'm not from the Internet, I just work there. | via Easynews.com https://bsky.app/profile/myrkraverk.bsky.social | for ( ;; ) _:;
    --- Synchronet 3.22a-Linux NewsLink 1.2