RetroArch
Macros | Functions | Variables
pkcs5.c File Reference

PKCS#5 functions. More...

#include "mbedtls/config.h"
#include "mbedtls/pkcs5.h"
#include "mbedtls/asn1.h"
#include "mbedtls/cipher.h"
#include "mbedtls/oid.h"
#include <string.h>
#include "mbedtls/platform.h"
Include dependency graph for pkcs5.c:

Macros

#define MAX_TESTS   6
 

Functions

static int pkcs5_parse_pbkdf2_params (const mbedtls_asn1_buf *params, mbedtls_asn1_buf *salt, int *iterations, int *keylen, mbedtls_md_type_t *md_type)
 
int mbedtls_pkcs5_pbes2 (const mbedtls_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 mbedtls_pkcs5_pbkdf2_hmac (mbedtls_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 mbedtls_pkcs5_self_test (int verbose)
 Checkup routine. More...
 

Variables

static const size_t plen [MAX_TESTS]
 
static const unsigned char password [MAX_TESTS][32]
 
static const size_t slen [MAX_TESTS]
 
static const unsigned char salt [MAX_TESTS][40]
 
static const uint32_t it_cnt [MAX_TESTS]
 
static const uint32_t key_len [MAX_TESTS]
 
static const unsigned char result_key [MAX_TESTS][32]
 

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-2015, ARM Limited, All Rights Reserved SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

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

Macro Definition Documentation

◆ MAX_TESTS

#define MAX_TESTS   6

Function Documentation

◆ mbedtls_pkcs5_pbes2()

int mbedtls_pkcs5_pbes2 ( const mbedtls_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 MBEDTLS_PKCS5_DECRYPT or MBEDTLS_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 MBEDTLS_ERR_XXX code if verification fails.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_pkcs5_pbkdf2_hmac()

int mbedtls_pkcs5_pbkdf2_hmac ( mbedtls_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 in bytes
outputGenerated key. Must be at least as big as key_length
Returns
0 on success, or a MBEDTLS_ERR_XXX code if verification fails.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_pkcs5_self_test()

int mbedtls_pkcs5_self_test ( int  verbose)

Checkup routine.

Returns
0 if successful, or 1 if the test failed
Here is the call graph for this function:

◆ pkcs5_parse_pbkdf2_params()

static int pkcs5_parse_pbkdf2_params ( const mbedtls_asn1_buf params,
mbedtls_asn1_buf salt,
int *  iterations,
int *  keylen,
mbedtls_md_type_t md_type 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ it_cnt

const uint32_t it_cnt[MAX_TESTS]
static
Initial value:
=
{ 1, 2, 4096, 4096, 4096 }

◆ key_len

const uint32_t key_len[MAX_TESTS]
static
Initial value:
=
{ 20, 20, 20, 25, 16 }

◆ password

const unsigned char password[MAX_TESTS][32]
static
Initial value:
=
{
"password",
"password",
"password",
"passwordPASSWORDpassword",
"pass\0word",
}

◆ plen

const size_t plen[MAX_TESTS]
static
Initial value:
=
{ 8, 8, 8, 24, 9 }

◆ result_key

const unsigned char result_key[MAX_TESTS][32]
static
Initial value:
=
{
{ 0x0c, 0x60, 0xc8, 0x0f, 0x96, 0x1f, 0x0e, 0x71,
0xf3, 0xa9, 0xb5, 0x24, 0xaf, 0x60, 0x12, 0x06,
0x2f, 0xe0, 0x37, 0xa6 },
{ 0xea, 0x6c, 0x01, 0x4d, 0xc7, 0x2d, 0x6f, 0x8c,
0xcd, 0x1e, 0xd9, 0x2a, 0xce, 0x1d, 0x41, 0xf0,
0xd8, 0xde, 0x89, 0x57 },
{ 0x4b, 0x00, 0x79, 0x01, 0xb7, 0x65, 0x48, 0x9a,
0xbe, 0xad, 0x49, 0xd9, 0x26, 0xf7, 0x21, 0xd0,
0x65, 0xa4, 0x29, 0xc1 },
{ 0x3d, 0x2e, 0xec, 0x4f, 0xe4, 0x1c, 0x84, 0x9b,
0x80, 0xc8, 0xd8, 0x36, 0x62, 0xc0, 0xe4, 0x4a,
0x8b, 0x29, 0x1a, 0x96, 0x4c, 0xf2, 0xf0, 0x70,
0x38 },
{ 0x56, 0xfa, 0x6a, 0xa7, 0x55, 0x48, 0x09, 0x9d,
0xcc, 0x37, 0xd7, 0xf0, 0x34, 0x25, 0xe0, 0xc3 },
}

◆ salt

const unsigned char salt[MAX_TESTS][40]
static
Initial value:
=
{
"salt",
"salt",
"salt",
"saltSALTsaltSALTsaltSALTsaltSALTsalt",
"sa\0lt",
}

◆ slen

const size_t slen[MAX_TESTS]
static
Initial value:
=
{ 4, 4, 4, 36, 5 }