pbkdf.c File Reference

PBKDF (Password-Based Key Derivation Function) More...

#include "core/crypto.h"
#include "kdf/pbkdf.h"
#include "mac/hmac.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL
 

Functions

error_t pbkdf1 (const HashAlgo *hash, const uint8_t *p, size_t pLen, const uint8_t *s, size_t sLen, uint_t c, uint8_t *dk, size_t dkLen)
 PBKDF1 key derivation function. More...
 
error_t pbkdf2 (const HashAlgo *hash, const uint8_t *p, size_t pLen, const uint8_t *s, size_t sLen, uint_t c, uint8_t *dk, size_t dkLen)
 PBKDF2 key derivation function. More...
 

Variables

const uint8_t PBKDF2_OID [9] = {0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x05, 0x0C}
 

Detailed Description

PBKDF (Password-Based Key Derivation Function)

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneCRYPTO Open.

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.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.0

Definition in file pbkdf.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL

Definition at line 32 of file pbkdf.c.

Function Documentation

◆ pbkdf1()

error_t pbkdf1 ( const HashAlgo hash,
const uint8_t *  p,
size_t  pLen,
const uint8_t *  s,
size_t  sLen,
uint_t  c,
uint8_t *  dk,
size_t  dkLen 
)

PBKDF1 key derivation function.

PBKDF1 applies a hash function, which shall be MD2, MD5 or SHA-1, to derive keys. The length of the derived key is bounded by the length of the hash function output, which is 16 octets for MD2 and MD5 and 20 octets for SHA-1

Parameters
[in]hashUnderlying hash function (MD2, MD5 or SHA-1)
[in]pPassword, an octet string
[in]pLenLength in octets of password
[in]sSalt, an octet string
[in]sLenLength in octets of salt
[in]cIteration count
[out]dkDerived key
[in]dkLenIntended length in octets of the derived key
Returns
Error code

Definition at line 64 of file pbkdf.c.

◆ pbkdf2()

error_t pbkdf2 ( const HashAlgo hash,
const uint8_t *  p,
size_t  pLen,
const uint8_t *  s,
size_t  sLen,
uint_t  c,
uint8_t *  dk,
size_t  dkLen 
)

PBKDF2 key derivation function.

PBKDF2 applies a pseudorandom function to derive keys. The length of the derived key is essentially unbounded

Parameters
[in]hashHash algorithm used by the underlying PRF
[in]pPassword, an octet string
[in]pLenLength in octets of password
[in]sSalt, an octet string
[in]sLenLength in octets of salt
[in]cIteration count
[out]dkDerived key
[in]dkLenIntended length in octets of the derived key
Returns
Error code

Definition at line 140 of file pbkdf.c.

Variable Documentation

◆ PBKDF2_OID

const uint8_t PBKDF2_OID[9] = {0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x05, 0x0C}

Definition at line 43 of file pbkdf.c.