icsf: update list of numeric attributes

ICSF expects that numeric attributes are encoded using an specific ASN.1
syntax. This commit updates the list of attribute classes that are
considered numeric.

Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
Reviewed-by: Debora Babb
Reviewed-by: Joy Latten
icsf: better usage of handle helper functions

Add a new helper function to build a token handle based on its name.
Also replace redundant code with calls for existing helper functions.

Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
Reviewed-by: Debora Babb
Reviewed-by: Joy Latten
icsf: add a generic function for all ICSF services

Add the `icsf_call` function that can be used for any ICSF call. This
commit also removes the `icsf_create` function replacing it with
`icsf_call` calls.

Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
Reviewed-by: Debora Babb
Reviewed-by: Joy Latten
icsf: remove `icsf_destroy` function

Removes the `icsf_destroy` function replacing it with `icsf_call` calls.

Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
Reviewed-by: Debora Babb
Reviewed-by: Joy Latten
icsf: update `icsf_list` to use `icsf_call`

Update the generic listing function to use `icsf_call` and to reduce
duplicated code.

Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
Reviewed-by: Debora Babb
Reviewed-by: Joy Latten
icsf: add support for symmetric key generation

Add a new function `icsf_generate_secret_key` that calls the CSFPGSK
service to create a key.

Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
Reviewed-by: Debora Babb
Reviewed-by: Joy Latten
icsf: add ASN.1 description for icsf_generate_secret_key

Add the ASN.1 sysntax for the CSFPGSK service used by icsf_generate_secret_key.

Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
Reviewed-by: Debora Babb
Reviewed-by: Joy Latten
icsf: add support for mechanisms in icsf_generate_secret_key

Add a new argument in icsf_generate_secret_key that specifies the
mechanism that has to be used. This means that SSL keys are now
supported.

Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
Reviewed-by: Debora Babb
Reviewed-by: Joy Latten
update token specific open session function

Update token_specific_session to use a SESSION* argument instead of slot
id. Also check if a token supports it before calling it and remove
unused token_specific_session functions from tokens that don't need it.

Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
Reviewed-by: Debora Babb
Reviewed-by: Joy Latten
update token specific login function

Update token_specific_login to use a SESSION* argument instead of slot
id.

Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
Reviewed-by: Debora Babb
Reviewed-by: Joy Latten
icsf: keep LDAP handle in a global structure

Add a list of open sessions that will keep the handle for the LDAP
connection.

Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
Reviewed-by: Debora Babb
Reviewed-by: Joy Latten
fix formatting for SC_GenerateKeu in new_host.c

Fix indentation and break long lines.

Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
Reviewed-by: Debora Babb
Reviewed-by: Joy Latten
token-specific function for symmetric key generation

Add a new token-specific function t_generate_key for symmetric key generation.

Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
Reviewed-by: Debora Babb
Reviewed-by: Joy Latten
icsf: add support for symmetric key generation

This commit adds to ICSF token the token-specific function for symmetric
key generation. It also adds a helper function in icsf_specific.c that
checks permissions based on the current session and on the object/key
attributes, this function can be reused for object creation.

Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
Reviewed-by: Debora Babb
Reviewed-by: Joy Latten
fix: remove unused macro ICSF_DIR

Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
Reviewed-by: Debora Babb
Reviewed-by: Joy Latten
fix: rename t_session() to t_open_session()

Also rename token_specific_session() to token_specific_open_session().

Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
Reviewed-by: Debora Babb
Reviewed-by: Joy Latten
add some comments about ICSF tag numbers and services

Include some comments in icsf.c and icsf.h to make clear the service
that is called and how tag numbers work.

Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
Reviewed-by: Debora Babb
Reviewed-by: Joy Latten
Indent with tabs instead of spaces

in icsf_specific.c

Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
Reviewed-by: Debora Babb
Reviewed-by: Joy Latten
Change lock ICSF's t_login to protect shared memory

Change the point where the futex is locked to cover any access to shared
memory in token_specific_login.

Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
Reviewed-by: Debora Babb
Reviewed-by: Joy Latten
icsf: use a RW lock for sessions

Change the way the sessions list is protected, replacing the futex with
a RW lock for that.

Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
Reviewed-by: Debora Babb
Reviewed-by: Joy Latten