Commit Graph

285 Commits

Author SHA1 Message Date
Benjamin Dauvergne 99fe56bec4 Fix all warnings in tests (#71400) 2022-11-21 13:28:02 +01:00
Benjamin Dauvergne 0705940804 Prevent loading of default cert file during tests (#71396) 2022-11-21 12:28:18 +01:00
Benjamin Dauvergne 4a880977d1 Remove ID-WSF 1.0, 2.0 and WS-* support (#56644)
It has been deprecated for a long time.
2021-09-11 18:54:41 +02:00
Jakub Hrozek 1b0000e016 test13_test_lasso_server_load_metadata: Don't verify signature if lasso is not configured with sha-1 (#54037) 2021-06-24 02:15:27 +02:00
Jakub Hrozek 0d34c97be1 Mass-replace LASSO_SIGNATURE_METHOD_RSA_SHA1 with lasso_get_default_signature_method() (#54037)
This should be backwards-compatible but at the same time use the
selected default instead of RSA-SHA1.

Related:
https://dev.entrouvert.org/issues/54037
2021-06-23 23:32:33 +02:00
Jakub Hrozek f095ac8f57 Make the default signature method and the minimal hash strength configurable (#54037)
Adds two new configure options:
    --with-default-sign-algo
    --min-hash-algo

--with-default-sign-algo sets the default signing algorithm and defaults
to rsa-sha1. At the moment, two algorithms are supported: rsa-sha1 and
rsa-sha256.

--min-hash-algo sets the minimum hash algorithm to be accepted. The
default is sha1 for backwards compatibility as well.

Related:
https://dev.entrouvert.org/issues/54037
2021-06-23 23:32:29 +02:00
Jakub Hrozek f625eaa007 tests: Move test08_lasso_key and test07_saml2_query_verify_signature to SHA256 (#54037)
These tests use a hardcoded query and private key which makes it
unsuitable to make the tests use the configured default digest. Let's
just convert them to SHA256 unconditionally.
2021-06-23 23:32:26 +02:00
Jakub Hrozek 8b8fd22a16 Fix lasso_query_sign HMAC other than SHA1 (#54037)
The switch clause was using SHA1 digests for all digest types when
signing. This obviously breaks verifying the signatures if HMAC-SHAXXX
is used and XXX is something else than 1.
2021-06-23 23:32:12 +02:00
Benjamin Dauvergne f912e8d1ef replace deprecated index() by strchr() (#51385) 2021-02-26 16:31:53 +01:00
Benjamin Dauvergne 4bae1c8b7c Release 2.6.1 2020-04-22 15:04:46 +02:00
Benjamin Dauvergne e5ad4b1702 misc: clear warnings about class_init signature using coccinelle
$ spatch --in-place --sp-file add-second-arg-to-class-init.cocci `git grep -l -C1 ^class_init \*.c`
	$ sed -i 's/\*unused\>/*unused G_GNUC_UNUSED/' `git grep -l 'void \*unused'`
2020-03-26 22:52:49 +01:00
Benjamin Dauvergne 6a0708ed5c tests: fix compilation with check>0.12 (#39101) 2020-03-26 22:52:27 +01:00
Benjamin Dauvergne 37a0fa6f8b Fix tests broken by new DEBUG logs (#12829) 2019-09-09 13:31:49 +02:00
Benjamin Dauvergne 3b72ad847c fix missing include <strings.h> for index() (fixes #33791)
tests/basic_tests.c:2141:7: warning: implicit declaration of function 'index' [-Wimplicit-function-declaration]
  qs = index(authnRequestUrl, '?') + 1;
       ^~~~~
tests/basic_tests.c:2141:7: warning: incompatible implicit declaration of built-in function 'index'
2019-07-04 16:12:42 +02:00
Benjamin Dauvergne 7c075657a4 tests: use self-generated certificate to sign federation metadata file (#33823)
Generation procedure :

	openssl genrsa -out rootCA.key 4096
	openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 99999 -out rootCA.crt
	openssl genrsa -out lasso.key 2048
	openssl req -new -sha256 -key lasso.key -subj "/C=FR/CN=Lasso" -out lasso.csr
	openssl x509 -req -in lasso.csr -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out lasso.crt -days 99999 -sha256
	openssl pkcs12 -export -inkey lasso.key -password pass: -in lasso.crt -name lasso -out lasso.pkcs12
	xmlsec1 --sign --output renater.xml --trusted-pem rootCA.crt --pwd "" --pkcs12 lasso.pkcs12 metadata/renater-metadata.xml
	xmlsec1 --verify --trusted-pem rootCA.crt metadata/renater-metadata.xml
2019-06-11 10:10:42 +02:00
John Dennis 642182bdf4 Fix ECP signature not found error when only assertion is signed (#26828)
With a SAML Authn Response either the message or the assertion
contained in the response message or both can be signed. Most IdP's
sign the message. This fixes a bug when processing an ECP authn
response when only the assertion is signed.

lasso_saml20_profile_process_soap_response_with_headers() performs a
signature check on the SAML message. A signature can also appear on
the assertion which is checked by
lasso_saml20_login_process_response_status_and_assertion() The problem
occurred when the message was not signed and
lasso_saml20_profile_process_soap_response_with_headers() returned
LASSO_DS_ERROR_SIGNATURE_NOT_FOUND as an error code which is not
actually an error because we haven't checked the signature on the
assertion yet. We were returning the first
LASSO_DS_ERROR_SIGNATURE_NOT_FOUND error when in fact the subsequent
signature check in
lasso_saml20_login_process_response_status_and_assertion() succeeded.

The ECP unit tests were enhanced to cover these cases.

The enhanced unit test revealed a problem in two switch statements
operating on the return value of
lasso_profile_get_signature_verify_hint() which were missing a case
statement for LASSO_PROFILE_SIGNATURE_VERIFY_HINT_FORCE which caused
an abort due to an unknown enumeration value.

Fixes Bug: 26828
License: MIT
Signed-off-by: John Dennis <jdennis@redhat.com>
2019-01-11 16:11:31 +01:00
John Dennis 3d9d58d52c Make more Python scripts compatible with both Py2 and Py3
While porting other Python code in the repo to run under Py3 (as well
as Py2) it was discovered there were a number of other Python scripts
which also needed porting. However these scripts are never invoked
during a build so there was no easy way to test the porting work. I
assume these scripts are for developers only and/or are
historical. Because there was no way for me to test the porting
changes on these scripts I did not want to include the changes in the
patch for the Py3 porting which fixed scripts that are invoked during
the build (the former patch is mandatory, this patch is optional at
the moment). I did verify the scripts compile cleanly under both Py2
and Py3, however it's possible I missed porting something or the error
does not show up until run-time.

Examples of the required changes are:

* Replace use of the built-in function file() with open().  file()
  does not exist in Py3, open works in both Py2 and Py3.  The code was
  also modified to use a file context manager (e.g. with open(xxx) as
  f:). This assures open files are properly closed when the code block
  using the file goes out of scope. This is a standard modern Python
  idiom.

* Replace all use of the print keyword with the six.print_()
  function, which itself is an emulation of Py3's print function. Py3
  no longer has a print keyword, only a print() function.

* The dict methods .keys(), .values(), .items() no longer return a
  list in Py3, instead they return a "view" object which is an
  iterator whose result is an unordered set. The most notable
  consequence is you cannot index the result of these functions like
  your could in Py2 (e.g. dict.keys()[0] will raise a run time
  exception).

* Replace use of StringIO.StringIO and cStringIO with
  six.StringIO. Py3 no longer has cStringIO and the six variant
  handles the correct import.

* Py3 no longer allows the "except xxx, variable" syntax, where
  variable appering after the comma is assigned the exception object,
  you must use the "as" keyword to perform the variable assignment
  (e.g. execpt xxx as variable)

* Python PEP 3113 removed tuple parameter unpacking. Therefore you can
  no longer define a formal parameter list that contains tuple
  notation representing a single parameter that is unpacked into
  multiple arguments.

License: MIT
Signed-off-by: John Dennis <jdennis@redhat.com>
2018-07-24 11:03:09 +02:00
Benjamin Dauvergne e29de3160d tools: fix segfault in lasso_get_saml_message (fixes #24830)
We reuse the "message" local variable but we should not.
Also fix a segfault in lasso_xmltextreader_from_message() when getting
the length of "message" before checking if it is NULL or not.
2018-06-28 10:30:53 +02:00
Benjamin Dauvergne 877f9e7888 deprecate loading PEM formatted public keys in lasso_xmlsec_load_key_info
Also ensure work-around bug[1] in libxmlsec 1.2.24 and 1.2.25.

[1]: https://github.com/lsh123/xmlsec/issues/164
2018-05-01 12:06:15 +02:00
Benjamin Dauvergne 87da2e6e14 tests: prevent crash in glib caused by abort on recursive logging
The fail() function from libcheck is doing a longjump() from inside the
logging subsystem, preventing the depth counter to be reinitialised to 0.
(Seen with g_private_get(&g_log_depth) in a gdb session).
2018-04-06 17:23:14 +02:00
Benjamin Dauvergne 48fb1c37ec route logs from libxml2 and libxmlsec through GLib logging 2018-04-06 17:23:13 +02:00
Benjamin Dauvergne 6dd28b20d3 fix get_issuer and get_in_response_to 2018-04-06 17:23:13 +02:00
Benjamin Dauvergne 5798311da1 fix definitions of error, critical and warning macros (fixes #12830)
They all log at the DEBUG level instead of their respective levels.
2016-08-04 13:41:29 +02:00
Benjamin Dauvergne a69c61f419 tests: convert log level as string 2016-08-04 13:12:39 +02:00
John Dennis fad04ed1c9 Fix ecp test validate_idp_list() (fixes #11421)
validate_idp_list was not using the correct list elements when it
iterated over the known_sp_provided_idp_entries_supporting_ecp list.
It treated them as lists of strings instead of lists of
LassoSamlp2IDPEntry.

Signed-off-by: John Dennis <jdennis@redhat.com>
License: MIT
2016-06-18 16:45:25 +02:00
Benjamin Dauvergne 84f1b2f601 tests: silence unused variable warning 2016-03-07 00:14:39 +01:00
Benjamin Dauvergne 9525237236 Choose the Reference transform based on the chosen Signature transform (fixes #10155)
i.e. if the signature use SHA2 then use SHA2 of the same strength for digesting
references.
2016-03-06 01:43:47 +01:00
Benjamin Dauvergne 8e78d90d54 tests: update valgrind suppressions 2015-11-25 04:15:27 +01:00
Benjamin Dauvergne 89ba752aa5 tests: fix leak 2015-11-25 04:15:27 +01:00
Benjamin Dauvergne cd515cb82c tests: fix leaks in test_ecp 2015-11-24 19:29:43 +01:00
Benjamin Dauvergne 5d77950b4c tests: fix leak in test test16_test_get_issuer 2015-11-24 19:17:17 +01:00
John Dennis 964530aaca add ECP unit test
Test ECP.
3 different variations of the SP provided IDP List are exercised.

Signed-off-by: John Dennis <jdennis@redhat.com>
License: MIT
2015-08-24 16:05:29 +02:00
Benjamin Dauvergne 9e5c4389a8 Add checks for failure of an allocation function from libxml (#8070)
g_malloc always trap on allocation errors but not xmlMalloc.
2015-08-24 10:25:03 +02:00
Benjamin Dauvergne 9854cd50f3 xml: handle failure of xmlSecBase64Decode() (fixes #8070)
Thanks to fpeters for the patch.
2015-08-24 10:25:03 +02:00
Benjamin Dauvergne 65bc705235 profile: add two new class methods, lasso_profile_get_issuer and lasso_profile_get_in_response_to (#4378)
The goal of those two methods is to allow IdP and SP to load metadata
dynamically without processing completely the incoming. Currently it's
impossible as message parsing and signature checking is done in the same
function.
2015-08-24 10:25:03 +02:00
Benjamin Dauvergne c5ec98a018 Makefile.am: fix automake warning
It fixes this warning:

	warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')

it seems INCLUDES is not to be used anymore.
2015-08-24 10:18:52 +02:00
Benjamin Dauvergne 9f99176b3c SAML-2.0: rework on commit 05fe802b8d, improve handling of ProtocolBinding and AssertionConsumerServiceURL
When the same URL was used for many bindings, the current code did not
work. Now we use
lasso_saml20_provider_check_assertion_consumer_service_url() to validate
url and binding are matching, if no binding is suggested we take the
first one defined for this URL.

Using AssertionConsumerServiceIndex and any of the other assertion
consumer designator attributes is still forbidden.
2015-03-26 19:36:44 +01:00
Benjamin Dauvergne 05fe802b8d SAML-2.0: Rework protocol profile selection when parsing AuthnRequest messages
This commit also add tests around authn request parsing.
2015-02-12 16:40:12 +01:00
Benjamin Dauvergne cabe31f5fc tests: add target to Makefile to produce valgrind suppression entries 2014-06-08 12:32:10 +02:00
Benjamin Dauvergne d6ec627844 tests/valgrind: add suppression of all leaks related to initialisation of the GLib type system 2014-06-08 12:32:10 +02:00
Benjamin Dauvergne a90d3ad1c8 tests: fix leaks 2014-06-08 12:32:10 +02:00
Benjamin Dauvergne b6282eda59 tests: fix leak in log message checker 2014-06-07 14:11:14 +02:00
Benjamin Dauvergne 880b833c6e tests: do not reuse tc_response_new_from_xmlNode test case 2014-06-07 14:11:13 +02:00
Benjamin Dauvergne 59b0569341 tests: pass automake CFLAGS when compiling tests2 2014-04-24 12:32:43 +02:00
Simo Sorce 3a6b2fdee7 Fix license boilerplates
Instad of referring to an old FSF address, point the reader to the FSF
website where the latest licenses and addresses are published.

Signed-off-by: Simo Sorce <simo@redhat.com>
2013-12-03 21:55:06 +01:00
Benjamin Dauvergne 16beadaff9 tests/data/Makefile: regenerate list of files and directories to distribute 2013-09-26 15:51:24 +02:00
Benjamin Dauvergne bb84a8d188 tests: add non-regression test to check that we correctly provide the ArtifactResolutionService index in artifacts 2013-09-08 21:34:12 +02:00
Benjamin Dauvergne 53f6f5c5ef tests: in check_equals() and check_not_equals() macros use long long int as a catchall type for printing compared values 2013-09-08 21:34:12 +02:00
Benjamin Dauvergne 05a01a8247 fix compilation errors on 64bits architectures
* sizeof(unsigned int) != sizeof(size_t)
 * INT_MAX != LONG_MAX
2013-09-08 21:33:58 +02:00
Benjamin Dauvergne b6faccae0f fix warnings about unused but set variables 2013-09-08 21:31:52 +02:00