RSA BSAFE Micro Edition Suite

Streamlined security for mobile and embedded devices

Search  Print

Context Functions

This section details the functions that facilitate certificate contexts. The certificate context stores the global state used to process single-type certificates, such as X.509 and WTLS.

Functions

int R_CDECL R_CERT_CTX_new (R_LIB_CTX *lib_ctx, R_RES_FLAG flag, R_CERT_TYPE certtype, R_CERT_CTX **cert_ctx)
 Creates a new certificate context. More...

int R_CDECL R_CERT_CTX_free (R_CERT_CTX *cert_ctx)
 Removes the certificate context and frees all of its associated memory. More...

int R_CDECL R_CERT_CTX_get_info (R_CERT_CTX *cert_ctx, int info_id, void *value)
 Returns information from the certificate context cert_ctx. More...

int R_CDECL R_CERT_CTX_set_info (R_CERT_CTX *cert_ctx, int info_id, void *value)
 Sets information against the certificate context cert_ctx. More...


Function Documentation

int R_CDECL R_CERT_CTX_free R_CERT_CTX   cert_ctx ;
 

Removes the certificate context and frees all of its associated memory.

Parameters:
cert_ctx [In] A reference to a certificate context.
Returns:
R_ERROR_NONE indicates success.
See Identifiers for valid values.
See also:
R_CERT_CTX_new().
Samples:
cert.c, cert_smpl.c, cm.c, cm_adv.c, cm_dgst.c, cm_env.c, cm_env_sm.c, cm_env_strm.c, cm_env_strm_membio.c, cm_open.c, cm_open_strm.c, cm_open_strm_cb.c, cm_open_strm_membio.c, cm_sign.c, cm_sign_dgst.c, cm_sign_sm.c, cm_sign_strm.c, cm_smpl.c, cm_strm.c, cm_vfy_strm_cb.c, ext.c, frombuf.c, ocsp_req_create.c, ocsp_resp_vfy.c, p7ssl_client.c, rcert2sslcert.c, req.c, reqgen.c, ss_cert_smpl.c, sslcert2rcert.c, store.c, verify.c, vfy_adv.c, vfy_bc.c, and vfy_smpl.c.

int R_CDECL R_CERT_CTX_get_info R_CERT_CTX   cert_ctx,
int    info_id,
void *    value
;
 

Returns information from the certificate context cert_ctx.

Parameters:
cert_ctx [In] The certificate context.
info_id [In] The information identifier.
See Context Information Types for valid values and the data type returned in value.
value [Out] The data for the information.
Returns:
R_ERROR_NONE indicates success.
See Identifiers for valid values.
See also:
R_CERT_CTX_set_info().

int R_CDECL R_CERT_CTX_new R_LIB_CTX   lib_ctx,
R_RES_FLAG    flag,
R_CERT_TYPE    certtype,
R_CERT_CTX **    cert_ctx
;
 

Creates a new certificate context.

Parameters:
lib_ctx [In] The library context.
flag [In] The flag indicating scope.
See Flags for valid values.
certtype [In] The certificate type.
See Certificate Types for valid values.
cert_ctx [Out] The created certificate context.
Returns:
R_ERROR_NONE indicates success.
See Identifiers for valid values.
See also:
R_CERT_CTX_free().
Example:

/* $Id: R_CERT_CTX_new.c,v 1.5 2003/06/18 02:29:01 hfrancis Exp $ */
/*
 * Copyright (C) 1998-2003 RSA Security Inc. All rights reserved.
 *
 * This work contains proprietary information of RSA Security.
 * Distribution is limited to authorized licensees of RSA
 * Security. Any unauthorized reproduction, distribution or
 * modification of this work is strictly prohibited.
 */
int ret = R_ERROR_NONE;          /* The return value */
BIO *bio_out;                    /* The output channel for error messages */
R_LIB_CTX *lib_ctx;              /* The library context */
R_CERT_CTX *cert_ctx = NULL;     /* The certificate context */
R_CERT *cert = NULL;             /* The certificate */
char *certfile;                  /* The file where the certificate is stored */
...
/* Create an X.509 certificate context */
if ((ret = R_CERT_CTX_new(lib_ctx, R_RES_FLAG_DEF, R_CERT_TYPE_X509,
    &cert_ctx)) != R_ERROR_NONE)
{
    BIO_printf(bio_out, "Certificate context new failure\n");
    goto end:
}

/* Read the certificate from a file */
if ((ret = R_CERT_read_file(cert_ctx, certfile, R_CERT_TYPE_X509,
    R_FORMAT_BINARY, &cert)) != R_ERROR_NONE)
{
    BIO_printf(bio_out, "Certificate read failure\n");
    goto end;
}

/* Check for the certificate sign key usage extension in the certificate */
if (R_CERT_test_key_usage(cert, R_CERT_KEY_USAGE_KEY_CERT_SIGN) == 1)
{
    BIO_printf(bio_out, "The certificate sign key usage extension is set\n");
}
else
{
    BIO_printf(bio_out, "The certificate sign key usage extension is not set\n");
}
...
end:

if (ret != R_ERROR_NONE)
{
    /* Error handling code */
}

Samples:
cert.c, cert_smpl.c, cm_env.c, cm_env_sm.c, cm_env_strm.c, cm_env_strm_membio.c, cm_open.c, cm_open_strm.c, cm_open_strm_cb.c, cm_open_strm_membio.c, cm_sign.c, cm_sign_dgst.c, cm_sign_sm.c, cm_sign_strm.c, ext.c, frombuf.c, ocsp_req_create.c, p7ssl_client.c, rcert2sslcert.c, req.c, reqgen.c, ss_cert_smpl.c, sslcert2rcert.c, store.c, verify.c, vfy_adv.c, vfy_bc.c, and vfy_smpl.c.

int R_CDECL R_CERT_CTX_set_info R_CERT_CTX   cert_ctx,
int    info_id,
void *    value
;
 

Sets information against the certificate context cert_ctx.

Parameters:
cert_ctx [In] The certificate context.
info_id [In] The information identifier.
See Context Information Types for valid values and the data type specified in value.
value [In] The data to set against the context.
Returns:
R_ERROR_NONE indicates success.
See Identifiers for valid values.
See also:
R_CERT_CTX_get_info().


Copyright (c) 1999-2005 RSA Security Inc. All rights reserved. 072-001001-2100-001-000 - 2.1