Commit Graph

197 Commits

Author SHA1 Message Date
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
Benjamin Dauvergne a041a2ef81 Initialize all uninitialized rc variables 2010-04-30 09:23:01 +00:00
Benjamin Dauvergne 1ef02e3fe2 Improve safety by replacing all g_string_free use by lasso_release_gstring 2010-04-22 00:44:49 +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 4b9f6d8305 Core: add lasso_set_string_from_prop(char**,xmlNode*,..) function 2010-03-27 16:51:50 +00:00
Benjamin Dauvergne 75598ef566 Core: export lasso_build_unique_id into public API
* lasso/xml/tools.h:
   add new header to export lasso_build_unique_id as a public API.

 * lasso/xml/Makefile.am:
   add tools.h to header list

 * lasso/xml/tools.c:
   add GObjectIntrospection annotations to exported functions.
2010-03-02 11:57:58 +00:00
Benjamin Dauvergne 8598c1327a Core: add a level argument to lasso_xmlnode_to_string and _lasso_node_export_to_xml 2010-03-02 11:57:29 +00:00
Benjamin Dauvergne 46a823ff85 Add lasso_string_to_xsd_integer, to parse xsd:integer values 2010-02-22 13:30:41 +00:00
Benjamin Dauvergne 5d9e6f550a Core: add a lasso_xmlnode_to_string function
* lasso/xml/tools.c lasso/xml/private.h:
   lots of functions duplicate this code, so we factorized it there.
   It has two parameters, the xmlnode and boolean deciding whether to
   format the resulting content (good for reading but bad for
   signatures).
2010-02-17 10:15:24 +00:00
Benjamin Dauvergne 39d4444475 in tools.c, add defines to permit import of timegm 2010-02-17 10:14:44 +00:00
Benjamin Dauvergne b13ddc086b Core: fix lasso_iso_8601_gmt_to_time_t, use timegm instead of mktime
* lasso/xml/tools.c:
   mktime convert works on local time, we need timegm to work with GMT
   time.
2010-02-17 10:14:41 +00:00
Benjamin Dauvergne 7041018303 Core: in lasso_verify_signature, fix conditional about single reference
* lasso/xml/toosl.c:
   verify that reference is unique if NO_SINGLE_REFERENCE is disabled.
2010-02-15 10:37:42 +00:00
Benjamin Dauvergne dad75ee5f1 Fix lasso_get_relaystate_from_query, support semi-colon and parameter at beginning
* lasso/xml/tools.c:
  getting first parameter was broken (query_string does not contain '?'
  at the beginning) and semi-colon support was missing.
2010-02-12 09:48:20 +00:00
Benjamin Dauvergne 6b601b55ee Documentation: complete non finished documentation comments
* too much warnings when generating doc, now we can concentrate on
   undocumented symbols (in
   lasso/docs/reference/lasso/lasso-undocumented.txt).
2010-02-10 13:58:40 +00:00
Benjamin Dauvergne f648941f01 SAML 2.0: when verifying query signature, do not presume order of field and separator
* lasso/xml/tools.c:
   in lasso_saml2_verify_query_signature, extract needed field and order
   them appropriately before computing digest, expect ';' as well as '&'
   as separator.
 * tests/random_test.c:
   add non-regression tests for query signature validation.
 * tests/Makefile.am:
   make tests link agains static version of liblasso, to get access to
   private functions.
2010-02-10 00:34:55 +00:00
Benjamin Dauvergne f176cde783 Core: in tools.c, enhance urlencoded_to_string to support semu-colon separator 2010-02-10 00:34:47 +00:00
Benjamin Dauvergne 72dc2ff63d Add a function to validate query signatures using SAML 2.0 semantic
* lasso/xml/tools.c:
   this new function is a placeholder for the new SAML 2.0 semantic
   following query signature validation function. It will start with the
   old code of lasso_query_verify_signature.
2010-02-10 00:33:45 +00:00
Benjamin Dauvergne 2800779b4c in lasso_xmlsec_load_private_key_from_buffer, do not let xmlSecBase64Decode show warnings 2010-02-08 09:34:08 +00:00
Benjamin Dauvergne e6a07df2bc Core: Finish support for all XMLDsig key formats
* lasso/xml/tools.c:
   xmlsec is not able to load a certificate public key without checking
   it against trusted root certificate, so we must work around and load
   the key by hand.
   lasso_xmlsec_load_private_key_from_buffer is made more robust in the
   same (loading of the key was extracted inside
   _lasso_xmlsec_load_key_from_buffer) and now can load certificates and
   keys directly embedded inside KeyValue nodes (in total opposition to
   the XMLDsig specification but...), with or without PEM headers.
 * tests/metadata/Makefile.am tests/metadata/metadata_06.xml
   tests/metadata_tests.c:
   add test case for RSAKeyValue public keys.
2010-02-04 22:24:04 +00:00
Benjamin Dauvergne 2a3ada925c Core: in lasso_xmlsec_load_key_info add flag to let xmlSec load certificates
* lasso/xml/tools.c:
   adding the flag XMLSEC_KEYINFO_FLAGS_X509DATA_DONT_VERIFY_CERTS make
   xmlSec able to load certificate, the 'hand made' code to load
   certificate is then useless.
2010-02-04 01:23:43 +00:00
Benjamin Dauvergne 845eb26d6a Core: in tools.c, add function to load XML files and KeyInfo nodes
* tools.c:
   add lasso_xml_parse_file, based on g_file_get_contents and
   lasso_xml_parse_memory.
   add lasso_xml_parse_memory_with_error which instead of logging
   errors, can return the xmlError structure.
   add lasso_xmlsec_load_key_info, which allows to load keys from
   ds:KeyInfo XML nodes. It also support the "Lasso" bug of using
   ds:KeyValue directly to store base64 encoded keys and certificates.
2010-02-04 00:02:19 +00:00