XML Security Library Reference Manual
<<< Previous Page | Home | Up | Next Page >>>

# keysmngr.h

## Name

keysmngr.h -- The simple keys manager implementation.

## Synopsis

    xmlSecKeysMngrPtr xmlSecSimpleKeysMngrCreate
                                                (void);
    void        xmlSecSimpleKeysMngrDestroy     (xmlSecKeysMngrPtr mngr);
    xmlSecKeyPtr xmlSecSimpleKeysMngrFindKey    (xmlSecKeysMngrPtr mngr,
                                                 void *context,
                                                 const xmlChar *name,
                                                 xmlSecKeyId id,
                                                 xmlSecKeyType type,
                                                 xmlSecKeyUsage usage);
    int         xmlSecSimpleKeysMngrAddKey      (xmlSecKeysMngrPtr mngr,
                                                 xmlSecKeyPtr key);
    int         xmlSecSimpleKeysMngrLoad        (xmlSecKeysMngrPtr mngr,
                                                 const char *uri,
                                                 int strict);
    int         xmlSecSimpleKeysMngrSave        (const xmlSecKeysMngrPtr mngr,
                                                 const char *filename,
                                                 xmlSecKeyType type);
    xmlSecKeyPtr xmlSecSimpleKeysMngrLoadPemKey (xmlSecKeysMngrPtr mngr,
                                                 const char *keyfile,
                                                 const char *keyPwd,
                                                 pem_password_cb *keyPwdCallback,
                                                 int privateKey);
    xmlSecX509DataPtr xmlSecSimpleKeysMngrX509Find
                                                (xmlSecKeysMngrPtr mngr,
                                                 void *context,
                                                 xmlChar *subjectName,
                                                 xmlChar *issuerName,
                                                 xmlChar *issuerSerial,
                                                 xmlChar *ski,
                                                 xmlSecX509DataPtr cert);
    int         xmlSecSimpleKeysMngrX509Verify  (xmlSecKeysMngrPtr mngr,
                                                 void *context,
                                                 xmlSecX509DataPtr cert);
    int         xmlSecSimpleKeysMngrLoadPemCert (xmlSecKeysMngrPtr mngr,
                                                 const char *filename,
                                                 int trusted);
    int         xmlSecSimpleKeysMngrAddCertsDir (xmlSecKeysMngrPtr mngr,
                                                 const char *path);
    int         xmlSecSimpleKeysMngrLoadPkcs12  (xmlSecKeysMngrPtr mngr,
                                                 const char *name,
                                                 const char *filename,
                                                 const char *pwd);

## Description

## Details

### xmlSecSimpleKeysMngrCreate ()

    xmlSecKeysMngrPtr xmlSecSimpleKeysMngrCreate
                                                (void);

Creates new simple keys manager.

Returns : | a pointer to newly allocated xmlSecKeysMngr structure or NULL if an error occurs.

### xmlSecSimpleKeysMngrDestroy ()

    void        xmlSecSimpleKeysMngrDestroy     (xmlSecKeysMngrPtr mngr);

Destroys the simple keys manager.

`mngr` : | the pointer to a simple keys manager.

### xmlSecSimpleKeysMngrFindKey ()

    xmlSecKeyPtr xmlSecSimpleKeysMngrFindKey    (xmlSecKeysMngrPtr mngr,
                                                 void *context,
                                                 const xmlChar *name,
                                                 xmlSecKeyId id,
                                                 xmlSecKeyType type,
                                                 xmlSecKeyUsage usage);

Searches the simple keys manager for specified key. This is an implementation of the xmlSecFindKeyCallback for the simple keys manager.

`mngr` : | the keys manager.
`context` : | the pointer to application specific data.
`name` : | the required key name (or NULL for "any").
`id` : | the required key Id (or NULL for "any").
`type` : | the required key (may be "any").
`usage` : | the required key usage.
Returns : | the pointer to key or NULL if the key is not found or an error occurs.

### xmlSecSimpleKeysMngrAddKey ()

    int         xmlSecSimpleKeysMngrAddKey      (xmlSecKeysMngrPtr mngr,
                                                 xmlSecKeyPtr key);

Adds new key to the key manager

`mngr` : | the pointer to the simple keys manager.
`key` : | the pointer to the xmlSecKey structure.
Returns : | 0 on success or a negative value otherwise.

### xmlSecSimpleKeysMngrLoad ()

    int         xmlSecSimpleKeysMngrLoad        (xmlSecKeysMngrPtr mngr,
                                                 const char *uri,
                                                 int strict);

Reads the XML keys files into simple keys manager.

`mngr` : | the pointer to the simple keys manager.
`uri` : | the keys file uri.
`strict` : | the flag which determines whether we stop after first error or not.
Returns : | 0 on success or a negative value otherwise.

### xmlSecSimpleKeysMngrSave ()

    int         xmlSecSimpleKeysMngrSave        (const xmlSecKeysMngrPtr mngr,
                                                 const char *filename,
                                                 xmlSecKeyType type);

Writes all the keys from the simple keys manager to an XML file `filename`.

`mngr` : | the pointer to the simple keys manager.
`filename` : | the destination filename.
`type` : | the keys type (private/public).
Returns : | 0 on success or a negative value otherwise.

### xmlSecSimpleKeysMngrLoadPemKey ()

    xmlSecKeyPtr xmlSecSimpleKeysMngrLoadPemKey (xmlSecKeysMngrPtr mngr,
                                                 const char *keyfile,
                                                 const char *keyPwd,
                                                 pem_password_cb *keyPwdCallback,
                                                 int privateKey);

Reads the key from a PEM file `keyfile`.

`mngr` : | the pointer to the simple keys manager.
`keyfile` : | the PEM key file name.
`keyPwd` : | the key file password.
`keyPwdCallback` : | the "ask password" callback.
`privateKey` : | the private/public flag.
Returns : | the pointer to a newly allocated xmlSecKey structure or NULL if an error occurs.

### xmlSecSimpleKeysMngrX509Find ()

    xmlSecX509DataPtr xmlSecSimpleKeysMngrX509Find
                                                (xmlSecKeysMngrPtr mngr,
                                                 void *context,
                                                 xmlChar *subjectName,
                                                 xmlChar *issuerName,
                                                 xmlChar *issuerSerial,
                                                 xmlChar *ski,
                                                 xmlSecX509DataPtr cert);

Searches for matching certificate in the keys manager. This is the implementation of the xmlSecX509FindCallback for the simple keys manager.

`mngr` : | the keys manager.
`context` : | the pointer application specific data.
`subjectName` : | the subject name string.
`issuerName` : | the issuer name string.
`issuerSerial` : | the issuer serial.
`ski` : | the SKI string.
`cert` : | the current X509 certs data (may be NULL).
Returns : | the pointer to certificate that matches given criteria or NULL if an error occurs or certificate not found.

### xmlSecSimpleKeysMngrX509Verify ()

    int         xmlSecSimpleKeysMngrX509Verify  (xmlSecKeysMngrPtr mngr,
                                                 void *context,
                                                 xmlSecX509DataPtr cert);

Validates certificate. This is the implementation of the xmlSecX509VerifyCallback callback for the simple keys manager.

`mngr` : | the keys manager.
`context` : | the pointer to application specific data.
`cert` : | the cert to verify.
Returns : | 1 if the cert is trusted, 0 if it is not trusted and -1 if an error occurs.

### xmlSecSimpleKeysMngrLoadPemCert ()

    int         xmlSecSimpleKeysMngrLoadPemCert (xmlSecKeysMngrPtr mngr,
                                                 const char *filename,
                                                 int trusted);

Reads PEM certificate from the file `filename` and adds to the keys manager `mngr`.

`mngr` : | the simple keys manager.
`filename` : | the PEM cert file name.
`trusted` : | the trusted/not-trusted cert flag.
Returns : | 0 on success or a negative value otherwise.

### xmlSecSimpleKeysMngrAddCertsDir ()

    int         xmlSecSimpleKeysMngrAddCertsDir (xmlSecKeysMngrPtr mngr,
                                                 const char *path);

Adds the certificates from the folder `path` to the list of trusted certificates.

`mngr` : | the simple keys manager.
`path` : | the certs dir path.
Returns : | 0 on success or a negative value otherwise.

### xmlSecSimpleKeysMngrLoadPkcs12 ()

    int         xmlSecSimpleKeysMngrLoadPkcs12  (xmlSecKeysMngrPtr mngr,
                                                 const char *name,
                                                 const char *filename,
                                                 const char *pwd);

Reads the key from pkcs12 file `filename` (along with all certs) and adds to the simple keys manager `mngr`.

`mngr` : | the simple keys manager.
`name` : | the key name (may by NULL).
`filename` : | the pkcs12 file name.
`pwd` : | the pkcs12 password.
Returns : | 0 on success or a negative value otherwise.

<<< Previous Page | Home | Up | Next Page >>>
keys.h | transforms.h