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 * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#ifndef _KEY_UTIL_H
2N/A#define _KEY_UTIL_H
2N/A
2N/A#include <stdio.h>
2N/A#include <sys/types.h>
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A/* Key algorithms */
2N/Atypedef enum {
2N/A WBKU_KEY_3DES,
2N/A WBKU_KEY_AES_128,
2N/A WBKU_KEY_HMAC_SHA1,
2N/A WBKU_KEY_RSA,
2N/A WBKU_KEY_UNKNOWN
2N/A} wbku_key_type_t;
2N/A
2N/A/* Algorithm keywords */
2N/A#define WBKU_KW_3DES "3des"
2N/A#define WBKU_KW_AES_128 "aes"
2N/A#define WBKU_KW_HMAC_SHA1 "sha1"
2N/A#define WBKU_KW_RSA "rsa"
2N/A
2N/A/* Algorithm types */
2N/A#define WBKU_ENCR_KEY (uint_t)0x1
2N/A#define WBKU_HASH_KEY (uint_t)0x2
2N/A#define WBKU_ANY_KEY (WBKU_ENCR_KEY | WBKU_HASH_KEY)
2N/A
2N/A/* Return codes */
2N/Atypedef enum {
2N/A WBKU_SUCCESS,
2N/A WBKU_INTERNAL_ERR,
2N/A WBKU_WRITE_ERR,
2N/A WBKU_NOKEY,
2N/A WBKU_BAD_KEYTYPE
2N/A} wbku_retcode_t;
2N/A
2N/A#define WBKU_NRET (WBKU_BAD_KEYTYPE + 1)
2N/A
2N/A/* The master key file location. */
2N/A#define MASTER_KEY_FILE "/etc/netboot/keystore"
2N/A
2N/A/* The root directory for all client keys */
2N/A#define CLIENT_KEY_DIR "/etc/netboot"
2N/A
2N/A/* The structure that defines the attributes of a particular key type */
2N/Atypedef struct key_attr {
2N/A wbku_key_type_t ka_type; /* key type */
2N/A uint_t ka_atype; /* key algorithm type */
2N/A uint_t ka_len; /* length of the current key */
2N/A uint_t ka_minlen; /* shortest allowable key value */
2N/A uint_t ka_maxlen; /* maximum allowable key length */
2N/A char *ka_str; /* key string identifier */
2N/A char *ka_oid; /* key algorithm oid */
2N/A boolean_t (*ka_keycheck)(const uint8_t *); /* keycheck function */
2N/A} wbku_key_attr_t;
2N/A
2N/Aextern void wbku_errinit(const char *);
2N/Aextern void wbku_printerr(const char *, ...);
2N/Aextern const char *wbku_retmsg(wbku_retcode_t);
2N/Aextern wbku_retcode_t wbku_str_to_keyattr(const char *, wbku_key_attr_t *,
2N/A uint_t);
2N/Aextern wbku_retcode_t wbku_find_key(FILE *, fpos_t *, wbku_key_attr_t *,
2N/A uint8_t *, boolean_t);
2N/Aextern wbku_retcode_t wbku_write_key(FILE *, const fpos_t *,
2N/A const wbku_key_attr_t *, uint8_t *, boolean_t);
2N/Aextern wbku_retcode_t wbku_delete_key(FILE *, FILE *, const wbku_key_attr_t *);
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _KEY_UTIL_H */