Re:Writing a C library, part 1: best practices for writing C...
by tptacek on Monday June 27, 2011 @09:25PM
(#2703657)
What's a well-regarded C library of medium complexity (something that isn't going to be the entire kernel of an application) that does that? I can't think of an example off the top of my head.
[ Parent
| on HN ]
Re:Writing a C library, part 1: best practices for writing C...
by sg2342 on Monday June 27, 2011 @09:39PM
(#2703687)
I would require this in every C library that provides a crypto framework or provides support functionality for such a framework. And to extend this: i would require this in every c library that touches cleartext (in an cryptographic application).
Re:Writing a C library, part 1: best practices for writing C...
by tptacek on Tuesday June 28, 2011 @01:15PM
(#2706223)
What popular encryption library does this? Also: what would you do specially in your allocator? It seems wrong to me that the users of a library should be expected to know (for instance) the precise incantation required to clear cache footprints on Core2 processors; that seems like an internal library concern.
Re:Writing a C library, part 1: best practices for writing C...
by sg2342 on Thursday June 30, 2011 @07:46AM
(#2713589)
on top of my head: libgmp (not a crypto library but used by some), libgcrypt, openssl (requires a dynamic engine to do this), libssh2, libmcrypt ...
IMHO the user of an encryption library (the developer of a crypto application) should at least be able to ensure that every bit of heap that was touched by the library is zeroed after it was freed.
Re:Writing a C library, part 1: best practices for writing C...
by shaggyfrog on Monday June 27, 2011 @09:33PM
(#2703678)
I would say it's not a common pattern, if only because most libraries aren't written with embedded systems with only a few megabytes (or even kilobytes) of available memory.
I've at least seen it firsthand in C++ systems written for game consoles (PS2) from my time in that industry.
Re:Writing a C library, part 1: best practices for writing C...
by shaggyfrog on Wednesday June 29, 2011 @11:31PM
(#2712402)
Stupid me, I forgot about libxml2. I even asked their mailing list about it 3 years ago: http://mail.gnome.org/archives/xml/2008-June/msg00085.html
Re:Writing a C library, part 1: best practices for writing C...
by defen on Monday June 27, 2011 @11:07PM
(#2703884)
libpng lets you specify your own malloc/free functions.
Re:Writing a C library, part 1: best practices for writing C...
by tptacek on Tuesday June 28, 2011 @01:15PM
(#2706225)
That's a great example. Thanks.