Blame lib/dns-pkcs11/dst_parse.h

Packit e9919e
/*
Packit e9919e
 * Portions Copyright (C) Internet Systems Consortium, Inc. ("ISC")
Packit e9919e
 *
Packit e9919e
 * This Source Code Form is subject to the terms of the Mozilla Public
Packit e9919e
 * License, v. 2.0. If a copy of the MPL was not distributed with this
Packit e9919e
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
Packit e9919e
 *
Packit e9919e
 * See the COPYRIGHT file distributed with this work for additional
Packit e9919e
 * information regarding copyright ownership.
Packit e9919e
 *
Packit e9919e
 * Portions Copyright (C) Network Associates, Inc.
Packit e9919e
 *
Packit e9919e
 * Permission to use, copy, modify, and/or distribute this software for any
Packit e9919e
 * purpose with or without fee is hereby granted, provided that the above
Packit e9919e
 * copyright notice and this permission notice appear in all copies.
Packit e9919e
 *
Packit e9919e
 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND NETWORK ASSOCIATES DISCLAIMS
Packit e9919e
 * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
Packit e9919e
 * WARRANTIES OF MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE
Packit e9919e
 * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
Packit e9919e
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
Packit e9919e
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
Packit e9919e
 * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Packit e9919e
 */
Packit e9919e
Packit e9919e
Packit e9919e
/*! \file */
Packit e9919e
#ifndef DST_DST_PARSE_H
Packit e9919e
#define DST_DST_PARSE_H 1
Packit e9919e
Packit e9919e
#include <isc/lang.h>
Packit e9919e
Packit e9919e
#include <dst/dst.h>
Packit e9919e
Packit e9919e
#define MAXFIELDSIZE		512
Packit e9919e
Packit e9919e
/*
Packit e9919e
 * Maximum number of fields in a private file is 18 (12 algorithm-
Packit e9919e
 * specific fields for RSA, plus 6 generic fields).
Packit e9919e
 */
Packit e9919e
#define MAXFIELDS		12+6
Packit e9919e
Packit e9919e
#define TAG_SHIFT		4
Packit e9919e
#define TAG_ALG(tag)		((unsigned int)(tag) >> TAG_SHIFT)
Packit e9919e
#define TAG(alg, off)		(((alg) << TAG_SHIFT) + (off))
Packit e9919e
Packit e9919e
/* These are used by both RSA-MD5 and RSA-SHA1 */
Packit e9919e
#define RSA_NTAGS		11
Packit e9919e
#define TAG_RSA_MODULUS		((DST_ALG_RSAMD5 << TAG_SHIFT) + 0)
Packit e9919e
#define TAG_RSA_PUBLICEXPONENT	((DST_ALG_RSAMD5 << TAG_SHIFT) + 1)
Packit e9919e
#define TAG_RSA_PRIVATEEXPONENT	((DST_ALG_RSAMD5 << TAG_SHIFT) + 2)
Packit e9919e
#define TAG_RSA_PRIME1		((DST_ALG_RSAMD5 << TAG_SHIFT) + 3)
Packit e9919e
#define TAG_RSA_PRIME2		((DST_ALG_RSAMD5 << TAG_SHIFT) + 4)
Packit e9919e
#define TAG_RSA_EXPONENT1	((DST_ALG_RSAMD5 << TAG_SHIFT) + 5)
Packit e9919e
#define TAG_RSA_EXPONENT2	((DST_ALG_RSAMD5 << TAG_SHIFT) + 6)
Packit e9919e
#define TAG_RSA_COEFFICIENT	((DST_ALG_RSAMD5 << TAG_SHIFT) + 7)
Packit e9919e
#define TAG_RSA_ENGINE		((DST_ALG_RSAMD5 << TAG_SHIFT) + 8)
Packit e9919e
#define TAG_RSA_LABEL		((DST_ALG_RSAMD5 << TAG_SHIFT) + 9)
Packit e9919e
Packit e9919e
#define DH_NTAGS		4
Packit e9919e
#define TAG_DH_PRIME		((DST_ALG_DH << TAG_SHIFT) + 0)
Packit e9919e
#define TAG_DH_GENERATOR	((DST_ALG_DH << TAG_SHIFT) + 1)
Packit e9919e
#define TAG_DH_PRIVATE		((DST_ALG_DH << TAG_SHIFT) + 2)
Packit e9919e
#define TAG_DH_PUBLIC		((DST_ALG_DH << TAG_SHIFT) + 3)
Packit e9919e
Packit e9919e
#define DSA_NTAGS		5
Packit e9919e
#define TAG_DSA_PRIME		((DST_ALG_DSA << TAG_SHIFT) + 0)
Packit e9919e
#define TAG_DSA_SUBPRIME	((DST_ALG_DSA << TAG_SHIFT) + 1)
Packit e9919e
#define TAG_DSA_BASE		((DST_ALG_DSA << TAG_SHIFT) + 2)
Packit e9919e
#define TAG_DSA_PRIVATE		((DST_ALG_DSA << TAG_SHIFT) + 3)
Packit e9919e
#define TAG_DSA_PUBLIC		((DST_ALG_DSA << TAG_SHIFT) + 4)
Packit e9919e
Packit e9919e
#define GOST_NTAGS		1
Packit e9919e
#define TAG_GOST_PRIVASN1	((DST_ALG_ECCGOST << TAG_SHIFT) + 0)
Packit e9919e
#define TAG_GOST_PRIVRAW	((DST_ALG_ECCGOST << TAG_SHIFT) + 1)
Packit e9919e
Packit e9919e
#define ECDSA_NTAGS		4
Packit e9919e
#define TAG_ECDSA_PRIVATEKEY	((DST_ALG_ECDSA256 << TAG_SHIFT) + 0)
Packit e9919e
#define TAG_ECDSA_ENGINE	((DST_ALG_ECDSA256 << TAG_SHIFT) + 1)
Packit e9919e
#define TAG_ECDSA_LABEL		((DST_ALG_ECDSA256 << TAG_SHIFT) + 2)
Packit e9919e
Packit e9919e
#define EDDSA_NTAGS		4
Packit e9919e
#define TAG_EDDSA_PRIVATEKEY	((DST_ALG_ED25519 << TAG_SHIFT) + 0)
Packit e9919e
#define TAG_EDDSA_ENGINE	((DST_ALG_ED25519 << TAG_SHIFT) + 1)
Packit e9919e
#define TAG_EDDSA_LABEL		((DST_ALG_ED25519 << TAG_SHIFT) + 2)
Packit e9919e
Packit e9919e
#define OLD_HMACMD5_NTAGS	1
Packit e9919e
#define HMACMD5_NTAGS		2
Packit e9919e
#define TAG_HMACMD5_KEY		((DST_ALG_HMACMD5 << TAG_SHIFT) + 0)
Packit e9919e
#define TAG_HMACMD5_BITS	((DST_ALG_HMACMD5 << TAG_SHIFT) + 1)
Packit e9919e
Packit e9919e
#define HMACSHA1_NTAGS		2
Packit e9919e
#define TAG_HMACSHA1_KEY	((DST_ALG_HMACSHA1 << TAG_SHIFT) + 0)
Packit e9919e
#define TAG_HMACSHA1_BITS	((DST_ALG_HMACSHA1 << TAG_SHIFT) + 1)
Packit e9919e
Packit e9919e
#define HMACSHA224_NTAGS	2
Packit e9919e
#define TAG_HMACSHA224_KEY	((DST_ALG_HMACSHA224 << TAG_SHIFT) + 0)
Packit e9919e
#define TAG_HMACSHA224_BITS	((DST_ALG_HMACSHA224 << TAG_SHIFT) + 1)
Packit e9919e
Packit e9919e
#define HMACSHA256_NTAGS	2
Packit e9919e
#define TAG_HMACSHA256_KEY	((DST_ALG_HMACSHA256 << TAG_SHIFT) + 0)
Packit e9919e
#define TAG_HMACSHA256_BITS	((DST_ALG_HMACSHA256 << TAG_SHIFT) + 1)
Packit e9919e
Packit e9919e
#define HMACSHA384_NTAGS	2
Packit e9919e
#define TAG_HMACSHA384_KEY	((DST_ALG_HMACSHA384 << TAG_SHIFT) + 0)
Packit e9919e
#define TAG_HMACSHA384_BITS	((DST_ALG_HMACSHA384 << TAG_SHIFT) + 1)
Packit e9919e
Packit e9919e
#define HMACSHA512_NTAGS	2
Packit e9919e
#define TAG_HMACSHA512_KEY	((DST_ALG_HMACSHA512 << TAG_SHIFT) + 0)
Packit e9919e
#define TAG_HMACSHA512_BITS	((DST_ALG_HMACSHA512 << TAG_SHIFT) + 1)
Packit e9919e
Packit e9919e
struct dst_private_element {
Packit e9919e
	unsigned short tag;
Packit e9919e
	unsigned short length;
Packit e9919e
	unsigned char *data;
Packit e9919e
};
Packit e9919e
Packit e9919e
typedef struct dst_private_element dst_private_element_t;
Packit e9919e
Packit e9919e
struct dst_private {
Packit e9919e
	unsigned short nelements;
Packit e9919e
	dst_private_element_t elements[MAXFIELDS];
Packit e9919e
};
Packit e9919e
Packit e9919e
typedef struct dst_private dst_private_t;
Packit e9919e
Packit e9919e
ISC_LANG_BEGINDECLS
Packit e9919e
Packit e9919e
void
Packit e9919e
dst__privstruct_free(dst_private_t *priv, isc_mem_t *mctx);
Packit e9919e
Packit e9919e
isc_result_t
Packit e9919e
dst__privstruct_parse(dst_key_t *key, unsigned int alg, isc_lex_t *lex,
Packit e9919e
		      isc_mem_t *mctx, dst_private_t *priv);
Packit e9919e
Packit e9919e
isc_result_t
Packit e9919e
dst__privstruct_writefile(const dst_key_t *key, const dst_private_t *priv,
Packit e9919e
			  const char *directory);
Packit e9919e
Packit e9919e
ISC_LANG_ENDDECLS
Packit e9919e
Packit e9919e
#endif /* DST_DST_PARSE_H */