"Fossies" - the Fresh Open Source Software Archive

Member "libksba-1.6.0/src/cms.h" (2 Jun 2021, 4618 Bytes) of package /linux/privat/libksba-1.6.0.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "cms.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.5.1_vs_1.6.0.

    1 /* cms.h - Internal definitions for the CMS functions
    2  * Copyright (C) 2001, 2012 g10 Code GmbH
    3  *
    4  * This file is part of KSBA.
    5  *
    6  * KSBA is free software; you can redistribute it and/or modify
    7  * it under the terms of either
    8  *
    9  *   - the GNU Lesser General Public License as published by the Free
   10  *     Software Foundation; either version 3 of the License, or (at
   11  *     your option) any later version.
   12  *
   13  * or
   14  *
   15  *   - the GNU General Public License as published by the Free
   16  *     Software Foundation; either version 2 of the License, or (at
   17  *     your option) any later version.
   18  *
   19  * or both in parallel, as here.
   20  *
   21  * KSBA is distributed in the hope that it will be useful, but WITHOUT
   22  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
   23  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
   24  * License for more details.
   25  *
   26  * You should have received a copies of the GNU General Public License
   27  * and the GNU Lesser General Public License along with this program;
   28  * if not, see <http://www.gnu.org/licenses/>.
   29  */
   30 
   31 #ifndef CMS_H
   32 #define CMS_H 1
   33 
   34 #include "ksba.h"
   35 
   36 #ifndef HAVE_TYPEDEFD_ASNNODE
   37 typedef struct asn_node_struct *AsnNode;  /* FIXME: should not go here */
   38 #define HAVE_TYPEDEFD_ASNNODE
   39 #endif
   40 
   41 
   42 /* This structure is used to store the results of a BER parser run. */
   43 struct value_tree_s {
   44   struct value_tree_s *next;
   45   AsnNode root;  /* root of the tree with the values */
   46   unsigned char *image;
   47   size_t imagelen;
   48 };
   49 
   50 
   51 struct enc_val_s {
   52   char *algo;
   53   unsigned char *value; /* RSA's "a" or ECDH's "s". (malloced) */
   54   size_t valuelen;
   55   struct {
   56     unsigned char *e; /* Malloced buffer.      */
   57     size_t elen;      /* Length of E.          */
   58     char *encr_algo;  /* Malloced OID string.  */
   59     char *wrap_algo;  /* Malloced OID string.  */
   60   } ecdh;
   61 };
   62 
   63 
   64 struct oidlist_s {
   65   struct oidlist_s *next;
   66   char *oid;
   67 };
   68 
   69 /* A structure to store an OID and a parameter. */
   70 struct oidparmlist_s {
   71   struct oidparmlist_s *next;
   72   char *oid;
   73   size_t parmlen;
   74   unsigned char parm[1];
   75 };
   76 
   77 
   78 struct certlist_s {
   79   struct certlist_s *next;
   80   ksba_cert_t cert;
   81   int  msg_digest_len;  /* used length of .. */
   82   char msg_digest[64];  /* enough space to store a SHA-512 hash */
   83   ksba_isotime_t signing_time;
   84   struct {
   85     AsnNode root;
   86     unsigned char *image;
   87   } sa;
   88   struct enc_val_s enc_val; /* used for creating enveloped data */
   89 };
   90 
   91 
   92 struct signer_info_s {
   93   struct signer_info_s *next;
   94   AsnNode root;  /* root of the tree with the values */
   95   unsigned char *image;
   96   size_t imagelen;
   97   struct {
   98     char *digest_algo;
   99   } cache;
  100 };
  101 
  102 struct sig_val_s {
  103   struct sig_val_s *next;
  104   char *algo;
  105   unsigned char *value;  /* Malloced buffer for parameter "s". */
  106   size_t valuelen;       /* Used length of VALUE.  */
  107   struct {
  108     unsigned char *r;    /* Malloced buffer for parameter "r". */
  109     size_t rlen;         /* Length of R.                       */
  110   } ecc;
  111 };
  112 
  113 
  114 struct ksba_cms_s {
  115   gpg_error_t last_error;
  116 
  117   ksba_reader_t reader;
  118   ksba_writer_t writer;
  119 
  120   void (*hash_fnc)(void *, const void *, size_t);
  121   void *hash_fnc_arg;
  122 
  123   ksba_stop_reason_t stop_reason;
  124 
  125   struct {
  126     char *oid;
  127     unsigned long length;
  128     int ndef;
  129     ksba_content_type_t ct;
  130     gpg_error_t (*handler)(ksba_cms_t);
  131   } content;
  132 
  133   /* Data used with auth enveloped data. */
  134   struct {
  135     unsigned char *mac;    /* The MAC (authtag)  */
  136     int mac_len;
  137     unsigned char *attr;   /* DER encoded authAttr.  */
  138     int attr_len;
  139   } authdata;
  140 
  141   int cms_version;
  142 
  143   struct oidlist_s *digest_algos;
  144   struct certlist_s *cert_list;
  145   char *inner_cont_oid; /* Encapsulated or Encrypted
  146                            ContentInfo.contentType as string */
  147   unsigned long inner_cont_len;
  148   int inner_cont_ndef;
  149   int detached_data; /* no actual data */
  150   char *encr_algo_oid;
  151   char *encr_iv;
  152   size_t encr_ivlen;
  153 
  154   struct certlist_s *cert_info_list; /* A list with certificates intended
  155                                         to be send with a signed message */
  156 
  157   struct oidparmlist_s *capability_list; /* A list of S/MIME capabilities. */
  158 
  159   struct signer_info_s *signer_info;
  160 
  161   struct value_tree_s *recp_info;
  162 
  163   struct sig_val_s *sig_val;
  164 
  165   struct enc_val_s *enc_val;
  166 };
  167 
  168 
  169 /*-- cms.c --*/
  170 
  171 
  172 /*-- cms-parser.c --*/
  173 gpg_error_t _ksba_cms_parse_content_info (ksba_cms_t cms);
  174 gpg_error_t _ksba_cms_parse_signed_data_part_1 (ksba_cms_t cms);
  175 gpg_error_t _ksba_cms_parse_signed_data_part_2 (ksba_cms_t cms);
  176 gpg_error_t _ksba_cms_parse_enveloped_data_part_1 (ksba_cms_t cms);
  177 gpg_error_t _ksba_cms_parse_enveloped_data_part_2 (ksba_cms_t cms);
  178 
  179 
  180 
  181 #endif /*CMS_H*/