PolarSSL v1.2.9
Macros | Functions
pkcs5.h File Reference
#include <string.h>
#include "asn1.h"
#include "md.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
 
#define OID_PKCS5   "\x2a\x86\x48\x86\xf7\x0d\x01\x05"
 
#define OID_PKCS5_PBES2   OID_PKCS5 "\x0d"
 
#define OID_PKCS5_PBKDF2   OID_PKCS5 "\x0c"
 
#define OID_DES_CBC   "\x2b\x0e\x03\x02\x07"
 
#define OID_DES_EDE3_CBC   "\x2a\x86\x48\x86\xf7\x0d\x03\x07"
 
#define OID_HMAC_SHA1   "\x2a\x86\x48\x86\xf7\x0d\x02\x07"
 

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...
 

Macro Definition Documentation

#define OID_DES_CBC   "\x2b\x0e\x03\x02\x07"

Definition at line 62 of file pkcs5.h.

#define OID_DES_EDE3_CBC   "\x2a\x86\x48\x86\xf7\x0d\x03\x07"

Definition at line 63 of file pkcs5.h.

#define OID_HMAC_SHA1   "\x2a\x86\x48\x86\xf7\x0d\x02\x07"

Definition at line 68 of file pkcs5.h.

#define OID_PKCS5   "\x2a\x86\x48\x86\xf7\x0d\x01\x05"

Definition at line 55 of file pkcs5.h.

#define OID_PKCS5_PBES2   OID_PKCS5 "\x0d"

Definition at line 56 of file pkcs5.h.

#define OID_PKCS5_PBKDF2   OID_PKCS5 "\x0c"

Definition at line 57 of file pkcs5.h.

#define PKCS5_DECRYPT   0

Definition at line 49 of file pkcs5.h.

#define PKCS5_ENCRYPT   1

Definition at line 50 of file pkcs5.h.

#define POLARSSL_ERR_PKCS5_BAD_INPUT_DATA   -0x3f80

Bad input parameters to function.

Definition at line 44 of file pkcs5.h.

#define POLARSSL_ERR_PKCS5_FEATURE_UNAVAILABLE   -0x3e80

Requested encryption or digest alg not available.

Definition at line 46 of file pkcs5.h.

#define POLARSSL_ERR_PKCS5_INVALID_FORMAT   -0x3f00

Unexpected ASN.1 data.

Definition at line 45 of file pkcs5.h.

#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.

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
plenlength of password
datadata to process
datalenlength of data
outputoutput buffer
Returns
0 on success, or a PolarSSL error 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 error code if verification fails.
int pkcs5_self_test ( int  verbose)

Checkup routine.

Returns
0 if successful, or 1 if the test failed