mbed TLS v1.3.19
Macros | Functions
pkcs5.h File Reference

PKCS#5 functions. More...

#include "asn1.h"
#include "md.h"
#include <stddef.h>
#include <inttypes.h>
Include dependency graph for pkcs5.h:

Go to the source code of this file.

Macros

#define POLARSSL_ERR_PKCS5_BAD_INPUT_DATA   -0x3f80
 Bad input parameters to function. More...
 
#define POLARSSL_ERR_PKCS5_INVALID_FORMAT   -0x3f00
 Unexpected ASN.1 data. More...
 
#define POLARSSL_ERR_PKCS5_FEATURE_UNAVAILABLE   -0x3e80
 Requested encryption or digest alg not available. More...
 
#define POLARSSL_ERR_PKCS5_PASSWORD_MISMATCH   -0x3e00
 Given private key password does not allow for correct decryption. More...
 
#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. More...
 
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. More...
 
int pkcs5_self_test (int verbose)
 Checkup routine. More...
 

Detailed Description

PKCS#5 functions.

Author
Mathias Olsson mathi.nosp@m.as@k.nosp@m.ompet.nosp@m.ensu.nosp@m.m.com

Copyright (C) 2006-2013, ARM Limited, All Rights Reserved

This file is part of mbed TLS (https://tls.mbed.org)

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.

Macro Definition Documentation

#define PKCS5_DECRYPT   0

Definition at line 46 of file pkcs5.h.

#define PKCS5_ENCRYPT   1

Definition at line 47 of file pkcs5.h.

#define POLARSSL_ERR_PKCS5_BAD_INPUT_DATA   -0x3f80

Bad input parameters to function.

Definition at line 41 of file pkcs5.h.

#define POLARSSL_ERR_PKCS5_FEATURE_UNAVAILABLE   -0x3e80

Requested encryption or digest alg not available.

Definition at line 43 of file pkcs5.h.

#define POLARSSL_ERR_PKCS5_INVALID_FORMAT   -0x3f00

Unexpected ASN.1 data.

Definition at line 42 of file pkcs5.h.

#define POLARSSL_ERR_PKCS5_PASSWORD_MISMATCH   -0x3e00

Given private key password does not allow for correct decryption.

Definition at line 44 of file pkcs5.h.

Function Documentation

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.

Parameters
pbe_paramsthe ASN.1 algorithm parameters
modeeither PKCS5_DECRYPT or PKCS5_ENCRYPT
pwdpassword to use when generating key
pwdlenlength of password
datadata to process
datalenlength of data
outputoutput buffer
Returns
0 on success, or a POLARSSL_ERR_xxx code if verification fails.
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.

Parameters
ctxGeneric HMAC context
passwordPassword to use when generating key
plenLength of password
saltSalt to use when generating key
slenLength of salt
iteration_countIteration count
key_lengthLength of generated key
outputGenerated key. Must be at least as big as key_length
Returns
0 on success, or a POLARSSL_ERR_xxx code if verification fails.
int pkcs5_self_test ( int  verbose)

Checkup routine.

Returns
0 if successful, or 1 if the test failed