Paul Bakker | ed27a04 | 2013-04-18 22:46:23 +0200 | [diff] [blame] | 1 | /** |
| 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 | */ |
Manuel Pégourié-Gonnard | d73b3c1 | 2013-08-12 17:06:05 +0200 | [diff] [blame] | 27 | |
Paul Bakker | ed27a04 | 2013-04-18 22:46:23 +0200 | [diff] [blame] | 28 | #ifndef POLARSSL_PK_H |
| 29 | #define POLARSSL_PK_H |
| 30 | |
Manuel Pégourié-Gonnard | 244569f | 2013-07-10 09:46:30 +0200 | [diff] [blame] | 31 | #include "config.h" |
| 32 | |
Manuel Pégourié-Gonnard | f73da02 | 2013-08-17 14:36:32 +0200 | [diff] [blame] | 33 | #include "md.h" |
| 34 | |
Manuel Pégourié-Gonnard | 244569f | 2013-07-10 09:46:30 +0200 | [diff] [blame] | 35 | #if defined(POLARSSL_RSA_C) |
| 36 | #include "rsa.h" |
| 37 | #endif |
| 38 | |
Manuel Pégourié-Gonnard | d73b3c1 | 2013-08-12 17:06:05 +0200 | [diff] [blame] | 39 | #if defined(POLARSSL_ECP_C) |
| 40 | #include "ecp.h" |
| 41 | #endif |
| 42 | |
Manuel Pégourié-Gonnard | 211a64c | 2013-08-09 15:04:26 +0200 | [diff] [blame] | 43 | #if defined(POLARSSL_ECDSA_C) |
| 44 | #include "ecdsa.h" |
| 45 | #endif |
| 46 | |
Manuel Pégourié-Gonnard | 7a6c946 | 2013-07-09 10:04:07 +0200 | [diff] [blame] | 47 | #define POLARSSL_ERR_PK_MALLOC_FAILED -0x2F80 /**< Memory alloation failed. */ |
Manuel Pégourié-Gonnard | fff80f8 | 2013-08-17 15:20:06 +0200 | [diff] [blame] | 48 | #define POLARSSL_ERR_PK_TYPE_MISMATCH -0x2F00 /**< Type mismatch, eg attempt to encrypt with an ECDSA key */ |
Manuel Pégourié-Gonnard | 1569938 | 2013-08-14 19:22:48 +0200 | [diff] [blame] | 49 | #define POLARSSL_ERR_PK_BAD_INPUT_DATA -0x2E80 /**< Bad input parameters to function. */ |
Manuel Pégourié-Gonnard | 7a6c946 | 2013-07-09 10:04:07 +0200 | [diff] [blame] | 50 | |
Manuel Pégourié-Gonnard | 360a583 | 2013-07-10 14:56:36 +0200 | [diff] [blame] | 51 | #if defined(POLARSSL_RSA_C) |
| 52 | /** |
| 53 | * Quick access to an RSA context inside a PK context. |
| 54 | * |
| 55 | * \warning You must make sure the PK context actually holds an RSA context |
| 56 | * before using this macro! |
| 57 | */ |
Manuel Pégourié-Gonnard | 3fb5c5e | 2013-08-14 18:26:41 +0200 | [diff] [blame] | 58 | #define pk_rsa( pk ) ( (rsa_context *) (pk).pk_ctx ) |
Manuel Pégourié-Gonnard | fd5164e | 2013-07-11 16:39:05 +0200 | [diff] [blame] | 59 | #endif /* POLARSSL_RSA_C */ |
Manuel Pégourié-Gonnard | 360a583 | 2013-07-10 14:56:36 +0200 | [diff] [blame] | 60 | |
| 61 | #if defined(POLARSSL_ECP_C) |
| 62 | /** |
| 63 | * Quick access to an EC context inside a PK context. |
| 64 | * |
| 65 | * \warning You must make sure the PK context actually holds an EC context |
| 66 | * before using this macro! |
| 67 | */ |
Manuel Pégourié-Gonnard | 3fb5c5e | 2013-08-14 18:26:41 +0200 | [diff] [blame] | 68 | #define pk_ec( pk ) ( (ecp_keypair *) (pk).pk_ctx ) |
Manuel Pégourié-Gonnard | fd5164e | 2013-07-11 16:39:05 +0200 | [diff] [blame] | 69 | #endif /* POLARSSL_ECP_C */ |
Manuel Pégourié-Gonnard | 360a583 | 2013-07-10 14:56:36 +0200 | [diff] [blame] | 70 | |
| 71 | |
Paul Bakker | ed27a04 | 2013-04-18 22:46:23 +0200 | [diff] [blame] | 72 | #ifdef __cplusplus |
| 73 | extern "C" { |
| 74 | #endif |
| 75 | |
| 76 | /** |
| 77 | * \brief Public key types |
| 78 | */ |
| 79 | typedef enum { |
| 80 | POLARSSL_PK_NONE=0, |
| 81 | POLARSSL_PK_RSA, |
Manuel Pégourié-Gonnard | 5a9b82e | 2013-07-01 16:57:44 +0200 | [diff] [blame] | 82 | POLARSSL_PK_ECKEY, |
| 83 | POLARSSL_PK_ECKEY_DH, |
Manuel Pégourié-Gonnard | 1e60cd0 | 2013-07-10 10:28:53 +0200 | [diff] [blame] | 84 | POLARSSL_PK_ECDSA, |
Manuel Pégourié-Gonnard | 12c1ff0 | 2013-08-21 12:28:31 +0200 | [diff] [blame] | 85 | POLARSSL_PK_RSA_ALT, |
Paul Bakker | ed27a04 | 2013-04-18 22:46:23 +0200 | [diff] [blame] | 86 | } pk_type_t; |
| 87 | |
Manuel Pégourié-Gonnard | 12e0ed9 | 2013-07-04 13:31:32 +0200 | [diff] [blame] | 88 | /** |
Manuel Pégourié-Gonnard | c6ac887 | 2013-08-14 18:04:18 +0200 | [diff] [blame] | 89 | * \brief Types for interfacing with the debug module |
| 90 | */ |
| 91 | typedef enum |
| 92 | { |
| 93 | POLARSSL_PK_DEBUG_NONE = 0, |
| 94 | POLARSSL_PK_DEBUG_MPI, |
| 95 | POLARSSL_PK_DEBUG_ECP, |
| 96 | } pk_debug_type; |
| 97 | |
| 98 | /** |
| 99 | * \brief Item to send to the debug module |
| 100 | */ |
| 101 | typedef struct |
| 102 | { |
| 103 | pk_debug_type type; |
| 104 | char *name; |
| 105 | void *value; |
| 106 | } pk_debug_item; |
| 107 | |
| 108 | /** Maximum number of item send for debugging, plus 1 */ |
| 109 | #define POLARSSL_PK_DEBUG_MAX_ITEMS 3 |
| 110 | |
| 111 | /** |
Manuel Pégourié-Gonnard | 3fb5c5e | 2013-08-14 18:26:41 +0200 | [diff] [blame] | 112 | * \brief Public key information and operations |
Manuel Pégourié-Gonnard | d73b3c1 | 2013-08-12 17:06:05 +0200 | [diff] [blame] | 113 | */ |
| 114 | typedef struct |
| 115 | { |
| 116 | /** Public key type */ |
| 117 | pk_type_t type; |
| 118 | |
Manuel Pégourié-Gonnard | f8c948a | 2013-08-12 19:45:32 +0200 | [diff] [blame] | 119 | /** Type name */ |
| 120 | const char *name; |
| 121 | |
| 122 | /** Get key size in bits */ |
Manuel Pégourié-Gonnard | b3d9187 | 2013-08-14 15:56:19 +0200 | [diff] [blame] | 123 | size_t (*get_size)( const void * ); |
Manuel Pégourié-Gonnard | f8c948a | 2013-08-12 19:45:32 +0200 | [diff] [blame] | 124 | |
Manuel Pégourié-Gonnard | f18c3e0 | 2013-08-12 18:41:18 +0200 | [diff] [blame] | 125 | /** Tell if the context implements this type (eg ECKEY can do ECDSA) */ |
| 126 | int (*can_do)( pk_type_t type ); |
| 127 | |
Manuel Pégourié-Gonnard | d73b3c1 | 2013-08-12 17:06:05 +0200 | [diff] [blame] | 128 | /** Verify signature */ |
Manuel Pégourié-Gonnard | f73da02 | 2013-08-17 14:36:32 +0200 | [diff] [blame] | 129 | int (*verify_func)( void *ctx, md_type_t md_alg, |
| 130 | const unsigned char *hash, size_t hash_len, |
Manuel Pégourié-Gonnard | d73b3c1 | 2013-08-12 17:06:05 +0200 | [diff] [blame] | 131 | const unsigned char *sig, size_t sig_len ); |
Manuel Pégourié-Gonnard | 765db07 | 2013-08-14 15:00:27 +0200 | [diff] [blame] | 132 | |
Manuel Pégourié-Gonnard | 8df2769 | 2013-08-21 10:34:38 +0200 | [diff] [blame] | 133 | /** Make signature */ |
| 134 | int (*sign_func)( void *ctx, md_type_t md_alg, |
| 135 | const unsigned char *hash, size_t hash_len, |
| 136 | unsigned char *sig, size_t *sig_len, |
| 137 | int (*f_rng)(void *, unsigned char *, size_t), |
| 138 | void *p_rng ); |
| 139 | |
Manuel Pégourié-Gonnard | a2d3f22 | 2013-08-21 11:51:08 +0200 | [diff] [blame] | 140 | /** Decrypt message */ |
| 141 | int (*decrypt_func)( void *ctx, const unsigned char *input, size_t ilen, |
| 142 | unsigned char *output, size_t *olen, size_t osize, |
| 143 | int (*f_rng)(void *, unsigned char *, size_t), |
| 144 | void *p_rng ); |
| 145 | |
| 146 | /** Encrypt message */ |
| 147 | int (*encrypt_func)( void *ctx, const unsigned char *input, size_t ilen, |
| 148 | unsigned char *output, size_t *olen, size_t osize, |
| 149 | int (*f_rng)(void *, unsigned char *, size_t), |
| 150 | void *p_rng ); |
| 151 | |
Manuel Pégourié-Gonnard | 765db07 | 2013-08-14 15:00:27 +0200 | [diff] [blame] | 152 | /** Allocate a new context */ |
| 153 | void * (*ctx_alloc_func)( void ); |
| 154 | |
| 155 | /** Free the given context */ |
| 156 | void (*ctx_free_func)( void *ctx ); |
| 157 | |
Manuel Pégourié-Gonnard | c6ac887 | 2013-08-14 18:04:18 +0200 | [diff] [blame] | 158 | /** Interface with the debug module */ |
| 159 | void (*debug_func)( const void *ctx, pk_debug_item *items ); |
| 160 | |
Manuel Pégourié-Gonnard | d73b3c1 | 2013-08-12 17:06:05 +0200 | [diff] [blame] | 161 | } pk_info_t; |
| 162 | |
| 163 | /** |
Manuel Pégourié-Gonnard | 12e0ed9 | 2013-07-04 13:31:32 +0200 | [diff] [blame] | 164 | * \brief Public key container |
| 165 | */ |
| 166 | typedef struct |
| 167 | { |
Manuel Pégourié-Gonnard | 3fb5c5e | 2013-08-14 18:26:41 +0200 | [diff] [blame] | 168 | const pk_info_t * pk_info; /**< Public key informations */ |
| 169 | void * pk_ctx; /**< Underlying public key context */ |
Manuel Pégourié-Gonnard | 12e0ed9 | 2013-07-04 13:31:32 +0200 | [diff] [blame] | 170 | } pk_context; |
| 171 | |
| 172 | /** |
Manuel Pégourié-Gonnard | 12c1ff0 | 2013-08-21 12:28:31 +0200 | [diff] [blame] | 173 | * \brief Types for RSA-alt abstraction |
| 174 | */ |
| 175 | typedef int (*pk_rsa_alt_decrypt_func)( void *ctx, int mode, size_t *olen, |
| 176 | const unsigned char *input, unsigned char *output, |
| 177 | size_t output_max_len ); |
| 178 | typedef int (*pk_rsa_alt_sign_func)( void *ctx, |
| 179 | int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, |
| 180 | int mode, int hash_id, unsigned int hashlen, |
| 181 | const unsigned char *hash, unsigned char *sig ); |
| 182 | typedef size_t (*pk_rsa_alt_key_len_func)( void *ctx ); |
| 183 | |
| 184 | /** |
Manuel Pégourié-Gonnard | ab46694 | 2013-08-15 11:30:27 +0200 | [diff] [blame] | 185 | * \brief Return information associated with the given PK type |
| 186 | * |
| 187 | * \param type PK type to search for. |
| 188 | * |
| 189 | * \return The PK info associated with the type or NULL if not found. |
| 190 | */ |
| 191 | const pk_info_t *pk_info_from_type( pk_type_t pk_type ); |
| 192 | |
| 193 | /** |
Manuel Pégourié-Gonnard | 12e0ed9 | 2013-07-04 13:31:32 +0200 | [diff] [blame] | 194 | * \brief Initialize a pk_context (as NONE) |
| 195 | */ |
| 196 | void pk_init( pk_context *ctx ); |
| 197 | |
| 198 | /** |
Manuel Pégourié-Gonnard | 12c1ff0 | 2013-08-21 12:28:31 +0200 | [diff] [blame] | 199 | * \brief Free a pk_context |
| 200 | */ |
| 201 | void pk_free( pk_context *ctx ); |
| 202 | |
| 203 | /** |
Manuel Pégourié-Gonnard | ab46694 | 2013-08-15 11:30:27 +0200 | [diff] [blame] | 204 | * \brief Initialize a PK context with the information given |
| 205 | * and allocates the type-specific PK subcontext. |
| 206 | * |
| 207 | * \param ctx Context to initialize. Must be empty (type NONE). |
| 208 | * \param info Information to use |
| 209 | * |
| 210 | * \return 0 on success, |
| 211 | * POLARSSL_ERR_PK_BAD_INPUT_DATA on invalid input, |
| 212 | * POLARSSL_ERR_PK_MALLOC_FAILED on allocation failure. |
Manuel Pégourié-Gonnard | 12c1ff0 | 2013-08-21 12:28:31 +0200 | [diff] [blame] | 213 | * |
| 214 | * \note For contexts holding an RSA-alt key, use |
| 215 | * \c pk_init_ctx_rsa_alt() instead. |
Manuel Pégourié-Gonnard | ab46694 | 2013-08-15 11:30:27 +0200 | [diff] [blame] | 216 | */ |
| 217 | int pk_init_ctx( pk_context *ctx, const pk_info_t *info ); |
| 218 | |
| 219 | /** |
Manuel Pégourié-Gonnard | 12c1ff0 | 2013-08-21 12:28:31 +0200 | [diff] [blame] | 220 | * \brief Initialiaze an RSA-alt context |
| 221 | * |
| 222 | * \param ctx Context to initialize. Must be empty (type NONE). |
| 223 | * \param key RSA key pointer |
| 224 | * \param decrypt_func Decryption function |
| 225 | * \param sign_func Signing function |
| 226 | * \param key_len_func Function returning key length |
| 227 | * |
| 228 | * \return 0 on success, or POLARSSL_ERR_PK_BAD_INPUT_DATA if the |
| 229 | * context wasn't already initialized as RSA_ALT. |
| 230 | * |
| 231 | * \note This function replaces \c pk_init_ctx() for RSA-alt. |
Manuel Pégourié-Gonnard | 12e0ed9 | 2013-07-04 13:31:32 +0200 | [diff] [blame] | 232 | */ |
Manuel Pégourié-Gonnard | 12c1ff0 | 2013-08-21 12:28:31 +0200 | [diff] [blame] | 233 | int pk_init_ctx_rsa_alt( pk_context *ctx, void * key, |
| 234 | pk_rsa_alt_decrypt_func decrypt_func, |
| 235 | pk_rsa_alt_sign_func sign_func, |
| 236 | pk_rsa_alt_key_len_func key_len_func ); |
Manuel Pégourié-Gonnard | 12e0ed9 | 2013-07-04 13:31:32 +0200 | [diff] [blame] | 237 | |
| 238 | /** |
Manuel Pégourié-Gonnard | b3d9187 | 2013-08-14 15:56:19 +0200 | [diff] [blame] | 239 | * \brief Get the size in bits of the underlying key |
| 240 | * |
| 241 | * \param ctx Context to use |
| 242 | * |
| 243 | * \return Key size in bits, or 0 on error |
| 244 | */ |
| 245 | size_t pk_get_size( const pk_context *ctx ); |
| 246 | |
| 247 | /** |
Manuel Pégourié-Gonnard | 0d42049 | 2013-08-21 16:14:26 +0200 | [diff] [blame] | 248 | * \brief Get the length in bytes of the underlying key |
| 249 | * \param ctx Context to use |
| 250 | * |
| 251 | * \return Key lenght in bytes, or 0 on error |
| 252 | */ |
| 253 | static size_t pk_get_len( const pk_context *ctx ) |
| 254 | { |
| 255 | return( ( pk_get_size( ctx ) + 7 ) / 8 ); |
| 256 | } |
| 257 | |
| 258 | /** |
Manuel Pégourié-Gonnard | b3d9187 | 2013-08-14 15:56:19 +0200 | [diff] [blame] | 259 | * \brief Tell if a context can do the operation given by type |
| 260 | * |
| 261 | * \param ctx Context to test |
| 262 | * \param type Target type |
| 263 | * |
| 264 | * \return 0 if context can't do the operations, |
| 265 | * 1 otherwise. |
| 266 | */ |
| 267 | int pk_can_do( pk_context *ctx, pk_type_t type ); |
| 268 | |
| 269 | /** |
| 270 | * \brief Verify signature |
| 271 | * |
| 272 | * \param ctx PK context to use |
Manuel Pégourié-Gonnard | bfe32ef | 2013-08-22 14:55:30 +0200 | [diff] [blame^] | 273 | * \param md_alg Hash algorithm used (see notes) |
Manuel Pégourié-Gonnard | b3d9187 | 2013-08-14 15:56:19 +0200 | [diff] [blame] | 274 | * \param hash Hash of the message to sign |
Manuel Pégourié-Gonnard | bfe32ef | 2013-08-22 14:55:30 +0200 | [diff] [blame^] | 275 | * \param hash_len Hash length or 0 (see notes) |
Manuel Pégourié-Gonnard | b3d9187 | 2013-08-14 15:56:19 +0200 | [diff] [blame] | 276 | * \param sig Signature to verify |
| 277 | * \param sig_len Signature length |
| 278 | * |
| 279 | * \return 0 on success (signature is valid), |
| 280 | * or a specific error code. |
Manuel Pégourié-Gonnard | bfe32ef | 2013-08-22 14:55:30 +0200 | [diff] [blame^] | 281 | * |
| 282 | * \note If hash_len is 0, then the length associated with md_alg |
| 283 | * is used instead, or an error returned if it is invalid. |
| 284 | * |
| 285 | * \note md_alg may be POLARSSL_MD_NONE, only if hash_len != 0 |
Manuel Pégourié-Gonnard | b3d9187 | 2013-08-14 15:56:19 +0200 | [diff] [blame] | 286 | */ |
Manuel Pégourié-Gonnard | f73da02 | 2013-08-17 14:36:32 +0200 | [diff] [blame] | 287 | int pk_verify( pk_context *ctx, md_type_t md_alg, |
| 288 | const unsigned char *hash, size_t hash_len, |
Manuel Pégourié-Gonnard | b3d9187 | 2013-08-14 15:56:19 +0200 | [diff] [blame] | 289 | const unsigned char *sig, size_t sig_len ); |
| 290 | |
Manuel Pégourié-Gonnard | c6ac887 | 2013-08-14 18:04:18 +0200 | [diff] [blame] | 291 | /** |
Manuel Pégourié-Gonnard | 8df2769 | 2013-08-21 10:34:38 +0200 | [diff] [blame] | 292 | * \brief Make signature |
| 293 | * |
| 294 | * \param ctx PK context to use |
Manuel Pégourié-Gonnard | bfe32ef | 2013-08-22 14:55:30 +0200 | [diff] [blame^] | 295 | * \param md_alg Hash algorithm used (see notes) |
Manuel Pégourié-Gonnard | 8df2769 | 2013-08-21 10:34:38 +0200 | [diff] [blame] | 296 | * \param hash Hash of the message to sign |
Manuel Pégourié-Gonnard | bfe32ef | 2013-08-22 14:55:30 +0200 | [diff] [blame^] | 297 | * \param hash_len Hash length or 0 (see notes) |
Manuel Pégourié-Gonnard | 8df2769 | 2013-08-21 10:34:38 +0200 | [diff] [blame] | 298 | * \param sig Place to write the signature |
| 299 | * \param sig_len Number of bytes written |
| 300 | * \param f_rng RNG function |
| 301 | * \param p_rng RNG parameter |
| 302 | * |
| 303 | * \return 0 on success, or a specific error code. |
Manuel Pégourié-Gonnard | bfe32ef | 2013-08-22 14:55:30 +0200 | [diff] [blame^] | 304 | * |
| 305 | * \note If hash_len is 0, then the length associated with md_alg |
| 306 | * is used instead, or an error returned if it is invalid. |
| 307 | * |
| 308 | * \note md_alg may be POLARSSL_MD_NONE, only if hash_len != 0 |
Manuel Pégourié-Gonnard | 8df2769 | 2013-08-21 10:34:38 +0200 | [diff] [blame] | 309 | */ |
| 310 | int pk_sign( pk_context *ctx, md_type_t md_alg, |
| 311 | const unsigned char *hash, size_t hash_len, |
| 312 | unsigned char *sig, size_t *sig_len, |
| 313 | int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); |
| 314 | |
| 315 | /** |
Manuel Pégourié-Gonnard | a2d3f22 | 2013-08-21 11:51:08 +0200 | [diff] [blame] | 316 | * \brief Decrypt message |
| 317 | * |
| 318 | * \param ctx PK context to use |
| 319 | * \param input Input to decrypt |
| 320 | * \param ilen Input size |
| 321 | * \param output Decrypted output |
| 322 | * \param olen Decrypted message lenght |
| 323 | * \param osize Size of the output buffer |
| 324 | * |
| 325 | * \return 0 on success, or a specific error code. |
| 326 | */ |
| 327 | int pk_decrypt( pk_context *ctx, |
| 328 | const unsigned char *input, size_t ilen, |
| 329 | unsigned char *output, size_t *olen, size_t osize, |
| 330 | int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); |
| 331 | |
| 332 | /** |
| 333 | * \brief Encrypt message |
| 334 | * |
| 335 | * \param ctx PK context to use |
| 336 | * \param input Message to encrypt |
| 337 | * \param ilen Message size |
| 338 | * \param output Encrypted output |
| 339 | * \param olen Encrypted output length |
| 340 | * \param osize Size of the output buffer |
| 341 | * |
| 342 | * \return 0 on success, or a specific error code. |
| 343 | */ |
| 344 | int pk_encrypt( pk_context *ctx, |
| 345 | const unsigned char *input, size_t ilen, |
| 346 | unsigned char *output, size_t *olen, size_t osize, |
| 347 | int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); |
| 348 | |
| 349 | /** |
Manuel Pégourié-Gonnard | c6ac887 | 2013-08-14 18:04:18 +0200 | [diff] [blame] | 350 | * \brief Export debug information |
| 351 | * |
| 352 | * \param ctx Context to use |
| 353 | * \param items Place to write debug items |
| 354 | * |
| 355 | * \return 0 on sucess or POLARSSL_ERR_PK_BAD_INPUT_DATA |
| 356 | */ |
| 357 | int pk_debug( const pk_context *ctx, pk_debug_item *items ); |
| 358 | |
Manuel Pégourié-Gonnard | 3fb5c5e | 2013-08-14 18:26:41 +0200 | [diff] [blame] | 359 | /** |
| 360 | * \brief Access the type name |
| 361 | * |
| 362 | * \param ctx Context to use |
| 363 | * |
| 364 | * \return Type name on success, or "invalid PK" |
| 365 | */ |
| 366 | const char * pk_get_name( const pk_context *ctx ); |
| 367 | |
Paul Bakker | ed27a04 | 2013-04-18 22:46:23 +0200 | [diff] [blame] | 368 | #ifdef __cplusplus |
| 369 | } |
| 370 | #endif |
| 371 | |
Manuel Pégourié-Gonnard | d73b3c1 | 2013-08-12 17:06:05 +0200 | [diff] [blame] | 372 | #endif /* POLARSSL_PK_H */ |