RSA BSAFE Micro Edition Suite

Streamlined security for mobile and embedded devices

Search  Print

r_crt_stor.h File Reference

This file details the R_CERT_STORE module, which provides a store for holding user certificates.

The certificates can be trusted or untrusted, chained or Root certificates. The module provides operations for creating and destroying a certificate store, and adding, deleting and retrieving a certificate from a store. A certificate can be retrieved by search functions using the certificate attributes. A user application can also assign identifiers to added certificates for future searches.

#include "r_com.h"
#include "r_lib.h"
#include "r_cert.h"
#include "r_pkey.h"
#include "r_crl.h"

Go to the source code of this file.

Data Structures

 R_CERT_STORE_CERT_DATA
 This structure is the public view of the data in the store. More...


Defines

#define R_CERT_STORE_CM_CERTIFICATE
 Indicates a cable modem certificate.

#define R_CERT_STORE_CA_CERTIFICATE
 Indicates a chain certificate.

#define R_CERT_STORE_CVC_CERTIFICATE
 Indicates a code verification certificate.

#define R_CERT_STORE_MAN_CERTIFICATE
 Indicates a cable modem manufacturer's certificate.

#define R_CERT_STORE_OWN_CERTIFICATE
 Indicates an application-specific certificate.

#define R_CERT_STORE_UNKNOWN_CERTIFICATE
 Indicates that the type of certificate stored is unknown.

#define R_CERT_STORE_ANY_CERTIFICATE
 Indicates that any type of certificate may be stored.

#define R_CERT_STORE_CTX_INFO_R_LIB_CTX
 Indicates the library context associated with the certificate store context. More...

#define R_CERT_STORE_CTX_INFO_FINGERPRINT_ALG
 Indicates the digest algorithm to use when calculating the fingerprint of a certificate. More...

#define R_CERT_STORE_CTX_INFO_ENTRY_COUNT
 Indicates the number of entries in the certificate store. More...

#define R_CERT_STORE_CTX_LOCK_READ
 Indicates that the lock is being obtained to read data only.

#define R_CERT_STORE_CTX_LOCK_WRITE
 Indicates that the lock is being obtained to write data.

#define R_CERT_STORE_INFO_R_CERT_STORE_CTX
 Indicates the certificate store context associated with the object. More...

#define R_CERT_STORE_INFO_INDEX
 Indicates the index of the entry in the certificate store. More...

#define R_CERT_STORE_INFO_CERTIFICATE_INFO
 Indicates the stored certificate information. More...

#define R_CERT_STORE_INFO_CERTIFICATE
 Indicates the certificate. More...

#define R_CERT_STORE_INFO_USER_ID
 Indicates the user-defined identifier for the certificate. More...

#define R_CERT_STORE_INFO_STATE
 Indicates the state of the certificate. More...

#define R_CERT_STORE_INFO_CLASS
 Indicates the class of the certificate. More...

#define R_CERT_STORE_INFO_CALLBACK
 Indicates the compare callback function of the certificate store object. More...

#define R_CERT_STORE_INFO_PRIV_KEY
 Indicates the private key of the certificate currently loaded into the store object. More...

#define R_CERT_STORE_INFO_CRL
 Indicates the list of revoked certicates that have been previously issued by the certificate currently loaded into the store object. More...

#define R_CERT_STORE_STATE_UNTRUSTED_CERTIFICATE
 Indicates that the certificate is known to be untrusted.

#define R_CERT_STORE_STATE_TRUSTED_CERTIFICATE
 Indicates that the certificate is known to be trusted.

#define R_CERT_STORE_STATE_CHAINED_CERTIFICATE
 Indicates that the certificate is in a chain.

#define R_CERT_STORE_STATE_ROOT_CERTIFICATE
 Indicates that the certificate is a Root certificate in a chain.


Typedefs

typedef struct r_cert_store_method_st R_CERT_STORE_METHOD
 This structure contains the method table of a certificate store.

typedef struct r_cert_store_ctx_st R_CERT_STORE_CTX
 The certificate store context is the object that holds the reference to the certificate store itself. More...

typedef struct r_cert_store_st R_CERT_STORE
 The certificate store object is the interface between the user and the certificate store itself. More...

typedef struct r_cert_store_cert_data_st R_CERT_STORE_CERT_DATA
 The certificate store data structure can be used to load or retrieve all the store entry details into/from an R_CERT_STORE object simultaneously (the alternative method requires making several calls to R_CERT_STORE_set_info() or R_CERT_STORE_get_info()). More...

typedef int(* R_CERT_STORE_CB_T )(void *, void *)
 The type of callback function that iterates over objects in the store. More...

typedef int R_CERT_STORE_CTX_INFO
 Indicates the type of the information identifiers of the certificate store context. More...

typedef int R_CERT_STORE_INFO
 Indicates the type of the information identifiers of the certificate store. More...

typedef int R_CERT_STORE_STATE
 Indicates the type of the state identifiers of the certificate store. More...

typedef int R_CERT_STORE_CERT_TYPE
 Indicates the type of the certificate in the certificate store. More...

typedef int R_CERT_STORE_INDEX
 Indicates the type of the index.


Functions

int R_CERT_STORE_CTX_new (R_LIB_CTX *lib_ctx, R_RES_FLAG flag, R_CERT_STORE_CTX **ctx)
 Creates a new certificate store context ctx by requesting the R_CERT_STORE resource from the library module and initializing the context state. More...

int R_CERT_STORE_CTX_free (R_CERT_STORE_CTX *ctx)
 Deallocates the certificate store context ctx and clears all state information associated with ctx, including all certificates within the store. More...

int R_CERT_STORE_CTX_get_info (R_CERT_STORE_CTX *ctx, R_CERT_STORE_CTX_INFO info_id, void *value)
 Returns information from the certificate store context. More...

int R_CERT_STORE_CTX_set_info (R_CERT_STORE_CTX *ctx, R_CERT_STORE_CTX_INFO info_id, void *value)
 Sets information into the certificate store context ctx. More...

int R_CERT_STORE_CTX_lock (R_CERT_STORE_CTX *ctx, int lock_type)
 Locks the certificate store context using the lock type lock_type. More...

int R_CERT_STORE_CTX_unlock (R_CERT_STORE_CTX *ctx, int lock_type)
 Releases a lock specified in lock_type. More...

int R_CERT_STORE_new (R_CERT_STORE_CTX *ctx, R_CERT_STORE **obj)
 Creates a new store object obj. More...

int R_CERT_STORE_free (R_CERT_STORE *obj)
 Deallocates the store object obj and clears any state associated with the object. More...

int R_CERT_STORE_get_info (R_CERT_STORE *obj, R_CERT_STORE_INFO info_id, void *value)
 Returns information from the certificate store object. More...

int R_CERT_STORE_set_info (R_CERT_STORE *obj, R_CERT_STORE_INFO info_id, void *value)
 Sets information into the certificate store object for the specified information identifier. More...

int R_CERT_STORE_init (R_CERT_STORE *obj)
 Initializes the state of the certificate store object. More...

int R_CERT_STORE_update (R_CERT_STORE *obj)
 Updates the certificate store content using the certificate in the certificate store object obj. More...

int R_CERT_STORE_add (R_CERT_STORE *obj)
 Adds the certificate associated with the certificate store object obj into the certificate store context. More...

int R_CERT_STORE_delete (R_CERT_STORE *obj)
 Deletes the certificate entry in the certificate store object obj from the certificate store. More...

int R_CERT_STORE_CTX_get_entry_count (R_CERT_STORE_CTX *ctx, int *entries)
 Returns the number of certificates in the R_CERT_STORE_CTX ctx. More...

int R_CERT_STORE_find (R_CERT_STORE *obj)
 Calls a custom search callback, specified by the application, to retrieve a certificate from the store. More...

int R_CERT_STORE_next (R_CERT_STORE *obj)
 Retrieves the certificate details of the certificate at the next index in the store. More...

int R_CERT_STORE_find_entry_by_subject (R_CERT_STORE *obj, R_CERT_NAME *subject, R_CERT_STORE_CERT_TYPE cert_class)
 Loads the certificate store object obj with the details of the first certificate store entry found with subject name subject and certificate class cert_class. More...

int R_CERT_STORE_find_entry_by_issuer (R_CERT_STORE *obj, R_CERT_NAME *issuer, R_CERT_STORE_CERT_TYPE cert_class)
 Loads the certificate store object obj with the details of the first certificate store entry found with issuer name issuer and certificate class cert_class. More...

int R_CERT_STORE_find_entry_by_pubkey (R_CERT_STORE *obj, R_PKEY *pubkey, R_CERT_STORE_CERT_TYPE cert_class)
 Loads the certificate store object obj with the details of the first certificate store entry found with public key pubkey and certificate class cert_class. More...

int R_CERT_STORE_find_entry_by_fingerprint (R_CERT_STORE *obj, R_ITEM *fprint, R_CERT_STORE_CERT_TYPE cert_class)
 Loads the certificate store object obj with the details of the first certificate store entry found with fingerprint fprint and certificate class cert_class. More...

int R_CERT_STORE_find_entry_by_issuer_and_serial (R_CERT_STORE *obj, R_CERT_NAME *issuer, R_ITEM *serial, int cert_class)
 Loads the certificate store object obj with the details of the first certificate store entry found with issuer name issuer, serial number serial and certificate class cert_class. More...

int R_CERT_STORE_set_cert_data (R_CERT_STORE *obj, R_CERT_STORE_CERT_DATA *data)
 Sets certificate information from the R_CERT_STORE_CERT_DATA structure data into the certificate store object obj. More...

int R_CERT_STORE_get_cert_data (R_CERT_STORE *obj, R_CERT_STORE_CERT_DATA *data)
 Retrieves certificate information into the R_CERT_STORE_CERT_DATA structure data from the certificate store object obj. More...

int R_CERT_STORE_set_cert (R_CERT_STORE *obj, R_CERT *cert, R_ITEM *id)
 Sets the certificate cert and user-defined identifier id into the certificate store object obj. More...

int R_CERT_STORE_get_cert (R_CERT_STORE *obj, R_CERT **cert, R_ITEM **id)
 Retrieves the certificate cert and user-defined identifier id from the certificate store object obj. More...

int R_CERT_STORE_set_cert_state (R_CERT_STORE *obj, R_CERT_STORE_STATE state)
 Sets the state of the certificate, which includes the trust level, into the certificate store object obj. More...

int R_CERT_STORE_get_cert_state (R_CERT_STORE *obj, R_CERT_STORE_STATE *state)
 Retrieves the state of the certificate, which includes the trust level, from the certificate store object obj. More...

int R_CERT_STORE_set_cert_class (R_CERT_STORE *obj, R_CERT_STORE_CERT_TYPE cert_class)
 Sets the class of the certificate into the certificate store object obj. More...

int R_CERT_STORE_get_cert_class (R_CERT_STORE *obj, R_CERT_STORE_CERT_TYPE *cert_class)
 Retrieves the class of the certificate cert_class from the certificate store object obj. More...

int R_CERT_STORE_set_compare_func (R_CERT_STORE *obj, R_CERT_STORE_CB_T *func)
 Sets the function to use for matching when searching through the certificates in the certificate store. More...

int R_CERT_STORE_cert_type_to_string (R_CERT_STORE_CERT_TYPE cert_type, unsigned int max_str_len, char *str)
 Returns the string representation for the certificate types cert_type. More...

int R_CERT_STORE_cert_type_from_string (char *str, R_CERT_STORE_CERT_TYPE *cert_type)
 Returns the certificate type for the string description str. More...

int R_CERT_STORE_STATE_to_string (R_CERT_STORE_STATE state, unsigned int max_str_len, char *str)
 Returns the string representation of the state state of a certificate. More...

int R_CERT_STORE_STATE_from_string (char *str, R_CERT_STORE_STATE *state)
 Returns the state flag for the string representation str of a certificate state state. More...


Typedef Documentation

typedef struct r_cert_store_st R_CERT_STORE
 

The certificate store object is the interface between the user and the certificate store itself. This object is loaded with the appropriate store details and added/updated/removed from the store via calls to R_CERT_STORE_add(), R_CERT_STORE_update() and R_CERT_STORE_delete(). A binary comparison of the user identifier (or the certificate in the case where the used id is NULL) is used to find the correct entry in the store. If R_CERT_STORE_add() is supplied with a certificate entry that already exists in the store, the certificate store will be updated by default. Once a certificate, private key or CRL has been supplied to the store object, the object assumes ownership and so the application should not free any allocated memory for these items. However if the application chooses to retrieve a certificate, CRL or private key from the object (for example, by calling R_CERT_STORE_get_info()) the ownership is transferred back to the application.

This structure provides access to:

  • The store context.
  • The store method table.
  • The currently selected store entry.
  • typedef struct r_cert_store_cert_data_st R_CERT_STORE_CERT_DATA
     

    The certificate store data structure can be used to load or retrieve all the store entry details into/from an R_CERT_STORE object simultaneously (the alternative method requires making several calls to R_CERT_STORE_set_info() or R_CERT_STORE_get_info()). If this structure is used to populate the store all the fields must be initialized. Optional fields that are not required must be set to NULL. Once the contents of this structure have been added to the store object (R_CERT_STORE_set_cert_data()), the certificate, private key and CRL are owned by the object and so do not need to be explicitly freed. Correspondingly any call to R_CERT_STORE_get_data() will transfer ownership back to the application.

    This structure provides access to:

  • The certificate.
  • The user-defined identification data (optional).
  • The state of the certificate.
  • The class of the certificate.
  • The private key of the certificate (optional).
  • A list of certificates that have been revoked by the store entry certificate (optional).
  • typedef struct r_cert_store_ctx_st R_CERT_STORE_CTX
     

    The certificate store context is the object that holds the reference to the certificate store itself. The certificate store however cannot be updated directly by modifying the context. Instead an R_CERT_STORE object must be loaded with the certificate details and provided to the store context via calls to R_CERT_STORE_add(), R_CERT_STORE_delete() or R_CERT_STORE_update(). A binary comparison of the user identifier (or the certificate in the case where the user id is NULL) is used to find the correct entry in the store. When a certificate is added into the store its fingerprint is calculated and can be subsequently used as search criteria. The default fingerprint algorithm is R_CR_ID_SHA1. This value should not be changed once certificates have been added to the store since the fingerprints of the existing certificates will no longer match those computed with the new algorithm.

    This structure provides access to:

  • The library context.
  • The actual store.
  • The store locking mechanism.
  • The lock identifier.
  • The digest algorithm for generating certificate fingerprint.
  • The store method table.

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