blowfish.h File Reference

Blowfish encryption algorithm. More...

#include "core/crypto.h"

Go to the source code of this file.

Data Structures

struct  BlowfishContext
 Blowfish algorithm context. More...
 

Macros

#define BLOWFISH_BLOCK_SIZE   8
 
#define BLOWFISH_CIPHER_ALGO   (&blowfishCipherAlgo)
 

Functions

error_t blowfishInit (BlowfishContext *context, const uint8_t *key, size_t keyLen)
 Initialize a Blowfish context using the supplied key. More...
 
error_t blowfishInitState (BlowfishContext *context)
 Blowfish state initialization. More...
 
error_t blowfishExpandKey (BlowfishContext *context, const uint8_t *salt, size_t saltLen, const uint8_t *key, size_t keyLen)
 Key expansion. More...
 
void blowfishEncryptBlock (BlowfishContext *context, const uint8_t *input, uint8_t *output)
 Encrypt a 8-byte block using Blowfish algorithm. More...
 
void blowfishDecryptBlock (BlowfishContext *context, const uint8_t *input, uint8_t *output)
 Decrypt a 8-byte block using Blowfish algorithm. More...
 
void blowfishXorBlock (uint8_t *data, const uint8_t *salt, size_t saltLen, size_t *saltIndex)
 XOR data block with random salt. More...
 
void blowfishDeinit (BlowfishContext *context)
 Release Blowfish context. More...
 

Variables

const CipherAlgo blowfishCipherAlgo
 

Detailed Description

Blowfish encryption algorithm.

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

Macro Definition Documentation

◆ BLOWFISH_BLOCK_SIZE

#define BLOWFISH_BLOCK_SIZE   8

Definition at line 38 of file blowfish.h.

◆ BLOWFISH_CIPHER_ALGO

#define BLOWFISH_CIPHER_ALGO   (&blowfishCipherAlgo)

Definition at line 40 of file blowfish.h.

Function Documentation

◆ blowfishDecryptBlock()

void blowfishDecryptBlock ( BlowfishContext context,
const uint8_t *  input,
uint8_t *  output 
)

Decrypt a 8-byte block using Blowfish algorithm.

Parameters
[in]contextPointer to the Blowfish context
[in]inputCiphertext block to decrypt
[out]outputPlaintext block resulting from decryption

Definition at line 461 of file blowfish.c.

◆ blowfishDeinit()

void blowfishDeinit ( BlowfishContext context)

Release Blowfish context.

Parameters
[in]contextPointer to the Blowfish context

Definition at line 548 of file blowfish.c.

◆ blowfishEncryptBlock()

void blowfishEncryptBlock ( BlowfishContext context,
const uint8_t *  input,
uint8_t *  output 
)

Encrypt a 8-byte block using Blowfish algorithm.

Parameters
[in]contextPointer to the Blowfish context
[in]inputPlaintext block to encrypt
[out]outputCiphertext block resulting from encryption

Definition at line 411 of file blowfish.c.

◆ blowfishExpandKey()

error_t blowfishExpandKey ( BlowfishContext context,
const uint8_t *  salt,
size_t  saltLen,
const uint8_t *  key,
size_t  keyLen 
)

Key expansion.

Parameters
[in]contextPointer to the Blowfish context
[in]saltRandom salt
[in]saltLenLength of the random salt, in bytes
[in]keySecret key
[in]keyLenLength of the secret key, in bytes
Returns
Error code

Definition at line 291 of file blowfish.c.

◆ blowfishInit()

error_t blowfishInit ( BlowfishContext context,
const uint8_t *  key,
size_t  keyLen 
)

Initialize a Blowfish context using the supplied key.

Parameters
[in]contextPointer to the Blowfish context to initialize
[in]keyPointer to the key
[in]keyLenLength of the key
Returns
Error code

Definition at line 227 of file blowfish.c.

◆ blowfishInitState()

error_t blowfishInitState ( BlowfishContext context)

Blowfish state initialization.

Parameters
[in]contextPointer to the Blowfish context
Returns
Error code

Definition at line 257 of file blowfish.c.

◆ blowfishXorBlock()

void blowfishXorBlock ( uint8_t *  data,
const uint8_t *  salt,
size_t  saltLen,
size_t *  saltIndex 
)

XOR data block with random salt.

Parameters
[in,out]dataPointer the data block (16 bytes)
[in]saltPointer to the random salt (16 bytes)
[in]saltLenLength of the salt, in bytes
[in,out]saltIndexCurrent salt index

Definition at line 512 of file blowfish.c.

Variable Documentation

◆ blowfishCipherAlgo

const CipherAlgo blowfishCipherAlgo
extern

Definition at line 204 of file blowfish.c.