usr/src/lib/openssl/Patches/pkcs11-engine/hw_pk11.h
author Cyril Plisko <cyril.plisko@grigale.com>
Mon, 08 Feb 2010 15:41:40 +0200
changeset 7 f96733ecc878
parent 3 ad3552f8e1ef
child 78 f18fd066fbf3
permissions -rw-r--r--
Import sfw build 133 Bugs Fixed ---------- 6462216 tomcat fails to build with java 1.6 6766826 SUNWopenldapr becomes inconsistent after a reboot 6900262 OpenSSL PKCS#11 engine files are not cstyle clean again 6902029 DoS vulnerability in ntpd NTP mode 7 (MODE_PRIVATE) handling [CVE-2009-3563] 6908571 77.5% snv_129 openssl-rsa1024-ncp_engine-verifys performance regression sparc 6909632 PKCS#11 engine should use CK_(TRUE|FALSE) instead of TRUE/FALSE 6910922 Apache 1.3 JServ module removal 6912691 don't need to reference /usr/openwin so much anymore 6912906 Apache 1.3 init.d script shouldn't refer to Tomcat 6913689 Several sfw packages no longer need to depend on SUNWmlib and SUNWmlibl 6917046 upgrade ncftp to 3.2.3 6918442 when /usr/bin/patch becomes gnu patch in opensolaris 131, it upsets a few things 6919344 SUNWgnu-readline consumers have undefined tgetent symbol 6919686 Tomcat vulnerable for CVE-2009-2901, CVE-2009-2902 and CVE-2009-2693 6920566 SUNWgnupg license is incorrect for gpgme 6920613 Apache Tomcat 6.0.24 stable 6920817 Wireshark update to version 1.2.6 6920889 make OpenSSL fips and non-fips builds run in parallel 6921161 SUNWusbccid should have gone away with SUNWocf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
     1
/*
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
     2
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
     3
 * Use is subject to license terms.
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
     4
 */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
     5
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
     6
#pragma ident	"@(#)hw_pk11.h	1.1	09/11/10 SMI"
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
     7
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
     8
/* crypto/engine/hw_pk11.h */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
     9
/*
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    10
 * This product includes software developed by the OpenSSL Project for
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    11
 * use in the OpenSSL Toolkit (http://www.openssl.org/).
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    12
 *
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    13
 * This project also referenced hw_pkcs11-0.9.7b.patch written by
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    14
 * Afchine Madjlessi.
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    15
 */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    16
/*
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    17
 * ====================================================================
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    18
 * Copyright (c) 2000-2001 The OpenSSL Project.  All rights reserved.
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    19
 *
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    20
 * Redistribution and use in source and binary forms, with or without
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    21
 * modification, are permitted provided that the following conditions
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    22
 * are met:
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    23
 *
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    24
 * 1. Redistributions of source code must retain the above copyright
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    25
 *    notice, this list of conditions and the following disclaimer.
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    26
 *
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    27
 * 2. Redistributions in binary form must reproduce the above copyright
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    28
 *    notice, this list of conditions and the following disclaimer in
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    29
 *    the documentation and/or other materials provided with the
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    30
 *    distribution.
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    31
 *
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    32
 * 3. All advertising materials mentioning features or use of this
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    33
 *    software must display the following acknowledgment:
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    34
 *    "This product includes software developed by the OpenSSL Project
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    35
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    36
 *
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    37
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    38
 *    endorse or promote products derived from this software without
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    39
 *    prior written permission. For written permission, please contact
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    40
 *    [email protected].
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    41
 *
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    42
 * 5. Products derived from this software may not be called "OpenSSL"
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    43
 *    nor may "OpenSSL" appear in their names without prior written
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    44
 *    permission of the OpenSSL Project.
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    45
 *
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    46
 * 6. Redistributions of any form whatsoever must retain the following
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    47
 *    acknowledgment:
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    48
 *    "This product includes software developed by the OpenSSL Project
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    49
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    50
 *
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    51
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    52
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    53
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    54
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    55
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    56
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    57
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    58
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    59
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    60
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    61
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    62
 * OF THE POSSIBILITY OF SUCH DAMAGE.
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    63
 * ====================================================================
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    64
 *
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    65
 * This product includes cryptographic software written by Eric Young
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    66
 * ([email protected]).  This product includes software written by Tim
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    67
 * Hudson ([email protected]).
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    68
 *
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    69
 */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    70
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    71
#ifndef	HW_PK11_H
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    72
#define	HW_PK11_H
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    73
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    74
#include "hw_pk11_err.h"
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    75
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    76
/* max byte length of a symetric key we support */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    77
#define	PK11_KEY_LEN_MAX			32
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    78
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    79
/*
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    80
 * This structure encapsulates all reusable information for a PKCS#11
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    81
 * session. A list of these objects is created on behalf of the
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    82
 * calling application using an on-demand method. Each operation
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    83
 * type (see PK11_OPTYPE below) has its own per-process list.
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    84
 * Each of the lists is basically a cache for faster PKCS#11 object
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    85
 * access to avoid expensive C_Find{,Init,Final}Object() calls.
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    86
 *
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    87
 * When a new request comes in, an object will be taken from the list
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    88
 * (if there is one) or a new one is created to handle the request
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    89
 * (if the list is empty). See pk11_get_session() on how it is done.
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    90
 */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    91
typedef struct PK11_st_SESSION
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    92
	{
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    93
	struct PK11_st_SESSION	*next;
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    94
	CK_SESSION_HANDLE	session;	/* PK11 session handle */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    95
	pid_t			pid;		/* Current process ID */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    96
	CK_BBOOL		persistent;	/* is that a keystore object? */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    97
	union
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    98
		{
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
    99
#ifndef OPENSSL_NO_RSA
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   100
		struct
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   101
			{
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   102
			CK_OBJECT_HANDLE	rsa_pub_key; /* pub handle */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   103
			CK_OBJECT_HANDLE	rsa_priv_key; /* priv handle */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   104
			RSA			*rsa_pub; /* pub key addr */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   105
			BIGNUM			*rsa_n_num; /* pub modulus */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   106
			BIGNUM			*rsa_e_num; /* pub exponent */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   107
			RSA			*rsa_priv; /* priv key addr */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   108
			BIGNUM			*rsa_d_num; /* priv exponent */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   109
			} u_RSA;
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   110
#endif /* OPENSSL_NO_RSA */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   111
#ifndef OPENSSL_NO_DSA
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   112
		struct
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   113
			{
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   114
			CK_OBJECT_HANDLE	dsa_pub_key; /* pub handle */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   115
			CK_OBJECT_HANDLE	dsa_priv_key; /* priv handle */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   116
			DSA			*dsa_pub; /* pub key addr */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   117
			BIGNUM			*dsa_pub_num; /* pub key */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   118
			DSA			*dsa_priv; /* priv key addr */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   119
			BIGNUM			*dsa_priv_num; /* priv key */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   120
			} u_DSA;
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   121
#endif /* OPENSSL_NO_DSA */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   122
#ifndef OPENSSL_NO_DH
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   123
		struct
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   124
			{
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   125
			CK_OBJECT_HANDLE	dh_key; /* key handle */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   126
			DH			*dh; /* dh key addr */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   127
			BIGNUM			*dh_priv_num; /* priv dh key */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   128
			} u_DH;
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   129
#endif /* OPENSSL_NO_DH */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   130
		struct
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   131
			{
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   132
			CK_OBJECT_HANDLE	cipher_key; /* key handle */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   133
			unsigned char		key[PK11_KEY_LEN_MAX];
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   134
			int			key_len; /* priv key len */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   135
			int			encrypt; /* 1/0 enc/decr */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   136
			} u_cipher;
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   137
		} opdata_u;
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   138
	} PK11_SESSION;
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   139
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   140
#define	opdata_rsa_pub_key	opdata_u.u_RSA.rsa_pub_key
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   141
#define	opdata_rsa_priv_key	opdata_u.u_RSA.rsa_priv_key
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   142
#define	opdata_rsa_pub		opdata_u.u_RSA.rsa_pub
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   143
#define	opdata_rsa_priv		opdata_u.u_RSA.rsa_priv
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   144
#define	opdata_rsa_n_num	opdata_u.u_RSA.rsa_n_num
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   145
#define	opdata_rsa_e_num	opdata_u.u_RSA.rsa_e_num
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   146
#define	opdata_rsa_d_num	opdata_u.u_RSA.rsa_d_num
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   147
#define	opdata_dsa_pub_key	opdata_u.u_DSA.dsa_pub_key
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   148
#define	opdata_dsa_priv_key	opdata_u.u_DSA.dsa_priv_key
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   149
#define	opdata_dsa_pub		opdata_u.u_DSA.dsa_pub
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   150
#define	opdata_dsa_pub_num	opdata_u.u_DSA.dsa_pub_num
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   151
#define	opdata_dsa_priv		opdata_u.u_DSA.dsa_priv
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   152
#define	opdata_dsa_priv_num	opdata_u.u_DSA.dsa_priv_num
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   153
#define	opdata_dh_key		opdata_u.u_DH.dh_key
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   154
#define	opdata_dh		opdata_u.u_DH.dh
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   155
#define	opdata_dh_priv_num	opdata_u.u_DH.dh_priv_num
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   156
#define	opdata_cipher_key	opdata_u.u_cipher.cipher_key
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   157
#define	opdata_key		opdata_u.u_cipher.key
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   158
#define	opdata_key_len		opdata_u.u_cipher.key_len
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   159
#define	opdata_encrypt		opdata_u.u_cipher.encrypt
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   160
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   161
/*
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   162
 * We have 3 different groups of operation types:
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   163
 *   1) asymmetric operations
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   164
 *   2) random operations
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   165
 *   3) symmetric and digest operations
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   166
 *
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   167
 * This division into groups stems from the fact that it's common that hardware
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   168
 * providers may support operations from one group only. For example, hardware
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   169
 * providers on UltraSPARC T2, n2rng(7d), ncp(7d), and n2cp(7d), each support
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   170
 * only a single group of operations.
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   171
 *
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   172
 * For every group a different slot can be chosen. That means that we must have
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   173
 * at least 3 different lists of cached PKCS#11 sessions since sessions from
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   174
 * different groups may be initialized in different slots.
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   175
 *
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   176
 * To provide locking granularity in multithreaded environment, the groups are
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   177
 * further splitted into types with each type having a separate session cache.
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   178
 */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   179
typedef enum PK11_OPTYPE_ENUM
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   180
	{
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   181
	OP_RAND,
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   182
	OP_RSA,
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   183
	OP_DSA,
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   184
	OP_DH,
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   185
	OP_CIPHER,
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   186
	OP_DIGEST,
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   187
	OP_MAX
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   188
	} PK11_OPTYPE;
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   189
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   190
/*
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   191
 * This structure contains the heads of the lists forming the object caches
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   192
 * and locks associated with the lists.
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   193
 */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   194
typedef struct PK11_st_CACHE
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   195
	{
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   196
	PK11_SESSION *head;
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   197
	pthread_mutex_t *lock;
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   198
	} PK11_CACHE;
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   199
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   200
/* structure for tracking handles of asymmetric key objects */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   201
typedef struct PK11_active_st
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   202
	{
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   203
	CK_OBJECT_HANDLE h;
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   204
	unsigned int refcnt;
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   205
	struct PK11_active_st *prev;
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   206
	struct PK11_active_st *next;
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   207
	} PK11_active;
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   208
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   209
extern pthread_mutex_t *find_lock[];
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   210
extern PK11_active *active_list[];
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   211
/*
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   212
 * These variables are specific for the RSA keys by reference code. See
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   213
 * hw_pk11_pub.c for explanation.
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   214
 */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   215
extern char *passphrasedialog;
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   216
extern CK_FLAGS pubkey_token_flags;
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   217
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   218
#define	LOCK_OBJSTORE(alg_type)	\
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   219
	(void) pthread_mutex_lock(find_lock[alg_type])
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   220
#define	UNLOCK_OBJSTORE(alg_type)	\
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   221
	(void) pthread_mutex_unlock(find_lock[alg_type])
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   222
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   223
extern PK11_SESSION *pk11_get_session(PK11_OPTYPE optype);
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   224
extern void pk11_return_session(PK11_SESSION *sp, PK11_OPTYPE optype);
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   225
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   226
#ifndef OPENSSL_NO_RSA
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   227
extern int pk11_destroy_rsa_key_objects(PK11_SESSION *session);
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   228
extern int pk11_destroy_rsa_object_pub(PK11_SESSION *sp, CK_BBOOL uselock);
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   229
extern int pk11_destroy_rsa_object_priv(PK11_SESSION *sp, CK_BBOOL uselock);
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   230
extern EVP_PKEY *pk11_load_privkey(ENGINE *e, const char *pubkey_file,
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   231
	UI_METHOD *ui_method, void *callback_data);
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   232
extern EVP_PKEY *pk11_load_pubkey(ENGINE *e, const char *pubkey_file,
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   233
	UI_METHOD *ui_method, void *callback_data);
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   234
extern RSA_METHOD *PK11_RSA(void);
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   235
#endif /* OPENSSL_NO_RSA */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   236
#ifndef OPENSSL_NO_DSA
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   237
extern int pk11_destroy_dsa_key_objects(PK11_SESSION *session);
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   238
extern int pk11_destroy_dsa_object_pub(PK11_SESSION *sp, CK_BBOOL uselock);
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   239
extern int pk11_destroy_dsa_object_priv(PK11_SESSION *sp, CK_BBOOL uselock);
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   240
extern DSA_METHOD *PK11_DSA(void);
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   241
#endif /* OPENSSL_NO_DSA */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   242
#ifndef OPENSSL_NO_DH
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   243
extern int pk11_destroy_dh_key_objects(PK11_SESSION *session);
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   244
extern int pk11_destroy_dh_object(PK11_SESSION *sp, CK_BBOOL uselock);
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   245
extern DH_METHOD *PK11_DH(void);
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   246
#endif /* OPENSSL_NO_DH */
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   247
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   248
extern CK_FUNCTION_LIST_PTR pFuncList;
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   249
ad3552f8e1ef Import sfw build 129
Cyril Plisko <cyril.plisko@grigale.com>
parents:
diff changeset
   250
#endif /* HW_PK11_H */