ReactOS 0.4.15-dev-7953-g1f49173
pkcs12.c
Go to the documentation of this file.
1/*
2 * PKCS#12 Personal Information Exchange Syntax
3 *
4 * Copyright The Mbed TLS Contributors
5 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
6 *
7 * This file is provided under the Apache License 2.0, or the
8 * GNU General Public License v2.0 or later.
9 *
10 * **********
11 * Apache License 2.0:
12 *
13 * Licensed under the Apache License, Version 2.0 (the "License"); you may
14 * not use this file except in compliance with the License.
15 * You may obtain a copy of the License at
16 *
17 * http://www.apache.org/licenses/LICENSE-2.0
18 *
19 * Unless required by applicable law or agreed to in writing, software
20 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
21 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 * See the License for the specific language governing permissions and
23 * limitations under the License.
24 *
25 * **********
26 *
27 * **********
28 * GNU General Public License v2.0 or later:
29 *
30 * This program is free software; you can redistribute it and/or modify
31 * it under the terms of the GNU General Public License as published by
32 * the Free Software Foundation; either version 2 of the License, or
33 * (at your option) any later version.
34 *
35 * This program is distributed in the hope that it will be useful,
36 * but WITHOUT ANY WARRANTY; without even the implied warranty of
37 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38 * GNU General Public License for more details.
39 *
40 * You should have received a copy of the GNU General Public License along
41 * with this program; if not, write to the Free Software Foundation, Inc.,
42 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
43 *
44 * **********
45 */
46/*
47 * The PKCS #12 Personal Information Exchange Syntax Standard v1.1
48 *
49 * http://www.rsa.com/rsalabs/pkcs/files/h11301-wp-pkcs-12v1-1-personal-information-exchange-syntax.pdf
50 * ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-12/pkcs-12v1-1.asn
51 */
52
53#if !defined(MBEDTLS_CONFIG_FILE)
54#include "mbedtls/config.h"
55#else
56#include MBEDTLS_CONFIG_FILE
57#endif
58
59#if defined(MBEDTLS_PKCS12_C)
60
61#include "mbedtls/pkcs12.h"
62#include "mbedtls/asn1.h"
63#include "mbedtls/cipher.h"
65
66#include <string.h>
67
68#if defined(MBEDTLS_ARC4_C)
69#include "mbedtls/arc4.h"
70#endif
71
72#if defined(MBEDTLS_DES_C)
73#include "mbedtls/des.h"
74#endif
75
76#if defined(MBEDTLS_ASN1_PARSE_C)
77
78static int pkcs12_parse_pbe_params( mbedtls_asn1_buf *params,
79 mbedtls_asn1_buf *salt, int *iterations )
80{
81 int ret;
82 unsigned char **p = &params->p;
83 const unsigned char *end = params->p + params->len;
84
85 /*
86 * pkcs-12PbeParams ::= SEQUENCE {
87 * salt OCTET STRING,
88 * iterations INTEGER
89 * }
90 *
91 */
95
96 if( ( ret = mbedtls_asn1_get_tag( p, end, &salt->len, MBEDTLS_ASN1_OCTET_STRING ) ) != 0 )
98
99 salt->p = *p;
100 *p += salt->len;
101
102 if( ( ret = mbedtls_asn1_get_int( p, end, iterations ) ) != 0 )
104
105 if( *p != end )
108
109 return( 0 );
110}
111
112#define PKCS12_MAX_PWDLEN 128
113
114static int pkcs12_pbe_derive_key_iv( mbedtls_asn1_buf *pbe_params, mbedtls_md_type_t md_type,
115 const unsigned char *pwd, size_t pwdlen,
116 unsigned char *key, size_t keylen,
117 unsigned char *iv, size_t ivlen )
118{
119 int ret, iterations = 0;
120 mbedtls_asn1_buf salt;
121 size_t i;
122 unsigned char unipwd[PKCS12_MAX_PWDLEN * 2 + 2];
123
124 if( pwdlen > PKCS12_MAX_PWDLEN )
126
127 memset( &salt, 0, sizeof(mbedtls_asn1_buf) );
128 memset( &unipwd, 0, sizeof(unipwd) );
129
130 if( ( ret = pkcs12_parse_pbe_params( pbe_params, &salt,
131 &iterations ) ) != 0 )
132 return( ret );
133
134 for( i = 0; i < pwdlen; i++ )
135 unipwd[i * 2 + 1] = pwd[i];
136
137 if( ( ret = mbedtls_pkcs12_derivation( key, keylen, unipwd, pwdlen * 2 + 2,
138 salt.p, salt.len, md_type,
139 MBEDTLS_PKCS12_DERIVE_KEY, iterations ) ) != 0 )
140 {
141 return( ret );
142 }
143
144 if( iv == NULL || ivlen == 0 )
145 return( 0 );
146
147 if( ( ret = mbedtls_pkcs12_derivation( iv, ivlen, unipwd, pwdlen * 2 + 2,
148 salt.p, salt.len, md_type,
149 MBEDTLS_PKCS12_DERIVE_IV, iterations ) ) != 0 )
150 {
151 return( ret );
152 }
153 return( 0 );
154}
155
156#undef PKCS12_MAX_PWDLEN
157
159 const unsigned char *pwd, size_t pwdlen,
160 const unsigned char *data, size_t len,
161 unsigned char *output )
162{
163#if !defined(MBEDTLS_ARC4_C)
164 ((void) pbe_params);
165 ((void) mode);
166 ((void) pwd);
167 ((void) pwdlen);
168 ((void) data);
169 ((void) len);
170 ((void) output);
172#else
173 int ret;
174 unsigned char key[16];
176 ((void) mode);
177
179
180 if( ( ret = pkcs12_pbe_derive_key_iv( pbe_params, MBEDTLS_MD_SHA1,
181 pwd, pwdlen,
182 key, 16, NULL, 0 ) ) != 0 )
183 {
184 return( ret );
185 }
186
187 mbedtls_arc4_setup( &ctx, key, 16 );
188 if( ( ret = mbedtls_arc4_crypt( &ctx, len, data, output ) ) != 0 )
189 goto exit;
190
191exit:
192 mbedtls_platform_zeroize( key, sizeof( key ) );
194
195 return( ret );
196#endif /* MBEDTLS_ARC4_C */
197}
198
199int mbedtls_pkcs12_pbe( mbedtls_asn1_buf *pbe_params, int mode,
200 mbedtls_cipher_type_t cipher_type, mbedtls_md_type_t md_type,
201 const unsigned char *pwd, size_t pwdlen,
202 const unsigned char *data, size_t len,
203 unsigned char *output )
204{
205 int ret, keylen = 0;
206 unsigned char key[32];
207 unsigned char iv[16];
208 const mbedtls_cipher_info_t *cipher_info;
209 mbedtls_cipher_context_t cipher_ctx;
210 size_t olen = 0;
211
212 cipher_info = mbedtls_cipher_info_from_type( cipher_type );
213 if( cipher_info == NULL )
215
216 keylen = cipher_info->key_bitlen / 8;
217
218 if( ( ret = pkcs12_pbe_derive_key_iv( pbe_params, md_type, pwd, pwdlen,
219 key, keylen,
220 iv, cipher_info->iv_size ) ) != 0 )
221 {
222 return( ret );
223 }
224
225 mbedtls_cipher_init( &cipher_ctx );
226
227 if( ( ret = mbedtls_cipher_setup( &cipher_ctx, cipher_info ) ) != 0 )
228 goto exit;
229
230 if( ( ret = mbedtls_cipher_setkey( &cipher_ctx, key, 8 * keylen, (mbedtls_operation_t) mode ) ) != 0 )
231 goto exit;
232
233 if( ( ret = mbedtls_cipher_set_iv( &cipher_ctx, iv, cipher_info->iv_size ) ) != 0 )
234 goto exit;
235
236 if( ( ret = mbedtls_cipher_reset( &cipher_ctx ) ) != 0 )
237 goto exit;
238
239 if( ( ret = mbedtls_cipher_update( &cipher_ctx, data, len,
240 output, &olen ) ) != 0 )
241 {
242 goto exit;
243 }
244
245 if( ( ret = mbedtls_cipher_finish( &cipher_ctx, output + olen, &olen ) ) != 0 )
247
248exit:
249 mbedtls_platform_zeroize( key, sizeof( key ) );
250 mbedtls_platform_zeroize( iv, sizeof( iv ) );
251 mbedtls_cipher_free( &cipher_ctx );
252
253 return( ret );
254}
255
256#endif /* MBEDTLS_ASN1_PARSE_C */
257
258static void pkcs12_fill_buffer( unsigned char *data, size_t data_len,
259 const unsigned char *filler, size_t fill_len )
260{
261 unsigned char *p = data;
262 size_t use_len;
263
264 while( data_len > 0 )
265 {
266 use_len = ( data_len > fill_len ) ? fill_len : data_len;
267 memcpy( p, filler, use_len );
268 p += use_len;
269 data_len -= use_len;
270 }
271}
272
273int mbedtls_pkcs12_derivation( unsigned char *data, size_t datalen,
274 const unsigned char *pwd, size_t pwdlen,
275 const unsigned char *salt, size_t saltlen,
276 mbedtls_md_type_t md_type, int id, int iterations )
277{
278 int ret;
279 unsigned int j;
280
281 unsigned char diversifier[128];
282 unsigned char salt_block[128], pwd_block[128], hash_block[128];
283 unsigned char hash_output[MBEDTLS_MD_MAX_SIZE];
284 unsigned char *p;
285 unsigned char c;
286
287 size_t hlen, use_len, v, i;
288
289 const mbedtls_md_info_t *md_info;
291
292 // This version only allows max of 64 bytes of password or salt
293 if( datalen > 128 || pwdlen > 64 || saltlen > 64 )
295
296 md_info = mbedtls_md_info_from_type( md_type );
297 if( md_info == NULL )
299
300 mbedtls_md_init( &md_ctx );
301
302 if( ( ret = mbedtls_md_setup( &md_ctx, md_info, 0 ) ) != 0 )
303 return( ret );
304 hlen = mbedtls_md_get_size( md_info );
305
306 if( hlen <= 32 )
307 v = 64;
308 else
309 v = 128;
310
311 memset( diversifier, (unsigned char) id, v );
312
313 pkcs12_fill_buffer( salt_block, v, salt, saltlen );
314 pkcs12_fill_buffer( pwd_block, v, pwd, pwdlen );
315
316 p = data;
317 while( datalen > 0 )
318 {
319 // Calculate hash( diversifier || salt_block || pwd_block )
320 if( ( ret = mbedtls_md_starts( &md_ctx ) ) != 0 )
321 goto exit;
322
323 if( ( ret = mbedtls_md_update( &md_ctx, diversifier, v ) ) != 0 )
324 goto exit;
325
326 if( ( ret = mbedtls_md_update( &md_ctx, salt_block, v ) ) != 0 )
327 goto exit;
328
329 if( ( ret = mbedtls_md_update( &md_ctx, pwd_block, v ) ) != 0 )
330 goto exit;
331
332 if( ( ret = mbedtls_md_finish( &md_ctx, hash_output ) ) != 0 )
333 goto exit;
334
335 // Perform remaining ( iterations - 1 ) recursive hash calculations
336 for( i = 1; i < (size_t) iterations; i++ )
337 {
338 if( ( ret = mbedtls_md( md_info, hash_output, hlen, hash_output ) ) != 0 )
339 goto exit;
340 }
341
342 use_len = ( datalen > hlen ) ? hlen : datalen;
343 memcpy( p, hash_output, use_len );
344 datalen -= use_len;
345 p += use_len;
346
347 if( datalen == 0 )
348 break;
349
350 // Concatenating copies of hash_output into hash_block (B)
351 pkcs12_fill_buffer( hash_block, v, hash_output, hlen );
352
353 // B += 1
354 for( i = v; i > 0; i-- )
355 if( ++hash_block[i - 1] != 0 )
356 break;
357
358 // salt_block += B
359 c = 0;
360 for( i = v; i > 0; i-- )
361 {
362 j = salt_block[i - 1] + hash_block[i - 1] + c;
363 c = (unsigned char) (j >> 8);
364 salt_block[i - 1] = j & 0xFF;
365 }
366
367 // pwd_block += B
368 c = 0;
369 for( i = v; i > 0; i-- )
370 {
371 j = pwd_block[i - 1] + hash_block[i - 1] + c;
372 c = (unsigned char) (j >> 8);
373 pwd_block[i - 1] = j & 0xFF;
374 }
375 }
376
377 ret = 0;
378
379exit:
380 mbedtls_platform_zeroize( salt_block, sizeof( salt_block ) );
381 mbedtls_platform_zeroize( pwd_block, sizeof( pwd_block ) );
382 mbedtls_platform_zeroize( hash_block, sizeof( hash_block ) );
383 mbedtls_platform_zeroize( hash_output, sizeof( hash_output ) );
384
385 mbedtls_md_free( &md_ctx );
386
387 return( ret );
388}
389
390#endif /* MBEDTLS_PKCS12_C */
The ARCFOUR stream cipher.
int mbedtls_arc4_crypt(mbedtls_arc4_context *ctx, size_t length, const unsigned char *input, unsigned char *output)
ARC4 cipher function.
void mbedtls_arc4_setup(mbedtls_arc4_context *ctx, const unsigned char *key, unsigned int keylen)
ARC4 key schedule.
void mbedtls_arc4_init(mbedtls_arc4_context *ctx)
Initialize ARC4 context.
void mbedtls_arc4_free(mbedtls_arc4_context *ctx)
Clear ARC4 context.
Generic ASN.1 parsing.
void pwd(int argc, const char *argv[])
Definition: cmds.c:1401
This file contains an abstraction interface for use with the cipher primitives provided by the librar...
int mbedtls_cipher_setup(mbedtls_cipher_context_t *ctx, const mbedtls_cipher_info_t *cipher_info)
This function initializes and fills the cipher-context structure with the appropriate values....
mbedtls_cipher_type_t
Supported {cipher type, cipher mode} pairs.
Definition: cipher.h:129
int mbedtls_cipher_setkey(mbedtls_cipher_context_t *ctx, const unsigned char *key, int key_bitlen, const mbedtls_operation_t operation)
This function sets the key to use with the given context.
int mbedtls_cipher_reset(mbedtls_cipher_context_t *ctx)
This function resets the cipher state.
int mbedtls_cipher_set_iv(mbedtls_cipher_context_t *ctx, const unsigned char *iv, size_t iv_len)
This function sets the initialization vector (IV) or nonce.
int mbedtls_cipher_finish(mbedtls_cipher_context_t *ctx, unsigned char *output, size_t *olen)
The generic cipher finalization function. If data still needs to be flushed from an incomplete block,...
void mbedtls_cipher_init(mbedtls_cipher_context_t *ctx)
This function initializes a cipher_context as NONE.
void mbedtls_cipher_free(mbedtls_cipher_context_t *ctx)
This function frees and clears the cipher-specific context of ctx. Freeing ctx itself remains the res...
int mbedtls_cipher_update(mbedtls_cipher_context_t *ctx, const unsigned char *input, size_t ilen, unsigned char *output, size_t *olen)
The generic cipher update function. It encrypts or decrypts using the given cipher context....
mbedtls_operation_t
Definition: cipher.h:231
#define NULL
Definition: types.h:112
unsigned char
Definition: typeof.h:29
__kernel_size_t size_t
Definition: linux.h:237
const GLdouble * v
Definition: gl.h:2040
GLuint GLuint end
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
const GLubyte * c
Definition: glext.h:8905
GLenum mode
Definition: glext.h:6217
GLenum const GLfloat * params
Definition: glext.h:5645
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
size_t len
Definition: asn1.h:162
#define MBEDTLS_ASN1_OCTET_STRING
Definition: asn1.h:100
unsigned char * p
Definition: asn1.h:163
#define MBEDTLS_ASN1_SEQUENCE
Definition: asn1.h:104
int mbedtls_asn1_get_int(unsigned char **p, const unsigned char *end, int *val)
Retrieve an integer ASN.1 tag and its value. Updates the pointer to immediately behind the full tag.
#define MBEDTLS_ASN1_CONSTRUCTED
Definition: asn1.h:114
#define MBEDTLS_ERR_ASN1_UNEXPECTED_TAG
Definition: asn1.h:77
#define MBEDTLS_ERR_ASN1_LENGTH_MISMATCH
Definition: asn1.h:79
int mbedtls_asn1_get_tag(unsigned char **p, const unsigned char *end, size_t *len, int tag)
Get the tag and length of the tag. Check for the requested tag. Updates the pointer to immediately be...
int const JOCTET unsigned int datalen
Definition: jpeglib.h:1031
#define c
Definition: ke_i.h:80
int mbedtls_md_setup(mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info, int hmac)
This function selects the message digest algorithm to use, and allocates internal structures.
mbedtls_md_type_t
Supported message digests.
Definition: md.h:83
@ MBEDTLS_MD_SHA1
Definition: md.h:88
int mbedtls_md_starts(mbedtls_md_context_t *ctx)
This function starts a message-digest computation.
int mbedtls_md(const mbedtls_md_info_t *md_info, const unsigned char *input, size_t ilen, unsigned char *output)
This function calculates the message-digest of a buffer, with respect to a configurable message-diges...
int mbedtls_md_update(mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen)
This function feeds an input buffer into an ongoing message-digest computation.
#define MBEDTLS_MD_MAX_SIZE
Definition: md.h:97
void mbedtls_md_init(mbedtls_md_context_t *ctx)
This function initializes a message-digest context without binding it to a particular message-digest ...
int mbedtls_md_finish(mbedtls_md_context_t *ctx, unsigned char *output)
This function finishes the digest operation, and writes the result to the output buffer.
unsigned char mbedtls_md_get_size(const mbedtls_md_info_t *md_info)
This function extracts the message-digest size from the message-digest information structure.
void mbedtls_md_free(mbedtls_md_context_t *ctx)
This function clears the internal structure of ctx and frees any embedded internal structure,...
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static const char filler[0x1000]
Definition: loader.c:167
PKCS#12 Personal Information Exchange Syntax.
int mbedtls_pkcs12_derivation(unsigned char *data, size_t datalen, const unsigned char *pwd, size_t pwdlen, const unsigned char *salt, size_t saltlen, mbedtls_md_type_t mbedtls_md, int id, int iterations)
The PKCS#12 derivation function uses a password and a salt to produce pseudo-random bits for a partic...
#define MBEDTLS_ERR_PKCS12_PBE_INVALID_FORMAT
Definition: pkcs12.h:66
#define MBEDTLS_ERR_PKCS12_PASSWORD_MISMATCH
Definition: pkcs12.h:67
#define MBEDTLS_ERR_PKCS12_BAD_INPUT_DATA
Definition: pkcs12.h:64
#define MBEDTLS_PKCS12_DERIVE_IV
Definition: pkcs12.h:70
#define MBEDTLS_PKCS12_DERIVE_KEY
Definition: pkcs12.h:69
#define MBEDTLS_ERR_PKCS12_FEATURE_UNAVAILABLE
Definition: pkcs12.h:65
int mbedtls_pkcs12_pbe(mbedtls_asn1_buf *pbe_params, int mode, mbedtls_cipher_type_t cipher_type, mbedtls_md_type_t md_type, const unsigned char *pwd, size_t pwdlen, const unsigned char *input, size_t len, unsigned char *output)
PKCS12 Password Based function (encryption / decryption) for cipher-based and mbedtls_md-based PBE's.
int mbedtls_pkcs12_pbe_sha1_rc4_128(mbedtls_asn1_buf *pbe_params, int mode, const unsigned char *pwd, size_t pwdlen, const unsigned char *input, size_t len, unsigned char *output)
PKCS12 Password Based function (encryption / decryption) for pbeWithSHAAnd128BitRC4.
void mbedtls_platform_zeroize(void *buf, size_t len)
Securely zeroize a buffer.
Definition: platform_util.c:98
Common and shared functions used by multiple modules in the Mbed TLS library.
#define mbedtls_md_info_from_type
#define mbedtls_cipher_info_from_type
Configuration options (set of defines)
DES block cipher.
#define exit(n)
Definition: config.h:202
#define memset(x, y, z)
Definition: compat.h:39
Definition: copy.c:22
ARC4 context structure.
Definition: arc4.h:83
unsigned int key_bitlen
Definition: cipher.h:281
unsigned int iv_size
Definition: cipher.h:290
int ret