mbed TLS v2.23.0: pk.h Source File

mbed TLS v2.23.0

pk.h
Go to the documentation of this file.
1
6 /*
7 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
8 * SPDX-License-Identifier: Apache-2.0
9 *
10 * Licensed under the Apache License, Version 2.0 (the "License"); you may
11 * not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
13 *
14 * http://www.apache.org/licenses/LICENSE-2.0
15 *
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 *
22 * This file is part of mbed TLS (https://tls.mbed.org)
23 */
24
25 #ifndef MBEDTLS_PK_H
26 #define MBEDTLS_PK_H
27
28 #if !defined(MBEDTLS_CONFIG_FILE)
29 #include "mbedtls/config.h"
30 #else
31 #include MBEDTLS_CONFIG_FILE
32 #endif
33
34 #include "mbedtls/md.h"
35
36 #if defined(MBEDTLS_RSA_C)
37 #include "mbedtls/rsa.h"
38 #endif
39
40 #if defined(MBEDTLS_ECP_C)
41 #include "mbedtls/ecp.h"
42 #endif
43
44 #if defined(MBEDTLS_ECDSA_C)
45 #include "mbedtls/ecdsa.h"
46 #endif
47
48 #if defined(MBEDTLS_USE_PSA_CRYPTO)
49 #include "psa/crypto.h"
50 #endif
51
52 #if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
53 !defined(inline) && !defined(__cplusplus)
54 #define inline __inline
55 #endif
56
57 #define MBEDTLS_ERR_PK_ALLOC_FAILED -0x3F80
58 #define MBEDTLS_ERR_PK_TYPE_MISMATCH -0x3F00
59 #define MBEDTLS_ERR_PK_BAD_INPUT_DATA -0x3E80
60 #define MBEDTLS_ERR_PK_FILE_IO_ERROR -0x3E00
61 #define MBEDTLS_ERR_PK_KEY_INVALID_VERSION -0x3D80
62 #define MBEDTLS_ERR_PK_KEY_INVALID_FORMAT -0x3D00
63 #define MBEDTLS_ERR_PK_UNKNOWN_PK_ALG -0x3C80
64 #define MBEDTLS_ERR_PK_PASSWORD_REQUIRED -0x3C00
65 #define MBEDTLS_ERR_PK_PASSWORD_MISMATCH -0x3B80
66 #define MBEDTLS_ERR_PK_INVALID_PUBKEY -0x3B00
67 #define MBEDTLS_ERR_PK_INVALID_ALG -0x3A80
68 #define MBEDTLS_ERR_PK_UNKNOWN_NAMED_CURVE -0x3A00
69 #define MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE -0x3980
70 #define MBEDTLS_ERR_PK_SIG_LEN_MISMATCH -0x3900
72 /* MBEDTLS_ERR_PK_HW_ACCEL_FAILED is deprecated and should not be used. */
73 #define MBEDTLS_ERR_PK_HW_ACCEL_FAILED -0x3880
75 #ifdef __cplusplus
76 extern "C" {
77 #endif
78
82 typedef enum {
83 MBEDTLS_PK_NONE=0,
84 MBEDTLS_PK_RSA,
85 MBEDTLS_PK_ECKEY,
86 MBEDTLS_PK_ECKEY_DH,
87 MBEDTLS_PK_ECDSA,
88 MBEDTLS_PK_RSA_ALT,
89 MBEDTLS_PK_RSASSA_PSS,
90 MBEDTLS_PK_OPAQUE,
91 } mbedtls_pk_type_t;
92
97 typedef struct mbedtls_pk_rsassa_pss_options
98 {
99 mbedtls_md_type_t mgf1_hash_id;
100 int expected_salt_len;
101
102 } mbedtls_pk_rsassa_pss_options;
103
107 /* We need to set MBEDTLS_PK_SIGNATURE_MAX_SIZE to the maximum signature
108 * size among the supported signature types. Do it by starting at 0,
109 * then incrementally increasing to be large enough for each supported
110 * signature mechanism.
111 *
112 * The resulting value can be 0, for example if MBEDTLS_ECDH_C is enabled
113 * (which allows the pk module to be included) but neither MBEDTLS_ECDSA_C
114 * nor MBEDTLS_RSA_C nor any opaque signature mechanism (PSA or RSA_ALT).
115 */
116 #define MBEDTLS_PK_SIGNATURE_MAX_SIZE 0
117
118 #if ( defined(MBEDTLS_RSA_C) || defined(MBEDTLS_PK_RSA_ALT_SUPPORT) ) && \
119 MBEDTLS_MPI_MAX_SIZE > MBEDTLS_PK_SIGNATURE_MAX_SIZE
120 /* For RSA, the signature can be as large as the bignum module allows.
121 * For RSA_ALT, the signature size is not necessarily tied to what the
122 * bignum module can do, but in the absence of any specific setting,
123 * we use that (rsa_alt_sign_wrap in pk_wrap will check). */
124 #undef MBEDTLS_PK_SIGNATURE_MAX_SIZE
125 #define MBEDTLS_PK_SIGNATURE_MAX_SIZE MBEDTLS_MPI_MAX_SIZE
126 #endif
127
128 #if defined(MBEDTLS_ECDSA_C) && \
129 MBEDTLS_ECDSA_MAX_LEN > MBEDTLS_PK_SIGNATURE_MAX_SIZE
130 /* For ECDSA, the ecdsa module exports a constant for the maximum
131 * signature size. */
132 #undef MBEDTLS_PK_SIGNATURE_MAX_SIZE
133 #define MBEDTLS_PK_SIGNATURE_MAX_SIZE MBEDTLS_ECDSA_MAX_LEN
134 #endif
135
136 #if defined(MBEDTLS_USE_PSA_CRYPTO)
137 #if PSA_SIGNATURE_MAX_SIZE > MBEDTLS_PK_SIGNATURE_MAX_SIZE
138 /* PSA_SIGNATURE_MAX_SIZE is the maximum size of a signature made
139 * through the PSA API in the PSA representation. */
140 #undef MBEDTLS_PK_SIGNATURE_MAX_SIZE
141 #define MBEDTLS_PK_SIGNATURE_MAX_SIZE PSA_SIGNATURE_MAX_SIZE
142 #endif
143
144 #if PSA_VENDOR_ECDSA_SIGNATURE_MAX_SIZE + 11 > MBEDTLS_PK_SIGNATURE_MAX_SIZE
145 /* The Mbed TLS representation is different for ECDSA signatures:
146 * PSA uses the raw concatenation of r and s,
147 * whereas Mbed TLS uses the ASN.1 representation (SEQUENCE of two INTEGERs).
148 * Add the overhead of ASN.1: up to (1+2) + 2 * (1+2+1) for the
149 * types, lengths (represented by up to 2 bytes), and potential leading
150 * zeros of the INTEGERs and the SEQUENCE. */
151 #undef MBEDTLS_PK_SIGNATURE_MAX_SIZE
152 #define MBEDTLS_PK_SIGNATURE_MAX_SIZE ( PSA_VENDOR_ECDSA_SIGNATURE_MAX_SIZE + 11 )
153 #endif
154 #endif /* defined(MBEDTLS_USE_PSA_CRYPTO) */
155
159 typedef enum
160 {
161 MBEDTLS_PK_DEBUG_NONE = 0,
162 MBEDTLS_PK_DEBUG_MPI,
163 MBEDTLS_PK_DEBUG_ECP,
164 } mbedtls_pk_debug_type;
165
169 typedef struct mbedtls_pk_debug_item
170 {
171 mbedtls_pk_debug_type type;
172 const char *name;
173 void *value;
174 } mbedtls_pk_debug_item;
175
177 #define MBEDTLS_PK_DEBUG_MAX_ITEMS 3
178
182 typedef struct mbedtls_pk_info_t mbedtls_pk_info_t;
183
187 typedef struct mbedtls_pk_context
188 {
189 const mbedtls_pk_info_t * pk_info;
190 void * pk_ctx;
191 } mbedtls_pk_context;
192
193 #if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE)
194
197 typedef struct
198 {
199 const mbedtls_pk_info_t * pk_info;
200 void * rs_ctx;
201 } mbedtls_pk_restart_ctx;
202 #else /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */
203 /* Now we can declare functions that take a pointer to that */
204 typedef void mbedtls_pk_restart_ctx;
205 #endif /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */
206
207 #if defined(MBEDTLS_RSA_C)
208
214 static inline mbedtls_rsa_context *mbedtls_pk_rsa( const mbedtls_pk_context pk )
215 {
216 return( (mbedtls_rsa_context *) (pk).pk_ctx );
217 }
218 #endif /* MBEDTLS_RSA_C */
219
220 #if defined(MBEDTLS_ECP_C)
221
227 static inline mbedtls_ecp_keypair *mbedtls_pk_ec( const mbedtls_pk_context pk )
228 {
229 return( (mbedtls_ecp_keypair *) (pk).pk_ctx );
230 }
231 #endif /* MBEDTLS_ECP_C */
232
233 #if defined(MBEDTLS_PK_RSA_ALT_SUPPORT)
234
237 typedef int (*mbedtls_pk_rsa_alt_decrypt_func)( void *ctx, int mode, size_t *olen,
238 const unsigned char *input, unsigned char *output,
239 size_t output_max_len );
240 typedef int (*mbedtls_pk_rsa_alt_sign_func)( void *ctx,
241 int (*f_rng)(void *, unsigned char *, size_t), void *p_rng,
242 int mode, mbedtls_md_type_t md_alg, unsigned int hashlen,
243 const unsigned char *hash, unsigned char *sig );
244 typedef size_t (*mbedtls_pk_rsa_alt_key_len_func)( void *ctx );
245 #endif /* MBEDTLS_PK_RSA_ALT_SUPPORT */
246
254 const mbedtls_pk_info_t *mbedtls_pk_info_from_type( mbedtls_pk_type_t pk_type );
255
262 void mbedtls_pk_init( mbedtls_pk_context *ctx );
263
275 void mbedtls_pk_free( mbedtls_pk_context *ctx );
276
277 #if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE)
278
284 void mbedtls_pk_restart_init( mbedtls_pk_restart_ctx *ctx );
285
292 void mbedtls_pk_restart_free( mbedtls_pk_restart_ctx *ctx );
293 #endif /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */
294
310 int mbedtls_pk_setup( mbedtls_pk_context *ctx, const mbedtls_pk_info_t *info );
311
312 #if defined(MBEDTLS_USE_PSA_CRYPTO)
313
341 int mbedtls_pk_setup_opaque( mbedtls_pk_context *ctx, const psa_key_handle_t key );
342 #endif /* MBEDTLS_USE_PSA_CRYPTO */
343
344 #if defined(MBEDTLS_PK_RSA_ALT_SUPPORT)
345
360 int mbedtls_pk_setup_rsa_alt( mbedtls_pk_context *ctx, void * key,
361 mbedtls_pk_rsa_alt_decrypt_func decrypt_func,
362 mbedtls_pk_rsa_alt_sign_func sign_func,
363 mbedtls_pk_rsa_alt_key_len_func key_len_func );
364 #endif /* MBEDTLS_PK_RSA_ALT_SUPPORT */
365
373 size_t mbedtls_pk_get_bitlen( const mbedtls_pk_context *ctx );
374
382 static inline size_t mbedtls_pk_get_len( const mbedtls_pk_context *ctx )
383 {
384 return( ( mbedtls_pk_get_bitlen( ctx ) + 7 ) / 8 );
385 }
386
399 int mbedtls_pk_can_do( const mbedtls_pk_context *ctx, mbedtls_pk_type_t type );
400
425 int mbedtls_pk_verify( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg,
426 const unsigned char *hash, size_t hash_len,
427 const unsigned char *sig, size_t sig_len );
428
449 int mbedtls_pk_verify_restartable( mbedtls_pk_context *ctx,
450 mbedtls_md_type_t md_alg,
451 const unsigned char *hash, size_t hash_len,
452 const unsigned char *sig, size_t sig_len,
453 mbedtls_pk_restart_ctx *rs_ctx );
454
484 int mbedtls_pk_verify_ext( mbedtls_pk_type_t type, const void *options,
485 mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg,
486 const unsigned char *hash, size_t hash_len,
487 const unsigned char *sig, size_t sig_len );
488
519 int mbedtls_pk_sign( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg,
520 const unsigned char *hash, size_t hash_len,
521 unsigned char *sig, size_t *sig_len,
522 int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
523
552 int mbedtls_pk_sign_restartable( mbedtls_pk_context *ctx,
553 mbedtls_md_type_t md_alg,
554 const unsigned char *hash, size_t hash_len,
555 unsigned char *sig, size_t *sig_len,
556 int (*f_rng)(void *, unsigned char *, size_t), void *p_rng,
557 mbedtls_pk_restart_ctx *rs_ctx );
558
576 int mbedtls_pk_decrypt( mbedtls_pk_context *ctx,
577 const unsigned char *input, size_t ilen,
578 unsigned char *output, size_t *olen, size_t osize,
579 int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
580
597 int mbedtls_pk_encrypt( mbedtls_pk_context *ctx,
598 const unsigned char *input, size_t ilen,
599 unsigned char *output, size_t *olen, size_t osize,
600 int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
601
614 int mbedtls_pk_check_pair( const mbedtls_pk_context *pub, const mbedtls_pk_context *prv );
615
624 int mbedtls_pk_debug( const mbedtls_pk_context *ctx, mbedtls_pk_debug_item *items );
625
633 const char * mbedtls_pk_get_name( const mbedtls_pk_context *ctx );
634
643 mbedtls_pk_type_t mbedtls_pk_get_type( const mbedtls_pk_context *ctx );
644
645 #if defined(MBEDTLS_PK_PARSE_C)
646
675 int mbedtls_pk_parse_key( mbedtls_pk_context *ctx,
676 const unsigned char *key, size_t keylen,
677 const unsigned char *pwd, size_t pwdlen );
678
701 int mbedtls_pk_parse_public_key( mbedtls_pk_context *ctx,
702 const unsigned char *key, size_t keylen );
703
704 #if defined(MBEDTLS_FS_IO)
705
726 int mbedtls_pk_parse_keyfile( mbedtls_pk_context *ctx,
727 const char *path, const char *password );
728
746 int mbedtls_pk_parse_public_keyfile( mbedtls_pk_context *ctx, const char *path );
747 #endif /* MBEDTLS_FS_IO */
748 #endif /* MBEDTLS_PK_PARSE_C */
749
750 #if defined(MBEDTLS_PK_WRITE_C)
751
764 int mbedtls_pk_write_key_der( mbedtls_pk_context *ctx, unsigned char *buf, size_t size );
765
779 int mbedtls_pk_write_pubkey_der( mbedtls_pk_context *ctx, unsigned char *buf, size_t size );
780
781 #if defined(MBEDTLS_PEM_WRITE_C)
782
792 int mbedtls_pk_write_pubkey_pem( mbedtls_pk_context *ctx, unsigned char *buf, size_t size );
793
804 int mbedtls_pk_write_key_pem( mbedtls_pk_context *ctx, unsigned char *buf, size_t size );
805 #endif /* MBEDTLS_PEM_WRITE_C */
806 #endif /* MBEDTLS_PK_WRITE_C */
807
808 /*
809 * WARNING: Low-level functions. You probably do not want to use these unless
810 * you are certain you do ;)
811 */
812
813 #if defined(MBEDTLS_PK_PARSE_C)
814
824 int mbedtls_pk_parse_subpubkey( unsigned char **p, const unsigned char *end,
825 mbedtls_pk_context *pk );
826 #endif /* MBEDTLS_PK_PARSE_C */
827
828 #if defined(MBEDTLS_PK_WRITE_C)
829
839 int mbedtls_pk_write_pubkey( unsigned char **p, unsigned char *start,
840 const mbedtls_pk_context *key );
841 #endif /* MBEDTLS_PK_WRITE_C */
842
843 /*
844 * Internal module functions. You probably do not want to use these unless you
845 * know you do.
846 */
847 #if defined(MBEDTLS_FS_IO)
848 int mbedtls_pk_load_file( const char *path, unsigned char **buf, size_t *n );
849 #endif
850
851 #if defined(MBEDTLS_USE_PSA_CRYPTO)
852
872 int mbedtls_pk_wrap_as_opaque( mbedtls_pk_context *pk,
873 psa_key_handle_t *handle,
874 psa_algorithm_t hash_alg );
875 #endif /* MBEDTLS_USE_PSA_CRYPTO */
876
877 #ifdef __cplusplus
878 }
879 #endif
880
881 #endif /* MBEDTLS_PK_H */
mbedtls_pk_parse_public_keyfile
int mbedtls_pk_parse_public_keyfile(mbedtls_pk_context *ctx, const char *path)
Load and parse a public key.
MBEDTLS_PK_RSA_ALT
@ MBEDTLS_PK_RSA_ALT
Definition: pk.h:88
MBEDTLS_PK_ECKEY_DH
@ MBEDTLS_PK_ECKEY_DH
Definition: pk.h:86
mbedtls_pk_debug_item::name
const char * name
Definition: pk.h:172
mbedtls_pk_rsassa_pss_options
struct mbedtls_pk_rsassa_pss_options mbedtls_pk_rsassa_pss_options
Options for RSASSA-PSS signature verification. See mbedtls_rsa_rsassa_pss_verify_ext()
mbedtls_pk_sign_restartable
int mbedtls_pk_sign_restartable(mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hash_len, unsigned char *sig, size_t *sig_len, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng, mbedtls_pk_restart_ctx *rs_ctx)
Restartable version of mbedtls_pk_sign()
mbedtls_md_type_t
mbedtls_md_type_t
Supported message digests.
Definition: md.h:58
mbedtls_pk_verify_restartable
int mbedtls_pk_verify_restartable(mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hash_len, const unsigned char *sig, size_t sig_len, mbedtls_pk_restart_ctx *rs_ctx)
Restartable version of mbedtls_pk_verify()
ecp.h
This file provides an API for Elliptic Curves over GF(P) (ECP).
mbedtls_pk_debug_item::value
void * value
Definition: pk.h:173
MBEDTLS_PK_DEBUG_MPI
@ MBEDTLS_PK_DEBUG_MPI
Definition: pk.h:162
mbedtls_pk_parse_subpubkey
int mbedtls_pk_parse_subpubkey(unsigned char **p, const unsigned char *end, mbedtls_pk_context *pk)
Parse a SubjectPublicKeyInfo DER structure.
ecdsa.h
This file contains ECDSA definitions and functions.
mbedtls_pk_can_do
int mbedtls_pk_can_do(const mbedtls_pk_context *ctx, mbedtls_pk_type_t type)
Tell if a context can do the operation given by type.
mbedtls_pk_rsassa_pss_options
Options for RSASSA-PSS signature verification. See mbedtls_rsa_rsassa_pss_verify_ext()
Definition: pk.h:98
mbedtls_pk_verify
int mbedtls_pk_verify(mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hash_len, const unsigned char *sig, size_t sig_len)
Verify signature (including padding if relevant).
md.h
This file contains the generic message-digest wrapper.
mbedtls_pk_context
Public key container.
Definition: pk.h:188
mbedtls_pk_write_pubkey
int mbedtls_pk_write_pubkey(unsigned char **p, unsigned char *start, const mbedtls_pk_context *key)
Write a subjectPublicKey to ASN.1 data Note: function works backwards in data buffer.
mbedtls_pk_parse_keyfile
int mbedtls_pk_parse_keyfile(mbedtls_pk_context *ctx, const char *path, const char *password)
Load and parse a private key.
mbedtls_pk_get_type
mbedtls_pk_type_t mbedtls_pk_get_type(const mbedtls_pk_context *ctx)
Get the key type.
mbedtls_pk_context::pk_ctx
void * pk_ctx
Definition: pk.h:190
mbedtls_pk_context::pk_info
const mbedtls_pk_info_t * pk_info
Definition: pk.h:189
mbedtls_pk_setup
int mbedtls_pk_setup(mbedtls_pk_context *ctx, const mbedtls_pk_info_t *info)
Initialize a PK context with the information given and allocates the type-specific PK subcontext.
mbedtls_pk_ec
static mbedtls_ecp_keypair * mbedtls_pk_ec(const mbedtls_pk_context pk)
Definition: pk.h:227
MBEDTLS_PK_DEBUG_NONE
@ MBEDTLS_PK_DEBUG_NONE
Definition: pk.h:161
mbedtls_pk_parse_public_key
int mbedtls_pk_parse_public_key(mbedtls_pk_context *ctx, const unsigned char *key, size_t keylen)
Parse a public key in PEM or DER format.
mbedtls_pk_restart_ctx
void mbedtls_pk_restart_ctx
Definition: pk.h:204
MBEDTLS_PK_OPAQUE
@ MBEDTLS_PK_OPAQUE
Definition: pk.h:90
mbedtls_pk_rsa_alt_key_len_func
size_t(* mbedtls_pk_rsa_alt_key_len_func)(void *ctx)
Definition: pk.h:244
mbedtls_pk_rsassa_pss_options::expected_salt_len
int expected_salt_len
Definition: pk.h:100
mbedtls_pk_debug
int mbedtls_pk_debug(const mbedtls_pk_context *ctx, mbedtls_pk_debug_item *items)
Export debug information.
mbedtls_pk_debug_item::type
mbedtls_pk_debug_type type
Definition: pk.h:171
mbedtls_ecp_keypair
The ECP key-pair structure.
Definition: ecp.h:343
crypto.h
Platform Security Architecture cryptography module.
rsa.h
This file provides an API for the RSA public-key cryptosystem.
mbedtls_pk_get_bitlen
size_t mbedtls_pk_get_bitlen(const mbedtls_pk_context *ctx)
Get the size in bits of the underlying key.
mbedtls_pk_get_len
static size_t mbedtls_pk_get_len(const mbedtls_pk_context *ctx)
Get the length in bytes of the underlying key.
Definition: pk.h:382
mbedtls_pk_debug_item
Item to send to the debug module.
Definition: pk.h:170
mbedtls_pk_parse_key
int mbedtls_pk_parse_key(mbedtls_pk_context *ctx, const unsigned char *key, size_t keylen, const unsigned char *pwd, size_t pwdlen)
Parse a private key in PEM or DER format.
mbedtls_pk_decrypt
int mbedtls_pk_decrypt(mbedtls_pk_context *ctx, const unsigned char *input, size_t ilen, unsigned char *output, size_t *olen, size_t osize, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
Decrypt message (including padding if relevant).
MBEDTLS_PK_NONE
@ MBEDTLS_PK_NONE
Definition: pk.h:83
mbedtls_pk_verify_ext
int mbedtls_pk_verify_ext(mbedtls_pk_type_t type, const void *options, mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hash_len, const unsigned char *sig, size_t sig_len)
Verify signature, with options. (Includes verification of the padding depending on type....
mbedtls_pk_type_t
mbedtls_pk_type_t
Public key types.
Definition: pk.h:82
psa_algorithm_t
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
Definition: crypto_types.h:98
mbedtls_pk_setup_rsa_alt
int mbedtls_pk_setup_rsa_alt(mbedtls_pk_context *ctx, void *key, mbedtls_pk_rsa_alt_decrypt_func decrypt_func, mbedtls_pk_rsa_alt_sign_func sign_func, mbedtls_pk_rsa_alt_key_len_func key_len_func)
Initialize an RSA-alt context.
MBEDTLS_PK_RSASSA_PSS
@ MBEDTLS_PK_RSASSA_PSS
Definition: pk.h:89
mbedtls_rsa_context
The RSA context structure.
Definition: rsa.h:101
MBEDTLS_PK_ECDSA
@ MBEDTLS_PK_ECDSA
Definition: pk.h:87
mbedtls_pk_rsa_alt_decrypt_func
int(* mbedtls_pk_rsa_alt_decrypt_func)(void *ctx, int mode, size_t *olen, const unsigned char *input, unsigned char *output, size_t output_max_len)
Types for RSA-alt abstraction.
Definition: pk.h:237
mbedtls_pk_rsassa_pss_options::mgf1_hash_id
mbedtls_md_type_t mgf1_hash_id
Definition: pk.h:99
mbedtls_pk_write_pubkey_der
int mbedtls_pk_write_pubkey_der(mbedtls_pk_context *ctx, unsigned char *buf, size_t size)
Write a public key to a SubjectPublicKeyInfo DER structure Note: data is written at the end of the bu...
mbedtls_pk_write_key_der
int mbedtls_pk_write_key_der(mbedtls_pk_context *ctx, unsigned char *buf, size_t size)
Write a private key to a PKCS#1 or SEC1 DER structure Note: data is written at the end of the buffer!...
mbedtls_pk_get_name
const char * mbedtls_pk_get_name(const mbedtls_pk_context *ctx)
Access the type name.
mbedtls_pk_debug_type
mbedtls_pk_debug_type
Types for interfacing with the debug module.
Definition: pk.h:160
mbedtls_pk_info_from_type
const mbedtls_pk_info_t * mbedtls_pk_info_from_type(mbedtls_pk_type_t pk_type)
Return information associated with the given PK type.
mbedtls_pk_info_t
struct mbedtls_pk_info_t mbedtls_pk_info_t
Public key information and operations.
Definition: pk.h:182
config.h
Configuration options (set of defines)
mbedtls_pk_debug_item
struct mbedtls_pk_debug_item mbedtls_pk_debug_item
Item to send to the debug module.
MBEDTLS_PK_ECKEY
@ MBEDTLS_PK_ECKEY
Definition: pk.h:85
mbedtls_pk_write_pubkey_pem
int mbedtls_pk_write_pubkey_pem(mbedtls_pk_context *ctx, unsigned char *buf, size_t size)
Write a public key to a PEM string.
MBEDTLS_PK_DEBUG_ECP
@ MBEDTLS_PK_DEBUG_ECP
Definition: pk.h:163
mbedtls_pk_sign
int mbedtls_pk_sign(mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hash_len, unsigned char *sig, size_t *sig_len, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
Make signature, including padding if relevant.
mbedtls_pk_write_key_pem
int mbedtls_pk_write_key_pem(mbedtls_pk_context *ctx, unsigned char *buf, size_t size)
Write a private key to a PKCS#1 or SEC1 PEM string.
mbedtls_pk_encrypt
int mbedtls_pk_encrypt(mbedtls_pk_context *ctx, const unsigned char *input, size_t ilen, unsigned char *output, size_t *olen, size_t osize, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
Encrypt message (including padding if relevant).
mbedtls_pk_init
void mbedtls_pk_init(mbedtls_pk_context *ctx)
Initialize a mbedtls_pk_context (as NONE).
psa_key_handle_t
uint16_t psa_key_handle_t
Definition: crypto_platform.h:50
mbedtls_pk_check_pair
int mbedtls_pk_check_pair(const mbedtls_pk_context *pub, const mbedtls_pk_context *prv)
Check if a public-private pair of keys matches.
mbedtls_pk_rsa
static mbedtls_rsa_context * mbedtls_pk_rsa(const mbedtls_pk_context pk)
Definition: pk.h:214
MBEDTLS_PK_RSA
@ MBEDTLS_PK_RSA
Definition: pk.h:84
mbedtls_pk_free
void mbedtls_pk_free(mbedtls_pk_context *ctx)
Free the components of a mbedtls_pk_context.
mbedtls_pk_rsa_alt_sign_func
int(* mbedtls_pk_rsa_alt_sign_func)(void *ctx, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, mbedtls_md_type_t md_alg, unsigned int hashlen, const unsigned char *hash, unsigned char *sig)
Definition: pk.h:240
mbedtls_pk_load_file
int mbedtls_pk_load_file(const char *path, unsigned char **buf, size_t *n)
mbedtls_pk_context
struct mbedtls_pk_context mbedtls_pk_context
Public key container.