/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef PKCS11_H
#define PKCS11_H

#define NULL_OP		0x00
#define ENCRYPT_OP	0x01
#define SIGN_OP		0x02
#define KEYGEN_OP	0x04
#define DIGEST_OP	0x08
#define HMAC_OP		0x10

typedef struct {
	CK_MECHANISM_TYPE	type;
	int			op;
	CK_MECHANISM_TYPE	keygenMech;
} MechInfo;

static int numMechs=118;
static MechInfo mechInfo[] = {
	{CKM_RSA_PKCS_KEY_PAIR_GEN,
				KEYGEN_OP,	CKM_RSA_PKCS_KEY_PAIR_GEN},
	{CKM_RSA_PKCS,		ENCRYPT_OP | SIGN_OP,
						CKM_RSA_PKCS_KEY_PAIR_GEN},
	{CKM_RSA_9796,		SIGN_OP,	CKM_RSA_PKCS_KEY_PAIR_GEN},
	{CKM_RSA_X_509,		ENCRYPT_OP | SIGN_OP,
						CKM_RSA_PKCS_KEY_PAIR_GEN},
	{CKM_MD2_RSA_PKCS,	SIGN_OP,	CKM_RSA_PKCS_KEY_PAIR_GEN},
	{CKM_MD5_RSA_PKCS,	SIGN_OP,	CKM_RSA_PKCS_KEY_PAIR_GEN},
	{CKM_SHA1_RSA_PKCS,	SIGN_OP,	CKM_RSA_PKCS_KEY_PAIR_GEN},
	{CKM_DSA_KEY_PAIR_GEN,	KEYGEN_OP,	CKM_DSA_KEY_PAIR_GEN},
	{CKM_DSA,		SIGN_OP,	CKM_DSA_KEY_PAIR_GEN},
	{CKM_DSA_SHA1,		SIGN_OP,	CKM_DSA_KEY_PAIR_GEN},
	{CKM_DH_PKCS_KEY_PAIR_GEN,
				KEYGEN_OP,	CKM_DH_PKCS_KEY_PAIR_GEN},
	{CKM_DH_PKCS_DERIVE,	NULL_OP,	0},
	{CKM_RC2_KEY_GEN,	KEYGEN_OP,	CKM_RC2_KEY_GEN},
	{CKM_RC2_ECB,		ENCRYPT_OP,	CKM_RC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