Changeset View
Standalone View
contrib/dhcpcd/compat/consttime_memequal.h
- This file was added.
Property | Old Value | New Value |
---|---|---|
svn:eol-style | null | native \ No newline at end of property |
svn:keywords | null | FreeBSD=%H \ No newline at end of property |
svn:mime-type | null | text/plain \ No newline at end of property |
/* | |||||
* Written by Matthias Drochner <drochner@NetBSD.org>. | |||||
* Public domain. | |||||
*/ | |||||
ziaee: I think according to the licensing guide this needs to be relicensed or get an exemption from… | |||||
Not Done Inline Actions
I can probably use FreeBSDs timingsafe_memcmp(3) in a macro instead to avoid including this compat file if that’s a problem. I will look into that next week when I get back to my desk. roy_marples.name: > I think according to the licensing guide this needs to be relicensed or get an exemption from… | |||||
Not Done Inline ActionsIf you can re-use other bits of FreeBSD, that's likely good to do. It would avoid the issue. And I think it makes good sense here to have that small variation from the upstream, since it can be handled easily enough in all the canonical ways. I'd go so far as to say reusing the FreeBSD standard thing is safer and better. Now, were it not the case that there's a great FreeBSD alternative, getting an exemption from core@ (more likely srcmgr@) for the public domain license wouldn't be a problem. It's only an issue, really, when it's something like the yacc-shaving-plenipotentiary-license-v1.58 (eg, something weird and against the goals of the project to make it easier to share). imp: If you can re-use other bits of FreeBSD, that's likely good to do. It would avoid the issue. | |||||
Not Done Inline Actions
Fixed upstream here: https://github.com/NetworkConfiguration/dhcpcd/commit/46b6a361bb0444c4e93bc565bbee2ea17e65d2d1 To get the same fix in this version if you want, simply change the generated config.h file to use - include "compat/consttime_memequal.h" + #define consttime_memequal !timingsafe_bcmp roy_marples.name: > > I think according to the licensing guide this needs to be relicensed or get an exemption… | |||||
#ifndef CONSTTIME_MEMEQUAL_H | |||||
#define CONSTTIME_MEMEQUAL_H | |||||
inline static int | |||||
consttime_memequal(const void *b1, const void *b2, size_t len) | |||||
{ | |||||
const unsigned char *c1 = b1, *c2 = b2; | |||||
unsigned int res = 0; | |||||
while (len--) | |||||
res |= *c1++ ^ *c2++; | |||||
/* | |||||
* Map 0 to 1 and [1, 256) to 0 using only constant-time | |||||
* arithmetic. | |||||
* | |||||
* This is not simply `!res' because although many CPUs support | |||||
* branchless conditional moves and many compilers will take | |||||
* advantage of them, certain compilers generate branches on | |||||
* certain CPUs for `!res'. | |||||
*/ | |||||
return (1 & ((res - 1) >> 8)); | |||||
} | |||||
#endif /* CONSTTIME_MEMEQUAL_H */ |
I think according to the licensing guide this needs to be relicensed or get an exemption from core@, many companies and countries don't accept "public domain dedications" as open source, e.g. I am forbidden by my company from touching this file.
https://docs.freebsd.org/en/articles/license-guide/