Commit Graph

1278 Commits

Author SHA1 Message Date
Joseph Sutton
b8f8906822 asn1: Fix binary search off-by-one read
Previously, if left==right==A1_HEADER_LEN(tos), this would read past the
end of the template array. Now we treat [left, right) as a half-open
interval and no longer try to read from 'right'.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2021-12-13 19:18:24 -06:00
Luke Howard
47282cae34 krb5: import Heimdal-597.121.1 AS/TGS client
Sync with most changes in AS/TGS client from Apple's Heimdal-597.121.1
(opensource.apple.com).

Changes include:

 - FAST support in TGS client
 - Refactored pre-auth client to be more easily extensible
 - Pin KDC host and AD site name in API calls

Note the completely refactored TGS client loop is not imported as that was
considered too intrusive.
2021-12-14 09:03:42 +11:00
Joseph Sutton
527906c821 heimdal:kdc: Properly check for unsupported critical FAST options
Decoding a FAST request will only give us the FastOptions flags that are
explicitly declared in the ASN1 source. This meant that the check for
unsupported mandatory options would never succeed, and an unsupported
option would go undetected.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2021-12-07 15:31:58 +11:00
Andrew Bartlett
7686028718 Use UTF-8 in KTH copyright notice
Samba is starting to protect against bi-di attacks and the starting point
is to require that input files be fully UTF-8.  In 2021 this is a reasonable
starting point anyway.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2021-11-29 12:50:26 +11: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
232c936ea3 asn1: Work around missing ENOTSUP (WIN32)
Sufficiently old CRTs on Windows lack ENOTSUP.  Use EINVAL instead then.
2021-11-23 18:12:45 -06:00
Nicolas Williams
92e5a4b7e5 Revert "asn1: use roken for generated source files"
This reverts commit e27e056b45.

e27e056b45 was needed mainly for ENOTSUP.
ENOTSUP is not available in older C run-times.

Also, lib/roken has wrappers for the CRT allocator, but we don't need
those in lib/asn1 because all the functions generated by the compiler
effectively encapsulate the corresponding DLL's CRT's allocator.

This will be followed by a change to not use ENOTSUP.
2021-11-23 18:12:45 -06:00
Jeffrey Altman
d269c30b2b lib/asn1: all exported functions must use ASN1CALL convention
Otherwise, on 32-bit Windows there is a mismatch that and the
ESP register will not be populated correctly.

Prior to this change some exports were ASN1CALL and others
were not.   All of the tests assume ASN1CALL.

Change-Id: Icecff44aed4726b86100c939f64628d121bbd7ee
2021-11-16 22:09:16 -05:00
Jeffrey Altman
e27e056b45 asn1: use roken for generated source files
roken ensures the correct headers are used for each platform,
ensures availability of non-portable constants (e.g. ENOTSUP),
and on Windows enforces a consistent source for memory management.

Change-Id: I31aa2935d0af9f3d9529166679d9eff35ccedfad
2021-11-16 13:29:32 -05:00
Luke Howard
18a7562fa4 asn1: initialize L in ASN1_MALLOC_ENCODE
MSVC complains about uninitialized variables, set (L) to zero in failure case
from ASN1_MALLOC_ENCODE()
2021-09-21 18:59:38 +10:00
Isaac Boukris
bb1d8f2a8c kdc: remove KRB5SignedPath, to be replaced with PAC
KRB5SignedPath was a Heimdal-specific authorization data element used to
protect the authenticity of evidence tickets when used in constrained
delegation (without a Windows PAC).

Remove this, to be replaced with the Windows PAC which itself now supports
signing the entire ticket in the TGS key.
2021-09-19 13:02:12 +10:00
Nicolas Williams
5702bd5b77 asn1: Also decode ProxyCertInfo 2021-09-15 10:56:19 -05:00
Luke Howard
207bfc066d krb5: add unkeyed SHA-2 checksum types
Add unkeyed checksum types for SHA-256, SHA-384 and SHA-512, for future
internal use. They are assigned private (negative) checksum types and must
never appear in cleartext on the wire.
2021-09-13 17:08:32 +10:00
Luke Howard
ebfd48e40a kdc: avoid re-encoding KDC-REQ-BODY
Use --preserve-binary=KDC-REQ-BODY option to ASN.1 compiler to avoid
re-encoding KDC-REQ-BODYs for verification in GSS preauth, TGS and PKINIT.
2021-09-13 13:50:45 +10:00
heitbaum
c7bd01c62a yyerror: update to POSIX standard
To comply with the latest POSIX standard, in Yacc compatibility mode
(options `-y`/`--yacc`) Bison now generates prototypes for yyerror and
yylex.  In some situations, this is breaking compatibility: if the user
has already declared these functions but with some differences (e.g., to
declare them as static, or to use specific attributes), the generated
parser will fail to compile.  To disable these prototypes, #define yyerror
(to `yyerror`), and likewise for yylex.

refer: https://git.savannah.gnu.org/cgit/bison.git/tree/NEWS

GNU Bison 3.8
2021-09-10 09:11:23 +10:00
Luke Howard
ed1ef5d776 asn1: correctly check gmtime_s() return value
gmtime_s(), used on Windows, returns an errno_t not a struct tm *.

The previous code caused strftime() to dereference a NULL struct tm *.
2021-08-27 16:10:03 +10:00
Nicolas Williams
edf259dac9 asn1: Update comment in rfc2459.asn1 2021-08-25 15:42:24 -05:00
Nicolas Williams
df4b09f8af asn1: Also pretty-print cert policies 2021-08-12 17:31:35 -05:00
Luke Howard
49f3f5bd99 kdc: support for GSS-API pre-authentication
Add support for GSS-API pre-authentication to the KDC, using a simplified
variation of draft-perez-krb-wg-gss-preauth-02 that encodes GSS-API context
tokens directly in PADATA, and uses FX-COOKIE for state management.

More information on the protocol and implementation may be found in
lib/gssapi/preauth/README.md.
2021-08-12 17:37:01 +10:00
Luke Howard
89ff0eb462 asn1: ensure template generator includes ASN1CALL
Windows 32-bit builds were broken as the ASN1CALL calling convention
macro was not included in the output of gen_template.c, only in the
generated header.
2021-08-12 16:33:45 +10:00
Isaac Boukris
a4527a28a3 Implement KERB_AP_OPTIONS_CBT (server side)
if the client asserted knowledge of channel-bindings by
passing KERB_AP_OPTIONS_CBT, and the server passed bindings,
require the bindings to match.
2021-08-06 13:15:19 +10:00
Luke Howard
b8728cae14 asn1: GSER is RFC3641, not RFC2641
Update README.md.
2021-07-09 20:04:56 +10:00
Luke Howard
f67dd0f903 roken: move Heimdal vis.h extensions to separate header
vis.h is not built on platforms (such as macOS) that already have
that header, which resulted in prototypes for Heimdal-specific
vis.h extensions being absent.

Move those prototypes to a separate header, vis-extras.h, which
must be explicitly included in order to use the Heimdal extensions.
2021-05-17 10:05:58 +10:00
Nicolas Williams
1e65ebd5eb asn1: Fix Windows build 2021-04-25 10:45:43 -05:00
Nicolas Williams
ec171ef0b6 asn1: Add missing file gen_print.c 2021-04-25 10:45:43 -05:00
Nicolas Williams
5c93af553b asn1: Build both backends
The codegen backend is faster than the template backend, even for
modules that don't use IOS.  On x64 we see the template backend being
4% slower for TGS requests using the kdc-tester program.

So let's build both, libasn1 (codegen) and libasn1template when
configured with --disable-asn1-templating, but make sure that the
asn1_print utility is linked with libasn1template.

Eventually we'll want to either optimize the template backend better,
or add IOS and JSON printing support to the codegen backend.
2021-04-23 22:15:51 -05:00
Nicolas Williams
32b314b174 asn1: Generate print stubs (codegen) 2021-04-23 22:15:51 -05:00
Nicolas Williams
407f12cc0b asn1: Fix --disable-asn1-templating build 2021-04-21 22:40:41 -05:00
Nicolas Williams
9dcab76724 asn1: Fix build concurrency bug 2021-04-01 01:08:00 -05:00
Nicolas Williams
9ff74bcd21 asn1: Fix check/print type confusion 2021-04-01 01:08:00 -05:00
Nicolas Williams
e7a8457fd2 asn1: Fix extra.c printer functions 2021-04-01 01:08:00 -05:00
Nicolas Williams
614b3a5914 asn1: Fix OS X build
We can't use VIS_DQ on when the OS has a vis implementation but lacks
VIS_DQ.
2021-03-27 23:29:34 -05:00
Nicolas Williams
7985f402cb asn1: Attempt to fix makefile concurrency bug 2021-03-26 17:27:47 -05:00
Nicolas Williams
c74c57a143 asn1: Fix lib/asn1/Makefile.am buglet 2021-03-26 17:27:47 -05:00
Nicolas Williams
f0e628c2cf asn1: Add Heimdal cert ext for ticket max_life 2021-03-24 19:12:00 -05:00
Nicolas Williams
94f9d67b3d asn1: Update AFL screenshot 2021-03-18 18:07:23 -05:00
Nicolas Williams
36c6342230 asn1: Fix Linux build 2021-03-18 18:03:34 -05:00
Nicolas Williams
57de79ce6d asn1: Make asn1_print good for benchmarking 2021-03-11 11:58:41 -06:00
Nicolas Williams
c4ff603adf asn1: Fix asn1_print build w/ templating 2021-03-11 11:58:18 -06:00
Nicolas Williams
36c6ff407e asn1: Fix Windows build harder 2021-03-11 09:57:18 -06:00
Nicolas Williams
a858821194 asn1: Fix Windows build 2021-03-11 09:50:48 -06:00
Nicolas Williams
4d39e8c1b2 asn1: Also fuzz using X.690 sample 2021-03-11 09:36:53 -06:00
Nicolas Williams
d0298e5804 asn1: Fix recent der_replace_tag() bug
Recently introduced.
2021-03-11 09:13:09 -06:00
Nicolas Williams
5bb5887f8c asn1: Fix recent der_match_tag2() bug
Recently introduced.
2021-03-11 09:12:43 -06:00
Nicolas Williams
1b5fe4a35c asn1: Test x690 sample with both backends
And remove it from the library itself.
2021-03-10 22:52:07 -06:00
Nicolas Williams
be2525ef29 asn1: Fix rfc2459.asn1 compilation w/o templates 2021-03-10 21:21:26 -06:00
Nicolas Williams
05a952dbb9 asn1: Fix IMPLICIT tagging (codegen) 2021-03-10 19:15:17 -06:00
Nicolas Williams
7f4e9db9f9 asn1: Make int sizing consistent and better 2021-03-10 19:15:17 -06:00
Nicolas Williams
440bfeda58 asn1: Allow asn1_print to build w/o templating 2021-03-10 16:00:04 -06:00
Nicolas Williams
c69a9764bc asn1: Update README.md 2021-03-10 12:24:01 -06:00