2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A#ifndef _KEYSTORE_H
2N/A#define _KEYSTORE_H
2N/A
2N/A
2N/A/*
2N/A * Module: keystore.h
2N/A * Description: This module contains the structure definitions for processing
2N/A * package keystore files.
2N/A */
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A#include <openssl/evp.h>
2N/A#include <openssl/x509.h>
2N/A#include "pkgerr.h"
2N/A
2N/A/* keystore structures */
2N/A
2N/A/* this opaque type represents a keystore */
2N/Atypedef void *keystore_handle_t;
2N/A
2N/A/* flags passed to open_keystore */
2N/A
2N/A/* opens keystore read-only. Attempts to modify results in an error */
2N/A#define KEYSTORE_ACCESS_READONLY 0x00000001L
2N/A
2N/A/* opens keystore read-write */
2N/A#define KEYSTORE_ACCESS_READWRITE 0x00000002L
2N/A
2N/A/*
2N/A * tells open_keystore to fall back to app-generic paths in the case that
2N/A * the app-specific paths do not exist.
2N/A */
2N/A#define KEYSTORE_PATH_SOFT 0x00000010L
2N/A
2N/A/*
2N/A * tells open_keystore to use the app-specific paths no matter what,
2N/A * failing if they cannot be used for any reason.
2N/A */
2N/A#define KEYSTORE_PATH_HARD 0x00000020L
2N/A
2N/A/* masks off various types of flags */
2N/A#define KEYSTORE_ACCESS_MASK 0x0000000FL
2N/A#define KEYSTORE_PATH_MASK 0x000000F0L
2N/A
2N/A/* default is read-only, soft */
2N/A#define KEYSTORE_DFLT_FLAGS \
2N/A (KEYSTORE_ACCESS_READONLY|KEYSTORE_PATH_SOFT)
2N/A
2N/A/*
2N/A * possible encoding formats used by the library, used
2N/A * by print_cert
2N/A */
2N/Atypedef enum {
2N/A KEYSTORE_FORMAT_PEM,
2N/A KEYSTORE_FORMAT_DER,
2N/A KEYSTORE_FORMAT_TEXT
2N/A} keystore_encoding_format_t;
2N/A
2N/A/*
2N/A * structure passed back to password callback for determining how
2N/A * to prompt for passphrase, and where to record errors
2N/A */
2N/Atypedef struct {
2N/A PKG_ERR *err;
2N/A} keystore_passphrase_data;
2N/A
2N/A
2N/A/* max length of a passphrase. One could use a short story! */
2N/A#define KEYSTORE_PASS_MAX 1024
2N/A
2N/A/* callback for collecting passphrase when open_keystore() is called */
2N/Atypedef int keystore_passphrase_cb(char *, int, int, void *);
2N/A
2N/A/* names of the individual files within the keystore path */
2N/A#define TRUSTSTORE "truststore"
2N/A#define KEYSTORE "keystore"
2N/A#define CERTSTORE "certstore"
2N/A
2N/A/* keystore.c */
2N/Aextern int open_keystore(PKG_ERR *, char *, char *,
2N/A keystore_passphrase_cb, long flags, keystore_handle_t *);
2N/A
2N/Aextern int print_certs(PKG_ERR *, keystore_handle_t, char *,
2N/A keystore_encoding_format_t, FILE *);
2N/A
2N/Aextern int check_cert(PKG_ERR *, X509 *);
2N/A
2N/Aextern int check_cert_and_key(PKG_ERR *, X509 *, EVP_PKEY *);
2N/A
2N/Aextern int print_cert(PKG_ERR *, X509 *,
2N/A keystore_encoding_format_t, char *, boolean_t, FILE *);
2N/A
2N/Aextern int close_keystore(PKG_ERR *, keystore_handle_t,
2N/A keystore_passphrase_cb);
2N/A
2N/Aextern int merge_ca_cert(PKG_ERR *, X509 *, keystore_handle_t);
2N/Aextern int merge_cert_and_key(PKG_ERR *, X509 *, EVP_PKEY *,
2N/A char *, keystore_handle_t);
2N/A
2N/Aextern int delete_cert_and_keys(PKG_ERR *, keystore_handle_t,
2N/A char *);
2N/A
2N/Aextern int find_key_cert_pair(PKG_ERR *, keystore_handle_t,
2N/A char *, EVP_PKEY **, X509 **);
2N/A
2N/Aextern int find_ca_certs(PKG_ERR *, keystore_handle_t,
2N/A STACK_OF(X509) **);
2N/A
2N/Aextern int find_cl_certs(PKG_ERR *, keystore_handle_t,
2N/A STACK_OF(X509) **);
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _KEYSTORE_H */