RSA Security logo

RSA BSAFE Cert-C
API Reference

cms.h

Go to the documentation of this file.
00001 /*
00002 * Copyright (c) RSA Security Inc., 1999-2003.  All rights reserved.
00003 * This work contains proprietary, confidential, and trade secret
00004 * information of RSA Security Inc.  Use, disclosure or reproduction
00005 * without the express written authorization of RSA Security Inc. is
00006 * prohibited.
00007 */
00008 
00017 #ifndef HEADER_BSAFE_CERTC_CMS
00018 #define HEADER_BSAFE_CERTC_CMS 1
00019 
00020 /* Includes */
00021 #include "bsafe.h"
00022 #include "basetype.h"
00023 #include "certpath.h"
00024 #include "certext.h"
00025 #include "certalg.h"   /* for SA_*, DAI_*, KA_* */
00026 
00027 #ifdef __cplusplus
00028 extern "C" {
00029 #endif
00030 
00031 /* Content type object identifiers */
00032 extern unsigned char CT_ID_DATA[];
00033 extern unsigned char CT_ID_SIGNED_DATA[];
00034 extern unsigned char CT_ID_ENVELOPED_DATA[];
00035 extern unsigned char CT_ID_DIGESTED_DATA[];
00036 extern unsigned char CT_ID_ENCRYPTED_DATA[];
00037 
00038 #define CT_ID_DATA_LEN           9
00039 #define CT_ID_SIGNED_DATA_LEN    9
00040 #define CT_ID_ENVELOPED_DATA_LEN 9
00041 #define CT_ID_DIGESTED_DATA_LEN  9
00042 #define CT_ID_ENCRYPTED_DATA_LEN 9
00043 
00044 /* CMS processing options.
00045    Individual flags may be combined using bitwise-OR */
00046 
00047 /* CMSF_NONE
00048 Setting this flag indicates none of the options are desired. */
00049 #define CMSF_NONE                  0x00000000
00050 
00051 /* CMSF_EXTERNAL_SIGNATURE
00052    Setting this flag causes the SignedData message to be formatted
00053    where the data content is not included in the message.  This
00054    enables the creation of a detached or external signature.  */
00055 #define CMSF_EXTERNAL_SIGNATURE    0x00000001
00056 
00057 /* CMSF_INCLUDE_CERTS
00058    Setting this flag causes the SignedData message processing to
00059    build certificate paths to a trusted roots by searching databases
00060    for required certificates and including these certificates in the
00061    set of certificates included in the message.  */
00062 #define CMSF_INCLUDE_CERTS         0x00000002
00063 
00064 /* CMSF_INCLUDE_CRLS
00065    Setting this flag causes the SignedData message processing to
00066    include relevant CRLs by searching databases for latest CRLs for
00067    each certificate in the certificate list and including these CRLs
00068    in the set of CRLs included in the message.  */
00069 #define CMSF_INCLUDE_CRLS          0x00000004
00070 
00071 /* CMSF_VERIFY_SIGNER_CERTS
00072    Setting this flag causes the SignedData extraction message
00073    processing to verify the revocation status and validate the
00074    certificate chain for each signer certificate.  */
00075 #define CMSF_VERIFY_SIGNER_CERTS   0x00000008
00076 
00077 /* CMSF_EXCLUDE_SIGNER_CERT
00078    Setting this flag causes the SignedData message processing not to
00079    include signer certificate in the message. By default, the signer
00080    certificate is included in the message. */
00081 #define CMSF_EXCLUDE_SIGNER_CERT   0x00000010
00082 
00083 
00098 typedef struct {
00099   NAME_OBJ issuerName;
00100   ITEM     serialNumber;
00101 } ISSUER_SERIAL_NUMBER;
00102 
00103 /* Choice(s) for CERT_IDENTIFIER.type below */
00104 #define ISSUER_SERIAL  1
00105 
00133 typedef struct {
00134   int type;
00135   union {
00136     ISSUER_SERIAL_NUMBER issuerSerialNumber;
00137   } id;
00138 } CERT_IDENTIFIER;
00139 
00193 typedef struct {
00194   CERT_IDENTIFIER      signerCertId;
00195   ALGORITHM_IDENTIFIER digestAlgorithmId;
00196   ATTRIBUTES_OBJ       signedAttributes;
00197   ALGORITHM_IDENTIFIER signatureAlgorithmId;
00198   ATTRIBUTES_OBJ       unsignedAttributes;
00199 } SIGNER_INFO;
00200 
00230 typedef struct {
00231   CERT_IDENTIFIER      recipCertId;
00232   ALGORITHM_IDENTIFIER keyEncryptionAlgorithmId;
00233 } KEY_TRANSPORT_INFO;
00234 
00235 /* Choice(s) for RECIPIENT_INFO.type below */
00236 #define KEY_TRANSPORT  1
00237 
00289 typedef struct {
00290   int type;
00291   union {
00292     KEY_TRANSPORT_INFO keyTrans;
00293   } info;
00294 } RECIPIENT_INFO;
00295 
00332 int C_ReadMessageType (
00333   CERTC_CTX  ctx,                          /* (in)  initialized Cert-C context */
00334   ITEM      *cmsMsg,                       /* (in)  formatted CMS message      */
00335   ITEM      *oid);                         /* (out) OID of the message         */
00336 
00360 int C_WriteDataMsg (
00361   CERTC_CTX  ctx,                          /* (in)  initialized Cert-C context */
00362   ITEM      *data,                         /* (in)  data to be written         */
00363   ITEM      *dataMsg);                     /* (out) formatted CMS message      */
00364 
00525 int C_WriteSignedDataMsg (
00526   CERTC_CTX      ctx,                      /* (in) Cert-C context              */
00527   CERT_PATH_CTX *pathCtx,                  /* (in) path context                */
00528   SERVICE        database,                 /* (in) database service            */
00529   ITEM          *data,                     /* (in) formated dataMsg            */
00530   UINT4          cmsOptions,               /* (in) options                     */
00531   LIST_OBJ       certificates,             /* (in) certificate list            */
00532   LIST_OBJ       crls,                     /* (in) crl list                    */
00533   LIST_OBJ       signers,                  /* (in) signer list                 */
00534   ITEM          *signedDataMsg);           /* (out) formated signedDataMsg     */
00535 
00635 int C_WriteEnvelopedDataMsg (
00636   CERTC_CTX             ctx,               /* (in) Cert-C context              */
00637   SERVICE               database,          /* (in) database                    */
00638   ITEM                 *data,              /* (in) formated dataMsg            */
00639   ALGORITHM_IDENTIFIER *contentEncryptionAlgorithmId,
00640                                            /* (in) content Encryption Algo ID  */
00641   LIST_OBJ              recipientInfos,    /* (in) list of recipient           */
00642   B_KEY_OBJ             encryptionKey,     /* (in) content encryption key      */
00643   POINTER               reserved1,         /* (unused) originatorInfo          */
00644   ATTRIBUTES_OBJ        reserved2,         /* (unused) unprotectedAttributes   */
00645   ITEM                 *envelopedDataMsg); /* (out) formated envelopedMsg      */
00646 
00675 int C_WriteDigestedDataMsg (
00676   CERTC_CTX  ctx,                          /* (in) Cert-C context              */
00677   ITEM      *data,                         /* (in) formated dataMsg            */
00678   int        digestAlgorithmId,            /* (in) digest Algo ID              */
00679   ITEM      *digestedDataMsg);             /* (out) formated digestedDataMsg   */
00680 
00719 int C_WriteEncryptedDataMsg (
00720   CERTC_CTX             ctx,               /* (in) Cert-C context              */
00721   ITEM                 *data,              /* (in) formated dataMsg            */
00722   ALGORITHM_IDENTIFIER *encryptAlgorithmId, /* (in)encryption Algo ID          */
00723   B_KEY_OBJ             encryptionKey,     /* (in) encryption key              */
00724   ATTRIBUTES_OBJ        reserved,          /* (unused) unprotectedAttributes   */
00725   ITEM                 *encryptedDataMsg); /* (out) formated encryptedDataMsg  */
00726 
00746 int C_ReadDataMsg (
00747   CERTC_CTX  ctx,                          /* (in) Cert-C context              */
00748   ITEM      *dataMsg,                      /* (in) formated dataMsg            */
00749   ITEM      *data);                        /* (out) data                       */
00750 
00971 int C_ReadSignedDataMsg (
00972   CERTC_CTX      ctx,                      /* (in) Cert-C context              */
00973   CERT_PATH_CTX *pathCtx,                  /* (in) path context                */
00974   SERVICE        database,                 /* (in) database                    */
00975   ITEM          *signedDataMsg,            /* (in) formated signedDataMsg      */
00976   UINT4          cmsOptions,               /* (in) options                     */
00977   ITEM          *data,                     /* (in/out) formated cms message    */
00978   ITEM          *oid,                      /* (out) OID                        */
00979   LIST_OBJ       certificates,             /* (out) cert list                  */
00980   LIST_OBJ       crls,                     /* (out) crl list                   */
00981   LIST_OBJ       verifiedSigners,          /* (out) verified signer            */
00982   LIST_OBJ       unverifiedSigners);       /* (out) unverified signer          */
00983 
01078 int C_ReadEnvelopedDataMsg (
01079   CERTC_CTX             ctx,               /* (in) Cert-C context               */
01080   SERVICE               database,          /* (in) database                     */
01081   ITEM                 *envelopedDataMsg,  /* (in) formated envelopedDataMsg    */
01082   ITEM                 *data,              /* (out) formated cms message        */
01083   ITEM                 *oid,               /* (out) OID                         */
01084   RECIPIENT_INFO       *recipientInfo,     /* (out) recipient info              */
01085   ALGORITHM_IDENTIFIER *contentEncryptionAlgorithmId,
01086                                            /* (out) content Encryption Algo ID  */
01087   B_KEY_OBJ             contentEncryptionKey, /* (out) content Encryption key    */
01088   POINTER               reserved1,         /* (unused) CMS' originatorInfo      */
01089   ATTRIBUTES_OBJ        reserved2);        /* (unused) CMS' unprotectedAttrs    */
01090 
01131 int C_ReadDigestedDataMsg (
01132   CERTC_CTX   ctx,                         /* (in) Cert-C context               */
01133   ITEM       *digestedDataMsg,             /* (in) formated digestedDataMsg     */
01134   ITEM       *data,                        /* (out) formated cms message        */
01135   ITEM       *oid);                        /* (out) OID                         */
01136 
01189 int C_ReadEncryptedDataMsg (
01190   CERTC_CTX       ctx,                     /* (in) Cert-C context               */
01191   ITEM           *encryptedDataMsg,        /* (in) formated encryptedDataMsg    */
01192   B_KEY_OBJ       decryptionKey,           /* (in) decryption key               */
01193   ITEM           *data,                    /* (out) formated cms message        */
01194   ITEM           *oid,                     /* (out) OID                         */
01195   ATTRIBUTES_OBJ  reserved);               /* (unused) CMS' unprotectedAttributes */
01196 
01197 /* List routines to handle Signer and Recipient List
01198  */
01199 
01200 
01222 int C_AddSignerToList(
01223   LIST_OBJ      listObject,                 /* (mod) list object                */
01224   SIGNER_INFO  *signer,                     /* (in)  singer to be added         */
01225   unsigned int *entryIndex);                /* (out) list entry index           */
01226 
01250 int C_InsertSignerInList(
01251   LIST_OBJ      listObject,                 /* (mod) list object                */
01252   SIGNER_INFO  *signer,                     /* (in)  singer to be inserted      */
01253   unsigned int  entryIndex);               /* (in)  list entry index            */
01254 
01280 int C_AddUniqueSignerToList(
01281   LIST_OBJ      listObject,                /* (mod) list object                 */
01282   SIGNER_INFO  *signer,                    /* (in)  singer to be added          */
01283   unsigned int *entryIndex);               /* (out) list entry index            */
01284 
01300 void C_FreeSignerEntry(
01301   SIGNER_INFO  **value);                   /* (mod) value to be deleted         */
01302 
01321 void C_FreeSignerInfo(
01322   SIGNER_INFO   *value);                   /* (mod) value to be deleted         */
01323 
01345 int C_AddRecipientToList(
01346   LIST_OBJ         listObject,             /* (mod) list object                 */
01347   RECIPIENT_INFO  *recipient,              /* (in)  recipient to be added       */
01348   unsigned int    *entryIndex);            /* (out) list entry index            */
01349 
01371 int C_InsertRecipientInList(
01372   LIST_OBJ        listObject,              /* (mod) list object                 */
01373   RECIPIENT_INFO *recipient,               /* (in)  recipient to be inserted    */
01374   unsigned int    entryIndex);             /* (in)  list entry index            */
01375 
01401 int C_AddUniqueRecipientToList(
01402   LIST_OBJ        listObject,              /* (mod) list object                 */
01403   RECIPIENT_INFO *recipient,               /* (in)  recipient to be added       */
01404   unsigned int   *entryIndex);             /* (out) list entry index            */
01405 
01421 void C_FreeRecipientEntry(
01422   RECIPIENT_INFO **value);                 /* (mod) value to be deleted         */
01423 
01440 void C_FreeRecipientInfo(
01441   RECIPIENT_INFO *value);                  /* (mod) value to be deleted         */
01442 
01443 #ifdef __cplusplus
01444 }
01445 #endif
01446 
01447 #endif /* HEADER_BSAFE_CERTC_CMS */



RSA BSAFE® Cert-C 2.7 API Reference