blob: 16aac43496261b801d66a398ab9ae7e5c72b7005 [file] [log] [blame]
Paul Bakkered27a042013-04-18 22:46:23 +02001/**
2 * \file pk.h
3 *
4 * \brief Public Key abstraction layer
5 *
6 * Copyright (C) 2006-2013, Brainspark B.V.
7 *
8 * This file is part of PolarSSL (http://www.polarssl.org)
9 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
10 *
11 * All rights reserved.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 */
27#ifndef POLARSSL_PK_H
28#define POLARSSL_PK_H
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34/**
35 * \brief Public key types
36 */
37typedef enum {
38 POLARSSL_PK_NONE=0,
39 POLARSSL_PK_RSA,
Manuel Pégourié-Gonnard5a9b82e2013-07-01 16:57:44 +020040 POLARSSL_PK_ECKEY,
41 POLARSSL_PK_ECKEY_DH,
Paul Bakkered27a042013-04-18 22:46:23 +020042} pk_type_t;
43
Manuel Pégourié-Gonnard12e0ed92013-07-04 13:31:32 +020044/**
45 * \brief Public key container
46 */
47typedef struct
48{
49 pk_type_t type; /**< Public key type */
50 void * data; /**< Public key data */
51} pk_context;
52
53/**
54 * \brief Initialize a pk_context (as NONE)
55 */
56void pk_init( pk_context *ctx );
57
58/**
59 * \brief Free a pk_context
60 */
61void pk_free( pk_context *ctx );
62
63/**
64 * \brief Set a pk_context to a given type
65 *
66 * \param ctx Context to initialize
67 * \param type Type of key
68 *
69 * \return O on success, -1 on memory allocation error
70 * TODO: use appropriate error constant
71 */
72int pk_set_type( pk_context *ctx, pk_type_t type );
73
Paul Bakkered27a042013-04-18 22:46:23 +020074#ifdef __cplusplus
75}
76#endif
77
78#endif /* pk.h */