Commit Graph

217 Commits

Author SHA1 Message Date
Benjamin Dauvergne 3e597eedb9 Add support for SHA-2 family of hash functions for RSA and HMAC signatures 2015-02-09 18:53:02 +01:00
Simo Sorce 3bd2c479a0 Assert on missing id
In this function id is required, so just assert if it is missing.
This also silences a warning about "reference" being used unintialized
if "id" is null.

License: MIT
Signed-off-by: Simo Sorce <simo@redhat.com>
2014-08-28 18:32:30 +02:00
Simo Sorce d911a2092f One more uninitialized value
encode_key may be release when not initialized if va_args returns null
on the first while loop.

License: MIT
Signed-off-by: Simo Sorce <simo@redhat.com>
2014-07-30 16:07:45 +02:00
Simo Sorce f91f4b4b8f Consistently check dsig_reference_ctx
Check if this is not NULL in all cases, to avoid NULL pointer dereference.
Found by clang

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
Simo Sorce 80757431b3 Missing check for Sig_Alg value
Initialize the sig_alg value to NULL (The compilers was complaining it may
be used initialized), but also make sure to check the re is any sig_alg at
all, otherwise return a proper error.

License: MIT
Signed-off-by: Simo Sorce <simo@redhat.com>
2014-07-30 16:07:44 +02:00
Simo Sorce 661f81014e Fix uninitialized values found by Coverity
These values where being used without being initialized at least in some edge
cases. Make Coverity happy by properly initializing them.
Some of these are real bugs, not just silencing a tool.

License: MIT
Signed-off-by: Simo Sorce <simo@redhat.com>
2014-07-30 16:07:43 +02:00
Simo Sorce 86328f2937 Fix format check for date
Coverity was complaining that tm was used uninitialized, but the truth is
that a third error condition where the string passed in matches no valid
format was not handled. Just return an error in that case.

License: MIT
Signed-off-by: Simo Sorce <simo@redhat.com>
2014-07-30 16:07:43 +02:00
Simo Sorce b6a3ec78a0 Be correct in dealing with varargs
Although in this cases it may be safe to omit va_end() that is not generally
so with an arbitrary compiler on an arbitrary platform.

Quoting from the spec: "Each invocation of va_start() must be matched by
a corresponding invocation of va_end() in the same function."
note the "must"

Checker tools like Coverity complain if va_start() is not always paired with
va_end(), so this patch mutes them.

License: MIT
Signed-off-by: Simo Sorce <simo@redhat.com>
2014-07-30 16:07:43 +02:00
Benjamin Dauvergne 6d854cef42 lasso/xml/tools.c: fix reference to unitialized memory 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 1a1d443f91 lasso/xml/tools.c: fix misuse of xmlURIUnescapeString
If the length argument is NULL, the full string is unescaped; the
behaviour we expected is to return a 0 length string.
2013-09-27 15:51:02 +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
Benjamin Dauvergne bd0f935a24 Rewrite all xmlNode serialization code to be compatible with libxml 2.9.0
Libxml stopped exposing the internal of the xmlOutputBuffer structure;
it was replace by proper use of the API and of the xmlBuffer structure.

There could be regression for older version of libxml as some functions
appeared in recent version of libxml; but the reference API document
does not give any introduction date for functions so it's hard to be
sure.
2012-09-28 22:58:24 +02:00
Benjamin Dauvergne 73a8c1faad [xml] fix typos 2012-05-05 22:51:43 +02:00
Benjamin Dauvergne f42bef0836 [key] add methods to send message using SAML 2.0 redirect and post bindings 2012-03-17 15:26:21 +01:00
Benjamin Dauvergne 08ec0a6fb7 Incompatibility with clang: local functions with closure does not work 2011-12-29 11:52:38 +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 900de512f2 [core] fix uninitialized pointer to a GError structure 2011-12-16 11:39:18 +01:00
Benjamin Dauvergne 5ba292521b [core] add the HMAC-SHA1 shared secret signature method 2011-12-05 13:11:53 +01:00
Benjamin Dauvergne 6c7114d5ce [core] refactor lasso_query_verify_signature and lasso_saml2_query_verify_signature
This commit introduces lasso_query_verify_helper which factorize
cryptographic operations.
2011-12-05 13:09:44 +01:00
Benjamin Dauvergne 2a63167627 [core] set the xmlSec log handler globally
The log handler is not set in lasso_init().
2011-12-05 12:03:13 +01:00
Benjamin Dauvergne 0c45b252dc [saml2] introduce a lasso_saml2_assertion_get_audirence_restrictions to factorize some code 2011-12-05 12:03:13 +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 71721b370c [core] add a lasso_base64_decode function 2011-12-05 12:03:13 +01:00
Benjamin Dauvergne e9212301d3 [tools] fix lasso_sha1 to return a glib allocated string 2011-12-05 12:03:13 +01:00
Benjamin Dauvergne 5a9a447bad [xml] add an inline function to validate LassoSignatureMethod values
- add also a LASSO_SIGNATURE_METHOD_NONE value
2011-12-05 12:03:12 +01:00
Benjamin Dauvergne fd7af65e91 [core] do not emit a warning for expected decryption errors
The only expected decryption error is on decryption of the symetric key
used to crypt the data. All other errors are critical and must be
logged.

Client of lasso_node_decrypt_xmlnode can then log the decryption failure
of the symetric if they tried with all possible keys (key rollover
case).
2011-11-22 18:51:49 +01:00
Benjamin Dauvergne 8b216a4307 [tools] redirect xmlsec errors to lasso error handler 2011-04-14 17:15:42 +02:00
Benjamin Dauvergne 890d88c8c5 [tools] use LASSO_LOG_DOMAIN instead of magic constant 2011-04-14 17:15:31 +02:00
Benjamin Dauvergne 6477d6043c [xml] if signature reference is empty check that signed node is the document root
An empty reference means the complete document, so the signed node is
the root element of this document. We must check that the parameter
signe_node dmatches our assumption.
2011-04-04 15:57:54 +02:00
Benjamin Dauvergne 04dd5610b0 [xml] allow empty reference in XML signature (document signature) 2011-03-29 18:43:47 +02:00
Benjamin Dauvergne e84a1e8a8a [xml] make id_attr_name parameter optional for lasso_verify_signature 2011-03-29 18:14:35 +02:00
Benjamin Dauvergne 447c610c9c [tools] fix xml decryption
This commit rewrite the extraction of the EncryptedKey when it is
embedded inside the EncryptedData element, which seem to be the frequent
case.
2010-12-14 01:58:38 +01:00
Benjamin Dauvergne 355df68dfe [saml2] use new encryption structure instead for internal field in LassoSaml2Assertion 2010-12-14 01:57:09 +01: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 3631ad59a9 [XML] fix memleak of xmlSecKeyMngr when loading a key from a KeyInfo node 2010-09-17 17:02:40 +02:00
Benjamin Dauvergne c3985f6f6d [Core] add LAST enum values to LassoSignatureMethod and LassoSignatureType enumerations
It helps making range checks.
2010-09-03 19:02:41 +02:00
Benjamin Dauvergne ad93e9f831 [Core] Change lasso_apply_signature to use quark stored annotated signature parameters
The node containing signature do not handle the private keys passwords.
As the fields for signature parameters are part of the public ABI we
cannot add the password field to the public structure for those nodes.
Instead we use the new quark annotation accessed through
lasso_node_get/set_signature, and if the sign_type parameter is non-NULL
we use it instead of the parameters stored in the public structure.
This is a gross hack :( but at least it is documented.
2010-07-16 19:34:26 +00:00
Benjamin Dauvergne 21ca128532 [Core] add password parameter to lasso_sign_node 2010-07-16 19:34:24 +00:00
Benjamin Dauvergne c939427f21 [Core] add a password parameter to lasso_query_sign
We force use of the password through a custom OpenSSL password callback.
2010-07-16 19:34:21 +00:00
Benjamin Dauvergne 9d9cf60aca [Core] extract signature adding into base class method lasso_node_get_xmlNode
In order to permit subclass to modify the base xmlNode created by
lasso_node_impl_get_xmlNode we must defer the concrete to the virtual
method wrapper, lasso_node_get_xmlNode.

To do that it whas needed to make id_attribute another virtual field of
LassoNode subclasses (it can be accessed through an offset registered in
the class object).

This commit solves signature validation error since the patch for
managing more than one SessionIndex element in samlp2:LogoutRequest.

It also factorize the creation of signatures in one place.
2010-07-12 14:09:17 +00:00
Benjamin Dauvergne a9b673cd4a Core: move logging function and macros to their own module, adapt perl binding 2010-06-12 00:43:49 +00:00
Benjamin Dauvergne 93bea17474 Core: update lasso_iso_8601_gmt_to_time_t to support milliseconds
* We now support the two possible formats for xsdtime XSchema datatype:
    - dddd-dd-ddTdd:dd:ddZ
    - dddd-dd-ddTdd:dd:dd.d*Z

   Where d denotes a digit, and * is the kleene star.

   XSD datetime also supports negative years, but as we cannot represent
   them with time_t, we can reject it at the lexical level.
2010-06-10 21:26:10 +00:00
Benjamin Dauvergne 2c0ea4d647 Change all logging to use message() 2010-06-09 16:54:55 +00:00
Benjamin Dauvergne aeb27a107c Core: in xml error message handler, escape messages to fit on one line 2010-06-09 16:54:54 +00:00
Benjamin Dauvergne 59d406b8a6 Core: remove arrow in log messages 2010-06-09 16:54:53 +00:00
Frédéric Péters 4c130d779a Add new lasso_log_set_handler and lasso_log_remove_handler functions
They are modeled around the g_log... functions of GLib, they just don't
have a domain parameter.
2010-06-09 07:51:52 +00:00
Benjamin Dauvergne f4130519fc Core: fix extraction of relaystate when URLs contains only one kind of separators 2010-05-31 07:13:46 +00:00