Commit Graph

542 Commits

Author SHA1 Message Date
Viktor Dukhovni
e4ba666221 hcrypto compiler warnings 2016-11-14 02:22:32 -05:00
Nicolas Williams
2d3c21cb61 There is no lib/hcrypto/dllmain.c 2016-11-11 15:58:33 -06:00
Nicolas Williams
81c778e0a3 Fix EVP PKCS#11 backend (#194) 2016-11-11 14:34:11 -06:00
Nicolas Williams
9c8b450aa0 Add EVP backend selection to example_evp_cipher.c 2016-11-11 14:30:13 -06:00
Nicolas Williams
e803b00bca Assume OpenCryptoki on Linux for evp-pkcs11 2016-11-11 14:30:13 -06:00
Viktor Dukhovni
a2ce04e87b We're not in Texas anymore 2016-11-10 22:29:49 -05:00
Simon Wilkinson
67ac841f8f hcrypto: Fix Win 32 cpp checks
The correct test for a windows build is if defined(_WIN32), not just
if _WIN32. Fix a few places in the build which do the wrong thing, as
it gives compiler warnings.
2016-11-09 15:36:04 +00:00
Simon Wilkinson
ac9109ff75 hcrypto: Remove roken.h include from hash.h
All of the hcrypto source files were updated with commit
0f97855826 to include roken.h. This
means that hash.h no longer needs to include the roken header.

Remove the multiple inclusion.
2016-11-09 14:22:38 +00:00
Luke Howard
7b720cf61c krb5: implement draft-ietf-kitten-aes-cts-hmac-sha2-07 2016-10-08 08:17:11 +02:00
Sean Davis
316387f619 Fix typo in rand-fortuna.c
`__GNUC__` was written as `__GUNC__`, which could have interesting results as it'll never be defined.
2016-09-19 16:06:03 -05:00
Benjamin Kaduk
aa87e08cc7 Use C99 designated initializers in a couple places
Some portions of libhcrypto are reused by other projects in
diverse environments, including within operating system kernel modules.
In some such build environments, hardening measures such as grsecurity
can (randomly) reorder structure elements, so as to make it harder
for an attacker to determine the offset from a known field's address
to a different field that is needed for an attack.

However, doing so requires the use of C99 designated initializers
to make the source code compatible with such structure rearrangement,
as opposed to the "traditional" C aggregate type initializers, which
just list fields in order.  This feature is also available as a
GCC extension since early versions of GCC.  However, it is not
provided by many common versions of visual studio (and presumably
also not by the vendor compiler for various commercial Unixes),
so the traditional initializers must remain, behind a conditional.
__GNUC__ or __STDC_VERSION__ >= 199901 should be enough to get
most cases with support for designated initializers, at least
for now.

Signed-off-by: Nicolas Williams <nico@twosigma.com>
2016-09-01 17:38:47 -05:00
David Mulder
2bee5966ab The evp-w32.h header should not be included on all platforms 2016-08-02 16:12:46 -06:00
Viktor Dukhovni
529a91d69a MacOS/X fixes 2016-06-09 01:13:14 -04:00
Roland C. Dowdeswell
b49431e47a lib/hcrypto/Makefile.am: set automake option: subdir-objects 2016-05-12 15:18:38 -04:00
Viktor Dukhovni
1017a594ef Use OpenSSL include path as needed
For consistency make "-I" part of the macro value set by autoconf.

For now, don't attempt to handle OpenSSL rpath in cf/crypto.m4.
That's much easier by just setting LDFLAGS when running configure.
Otherwise too many Makefiles to edit and libtool and automake do
their best to undo the rpath.
2016-05-07 05:29:12 -04:00
Viktor Dukhovni
9393d53538 Actually capture libcrypto autoconf results
Also infer lib path not just include path, and set rpath if not from /usr.
Also need libcrypto for test_rand.
2016-05-07 02:36:34 -04:00
Jeffrey Altman
6c1ba82623 hcrypto: no openssl build requires evp-hcrypto.h include
When building evp-openssl.c without support for OpenSSL it is necessary
to include evp-hcrypto.h to define the HCRYPTO_FALLBACK functions.

Change-Id: Ifd51f9fcd2b1805a534a9f88992162818afffe7d
2016-04-23 19:03:56 -04:00
Nicolas Williams
ca0dff891b Check HCRYPTO_FALLBACK in W32 backend 2016-04-19 13:40:47 -05:00
Nicolas Williams
c6c858c0ca Check HCRYPTO_FALLBACK in PKCS#11 backend 2016-04-19 13:40:47 -05:00
Nicolas Williams
7f96a2cc1a Check HCRYPTO_FALLBACK in CC backend 2016-04-19 13:40:47 -05:00
Nicolas Williams
8a749ced78 Check HCRYPTO_FALLBACK in ossl backend 2016-04-19 13:40:47 -05:00
Nicolas Williams
e751e09108 Fix warnings in test_bulk.c 2016-04-19 13:40:46 -05:00
Nicolas Williams
7df276258a Fix mis-merge in evp-openssl.c 2016-04-19 13:40:46 -05:00
Nicolas Williams
e02832b199 Fix initialization race in evp-openssl.c 2016-04-19 13:24:36 -05:00
Jeffrey Altman
4ad2f5830a hcrypto: p11_module_init_once make handle static global
Coverity complains about the leakage of 'handle' when the identifier
goes out of scope.  Change handle into a static global to hold the
value instead of a stack variable.

Change-Id: I040707ac731558f7d523f128a006a80b98d45b79
2016-04-17 15:11:55 -05:00
Nicolas Williams
514f719e4a evp-openssl: fallback to hcrypto
The Windows and PKCS#11 backends do this.  The Common Crypto (OS X)
backend does not.  Ideally this should be a ./configure option, and that
might be the next step, but right now we need this fallback in order to
get tests passing in Travis-CI.
2016-04-16 18:05:26 -05:00
Nicolas Williams
3d4fbf9aac Fix lib/hcrypto for Windows 2016-04-16 16:58:08 -05:00
Nicolas Williams
b2a78463de Add missing <hcrypto/undef.h> 2016-04-16 13:59:34 -05:00
Nicolas Williams
f064f2d14b Add seed operation for unix RAND method 2016-04-15 00:16:18 -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
6bbe7f0ffa Implement EVP_CIPH_CTRL_INIT 2016-04-15 00:16:16 -05:00
Nicolas Williams
8033eb298b lib/hcrypto/evp.c: missing MD guards 2016-04-15 00:16:16 -05:00
Nicolas Williams
0f138cf2d5 Add missing hcrypto rename macros 2016-04-15 00:16:15 -05:00
Nicolas Williams
d494f2f679 hcrypto-pkcs11: fix MD4 block size 2016-04-15 00:16:15 -05:00
Nicolas Williams
0b3055fdad hcrypto-pkcs11: rc2_cbc is variable length 2016-04-15 00:16:15 -05:00
Nicolas Williams
1e6f88f721 Fix hcrypto evp_md cleanup call protocol 2016-04-15 00:16:14 -05:00
Jeffrey Altman
0f97855826 hcrypto: config/roken cleanup
All source files in lib/hcrypto should be built the same way.
Since this source directory is dependent on libroken then all source
files must be built using the roken.h declarations and included headers.

Also, there is no config.h in the local directory so angle brackets
include of quotes should be used.

Finally, because roken.h includes stdio.h, stdlib.h, stdarg.h, limits.h,
strings.h, sys/types.h, etc., do not include them separately.

Start all source files with

  #include <config.h>
  #include <roken.h>

Change-Id: I09ab47f8a5472018efe6c8b59a0e51fde8f24724
2016-04-10 17:05:07 -05:00
Nicolas Williams
b4cf4de807 Fix warnings (clang 3.6) 2016-02-26 01:04:31 -06:00
Nicolas Williams
78343d0907 Fix Windows tests: add missing hcrypto export 2016-01-20 11:34:41 -06:00
Nicolas Williams
62f797ed4e Fix Windows build (inc. roken.h before assert.h)
The build was failing at lib/hcrypto/evp-pkcs11.c because roken.h was
being included after <assert.h>.  It's not clear why that would be a
problem.

Here are some of the errors and warnings that resulted from including
<roken.h> after <assert.h> in evp-pkcs11.c:

evp-pkcs11.c                                                                                                                                      C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\ws2def.h(91) : warning C4005: 'AF_IPX' : macro redefinition                           s              C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\winsock.h(460) : see previous definition of 'AF_IPX'
C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\ws2def.h(124) : warning C4005: 'AF_MAX' : macro redefinition
        C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\winsock.h(479) : see previous definition of 'AF_MAX'
C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\ws2def.h(168) : warning C4005: 'SO_DONTLINGER' : macro redefinition
        C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\winsock.h(402) : see previous definition of 'SO_DONTLINGER'
C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\ws2def.h(212) : error C2011: 'sockaddr' : 'struct' type redefinition
        C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\winsock.h(485) : see declaration of 'sockaddr'
C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\ws2def.h(390) : error C2059: syntax error : 'constant'
C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\ws2def.h(524) : warning C4005: 'IN_CLASSA' : macro redefinition
        C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\winsock.h(287) : see previous definition of 'IN_CLASSA'
2016-01-18 11:05:48 -06:00
Luke Howard
fdf8782db2 hcrypto: PKCS#11 backend
implement a PKCS#11 backend for hcrypto. tested with Solaris 11 and
SoftHSM, this is now the default when building on Solaris.
2015-12-09 11:08:35 +11:00
Luke Howard
494b11f962 hcrypto: fix spelling mistakes in comments 2015-12-09 11:07:29 +11:00
Luke Howard
9aeb08173a add CommonCrypto SHA-384/512 to test_bulk 2015-12-05 00:05:49 +11:00
Luke Howard
87c59d1db2 export CommonCrypto SHA-384/512 implementations 2015-12-05 00:04:24 +11:00
Luke Howard
4f9cc8feea add CommonCrypto support for SHA-384 and SHA-512 2015-12-04 23:56:12 +11:00
Luke Howard
93725f01f0 Fix broken CFB8 implementation, use CC for CFB8 2015-12-04 23:49:23 +11:00
Jeffrey Altman
6fbe672451 hcrypto: Default to CommonCrypto on Apple OSes
When __APPLE__ is defined and HCRYPTO_DEF_PROVIDER is not defined,
define HCRYPTO_DEF_PROVIDER to be "cc" so that Apple's CommonCrypto
implementations are used instead of the built-in "hcrypto"
implementations.

Change-Id: I393e5fc3f6c3b9339c96db58d926ff8ea1867cbb
2015-11-24 09:48:44 -05:00
hasufell
427a60057c Completely remove RAND_egd support
The EGD daemon is completely unmaintained and has not seen a release
since 13 years which is not an acceptable timeframe for cryptographic
software. It is not packaged in any linux distribution I know of
and definitely not in *BSD.

LibreSSL has already dropped support for RAND_egd.
2015-10-06 15:44:47 +02:00
Bernard Spil
858480145b Refactor EGD conditional support
As per Jeremy's request in #124
Windows does not define HAVE_RAND_EGD resulting in the same conditional
support for EGD.
2015-04-21 10:04:08 +02:00
Bernard
828f4f4fb1 Fix build when OpenSSL has no EGD support 2015-04-10 22:47:03 +02:00