Commit Graph

107 Commits

Author SHA1 Message Date
Daria Phoebe Brashear
133f517482 rewrite fallthrough to HEIM_FALLTHROUGH to deal with new Apple SDKs
Apple clang version 14.0.0 (clang-1400.0.17.3.1) fails the build
because stds.h defines `fallthrough` as a macro which is then
expanded when base.h evaluates

  # if __has_attribute(fallthrough) && __clang_major__ >= 5

The macOS SDK defines `DISPATCH_FALLTHROUGH` as the macro instead
of `fallthrough`.

This change replaces the use of `fallthrough` in the tree with
`HEIM_FALLTHROUGH` and updates the declaration in configure logic
to define `HEIM_FALLTHROUGH` based upon existing definitions
(if any) of `fallthrough` or `DISPATCH_FALLTHROUGH`.
2022-09-16 15:58:45 -04:00
Jeffrey Altman
04527412e3 Follow the Linux kernel's lead on "fallthrough"
The pseudo keyword 'fallthrough' is defined such that case statement
blocks must end with any of these keywords:
 * break;
 * fallthrough;
 * continue;
 * goto <label>;
 * return [expression];
 *
 *  gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes

The macro is defined either as

  __attribute__((__fallthrough__))

or as

  do {} while (0)  /* fallthrough */

not including the semicolon.

This change implements the Linux kernel style and updates several locations
where "/*fallthrough*/ and /* FALLTHROUGH */ were not previously replaced.

Externally imported code such as libedit, libtommath and sqlite are
restored to their unaltered state.

Change-Id: I69db8167b0d5884f55d96d72de3059a0235a1ba3
2022-01-21 10:39:47 -05:00
Nicolas Williams
dd71303a2f hx509: Fix coverity warnings 2022-01-17 17:36:48 -06:00
Nicolas Williams
c607135a03 Use fallthrough statement attribute (moar) 2022-01-14 16:53:34 -06:00
Nicolas Williams
ddc6113610 Use fallthrough statement attribute 2022-01-14 16:32:58 -06:00
Luke Howard
ef1d63a997 kinit: add --pk-anon-fast-armor option
Add the  --pk-anon-fast-armor option, which acquires a temporary anonymous
PKINIT TGT to use as a FAST armor key.
2021-08-10 15:30:45 +10:00
Nicolas Williams
db7763ca7b asn1: X.681/682/683 magic handling of open types
Status:

 - And it works!

 - We have an extensive test based on decoding a rich EK certficate.

   This test exercises all of:

    - decoding
    - encoding with and without decoded open types
    - copying of decoded values with decoded open types
    - freeing of decoded values with decoded open types

   Valgrind finds no memory errors.

 - Added a manual page for the compiler.

 - rfc2459.asn1 now has all three primary PKIX types that we care about
   defined as in RFC5912, with IOS constraints and parameterization:

    - `Extension`       (embeds open type in an `OCTET STRING`)
    - `OtherName`       (embeds open type in an        `ANY`-like type)
    - `SingleAttribute` (embeds open type in an        `ANY`-like type)
    - `AttributeSet`    (embeds open type in a  `SET OF ANY`-like type)

   All of these use OIDs as the open type type ID field, but integer
   open type type ID fields are also supported (and needed, for
   Kerberos).

   That will cover every typed hole pattern in all our ASN.1 modules.

   With this we'll be able to automatically and recursively decode
   through all subject DN attributes even when the subject DN is a
   directoryName SAN, and subjectDirectoryAttributes, and all
   extensions, and all SANs, and all authorization-data elements, and
   PA-data, and...

   We're not really using `SingleAttribute` and `AttributeSet` yet
   because various changes are needed in `lib/hx509` for that.

 - `asn1_compile` builds and recognizes the subset of X.681/682/683 that
   we need for, and now use in, rfc2459.asn1.  It builds the necessary
   AST, generates the correct C types, and generates templating for
   object sets and open types!

 - See READMEs for details.

 - Codegen backend not tested; I won't make it implement automatic open
   type handling, but it should at least not crash by substituting
   `heim_any` for open types not embedded in `OCTET STRING`.

 - We're _really_ starting to have problems with the ITU-T ASN.1
   grammar and our version of it...

   Type names have to start with upper-case, value names with
   lower-case, but it's not enough to disambiguate.

   The fact the we've allowed value and type names to violate their
   respective start-with case rules is causing us trouble now that we're
   adding grammar from X.681/682/683, and we're going to have to undo
   that.

   In preparation for that I'm capitalizing the `heim_any` and
   `heim_any_set` types, and doing some additional cleanup, which
   requires changes to other parts of Heimdal (all in this same commit
   for now).

   Problems we have because of this:

    - We cannot IMPORT values into modules because we have no idea if a
      symbol being imported refers to a value or a type because the only
      clue we would have is the symbol's name, so we assume IMPORTed
      symbols are for types.

      This means we can't import OIDs, for example, which is super
      annoying.

      One thing we might be able to do here is mark imported symbols as
      being of an undetermined-but-not-undefined type, then coerce the
      symbol's type the first time it's used in a context where its type
      is inferred as type, value, object, object set, or class.  (Though
      since we don't generate C symbols for objects or classes, we won't
      be able to import them, especially since we need to know them at
      compile time and cannot defer their handling to link- or
      run-time.)

    - The `NULL` type name, and the `NULL` value name now cause two
      reduce/reduce conflicts via the `FieldSetting` production.

    - Various shift/reduce conflicts involving `NULL` values in
      non-top-level contexts (in constraints, for example).

 - Currently I have a bug where to disambiguate the grammar I have a
   CLASS_IDENTIFIER token that is all caps, while TYPE_IDENTIFIER must
   start with a capital but not be all caps, but this breaks Kerberos
   since all its types are all capitalized -- oof!

   To fix this I made it so class names have to be all caps and
   start with an underscore (ick).

TBD:

 - Check all the XXX comments and address them
 - Apply this treatment to Kerberos!  Automatic handling of authz-data
   sounds useful :)
 - Apply this treatment to PKCS#10 (CSRs) and other ASN.1 modules too.
 - Replace various bits of code in `lib/hx509/` with uses of this
   feature.
 - Add JER.
 - Enhance `hxtool` and `asn1_print`.

Getting there!
2021-02-28 18:13:08 -06:00
Nicolas Williams
7d50445d1b Generic: Fix warnings (fallthrough mosty) 2020-09-07 22:04:59 -05:00
Jeffrey Altman
387684aa93 WIN32: fix calling conventions for 32-bit builds
On 32-bit Windows Intel builds the __cdecl and __stdcall calling
conventions are different so labeling the functions that are
exported or assigned to function pointers matters.

Change-Id: I03b6f34baeb9ffb2e683fd979f12f27a5078a4da
2019-01-14 06:12:36 -05:00
Jeffrey Altman
1dd38cc3de lib/hx509: declare and apply HX509_LIB_xxx macros
libhx509 is not built according to the same export and calling conventions
on Windows as the other libraries.  This change declares and applies
HX509_LIB_FUNCTION, HX509_LIB_NORETURN_FUNCTION, HX509_LIB_CALL and
HX509_LIB_VARIABLE to lib/hx509.

As a result of this change the calling convention for exported functions
will be __stdcall instead of __cdecl.

Change-Id: Ibc3f05e8088030ef7d13798f1d9c9b190bc57797
2019-01-02 10:23:39 -06:00
Chris Lamb
9c2351eb25 Correct "paramaters" typos.
Signed-off-by: Chris Lamb <chris@chris-lamb.co.uk>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>

(cherry-picked from Samba commit e0366ea49d5daa8fbf8b2ca22b1d3c77cc2daf9a)
2018-09-10 14:42:18 -04:00
Quanah Gibson-Mount
7c16ce3457 Minor typo/grammar fixes 2017-03-10 15:47:43 -05:00
Nicolas Williams
2ebec2e4ec Fix some Doxygen warnings 2016-12-14 22:05:46 -06:00
Nicolas Williams
953dc07391 Round #1 of scan-build warnings cleanup 2016-11-15 21:27:20 -06:00
Love Hornquist Astrand
029de6cfa4 pass back an heim_error from hx509_cert_init 2012-10-07 06:33:13 -07:00
Roland C. Dowdeswell
cc47c8fa7b Turn on -Wextra -Wno-sign-compare -Wno-unused-paramter and fix issues.
We turn on a few extra warnings and fix the fallout that occurs
when building with --enable-developer.  Note that we get different
warnings on different machines and so this will be a work in
progress.  So far, we have built on NetBSD/amd64 5.99.64 (which
uses gcc 4.5.3) and Ubuntu 10.04.3 LTS (which uses gcc 4.4.3).

Notably, we fixed

	1.  a lot of missing structure initialisers,

	2.  unchecked return values for functions that glibc
	    marks as __attribute__((warn-unused-result)),

	3.  made minor modifications to slc and asn1_compile
	    which can generate code which generates warnings,
	    and

	4.  a few stragglers here and there.

We turned off the extended warnings for many programs in appl/ as
they are nearing the end of their useful lifetime, e.g.  rsh, rcp,
popper, ftp and telnet.

Interestingly, glibc's strncmp() macro needed to be worked around
whereas the function calls did not.

We have not yet tried this on 32 bit platforms, so there will be
a few more warnings when we do.
2012-02-20 19:45:41 +00:00
Love Hornquist Astrand
0879b9831a remove trailing whitespace 2011-05-21 11:57:31 -07:00
Love Hornquist Astrand
2ac7566997 Fix logic for adding digestAlgorithm, original patch from Douglas E Engert. 2011-05-17 07:43:42 -07:00
Love Hornquist Astrand
f5f9014c90 Warning fixes from Christos Zoulas
- shadowed variables
- signed/unsigned confusion
- const lossage
- incomplete structure initializations
- unused code
2011-04-29 20:25:05 -07:00
Jelmer Vernooij
36ade8b509 hx509: Make various functions used by Samba public.
* hx509_cert_public_encrypt
* hx509_parse_private_key
* hx509_private_key_assign_rsa
* hx509_private_key_free
* hx509_private_key_private_decrypt
* hx509_private_key_init
* hx509_private_key2SPKI
* hx509_request_get_name
* hx509_request_get_SubjectPublicKeyInfo
* hx509_request_free
* hx509_request_init
* hx509_request_set_name
* hx509_request_set_SubjectPublicKeyInfo

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2011-02-23 19:47:28 -08:00
Love Hornquist Astrand
667ec8eb81 Use version 0 for issuer name serial number and version 2 for ski
Pointed by subject Michael Wood <esiotrot@gmail.com> on samba-technical
2010-10-07 00:22:09 -07:00
Love Hornquist Astrand
739c79b76b don't add dup digestAlgorithms 2010-08-10 10:40:54 -07:00
Love Hornquist Astrand
4bb81d921d add HX509_CMS_SIGNATURE_NO_CERTS and HX509_CMS_SIGNATURE_LEAF_ONLY 2010-08-10 10:19:48 -07:00
Love Hornquist Astrand
b1eb65c5ba use hx509_certs_iter_f 2009-11-22 13:52:31 -08:00
Love Hörnquist Åstrand
2baa886d7a Use OID variable instead of function.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25240 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-05-28 01:18:43 +00:00
Love Hörnquist Åstrand
f6800d16eb catch memory leak
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25192 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-05-06 19:03:48 +00:00
Love Hörnquist Åstrand
3221f51f1c document flags
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24962 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-03-26 23:12:57 +00:00
Love Hörnquist Åstrand
15d0edc29a allow weak flags for cms
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24820 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-27 03:24:28 +00:00
Love Hörnquist Åstrand
ff5dab4f4a remove rcsid
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24795 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-22 23:28:18 +00:00
Love Hörnquist Åstrand
0d03799468 spelling
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24667 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-09 17:18:16 +00:00
Love Hörnquist Åstrand
1228f20e92 spelling and doxygen
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24591 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-04 22:06:22 +00:00
Love Hörnquist Åstrand
08e864fbe9 spelling
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24590 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-04 22:06:12 +00:00
Love Hörnquist Åstrand
90a9ed5fd2 Add hx509_cms_create_signed() that allows signing with 0 or more certs.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24580 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-04 22:04:28 +00:00
Love Hörnquist Åstrand
afb2abb65d Add HX509_CMS_VS_ALLOW_ZERO_SIGNER and HX509_CMS_VS_NO_VALIDATE
Doxygen.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24576 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-04 22:03:47 +00:00
Love Hörnquist Åstrand
26abb7e637 option to turn off the KeyUsage check in CMS verify SignedData
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24204 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-12-15 04:32:49 +00:00
Love Hörnquist Åstrand
61d49ed472 add options to skipping KeyUsage check
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24197 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-12-15 04:31:41 +00:00
Love Hörnquist Åstrand
ba69102e6b add flags to hx509_cms_verify_signed
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24192 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-12-15 04:30:52 +00:00
Love Hörnquist Åstrand
a40d246195 simplify CMS handling, coverity #158
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24089 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-12-11 04:57:40 +00:00
Love Hörnquist Åstrand
6937d41a02 remove trailing whitespace
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23815 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-13 09:21:03 +00:00
Love Hörnquist Åstrand
e172367898 switch to utf8 encoding of all files
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23814 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-13 08:53:55 +00:00
Love Hörnquist Åstrand
9d452c8bd0 Pass in time_now to unevelope, us verify context time in verify_signed.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23268 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-06-23 03:23:47 +00:00
Love Hörnquist Åstrand
b3efcbda59 more documentation
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22327 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-12-15 04:49:37 +00:00
Love Hörnquist Åstrand
ceb99a8536 Doxygen documentation.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22320 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-12-15 03:00:41 +00:00
Love Hörnquist Åstrand
b1a669bf5e fix syntax error, from David Love.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22292 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-12-14 05:21:27 +00:00
Love Hörnquist Åstrand
d651f2187d More documentation
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22275 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-12-11 11:02:11 +00:00
Love Hörnquist Åstrand
5fed824f37 its vs it\'s etc. From Bjorn Sandell
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22071 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-11-14 20:04:50 +00:00
Love Hörnquist Åstrand
ef581cc5de remove stale comment.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21785 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-08-01 19:37:03 +00:00
Love Hörnquist Åstrand
a5e5db51bd Use hx509_crypto_random_iv.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21319 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-25 19:46:52 +00:00
Love Hörnquist Åstrand
bff0a5c11c Implement and use HX509_CMS_SIGATURE_ID_NAME.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21267 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-24 19:24:20 +00:00
Love Hörnquist Åstrand
f622a16e97 Add hx509_cert_init_data and use everywhere
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21085 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-13 06:39:53 +00:00