bcrypt.c File Reference

bcrypt password hashing function More...

#include "core/crypto.h"
#include "kdf/bcrypt.h"
#include "encoding/radix64.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL
 

Functions

error_t bcryptHashPassword (const PrngAlgo *prngAlgo, void *prngContext, uint_t cost, const char_t *password, char_t *hash, size_t *hashLen)
 Password hashing function. More...
 
error_t bcryptVerifyPassword (const char_t *password, const char_t *hash)
 Password verification function. More...
 
error_t bcrypt (uint_t cost, const uint8_t *salt, const char_t *password, char_t *hash, size_t *hashLen)
 bcrypt algorithm More...
 
error_t eksBlowfishSetup (BlowfishContext *context, uint_t cost, const uint8_t *salt, size_t saltLen, const char_t *password, size_t passwordLen)
 Expensive key setup. More...
 

Detailed Description

bcrypt password hashing 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.4

Definition in file bcrypt.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL

Definition at line 32 of file bcrypt.c.

Function Documentation

◆ bcrypt()

error_t bcrypt ( uint_t  cost,
const uint8_t *  salt,
const char_t password,
char_t hash,
size_t *  hashLen 
)

bcrypt algorithm

Parameters
[in]costKey expansion iteration count as a power of two
[in]saltRandom salt (16 bytes)
[in]passwordNULL-terminated password to be encoded
[out]hashNULL-terminated hash string
[out]hashLenLength of the hash string (optional parameter)
Returns
Error code

Definition at line 157 of file bcrypt.c.

◆ bcryptHashPassword()

error_t bcryptHashPassword ( const PrngAlgo prngAlgo,
void *  prngContext,
uint_t  cost,
const char_t password,
char_t hash,
size_t *  hashLen 
)

Password hashing function.

Parameters
[in]prngAlgoPRNG algorithm
[in]prngContextPointer to the PRNG context
[in]costKey expansion iteration count as a power of two
[in]passwordNULL-terminated password to be encoded
[out]hashNULL-terminated hash string
[out]hashLenLength of the hash string (optional parameter)
Returns
Error code

Definition at line 54 of file bcrypt.c.

◆ bcryptVerifyPassword()

error_t bcryptVerifyPassword ( const char_t password,
const char_t hash 
)

Password verification function.

Parameters
[in]passwordNULL-terminated password to be checked
[in]hashNULL-terminated hash string
Returns
Error code

Definition at line 89 of file bcrypt.c.

◆ eksBlowfishSetup()

error_t eksBlowfishSetup ( BlowfishContext context,
uint_t  cost,
const uint8_t *  salt,
size_t  saltLen,
const char_t password,
size_t  passwordLen 
)

Expensive key setup.

Parameters
[in]contextPointer to the Blowfish context
[in]costKey expansion iteration count as a power of 2
[in]saltRandom salt
[in]saltLenLength of the random salt, in bytes
[in]passwordNULL-terminated password to be encoded
[in]passwordLenLength of the password, in bytes
Returns
Error code

Definition at line 246 of file bcrypt.c.