Commit Graph

1288 Commits

Author SHA1 Message Date
Nicolas Williams
1cede09a0b krb5: Add support for AD-KDC-ISSUED 2022-01-01 23:30:15 -06:00
Nicolas Williams
87f8c0d2b5 krb5: Add name attributes to krb5_principal
We now have what we need in krb5_principal to implement much of RFC6680.
Now we populate those fields so that they can be accessed by GSS-API
RFC6680 name attributes functions.

The next commit should add much of the GSS-API RFC6680 name attributes
functions and functionality.
2022-01-01 23:30:15 -06:00
Nicolas Williams
ca71e365ec asn1: Move decoration to krb5.opt file 2021-12-30 18:54:54 +11:00
Nicolas Williams
6baac3126f asn1: Fix template decoration copy 2021-12-23 19:11:49 -06:00
Luke Howard
7990dc287d asn1: use " instead of ' when quoting on Windows
NMAKE on Windows requires " instead of ' be used when quoting arguments. Fixes
regression introduced in fe095aa1c0.
2021-12-22 14:52:04 +11:00
Nicolas Williams
fe095aa1c0 krb5: Decorate Principal type with name attributes
See `asn1: Add --decorate=... for internal bookkeeping`, which adds an
option to `asn1_compile` for decorating SET/SEQUENCE types with fields
that are neither encoded nor decoded, but which _are_ copied and freed.

We'll use this to add name attributes to the `Principal` type (which is
used to represent Kerberos principal names in the krb5 GSS mechanism)
without having to rototill the GSS krb5 mechanism nor the krb5 library,
and without affecting the encodings of HDB entries (which happen to use
the `Principal` type).
2021-12-20 11:51:53 -06:00
Nicolas Williams
8962abdfbc asn1: Fix build (revert bits of 823fb8247) 2021-12-20 11:51:53 -06:00
Nicolas Williams
823fb82477 asn1: Add --decorate=... for internal bookkeeping
This option, `--decorate=TYPE-NAME:FIELD-TYPE:field-name[?]` allows one to add
a field to any struct generated by the ASN.1 compiler for any SET or SEQUENCE
type such that:

 - the field will     be freed by the `free_TYPE_NAME()` function
 - the field will     be copied by the `copy_TYPE_NAME()` function
 - the field will not be printed by the `print_TYPE_NAME()` function
 - the field will NOT be encoded or decoded

This is useful for internal bookkeeping.

The first use of this may well be for adding an optional field to
`Principal` where information about name attributes will be stored,
which will then allow us to have GSS name attributes for the krb5
mechanism w/o having to refactor the mechanism to use a different
structure for representing `gss_name_t` mechnames than the one currently
used (`Principal`; `krb5_principal` happens to be a typedef alias of
`Principal *`).

So w/o massive rototilling of the GSS krb5 mechanism we can have name
attributes, _and_ we'll also be able to have those in the krb5 API as
well w/o any massive rototilling there either.
2021-12-19 23:21:35 -06:00
Nicolas Williams
309d1192df asn1: Add module->JSON dump 2021-12-19 23:21:35 -06:00
Luke Howard
e7588952ce kdc: add auth data type for synthetic principals
Add a new authorization data type to indicate a synthetic principal was used,
to allow synthetic clients acquired outside of PKINIT (e.g. with GSS-API
pre-authentication) to use the TGS.

Note: we continue to honor KRB5_AUTHDATA_INITIAL_VERIFIED_CAS to indicate that
it is OK for the client to be synthetic, even though it is only an indication
that the client *may* have been synthetic.
2021-12-18 15:09:38 +11:00
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