ReactOS 0.4.15-dev-8222-g9164419
pem.c
Go to the documentation of this file.
1/*
2 * Privacy Enhanced Mail (PEM) decoding
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#if !defined(MBEDTLS_CONFIG_FILE)
48#include "mbedtls/config.h"
49#else
50#include MBEDTLS_CONFIG_FILE
51#endif
52
53#if defined(MBEDTLS_PEM_PARSE_C) || defined(MBEDTLS_PEM_WRITE_C)
54
55#include "mbedtls/pem.h"
56#include "mbedtls/base64.h"
57#include "mbedtls/des.h"
58#include "mbedtls/aes.h"
59#include "mbedtls/md5.h"
60#include "mbedtls/cipher.h"
62
63#include <string.h>
64
65#if defined(MBEDTLS_PLATFORM_C)
66#include "mbedtls/platform.h"
67#else
68#include <stdlib.h>
69#define mbedtls_calloc calloc
70#define mbedtls_free free
71#endif
72
73#if defined(MBEDTLS_PEM_PARSE_C)
74void mbedtls_pem_init( mbedtls_pem_context *ctx )
75{
76 memset( ctx, 0, sizeof( mbedtls_pem_context ) );
77}
78
79#if defined(MBEDTLS_MD5_C) && defined(MBEDTLS_CIPHER_MODE_CBC) && \
80 ( defined(MBEDTLS_DES_C) || defined(MBEDTLS_AES_C) )
81/*
82 * Read a 16-byte hex string and convert it to binary
83 */
84static int pem_get_iv( const unsigned char *s, unsigned char *iv,
85 size_t iv_len )
86{
87 size_t i, j, k;
88
89 memset( iv, 0, iv_len );
90
91 for( i = 0; i < iv_len * 2; i++, s++ )
92 {
93 if( *s >= '0' && *s <= '9' ) j = *s - '0'; else
94 if( *s >= 'A' && *s <= 'F' ) j = *s - '7'; else
95 if( *s >= 'a' && *s <= 'f' ) j = *s - 'W'; else
97
98 k = ( ( i & 1 ) != 0 ) ? j : j << 4;
99
100 iv[i >> 1] = (unsigned char)( iv[i >> 1] | k );
101 }
102
103 return( 0 );
104}
105
106static int pem_pbkdf1( unsigned char *key, size_t keylen,
107 unsigned char *iv,
108 const unsigned char *pwd, size_t pwdlen )
109{
110 mbedtls_md5_context md5_ctx;
111 unsigned char md5sum[16];
112 size_t use_len;
113 int ret;
114
115 mbedtls_md5_init( &md5_ctx );
116
117 /*
118 * key[ 0..15] = MD5(pwd || IV)
119 */
120 if( ( ret = mbedtls_md5_starts_ret( &md5_ctx ) ) != 0 )
121 goto exit;
122 if( ( ret = mbedtls_md5_update_ret( &md5_ctx, pwd, pwdlen ) ) != 0 )
123 goto exit;
124 if( ( ret = mbedtls_md5_update_ret( &md5_ctx, iv, 8 ) ) != 0 )
125 goto exit;
126 if( ( ret = mbedtls_md5_finish_ret( &md5_ctx, md5sum ) ) != 0 )
127 goto exit;
128
129 if( keylen <= 16 )
130 {
131 memcpy( key, md5sum, keylen );
132 goto exit;
133 }
134
135 memcpy( key, md5sum, 16 );
136
137 /*
138 * key[16..23] = MD5(key[ 0..15] || pwd || IV])
139 */
140 if( ( ret = mbedtls_md5_starts_ret( &md5_ctx ) ) != 0 )
141 goto exit;
142 if( ( ret = mbedtls_md5_update_ret( &md5_ctx, md5sum, 16 ) ) != 0 )
143 goto exit;
144 if( ( ret = mbedtls_md5_update_ret( &md5_ctx, pwd, pwdlen ) ) != 0 )
145 goto exit;
146 if( ( ret = mbedtls_md5_update_ret( &md5_ctx, iv, 8 ) ) != 0 )
147 goto exit;
148 if( ( ret = mbedtls_md5_finish_ret( &md5_ctx, md5sum ) ) != 0 )
149 goto exit;
150
151 use_len = 16;
152 if( keylen < 32 )
153 use_len = keylen - 16;
154
155 memcpy( key + 16, md5sum, use_len );
156
157exit:
158 mbedtls_md5_free( &md5_ctx );
159 mbedtls_platform_zeroize( md5sum, 16 );
160
161 return( ret );
162}
163
164#if defined(MBEDTLS_DES_C)
165/*
166 * Decrypt with DES-CBC, using PBKDF1 for key derivation
167 */
168static int pem_des_decrypt( unsigned char des_iv[8],
169 unsigned char *buf, size_t buflen,
170 const unsigned char *pwd, size_t pwdlen )
171{
172 mbedtls_des_context des_ctx;
173 unsigned char des_key[8];
174 int ret;
175
176 mbedtls_des_init( &des_ctx );
177
178 if( ( ret = pem_pbkdf1( des_key, 8, des_iv, pwd, pwdlen ) ) != 0 )
179 goto exit;
180
181 if( ( ret = mbedtls_des_setkey_dec( &des_ctx, des_key ) ) != 0 )
182 goto exit;
183 ret = mbedtls_des_crypt_cbc( &des_ctx, MBEDTLS_DES_DECRYPT, buflen,
184 des_iv, buf, buf );
185
186exit:
187 mbedtls_des_free( &des_ctx );
189
190 return( ret );
191}
192
193/*
194 * Decrypt with 3DES-CBC, using PBKDF1 for key derivation
195 */
196static int pem_des3_decrypt( unsigned char des3_iv[8],
197 unsigned char *buf, size_t buflen,
198 const unsigned char *pwd, size_t pwdlen )
199{
200 mbedtls_des3_context des3_ctx;
201 unsigned char des3_key[24];
202 int ret;
203
204 mbedtls_des3_init( &des3_ctx );
205
206 if( ( ret = pem_pbkdf1( des3_key, 24, des3_iv, pwd, pwdlen ) ) != 0 )
207 goto exit;
208
209 if( ( ret = mbedtls_des3_set3key_dec( &des3_ctx, des3_key ) ) != 0 )
210 goto exit;
211 ret = mbedtls_des3_crypt_cbc( &des3_ctx, MBEDTLS_DES_DECRYPT, buflen,
212 des3_iv, buf, buf );
213
214exit:
215 mbedtls_des3_free( &des3_ctx );
217
218 return( ret );
219}
220#endif /* MBEDTLS_DES_C */
221
222#if defined(MBEDTLS_AES_C)
223/*
224 * Decrypt with AES-XXX-CBC, using PBKDF1 for key derivation
225 */
226static int pem_aes_decrypt( unsigned char aes_iv[16], unsigned int keylen,
227 unsigned char *buf, size_t buflen,
228 const unsigned char *pwd, size_t pwdlen )
229{
230 mbedtls_aes_context aes_ctx;
231 unsigned char aes_key[32];
232 int ret;
233
234 mbedtls_aes_init( &aes_ctx );
235
236 if( ( ret = pem_pbkdf1( aes_key, keylen, aes_iv, pwd, pwdlen ) ) != 0 )
237 goto exit;
238
239 if( ( ret = mbedtls_aes_setkey_dec( &aes_ctx, aes_key, keylen * 8 ) ) != 0 )
240 goto exit;
241 ret = mbedtls_aes_crypt_cbc( &aes_ctx, MBEDTLS_AES_DECRYPT, buflen,
242 aes_iv, buf, buf );
243
244exit:
245 mbedtls_aes_free( &aes_ctx );
247
248 return( ret );
249}
250#endif /* MBEDTLS_AES_C */
251
252#endif /* MBEDTLS_MD5_C && MBEDTLS_CIPHER_MODE_CBC &&
253 ( MBEDTLS_AES_C || MBEDTLS_DES_C ) */
254
255int mbedtls_pem_read_buffer( mbedtls_pem_context *ctx, const char *header, const char *footer,
256 const unsigned char *data, const unsigned char *pwd,
257 size_t pwdlen, size_t *use_len )
258{
259 int ret, enc;
260 size_t len;
261 unsigned char *buf;
262 const unsigned char *s1, *s2, *end;
263#if defined(MBEDTLS_MD5_C) && defined(MBEDTLS_CIPHER_MODE_CBC) && \
264 ( defined(MBEDTLS_DES_C) || defined(MBEDTLS_AES_C) )
265 unsigned char pem_iv[16];
267#else
268 ((void) pwd);
269 ((void) pwdlen);
270#endif /* MBEDTLS_MD5_C && MBEDTLS_CIPHER_MODE_CBC &&
271 ( MBEDTLS_AES_C || MBEDTLS_DES_C ) */
272
273 if( ctx == NULL )
275
276 s1 = (unsigned char *) strstr( (const char *) data, header );
277
278 if( s1 == NULL )
280
281 s2 = (unsigned char *) strstr( (const char *) data, footer );
282
283 if( s2 == NULL || s2 <= s1 )
285
286 s1 += strlen( header );
287 if( *s1 == ' ' ) s1++;
288 if( *s1 == '\r' ) s1++;
289 if( *s1 == '\n' ) s1++;
291
292 end = s2;
293 end += strlen( footer );
294 if( *end == ' ' ) end++;
295 if( *end == '\r' ) end++;
296 if( *end == '\n' ) end++;
297 *use_len = end - data;
298
299 enc = 0;
300
301 if( s2 - s1 >= 22 && memcmp( s1, "Proc-Type: 4,ENCRYPTED", 22 ) == 0 )
302 {
303#if defined(MBEDTLS_MD5_C) && defined(MBEDTLS_CIPHER_MODE_CBC) && \
304 ( defined(MBEDTLS_DES_C) || defined(MBEDTLS_AES_C) )
305 enc++;
306
307 s1 += 22;
308 if( *s1 == '\r' ) s1++;
309 if( *s1 == '\n' ) s1++;
310 else return( MBEDTLS_ERR_PEM_INVALID_DATA );
311
312
313#if defined(MBEDTLS_DES_C)
314 if( s2 - s1 >= 23 && memcmp( s1, "DEK-Info: DES-EDE3-CBC,", 23 ) == 0 )
315 {
317
318 s1 += 23;
319 if( s2 - s1 < 16 || pem_get_iv( s1, pem_iv, 8 ) != 0 )
321
322 s1 += 16;
323 }
324 else if( s2 - s1 >= 18 && memcmp( s1, "DEK-Info: DES-CBC,", 18 ) == 0 )
325 {
326 enc_alg = MBEDTLS_CIPHER_DES_CBC;
327
328 s1 += 18;
329 if( s2 - s1 < 16 || pem_get_iv( s1, pem_iv, 8) != 0 )
331
332 s1 += 16;
333 }
334#endif /* MBEDTLS_DES_C */
335
336#if defined(MBEDTLS_AES_C)
337 if( s2 - s1 >= 14 && memcmp( s1, "DEK-Info: AES-", 14 ) == 0 )
338 {
339 if( s2 - s1 < 22 )
341 else if( memcmp( s1, "DEK-Info: AES-128-CBC,", 22 ) == 0 )
343 else if( memcmp( s1, "DEK-Info: AES-192-CBC,", 22 ) == 0 )
345 else if( memcmp( s1, "DEK-Info: AES-256-CBC,", 22 ) == 0 )
347 else
349
350 s1 += 22;
351 if( s2 - s1 < 32 || pem_get_iv( s1, pem_iv, 16 ) != 0 )
353
354 s1 += 32;
355 }
356#endif /* MBEDTLS_AES_C */
357
358 if( enc_alg == MBEDTLS_CIPHER_NONE )
360
361 if( *s1 == '\r' ) s1++;
362 if( *s1 == '\n' ) s1++;
363 else return( MBEDTLS_ERR_PEM_INVALID_DATA );
364#else
366#endif /* MBEDTLS_MD5_C && MBEDTLS_CIPHER_MODE_CBC &&
367 ( MBEDTLS_AES_C || MBEDTLS_DES_C ) */
368 }
369
370 if( s1 >= s2 )
372
373 ret = mbedtls_base64_decode( NULL, 0, &len, s1, s2 - s1 );
374
377
378 if( ( buf = mbedtls_calloc( 1, len ) ) == NULL )
380
381 if( ( ret = mbedtls_base64_decode( buf, len, &len, s1, s2 - s1 ) ) != 0 )
382 {
384 mbedtls_free( buf );
386 }
387
388 if( enc != 0 )
389 {
390#if defined(MBEDTLS_MD5_C) && defined(MBEDTLS_CIPHER_MODE_CBC) && \
391 ( defined(MBEDTLS_DES_C) || defined(MBEDTLS_AES_C) )
392 if( pwd == NULL )
393 {
395 mbedtls_free( buf );
397 }
398
399 ret = 0;
400
401#if defined(MBEDTLS_DES_C)
402 if( enc_alg == MBEDTLS_CIPHER_DES_EDE3_CBC )
403 ret = pem_des3_decrypt( pem_iv, buf, len, pwd, pwdlen );
404 else if( enc_alg == MBEDTLS_CIPHER_DES_CBC )
405 ret = pem_des_decrypt( pem_iv, buf, len, pwd, pwdlen );
406#endif /* MBEDTLS_DES_C */
407
408#if defined(MBEDTLS_AES_C)
409 if( enc_alg == MBEDTLS_CIPHER_AES_128_CBC )
410 ret = pem_aes_decrypt( pem_iv, 16, buf, len, pwd, pwdlen );
411 else if( enc_alg == MBEDTLS_CIPHER_AES_192_CBC )
412 ret = pem_aes_decrypt( pem_iv, 24, buf, len, pwd, pwdlen );
413 else if( enc_alg == MBEDTLS_CIPHER_AES_256_CBC )
414 ret = pem_aes_decrypt( pem_iv, 32, buf, len, pwd, pwdlen );
415#endif /* MBEDTLS_AES_C */
416
417 if( ret != 0 )
418 {
419 mbedtls_free( buf );
420 return( ret );
421 }
422
423 /*
424 * The result will be ASN.1 starting with a SEQUENCE tag, with 1 to 3
425 * length bytes (allow 4 to be sure) in all known use cases.
426 *
427 * Use that as a heuristic to try to detect password mismatches.
428 */
429 if( len <= 2 || buf[0] != 0x30 || buf[1] > 0x83 )
430 {
432 mbedtls_free( buf );
434 }
435#else
437 mbedtls_free( buf );
439#endif /* MBEDTLS_MD5_C && MBEDTLS_CIPHER_MODE_CBC &&
440 ( MBEDTLS_AES_C || MBEDTLS_DES_C ) */
441 }
442
443 ctx->buf = buf;
444 ctx->buflen = len;
445
446 return( 0 );
447}
448
449void mbedtls_pem_free( mbedtls_pem_context *ctx )
450{
451 if ( ctx->buf != NULL )
452 {
453 mbedtls_platform_zeroize( ctx->buf, ctx->buflen );
454 mbedtls_free( ctx->buf );
455 }
456 mbedtls_free( ctx->info );
457
458 mbedtls_platform_zeroize( ctx, sizeof( mbedtls_pem_context ) );
459}
460#endif /* MBEDTLS_PEM_PARSE_C */
461
462#if defined(MBEDTLS_PEM_WRITE_C)
463int mbedtls_pem_write_buffer( const char *header, const char *footer,
464 const unsigned char *der_data, size_t der_len,
465 unsigned char *buf, size_t buf_len, size_t *olen )
466{
467 int ret;
468 unsigned char *encode_buf = NULL, *c, *p = buf;
469 size_t len = 0, use_len, add_len = 0;
470
471 mbedtls_base64_encode( NULL, 0, &use_len, der_data, der_len );
472 add_len = strlen( header ) + strlen( footer ) + ( use_len / 64 ) + 1;
473
474 if( use_len + add_len > buf_len )
475 {
476 *olen = use_len + add_len;
478 }
479
480 if( use_len != 0 &&
481 ( ( encode_buf = mbedtls_calloc( 1, use_len ) ) == NULL ) )
483
484 if( ( ret = mbedtls_base64_encode( encode_buf, use_len, &use_len, der_data,
485 der_len ) ) != 0 )
486 {
487 mbedtls_free( encode_buf );
488 return( ret );
489 }
490
491 memcpy( p, header, strlen( header ) );
492 p += strlen( header );
493 c = encode_buf;
494
495 while( use_len )
496 {
497 len = ( use_len > 64 ) ? 64 : use_len;
498 memcpy( p, c, len );
499 use_len -= len;
500 p += len;
501 c += len;
502 *p++ = '\n';
503 }
504
505 memcpy( p, footer, strlen( footer ) );
506 p += strlen( footer );
507
508 *p++ = '\0';
509 *olen = p - buf;
510
511 /* Clean any remaining data previously written to the buffer */
512 memset( buf + *olen, 0, buf_len - *olen );
513
514 mbedtls_free( encode_buf );
515 return( 0 );
516}
517#endif /* MBEDTLS_PEM_WRITE_C */
518#endif /* MBEDTLS_PEM_PARSE_C || MBEDTLS_PEM_WRITE_C */
519
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
This file contains AES definitions and functions.
int mbedtls_aes_setkey_dec(mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits)
This function sets the decryption key.
int mbedtls_aes_crypt_cbc(mbedtls_aes_context *ctx, int mode, size_t length, unsigned char iv[16], const unsigned char *input, unsigned char *output)
This function performs an AES-CBC encryption or decryption operation on full blocks.
void mbedtls_aes_init(mbedtls_aes_context *ctx)
This function initializes the specified AES context.
#define MBEDTLS_AES_DECRYPT
Definition: aes.h:81
void mbedtls_aes_free(mbedtls_aes_context *ctx)
This function releases and clears the specified AES context.
RFC 1521 base64 encoding/decoding.
int mbedtls_base64_decode(unsigned char *dst, size_t dlen, size_t *olen, const unsigned char *src, size_t slen)
Decode a base64-formatted buffer.
int mbedtls_base64_encode(unsigned char *dst, size_t dlen, size_t *olen, const unsigned char *src, size_t slen)
Encode a buffer into base64 format.
#define MBEDTLS_ERR_BASE64_INVALID_CHARACTER
Definition: base64.h:61
#define MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL
Definition: base64.h:60
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...
mbedtls_cipher_type_t
Supported {cipher type, cipher mode} pairs.
Definition: cipher.h:129
@ MBEDTLS_CIPHER_DES_EDE3_CBC
Definition: cipher.h:167
@ MBEDTLS_CIPHER_AES_128_CBC
Definition: cipher.h:135
@ MBEDTLS_CIPHER_DES_CBC
Definition: cipher.h:163
@ MBEDTLS_CIPHER_NONE
Definition: cipher.h:130
@ MBEDTLS_CIPHER_AES_192_CBC
Definition: cipher.h:136
@ MBEDTLS_CIPHER_AES_256_CBC
Definition: cipher.h:137
#define NULL
Definition: types.h:112
unsigned char
Definition: typeof.h:29
GLdouble s
Definition: gl.h:2039
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 GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
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
#define c
Definition: ke_i.h:80
struct S1 s1
struct S2 s2
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
int k
Definition: mpi.c:3369
Privacy Enhanced Mail (PEM) decoding.
#define MBEDTLS_ERR_PEM_UNKNOWN_ENC_ALG
Definition: pem.h:70
#define MBEDTLS_ERR_PEM_FEATURE_UNAVAILABLE
Definition: pem.h:73
#define MBEDTLS_ERR_PEM_BAD_INPUT_DATA
Definition: pem.h:74
#define MBEDTLS_ERR_PEM_INVALID_ENC_IV
Definition: pem.h:69
#define MBEDTLS_ERR_PEM_INVALID_DATA
Definition: pem.h:67
#define MBEDTLS_ERR_PEM_ALLOC_FAILED
Definition: pem.h:68
#define MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT
Definition: pem.h:66
#define MBEDTLS_ERR_PEM_PASSWORD_REQUIRED
Definition: pem.h:71
#define MBEDTLS_ERR_PEM_PASSWORD_MISMATCH
Definition: pem.h:72
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.
Configuration options (set of defines)
DES block cipher.
void mbedtls_des_init(mbedtls_des_context *ctx)
Initialize DES context.
int mbedtls_des_setkey_dec(mbedtls_des_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE])
DES key schedule (56-bit, decryption)
void mbedtls_des3_free(mbedtls_des3_context *ctx)
Clear Triple-DES context.
int mbedtls_des3_crypt_cbc(mbedtls_des3_context *ctx, int mode, size_t length, unsigned char iv[8], const unsigned char *input, unsigned char *output)
3DES-CBC buffer encryption/decryption
int mbedtls_des_crypt_cbc(mbedtls_des_context *ctx, int mode, size_t length, unsigned char iv[8], const unsigned char *input, unsigned char *output)
DES-CBC buffer encryption/decryption.
void mbedtls_des3_init(mbedtls_des3_context *ctx)
Initialize Triple-DES context.
#define MBEDTLS_DES_DECRYPT
Definition: des.h:67
int mbedtls_des3_set3key_dec(mbedtls_des3_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE *3])
Triple-DES key schedule (168-bit, decryption)
void mbedtls_des_free(mbedtls_des_context *ctx)
Clear DES context.
MD5 message digest algorithm (hash function)
void mbedtls_md5_free(mbedtls_md5_context *ctx)
Clear MD5 context.
int mbedtls_md5_starts_ret(mbedtls_md5_context *ctx)
MD5 context setup.
void mbedtls_md5_init(mbedtls_md5_context *ctx)
Initialize MD5 context.
int mbedtls_md5_update_ret(mbedtls_md5_context *ctx, const unsigned char *input, size_t ilen)
MD5 process buffer.
int mbedtls_md5_finish_ret(mbedtls_md5_context *ctx, unsigned char output[16])
MD5 final digest.
This file contains the definitions and functions of the Mbed TLS platform abstraction layer.
#define mbedtls_free
Definition: platform.h:168
#define mbedtls_calloc
Definition: platform.h:169
#define exit(n)
Definition: config.h:202
#define memset(x, y, z)
Definition: compat.h:39
Definition: copy.c:22
The AES context-type definition.
Definition: aes.h:113
Triple-DES context structure.
Definition: des.h:101
DES context structure.
Definition: des.h:92
MD5 context structure.
Definition: md5.h:85
int ret