store_locl.h 2.8 KB
Newer Older
R
Richard Levitte 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
/*
 * Copyright 2016-2017 The OpenSSL Project Authors. All Rights Reserved.
 *
 * Licensed under the OpenSSL license (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
 * in the file LICENSE in the source distribution or at
 * https://www.openssl.org/source/license.html
 */

#include "internal/thread_once.h"
#include <openssl/dsa.h>
#include <openssl/engine.h>
#include <openssl/evp.h>
#include <openssl/lhash.h>
#include <openssl/x509.h>
#include <openssl/store.h>

/*-
 *  OSSL_STORE_INFO stuff
 *  ---------------------
 */

struct ossl_store_info_st {
    int type;
    union {
26 27 28 29 30 31 32
        void *data;              /* used internally as generic pointer */

        struct {
            BUF_MEM *blob;
            char *pem_name;
        } embedded;              /* when type == OSSL_STORE_INFO_EMBEDDED */

R
Richard Levitte 已提交
33 34 35 36 37 38 39 40 41 42 43 44 45 46
        struct {
            char *name;
            char *desc;
        } name;                  /* when type == OSSL_STORE_INFO_NAME */

        EVP_PKEY *params;        /* when type == OSSL_STORE_INFO_PARAMS */
        EVP_PKEY *pkey;          /* when type == OSSL_STORE_INFO_PKEY */
        X509 *x509;              /* when type == OSSL_STORE_INFO_CERT */
        X509_CRL *crl;           /* when type == OSSL_STORE_INFO_CRL */
    } _;
};

DEFINE_STACK_OF(OSSL_STORE_INFO)

47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
/*
 * EMBEDDED is a special type of OSSL_STORE_INFO, specially for the file
 * handlers.  It should never reach a calling application or any engine.
 * However, it can be used by a FILE_HANDLER's try_decode function to signal
 * that it has decoded the incoming blob into a new blob, and that the
 * attempted decoding should be immediately restarted with the new blob, using
 * the new PEM name.
 */
/*
 * Because this is an internal type, we don't make it public.
 */
#define OSSL_STORE_INFO_EMBEDDED       -1
OSSL_STORE_INFO *ossl_store_info_new_EMBEDDED(const char *new_pem_name,
                                              BUF_MEM *embedded);
BUF_MEM *ossl_store_info_get0_EMBEDDED_buffer(OSSL_STORE_INFO *info);
char *ossl_store_info_get0_EMBEDDED_pem_name(OSSL_STORE_INFO *info);

R
Richard Levitte 已提交
64 65 66 67 68 69 70 71 72 73 74
/*-
 *  OSSL_STORE_LOADER stuff
 *  -----------------------
 */

int ossl_store_register_loader_int(OSSL_STORE_LOADER *loader);
OSSL_STORE_LOADER *ossl_store_unregister_loader_int(const char *scheme);

/* loader stuff */
struct ossl_store_loader_st {
    const char *scheme;
75
    ENGINE *engine;
R
Richard Levitte 已提交
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
    OSSL_STORE_open_fn open;
    OSSL_STORE_ctrl_fn ctrl;
    OSSL_STORE_load_fn load;
    OSSL_STORE_eof_fn eof;
    OSSL_STORE_error_fn error;
    OSSL_STORE_close_fn close;
};
DEFINE_LHASH_OF(OSSL_STORE_LOADER);

const OSSL_STORE_LOADER *ossl_store_get0_loader_int(const char *scheme);
void ossl_store_destroy_loaders_int(void);

/*-
 *  OSSL_STORE init stuff
 *  ---------------------
 */

int ossl_store_init_once(void);
94
int ossl_store_file_loader_init(void);