OPENSSL

apps/openssl.c
main()

  • apps_startup
  • prog = prog_init -> LHASH_OF(FUNCTION) * /* init f from function [] in prog.h */
  • pname = opt_progname
  • f.name = pname
  • fp = lh_FUNCTION_retrieve(prog, &f)
    /* first check the program name */
  • if (fp != NULL)
  • argv[0] = pname
  • ret = fp->func(argc, argv)
  • goto end;
    /* If there is stuff on the command line, run with that. */
  • if (argc != 1)
  • do_cmd(prog, argc, argv)
    /* ok, lets enter interactive mode */
  • for(;
    /* Read a line, continue reading if line ends with \ */
  • for(p = buf, n = sizeof(buf), i = 0, first = 1; n > 0; first = 0)
  •   chopup_args(&arg, buf) -> arg
    
  •   do_cmd(prog, arg.argc, arg.argv)
    

+end:

  • lh_FUNCTION_free(prog)

  • apps_shutdown

    const OPTIONS list_options[]
    list_main
    const OPTIONS help_options[]
    help_main

+++ EVP_get_digestbyname
f.type = FT_md;
f.func = dgst_main;
fp = &f;
+++ EVP_get_cipherbyname
f.type = FT_cipher;
f.func = enc_main;
fp = &f;
ssl/ssl_init.c
++ OPENSSL_init_ssl
crypto/init.c
+++ OPENSSL_init_crypto
+++ #define RUN_ONCE

conf_lib.c
CONF *NCONF_new
void CONF_free

typedef struct ASN1_ENCODING_st {
    unsigned char *enc;         /* DER encoding */
    long len;                   /* Length of encoding */
    int modified;               /* set to 1 if 'enc' is invalid */
} ASN1_ENCODING;

typedef struct ASN1_AUX_st {
    void *app_data;
    int  flags;
    int  ref_offset;          /* Offset of reference value */
    int  ref_lock;            /* Lock type to use */
    ASN1_aux_cb *asn1_cb; 
    int  enc_offset;          /* Offset of ASN1_ENCODING structure */
} ASN1_AUX;

/* 
 * This is the ASN1 template structure that defines a wrapper round the
 * actual type. It determines the actual position of the field in the value
 * structure, various flags such as OPTIONAL and the field name.
 */
struct ASN1_TEMPLATE_st {
  unsigned long flags;        /* Various flags */
  long tag;                   /* tag, not used if no tagging */
  unsigned long offset;       /* Offset of this field in structure */
  const char *field_name;     /* Field name */
  ASN1_ITEM_EXP *item;        /* Relevant ASN1_ITEM or ASN1_ADB */
};

struct ASN1_ITEM_st {
  char type;                          /* The item type, primitive, SEQUENCE, CHOICE
                                       * or extern */
  long utype;                         /* underlying type */
  const ASN1_TEMPLATE *template;      /* If SEQUENCE or CHOICE this contains
                                       * the contents */
  long count;                         /* Number of templates if SEQUENCE or CHOICE */
  const void *funcs;                  /* functions that handle this type */
  long size;                          /* Structure size (usually) */
  const char *sname;                  /* Structure name */
};

OPENSSL Wiki
Compilation_and_Installation
How_to_Integrate_a_Symmetric_Cipher
How_To_Write_Unit_Tests_For_OpenSSL
OpenSSL Command-Line HOWTO
Command Line Utilities
Stack API
CSDN文章
openssl源码之ASN1从找不到X509_new的定义说起
asn1编码格式的解析过程
openssl 代码分析(4) ASN1_item_ex_d2i
OPENSSL
ASN1_AUX
ASN1_ITEM

原文地址:https://www.cnblogs.com/anyboo/p/15728449.html