16f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo/*
26f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
36f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo *
46f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo * Redistribution and use in source and binary forms, with or without
56f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo * modification, are permitted provided that the following conditions are met:
66f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo *
76f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo * Redistributions of source code must retain the above copyright notice, this
86f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo * list of conditions and the following disclaimer.
96f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo *
106f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo * Redistributions in binary form must reproduce the above copyright notice,
116f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo * this list of conditions and the following disclaimer in the documentation
126f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo * and/or other materials provided with the distribution.
136f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo *
146f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo * Neither the name of ARM nor the names of its contributors may be used
156f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo * to endorse or promote products derived from this software without specific
166f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo * prior written permission.
176f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo *
186f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
196f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
206f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
216f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
226f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
236f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
246f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
256f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
266f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
276f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
286f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo * POSSIBILITY OF SUCH DAMAGE.
296f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo */
306f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo
316f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo#ifndef KEY_H_
326f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo#define KEY_H_
336f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo
346f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo#include <openssl/ossl_typ.h>
356f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo
366f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo#define RSA_KEY_BITS		2048
376f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo
386f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo/*
396f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo * This structure contains the relevant information to create the keys
406f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo * required to sign the certificates.
416f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo *
426f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo * One instance of this structure must be created for each key, usually in an
436f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo * array fashion. The filename is obtained at run time from the command line
446f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo * parameters
456f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo */
466f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillotypedef struct key_s {
476f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo	int id;			/* Key id */
486f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo	const char *desc;	/* Key description (debug purposes) */
496f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo	char *fn;		/* Filename to load/store the key */
506f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo	EVP_PKEY *key;		/* Key container */
516f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo} key_t;
526f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo
536f97162237603eb6e5c497e5ba903512bdd428a9Juan Castilloint key_new(key_t *key);
546f97162237603eb6e5c497e5ba903512bdd428a9Juan Castilloint key_load(key_t *key);
556f97162237603eb6e5c497e5ba903512bdd428a9Juan Castilloint key_store(key_t *key);
566f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo
576f97162237603eb6e5c497e5ba903512bdd428a9Juan Castillo#endif /* KEY_H_ */
58