Commit Graph

196 Commits

Author SHA1 Message Date
Benjamin Dauvergne 72b778e47e Fix all cast-function-type warnings (#71400) 2022-11-21 13:28:08 +01:00
Benjamin Dauvergne 8a588a8acb Replace all use of xmlSecBase64Decode by lasso_base64_decode (#71399) 2022-11-21 13:27:15 +01:00
Benjamin Dauvergne 66ebd11166 Use OpenSSL EVP API to work around deprecation of low level APIs in OpenSSL 3 (#71313)
OpenSSL API is used to sign query-string values in the SAML 2.0 Redirect binding.
Other binding only need the libxmlsec API as signature are XML DSIG signatures.
2022-11-21 13:22:04 +01:00
Benjamin Dauvergne 53b0bd3569 Change default key encryption padding algorithm to RSA-OAEP (#56023)
The key encryption padding algorithm is now configurable, the default
being changed to OAEP. It's possible to set the default through
./configure with:

    --with-default-key-encryption-method=[rsa-pkcs1|rsa-oaep]

at initialization time with an environment variable:

    LASSO_DEFAULT_KEY_ENCRYPTION_METHOD=[rsa-pkcs1|rsa-oaep]

or at runtime for a service provider:

    lasso_provider_set_key_encryption_method(LassoProvider *provider,
        LassoKeyEncryptionMethod key_encryption_method)

The setting is global for all encrypted nodes (Assertion or NameID).
2021-09-11 19:20:04 +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
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
John Dennis 4544ea9e9d Add function to set protocol conformance
Lasso uses an internal private variable bound to the provider to
indicate which protocol the provider is servicing. It is vital this
value be correctly set because many Lasso routines used it to dispatch
to the appropriate protocol handlers.

Normally the provider's protocol conformance is set as a side-effect
of parsing the XML metadata that describes the provider (e.g. an SP or
IdP). However there are some providers (e.g. an ECP client) which do
not have metadata. For providers lacking metadata it is essential
there be a mechanism to set the protocol conformance otherwise the
library will malfunction.

The function comes with documentation that includes a clear warning
this is to be used only in limited circumstances.

Signed-off-by: John Dennis <jdennis@redhat.com>
License: MIT
2015-08-24 16:05:29 +02:00
Simo Sorce 99376a3c88 Fix potential null dereference errors
Ina  number of cases function inputs are not checked for NULL although
values may end up with a NULL value and then they are dereferenced
directly.
Check values in the function (or the caller) if appropriate.

License: MIT
Signed-off-by: Simo Sorce <simo@redhat.com>
2014-07-30 16:07:45 +02:00
Simo Sorce 4789e8d4d6 Trim unused code
Clang complains these values are never used, avoid even assigning them.

License: MIT
Signed-off-by: Simo Sorce <simo@redhat.com>
2014-07-30 16:07:44 +02:00
Simo Sorce 1f97a06a01 Fix some uninitialized value
The compiler complain about these values not being initialized.
come of them do not really matter as they are only really used when
later initialized in the code and the code paths would not use them
if not initialized in a previous block, however some of these seem
real issues.
In all cases make the compiler happy so we get less noise in the build
and less false positives in code chckers.

License: MIT
Signed-off-by: Simo Sorce <simo@redhat.com>
2014-07-30 16:07:44 +02:00
Benjamin Dauvergne 7d514b67fc id-ff/provider: fix leak of xmlSecKey 2014-06-08 12:32:09 +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 154812b401 [xml] rewrite schema directed serialization/deserialization methods
The new implementations of lasso_node_impl_init_from_xml now validate
namespace of all child nodes befores parsing. It stops on any error. For
node which implement their own parsing of an attribute or a node, it
must declare an XmlSnippet with an offset field set to 0. The 0 value is
invalid for public GObject structure (it's the place of the GObject
machinery like the reference count). The 0 offset can be used for
XmlSnippet in a private structure, so never set the offset to 0 with the
flag SNIPPET_PRIVATE, for a field which is parsed by you get_xmlNode
virtual method.

Other ameliorations in this commit is the possibility to set attributes
with namespace when using the flags SNIPPET_ATTRIBUTE|SNIPPET_ANY. The
syntax for an attribute is inspired by the element tree API from Python:

	{namespace}attribute_name

an example:

	{http://www.w3.org/2001/XMLSchema-instance}type

for the classic xsi:type attribute.
2011-12-16 11:39:24 +01:00
Benjamin Dauvergne 18a10593fc [provider] fix doc comment 2011-12-08 18:11:46 +01:00
Benjamin Dauvergne 5e5c38b451 [core] rename lasso_provider_set_specific_signing_key to lasso_provider_set_server_signing_key 2011-12-05 14:25:34 +01:00
Benjamin Dauvergne 57241e3e86 [core] add lasso_provider_add_key to add other key for signature validation
The added key can be appended or prepended, depending on the need for the key:
 - rollover
 - improving performances (using simpler cryptographic algorithmss using shared secret keys)
2011-12-05 12:03:31 +01:00
Benjamin Dauvergne 109c562260 [core] add method lasso_provider_set_specific_signing_key
Using this method you can specify a signing which will be used for
communication with the specified provider instead of the one configured
on the LassoServer object. The main objective is to allow shared secret
cryptography instead of public key cryptography.
2011-12-05 12:03:14 +01:00
Benjamin Dauvergne cd017964d0 [core] introduce the LassoSignatureContext context, to pass around signature parameters
This structure is used to pass around the signature algorithm
and the signature key.
2011-12-05 12:03:13 +01:00
Benjamin Dauvergne dfacafb3b0 [core] replace explicit allocation of LassoProviderPrivate by use of g_type_class_add_private
The private part is allocated contiguously to the public structure data.
2011-12-05 12:03:13 +01:00
Benjamin Dauvergne ad51948373 [core] simplify lasso_provider_load_public_key 2011-12-05 12:03:12 +01:00
Benjamin Dauvergne 5192cdf7a0 [core] multiple decryption keys support
This commit complements the support for multiple signing certificate
support in the metadata files. The use-case is still key roll-over.

The structure LassoServerPrivateData was changed to accomodate multiple
decryption keys, and so:

 xmlSecKey *encryption_private_key

became:

 GList *encryption_private_keys

All uses of this key were replaced by a loop over this list, terminating
with the first key to be able to decrypt the content.

The private key passed to lasso_server_new() or
lasso_server_new_from_buffers() is first added to the list of decryption
keys. Any other call to
lasso_server_set_encryption_private_key_with_password() or
lasso_server_set_encryption_private_key() will add a new key to the
list.
2011-11-21 10:25:03 +01:00
Benjamin Dauvergne 9cedec628e [core] finish transition from single encryption key to multiple ones
Some code still reference provider->private->encryption_public_key, this
commit make them use lasso_provider_get_encryption_public_key().
2011-05-30 22:24:37 +02:00
Benjamin Dauvergne e67f2bb658 [core] first try at multiple signing keys support
The idea was to replace every use of an xmlSecKey* by a loop over a
GList* of xmlSecKey*.

 - In the structure LassoProviderPrivate changed
    xmlSecKey*public_key            ->   GList* signing_public_keys
    xmlNode*signing_key_descriptor  ->   GList* signing_key_descriptors.
 - Renamed lasso_provider_try_loading_public_key to
   lasso_provider_try_loading_public_keys and chaned its signature
   accordingly
 - Renamed lasso_provider_get_public_key to
   lasso_provider_get_public_keys and changed the signature accordingly.
 - Changed lasso_provider_get_encryption_public_key to return the first
   signing key from the list as a temporary work around. Multiple
   encryption keys will be supported later.
 - Changed lasso_provider_load_public_key to load keys from the passed
   file on the LassoProvider constructor, from every key descriptors
   found for signing and eventually from the key descriptor marked for
   encryption.
 - Every failure to load from a file or an XML KeyInfo descriptor are
   noew reported as warning.
 - Query signature checking was completely moved to
   lasso_provider_verify_query_signature and
   lasso_provider_verify_signature now calls it.
 - lasso_provider_verify_signature is now using lasso_verify_signature
   from the xml/tools.o module.
 - lasso_provider_verify_single_signature was modified to support
   multiple signing keys.
2011-05-19 17:54:16 +02:00
Benjamin Dauvergne e14652e7a4 [utils] add macros to append to and release a list of xmlSecKey*
[core] make lasso_provider_verify_query_signature use lasso_provider_verify_signature
2011-05-19 17:54:16 +02:00
Benjamin Dauvergne f840037c6a [core] add a private constructor to build LassoProvider object from an xmlNode
I'm not sure of the need outside lasso so I will let this method private
for the moment. It's an helper method for the
lasso_server_load_federation method which traverses an
EntitiesDescriptor node to find all the EntityDescriptor contained
inside.
2011-03-29 18:43:48 +02:00
Benjamin Dauvergne 4ebb7067a0 [core] check type of first argument of lasso_provider_get_assertion_consumer_url 2010-10-09 15:51:23 +02:00
Benjamin Dauvergne 6b2a21d116 [core] adapt lasso_provider_get_assertion_consumer_service_url for SAMLv2 2010-10-07 18:38:21 +02:00
Benjamin Dauvergne 462c9a1cd0 [Core] replace all use of g_strcmp0 by lasso_strisequal and lasso_strisnotequal
Too much human errors with strcmp kind of functions. Also change name os
lasso_is_empty_string to lasso_strisempty.
2010-10-01 15:29:38 +02:00
Benjamin Dauvergne 667f846085 [Core] fix leak of provider->private_data->endpoints 2010-09-17 17:02:41 +02:00
Benjamin Dauvergne 69f46ad974 [Core] fix leak of provider->private_data->endpoints 2010-09-17 17:02:40 +02:00
Benjamin Dauvergne 3f336a8e83 Merge branch 'develop' into hotfixes-2.3.1 2010-09-03 19:07:08 +02:00
Benjamin Dauvergne 9ab6b944f1 [Core] fix memory leak in lasso_endpoint_free 2010-09-03 19:05:27 +02:00
Benjamin Dauvergne aaca9ce992 [ID-FFv1.2&SAMLv2] add more warning for failure to load metadata file
Report detailf of the failure through warning log.
2010-09-03 19:02:42 +02:00
Benjamin Dauvergne 5c85507ffd [Core] add destroy code for new private field endpoints
The contained string must be disallocated if the object is destroyed.
2010-08-25 18:55:04 +02:00
Benjamin Dauvergne 7352ec8036 [Provider] Fix loading of provider without a public key
This commit also emit propre warning when loading fails for a provider
*with* a public key.
2010-07-05 21:27:08 +00:00
Benjamin Dauvergne 129e7ac6ea Merge branch 'issue-101' 2010-06-29 09:15:06 +00:00
Benjamin Dauvergne 4a55c53ee6 SAMLv2: fix error in naming of function in the documentation 2010-06-04 09:32:48 +00:00
Benjamin Dauvergne dc0da3d1b0 Provider: fix problem when reusing the same lists nodes in Descriptors 2010-04-22 01:12:32 +00:00
Benjamin Dauvergne 0e8441afe3 Improve safety by replacing all g_hash_table_destroy use by lasso_release_ghashtable 2010-04-22 00:45:02 +00:00
Benjamin Dauvergne 2f5ef5fef0 Improve safety by replacing all g_list_free use by lasso_release_list 2010-04-22 00:44:57 +00:00
Benjamin Dauvergne 0a169eda51 Improve safety by replacing all g_free use by lasso_release 2010-04-22 00:44:45 +00:00
Benjamin Dauvergne 05aad98ec3 Fix documentation problems 2010-04-19 11:30:35 +00:00
Benjamin Dauvergne 143e775942 ID-FF 1.2 & SAML 2.0: factorize access to role prefix 2010-04-06 13:11:36 +00:00
Benjamin Dauvergne c07cd3898c SAML 2.0&ID-FF 1.2: simplify and complete metadata loading for multi-role support 2010-03-27 16:52:04 +00:00
Benjamin Dauvergne f5442dc84b SAML 2.0: add support for attribute, authentication and authorization authorities metadata
* server.c,serverprivate.h: add new private method
   lasso_server_get_firs_providerID_by_role(server, role)w
 * defederation.c: use new private method
   lasso_server_get_first_providerID_by_role for find providerID
   when the argument remote_providerID is null in
   lasso_defederation_init_notification.
 * lasso/id-ff/login.c (lasso_login_init_authn_request): use new private
   method lasso_server_get_first_providerID_by_role.
 * provider.h: add thre new provider role (authn,pdp,attribute) and
    four new services (authn,assertionid,attribute,authz) and also
    a ROLE_ANY value (-1) for catchall purpose and a ROLE_LAST for
    array sizing.
 * provider.h: add a LAST member to LassoMdProtocolType enum.
  * providerprivate.h,provider.c:
   - removes separate hashtable for descriptors depending on provider role,
     use only one table named Descriptors.
   - use the LAST members of enumerations to dimention static string arrays.
  * provider.h: add a LAST member to the e
2010-03-27 16:51:43 +00:00
Benjamin Dauvergne 95f5d99be6 Core: add missing return value owner semantic annotations to getters
* lasso/id-ff/provider.c:
   fix lasso_provider_get_base64_succinct_id, it returned a libxml
   string, copy it with g_strdup before releasing it to stay with GLib
   allocated string in return values.
2010-02-17 10:14:59 +00:00
Benjamin Dauvergne 0119b91e56 Adapt LassoProvider methods to care for protocol profile version when verifying signature
* lasso/id-ff/provider.c:
   there is now 2 methods to verify signatures, methods calling the old
   one must now choose whether to call the liberty one of the SAML 2.0
   one.
2010-02-10 00:33:49 +00:00
Benjamin Dauvergne 8e1398e65c Core: in provider.c, make lasso_provider_load_metadata_from_buffer the main metadata loading function
* (init_from_xml) fail initialization if we cannot load the metadatas,
   and log a warning.
 * extract _lasso_provider_load_metadata_from_buffer from
   lasso_provider_load_metadata_from_buffer, which accept a length
   parameter. use it inside lasso_provider_load_metadata, instead of
   xmlParseFile.
 * (lasso_provider_load_public_key) use lasso_xmlsec_load_key_info and
   lasso_xmlsec_load_private_key to load the public keys.
2010-02-04 00:02:22 +00:00
Benjamin Dauvergne f520348197 Core: use lasso_node_new_from_dump to implement _new_from_dump methods
* provider.c:
   add annotation for nullable arguments (necessary for bindings of
   new_from_buffer).
 * server.c: add annotations, allow to set encryption_private_key from
   buffers
2010-02-04 00:02:12 +00:00
Benjamin Dauvergne 7aa18e07b1 Fix leaks, change signature of lasso_provider_get_sp_name_qualifier, make it return a const char* 2010-02-04 00:02:05 +00:00