12 Commits

Author SHA1 Message Date
Nicolas Williams
08c48c10c8 base: Add atomic CAS macros/functions 2023-01-10 23:28:33 -06:00
Nicolas Williams
1429814eda base: HEIM_JSON_F_TRY_DECODE_DATA cannot work
The idea with HEIM_JSON_F_TRY_DECODE_DATA is that on parsing of JSON
texts, if we find a base64-encoded string, decode it.  But a lot of
strings that aren't base64-encoded can be decoded anyways, leaving a
mess.

Insted we should -in a future commit- implement this only for the string
values of "heimdal-type-data-76d7fca2-d0da-4b20-a126-1a10f8a0eae6" names
in singleton objects.
2022-10-02 22:46:37 -05:00
Nicolas Williams
8364bdd8f3 base: Add JSON string non-ASCII escaping options
- Add HEIM_JSON_F_ESCAPE_NON_ASCII to indicate that non-ASCII must be
   escaped as \uXXXX.

 - Add HEIM_JSON_F_NO_ESCAPE_NON_ASCII to force non-escaping of BMP
   codepoints.

 - If the locale's codeset is not UTF-8 and
   HEIM_JSON_F_NO_ESCAPE_NON_ASCII is not set, then set
   HEIM_JSON_F_ESCAPE_NON_ASCII.
2022-10-02 22:46:37 -05:00
Nicolas Williams
c6a46f0c96 base: Implement JSON string escaping
We encode JSON in the KDC's audit logs, and soon in bx509d's /get-tgts.
Therefore, we should be reasonable in terms of what we encode.
2022-09-29 17:05:24 -05:00
Luke Howard
917e16049a base: make heim_alloc deallocator use HEIM_CALLCONV 2022-01-28 17:24:57 -06:00
Nicolas Williams
3f2b1007a3 base: Fix test_base clang-13 build 2022-01-02 21:16:36 -06:00
Nicolas Williams
5f63215d0d Always perform == or != operation on cmp function result
Although not required to address bad code generation in
some versions of gcc 9 and 10, a coding style that requires
explicit comparison of the result to zero before use is
both clearer and would have avoided the generation of bad
code.

This change converts all use of cmp function usage from

```
    if (strcmp(a, b) || !strcmp(c, d)) ...
```

to

```
    if (strcmp(a, b) != 0 || strcmp(c, d)) == 0
```

for all C library cmp functions and related:

 - strcmp(), strncmp()
 - strcasecmp(), strncasecmp()
 - stricmp(), strnicmp()
 - memcmp()

Change-Id: Ic60c15e1e3a07e4faaf10648eefe3adae2543188
2021-11-24 22:30:44 -05:00
Nicolas Williams
490337f4f9 Make OpenSSL an hcrypto backend proper
This adds a new backend for libhcrypto: the OpenSSL backend.

Now libhcrypto has these backends:

 - hcrypto itself (i.e., the algorithms coded in lib/hcrypto)
 - Common Crypto (OS X)
 - PKCS#11 (specifically for Solaris, but not Solaris-specific)
 - Windows CNG (Windows)
 - OpenSSL (generic)

The ./configure --with-openssl=... option no longer disables the use of
hcrypto.  Instead it enables the use of OpenSSL as a (and the default)
backend in libhcrypto.  The libhcrypto framework is now always used.

OpenSSL should no longer be used directly within Heimdal, except in the
OpenSSL hcrypto backend itself, and files where elliptic curve (EC)
crypto is needed.

Because libhcrypto's EC support is incomplete, we can only use OpenSSL
for EC.  Currently that means separating all EC-using code so that it
does not use hcrypto, thus the libhx509/hxtool and PKINIT EC code has
been moved out of the files it used to be in.
2016-04-15 00:16:17 -05:00
Nicolas Williams
9f2642acae Fix lib/base/test_base rwlock test 2016-04-15 00:16:14 -05:00
Jeffrey Altman
1dcfceb090 lib/base: add tests for mutex and rwlock
Add a basic set of tests for the HEIMDAL_MUTEX and HEIMDAL_RWLOCK
abstraction using both static and dynamic initialization.

Change-Id: Iaeb16e5dfcf00d29be7eaa4f2e6970c4f1268fb0
2016-04-10 17:05:07 -05:00
Love Hornquist Astrand
58ff480763 rewrite send to kdc to be more agressive, try kdcs in paralell and easier to configure behavior 2013-02-10 19:02:52 -08:00
Nicolas Williams
98809e86ce Move base into lib
This involves reverting dd267e8fc3,
    but that gets lost in the move.

    This builds on Ubuntu and Windows at this time.
2012-06-20 19:32:08 -05:00