Privacy Enhanced Mail (PEM) decoding. More...
#include <string.h>
Go to the source code of this file.
Data Structures | |
struct | pem_context |
PEM context structure. More... | |
Defines | |
PEM Error codes | |
#define | POLARSSL_ERR_PEM_NO_HEADER_FOOTER_PRESENT -0x1080 |
No PEM header or footer found. | |
#define | POLARSSL_ERR_PEM_INVALID_DATA -0x1100 |
PEM string is not as expected. | |
#define | POLARSSL_ERR_PEM_MALLOC_FAILED -0x1180 |
Failed to allocate memory. | |
#define | POLARSSL_ERR_PEM_INVALID_ENC_IV -0x1200 |
RSA IV is not in hex-format. | |
#define | POLARSSL_ERR_PEM_UNKNOWN_ENC_ALG -0x1280 |
Unsupported key encryption algorithm. | |
#define | POLARSSL_ERR_PEM_PASSWORD_REQUIRED -0x1300 |
Private key password can't be empty. | |
#define | POLARSSL_ERR_PEM_PASSWORD_MISMATCH -0x1380 |
Given private key password does not allow for correct decryption. | |
#define | POLARSSL_ERR_PEM_FEATURE_UNAVAILABLE -0x1400 |
Unavailable feature, e.g. | |
#define | POLARSSL_ERR_PEM_BAD_INPUT_DATA -0x1480 |
Bad input parameters to function. | |
Functions | |
void | pem_init (pem_context *ctx) |
PEM context setup. | |
int | pem_read_buffer (pem_context *ctx, const char *header, const char *footer, const unsigned char *data, const unsigned char *pwd, size_t pwdlen, size_t *use_len) |
Read a buffer for PEM information and store the resulting data into the specified context buffers. | |
void | pem_free (pem_context *ctx) |
PEM context memory freeing. | |
int | pem_write_buffer (const char *header, const char *footer, const unsigned char *der_data, size_t der_len, unsigned char *buf, size_t buf_len, size_t *olen) |
Write a buffer of PEM information from a DER encoded buffer. |
Privacy Enhanced Mail (PEM) decoding.
Copyright (C) 2006-2013, Brainspark B.V.
This file is part of PolarSSL (http://www.polarssl.org) Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
All rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Definition in file pem.h.
#define POLARSSL_ERR_PEM_BAD_INPUT_DATA -0x1480 |
Bad input parameters to function.
Definition at line 46 of file pem.h.
Referenced by pem_read_buffer(), polarssl_strerror(), and x509_crt_parse().
#define POLARSSL_ERR_PEM_FEATURE_UNAVAILABLE -0x1400 |
Unavailable feature, e.g.
hashing/encryption combination.
Definition at line 45 of file pem.h.
Referenced by pem_read_buffer(), and polarssl_strerror().
#define POLARSSL_ERR_PEM_INVALID_DATA -0x1100 |
PEM string is not as expected.
Definition at line 39 of file pem.h.
Referenced by pem_read_buffer(), and polarssl_strerror().
#define POLARSSL_ERR_PEM_INVALID_ENC_IV -0x1200 |
RSA IV is not in hex-format.
Definition at line 41 of file pem.h.
Referenced by pem_get_iv(), pem_read_buffer(), and polarssl_strerror().
#define POLARSSL_ERR_PEM_MALLOC_FAILED -0x1180 |
Failed to allocate memory.
Definition at line 40 of file pem.h.
Referenced by pem_read_buffer(), pem_write_buffer(), and polarssl_strerror().
#define POLARSSL_ERR_PEM_NO_HEADER_FOOTER_PRESENT -0x1080 |
No PEM header or footer found.
Definition at line 38 of file pem.h.
Referenced by dhm_parse_dhm(), pem_read_buffer(), pk_parse_key(), pk_parse_public_key(), polarssl_strerror(), x509_crl_parse(), x509_crt_parse(), and x509_csr_parse().
#define POLARSSL_ERR_PEM_PASSWORD_MISMATCH -0x1380 |
Given private key password does not allow for correct decryption.
Definition at line 44 of file pem.h.
Referenced by pem_read_buffer(), pk_parse_key(), and polarssl_strerror().
#define POLARSSL_ERR_PEM_PASSWORD_REQUIRED -0x1300 |
Private key password can't be empty.
Definition at line 43 of file pem.h.
Referenced by pem_read_buffer(), pk_parse_key(), and polarssl_strerror().
#define POLARSSL_ERR_PEM_UNKNOWN_ENC_ALG -0x1280 |
Unsupported key encryption algorithm.
Definition at line 42 of file pem.h.
Referenced by pem_read_buffer(), and polarssl_strerror().
void pem_free | ( | pem_context * | ctx | ) |
PEM context memory freeing.
ctx | context to be freed |
Definition at line 366 of file pem.c.
References pem_context::buf, pem_context::info, and polarssl_free.
Referenced by dhm_parse_dhm(), pk_parse_key(), pk_parse_public_key(), x509_crl_parse(), x509_crt_parse(), and x509_csr_parse().
void pem_init | ( | pem_context * | ctx | ) |
PEM context setup.
ctx | context to be initialized |
Definition at line 46 of file pem.c.
Referenced by dhm_parse_dhm(), pk_parse_key(), pk_parse_public_key(), x509_crl_parse(), x509_crt_parse(), and x509_csr_parse().
int pem_read_buffer | ( | pem_context * | ctx, | |
const char * | header, | |||
const char * | footer, | |||
const unsigned char * | data, | |||
const unsigned char * | pwd, | |||
size_t | pwdlen, | |||
size_t * | use_len | |||
) |
Read a buffer for PEM information and store the resulting data into the specified context buffers.
ctx | context to use | |
header | header string to seek and expect | |
footer | footer string to seek and expect | |
data | source data to look in | |
pwd | password for decryption (can be NULL) | |
pwdlen | length of password | |
use_len | destination for total length used (set after header is correctly read, so unless you get POLARSSL_ERR_PEM_BAD_INPUT_DATA or POLARSSL_ERR_PEM_NO_HEADER_FOOTER_PRESENT, use_len is the length to skip) |
Definition at line 190 of file pem.c.
References base64_decode(), pem_context::buf, pem_context::buflen, pem_aes_decrypt(), pem_des3_decrypt(), pem_des_decrypt(), pem_get_iv(), POLARSSL_CIPHER_AES_128_CBC, POLARSSL_CIPHER_AES_192_CBC, POLARSSL_CIPHER_AES_256_CBC, POLARSSL_CIPHER_DES_CBC, POLARSSL_CIPHER_DES_EDE3_CBC, POLARSSL_CIPHER_NONE, POLARSSL_ERR_BASE64_INVALID_CHARACTER, POLARSSL_ERR_PEM_BAD_INPUT_DATA, POLARSSL_ERR_PEM_FEATURE_UNAVAILABLE, POLARSSL_ERR_PEM_INVALID_DATA, POLARSSL_ERR_PEM_INVALID_ENC_IV, POLARSSL_ERR_PEM_MALLOC_FAILED, POLARSSL_ERR_PEM_NO_HEADER_FOOTER_PRESENT, POLARSSL_ERR_PEM_PASSWORD_MISMATCH, POLARSSL_ERR_PEM_PASSWORD_REQUIRED, POLARSSL_ERR_PEM_UNKNOWN_ENC_ALG, polarssl_free, and polarssl_malloc.
Referenced by dhm_parse_dhm(), pk_parse_key(), pk_parse_public_key(), x509_crl_parse(), x509_crt_parse(), and x509_csr_parse().
int pem_write_buffer | ( | const char * | header, | |
const char * | footer, | |||
const unsigned char * | der_data, | |||
size_t | der_len, | |||
unsigned char * | buf, | |||
size_t | buf_len, | |||
size_t * | olen | |||
) |
Write a buffer of PEM information from a DER encoded buffer.
header | header string to write | |
footer | footer string to write | |
der_data | DER data to write | |
der_len | length of the DER data | |
buf | buffer to write to | |
buf_len | length of output buffer | |
olen | total length written / required (if buf_len is not enough) |
Definition at line 379 of file pem.c.
References add_len, base64_encode(), POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL, POLARSSL_ERR_PEM_MALLOC_FAILED, polarssl_free, and polarssl_malloc.
Referenced by pk_write_key_pem(), pk_write_pubkey_pem(), x509write_crt_pem(), and x509write_csr_pem().