Subsections


Certificate and key import/export functions

Apart from two file checking functions in section 3, in this section you will find all functions that allow the Maemo Certificate Manager API to communicate with the outside world.

Also, functions for importing/exporting bare keys are also included here.

CST_import_PKCS12

void CST_import_PKCS12 ( CST * st, FILE * file, cst_pkcs12_confirm_cb confirm_cb, cst_pkcs12_error_cb error_cb, unsigned char * password, void * user_data, GError ** error)

Import certificate with private key (if any) from the PKCS12-format file.
Parameters

Confirm_cb callback function received parameters

Error_cb callback function received parameters

Callback functions details

Confirm_cb callback function example

int confirm_cb(X509 * xcert, cst_t_cert_folder * folder, cst_t_cert_purpose * purpose,

               unsigned char * out_pass, int is_pair, int *cancel, 

               void * user_data)

{

    if (is_pair) {

        *out_pass = "secret";

        *purpose = CST_PURPOSE_SSL_CLIENT;

        *folder = CST_FOLDER_PERSONAL;

        *cancel = FALSE;

        return TRUE;

    } else {

        *purpose = CST_PURPOSE_CA;

        *folder = CST_FOLDER_CA;

        *cancel = FALSE;

        return TRUE;

    }

}

Returns

Errors


CST_import_cert

int CST_import_cert (CST * st, FILE * file, unsigned char * password)

Import certificate from the PEM-format file. (TODO: does it set folder and purpose based on certificate data?)
Parameters

Returns

Errors

CST_import_cert_DER

int CST_import_cert_DER (CST * st, FILE * file)

Import certificate from the DER-format file.
Parameters

Returns

Error code
Errors

CST_import_cert_f

int CST_import_cert_f (CST * st, FILE * file, unsigned char * password, const cst_t_cert_folder folder)

Import certificate from the PEM-format file and set its folder.
Parameters

Returns

Errors

CST_import_cert_f_DER

int CST_import_cert_f_DER (CST * st, FILE * file, const cst_t_cert_folder folder)

Import certificate from the DER-format file to a folder.
Parameters

Returns

Errors

CST_import_cert_adv

cst_t_seqnum CST_import_cert_adv (CST * st, FILE * file, const cst_t_cert_folder folder, GError ** error)

Import certificate from the file and set folder (PEM format). If folder incorrect cert placed in default folder (CST_FOLDER_UNKNOWN) and error returned.
Parameters

Returns

Errors

CST_import_cert_adv_DER

cst_t_seqnum CST_import_cert_adv_DER (CST * st, FILE * file, const cst_t_cert_folder folder, GError ** error)

Import all certificates from the file and set folder (DER format). If folder incorrect cert placed in default folder (CST_FOLDER_UNKNOWN) and error returned.
Parameters

Returns

Errors

CST_export_all

int CST_export_all (CST * st, FILE * file, const cst_t_cert_folder folder)

Export all certificates to the file (PEM format).
Parameters

Returns

Errors

CST_export_all_DER

int CST_export_all_DER (CST * st, FILE * file, const cst_t_cert_folder folder)

Export all certificates to the file (DER format).
Parameters

Returns

Errors

CST_export_cert

int CST_export_cert (CST * st, X509 * cert, FILE * file)

Export selected certificate to a PEM format file.
Parameters

Returns

Errors

CST_export_cert_DER

int CST_export_cert_DER (CST * st, X509 * cert, FILE * file)

Export selected certificate to the file (DER format)
Parameters

Returns

Errors

CST_export_cert_by_id

int CST_export_cert_by_id (CST * st, const cst_t_seqnum certID, FILE * file)

Export selected certificate (by certID) to the file (PEM format)
Parameters

Returns

Errors

CST_export_cert_by_id_DER

int CST_export_cert_by_id_DER (CST * st, const cst_t_seqnum certID, FILE * file)

Export selected certificate (by certID) to the file (DER format)
Parameters

Returns

Errors


CST_import_priv_key

int CST_import_priv_key ( CST * st, X509_NAME * account, FILE * file, unsigned char * inpass, unsigned char * outpass)

Import private key from PEM encoded file. If a private key for the same account exists in storage, key is appended.
Parameters

Returns

Errors

CST_import_priv_key_DER

int CST_import_priv_key_DER ( CST * st, X509_NAME * account, FILE * file, unsigned char * outpass)

Import private key from DER encoded file. If a private key for the same account exists in storage, key is appended.
Parameters

Returns

Errors

CST_import_priv_key_adv

cst_t_seqnum CST_import_priv_key_adv (CST * st, X509_NAME * account, FILE * file, unsigned char * inpass, unsigned char * outpass, GError ** error)

Import private key from PEM encoded file. If a private key for the same account exists in storage, key is appended.
Parameters

Returns

Errors

CST_import_priv_key_adv_DER

cst_t_seqnum CST_import_priv_key_adv_DER (CST * st, X509_NAME * account, FILE * file, unsigned char * outpass, GError ** error)

Import private key from DER encoded file. If a private key for the same account exists in storage, key is appended.
Parameters

Returns

Errors

CST_export_priv_key

int CST_export_priv_key (CST * st, EVP_PKEY * key, FILE * file, unsigned char * password)

Export private key with given account to PEM format file.
Parameters

Returns

Errors

CST_export_priv_key_DER

int CST_export_priv_key_DER (CST * st, EVP_PKEY * key, FILE * file, unsigned char * password)

Export private key with given account to file (DER format).
Parameters

Returns

Errors

CST_import_pub_key

int CST_import_pub_key (CST * st, X509_NAME * account, FILE * file)

Import public key from file. If a public key for the same account exists in storage, key is appended.
Parameters

Returns

Errors

CST_import_pub_key_DER

int CST_import_pub_key_DER (CST * st, X509_NAME * account, FILE * file)

Import public key from file. If a public key for the same account exists in storage, key is appended.
Parameters

Returns

Errors

CST_import_pub_key_adv

cst_t_seqnum CST_import_pub_key_adv (CST * st, X509_NAME * account, FILE * file, GError ** error)

Import public key from file. If a public key for the same account exists in storage, key is appended.
Parameters

Returns

Errors

CST_import_pub_key_adv_DER

cst_t_seqnum CST_import_pub_key_adv_DER (CST * st, X509_NAME * account, FILE * file, GError ** error)

Import public key from file. If a public key for the same account exists in storage, key is appended.
Parameters

Returns

Errors

CST_export_all_pub_key

int CST_export_all_pub_key (CST * st, X509_NAME * account, FILE * file)

Export all public keys with given account to file (PEM format).
Parameters

Returns

Errors

CST_export_all_pub_key_DER

int CST_export_all_pub_key_DER (CST * st, X509_NAME * account, FILE * file)

Export all public keys with given account to file (DER format).
Parameters

Returns

Errors

CST_export_pub_key

int CST_export_pub_key (CST * st, EVP_PKEY * key, FILE * file)

Export public key with given account to file (PEM format).
Parameters

Returns

Errors

CST_export_pub_key_DER

int CST_export_pub_key_DER (CST * st, EVP_PKEY * key, FILE * file)

Export public key with given account to file (DER format)
Parameters

Returns

Errors

Elvis Pfutzenreuter 2006-02-17