PKCS#5 functions. More...
#include <string.h>
#include "asn1.h"
#include "md.h"
#include <inttypes.h>
Go to the source code of this file.
Defines | |
#define | POLARSSL_ERR_PKCS5_BAD_INPUT_DATA -0x3f80 |
Bad input parameters to function. | |
#define | POLARSSL_ERR_PKCS5_INVALID_FORMAT -0x3f00 |
Unexpected ASN.1 data. | |
#define | POLARSSL_ERR_PKCS5_FEATURE_UNAVAILABLE -0x3e80 |
Requested encryption or digest alg not available. | |
#define | POLARSSL_ERR_PKCS5_PASSWORD_MISMATCH -0x3e00 |
Given private key password does not allow for correct decryption. | |
#define | PKCS5_DECRYPT 0 |
#define | PKCS5_ENCRYPT 1 |
Functions | |
int | pkcs5_pbes2 (asn1_buf *pbe_params, int mode, const unsigned char *pwd, size_t pwdlen, const unsigned char *data, size_t datalen, unsigned char *output) |
PKCS#5 PBES2 function. | |
int | pkcs5_pbkdf2_hmac (md_context_t *ctx, const unsigned char *password, size_t plen, const unsigned char *salt, size_t slen, unsigned int iteration_count, uint32_t key_length, unsigned char *output) |
PKCS#5 PBKDF2 using HMAC. | |
int | pkcs5_self_test (int verbose) |
Checkup routine. |
PKCS#5 functions.
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 pkcs5.h.
#define PKCS5_DECRYPT 0 |
Definition at line 49 of file pkcs5.h.
Referenced by pk_parse_key_pkcs8_encrypted_der().
#define POLARSSL_ERR_PKCS5_BAD_INPUT_DATA -0x3f80 |
Bad input parameters to function.
Definition at line 44 of file pkcs5.h.
Referenced by pkcs5_pbkdf2_hmac(), and polarssl_strerror().
#define POLARSSL_ERR_PKCS5_FEATURE_UNAVAILABLE -0x3e80 |
Requested encryption or digest alg not available.
Definition at line 46 of file pkcs5.h.
Referenced by pkcs5_parse_pbkdf2_params(), pkcs5_pbes2(), and polarssl_strerror().
#define POLARSSL_ERR_PKCS5_INVALID_FORMAT -0x3f00 |
Unexpected ASN.1 data.
Definition at line 45 of file pkcs5.h.
Referenced by pkcs5_parse_pbkdf2_params(), pkcs5_pbes2(), and polarssl_strerror().
#define POLARSSL_ERR_PKCS5_PASSWORD_MISMATCH -0x3e00 |
Given private key password does not allow for correct decryption.
Definition at line 47 of file pkcs5.h.
Referenced by pk_parse_key_pkcs8_encrypted_der(), pkcs5_pbes2(), and polarssl_strerror().
int pkcs5_pbes2 | ( | asn1_buf * | pbe_params, | |
int | mode, | |||
const unsigned char * | pwd, | |||
size_t | pwdlen, | |||
const unsigned char * | data, | |||
size_t | datalen, | |||
unsigned char * | output | |||
) |
PKCS#5 PBES2 function.
pbe_params | the ASN.1 algorithm parameters | |
mode | either PKCS5_DECRYPT or PKCS5_ENCRYPT | |
pwd | password to use when generating key | |
pwdlen | length of password | |
data | data to process | |
datalen | length of data | |
output | output buffer |
Definition at line 102 of file pkcs5.c.
References ASN1_CONSTRUCTED, asn1_get_alg(), ASN1_OCTET_STRING, ASN1_SEQUENCE, cipher_finish(), cipher_free_ctx(), cipher_info_from_type(), cipher_init_ctx(), cipher_reset(), cipher_set_iv(), cipher_setkey(), cipher_update(), iv, cipher_info_t::iv_size, key, cipher_info_t::key_length, _asn1_buf::len, md_free_ctx(), md_info_from_type(), md_init_ctx(), OID_CMP, oid_get_cipher_alg(), OID_PKCS5_PBKDF2, _asn1_buf::p, pkcs5_parse_pbkdf2_params(), pkcs5_pbkdf2_hmac(), POLARSSL_ERR_ASN1_UNEXPECTED_TAG, POLARSSL_ERR_PKCS5_FEATURE_UNAVAILABLE, POLARSSL_ERR_PKCS5_INVALID_FORMAT, POLARSSL_ERR_PKCS5_PASSWORD_MISMATCH, POLARSSL_MD_SHA1, salt, and _asn1_buf::tag.
Referenced by pk_parse_key_pkcs8_encrypted_der().
int pkcs5_pbkdf2_hmac | ( | md_context_t * | ctx, | |
const unsigned char * | password, | |||
size_t | plen, | |||
const unsigned char * | salt, | |||
size_t | slen, | |||
unsigned int | iteration_count, | |||
uint32_t | key_length, | |||
unsigned char * | output | |||
) |
PKCS#5 PBKDF2 using HMAC.
ctx | Generic HMAC context | |
password | Password to use when generating key | |
plen | Length of password | |
salt | Salt to use when generating key | |
slen | Length of salt | |
iteration_count | Iteration count | |
key_length | Length of generated key | |
output | Generated key. Must be at least as big as key_length |
Definition at line 212 of file pkcs5.c.
References md_get_size(), md_hmac_finish(), md_hmac_starts(), md_hmac_update(), md_context_t::md_info, POLARSSL_ERR_PKCS5_BAD_INPUT_DATA, and POLARSSL_MD_MAX_SIZE.
Referenced by pbkdf2_hmac(), pkcs5_pbes2(), pkcs5_self_test(), and test_suite_pbkdf2_hmac().
int pkcs5_self_test | ( | int | verbose | ) |
Checkup routine.
Definition at line 344 of file pkcs5.c.
References it_cnt, key, key_len, MAX_TESTS, md_free_ctx(), md_info_from_type(), md_init_ctx(), password, pkcs5_pbkdf2_hmac(), plen, POLARSSL_MD_SHA1, result_key, salt, and slen.
Referenced by pbkdf2_self_test().