pic32mz_crypto_hash.c File Reference

PIC32MZ hash hardware accelerator. More...

#include <p32xxxx.h>
#include <sys/kmem.h>
#include "core/crypto.h"
#include "hardware/pic32mz/pic32mz_crypto.h"
#include "hardware/pic32mz/pic32mz_crypto_hash.h"
#include "hash/hash_algorithms.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL
 

Functions

volatile Pic32mzCryptoBufferDesc hashBufferDesc __attribute__ ((coherent, aligned(8)))
 
uint8_t hashInput[PIC32MZ_CRYPTO_BUFFER_SIZE__attribute__ ((coherent, aligned(4)))
 
void hashProcessData (uint32_t algo, const uint8_t *data, size_t length)
 Digest a message using the specified hash algorithm. More...
 
error_t md5Compute (const void *data, size_t length, uint8_t *digest)
 Digest a message using MD5. More...
 
error_t sha1Compute (const void *data, size_t length, uint8_t *digest)
 Digest a message using SHA-1. More...
 
error_t sha256Compute (const void *data, size_t length, uint8_t *digest)
 Digest a message using SHA-256. More...
 

Variables

const uint8_t md5EmptyDigest []
 
const uint8_t sha1EmptyDigest []
 
const uint8_t sha256EmptyDigest []
 

Detailed Description

PIC32MZ hash hardware accelerator.

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

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL

Definition at line 32 of file pic32mz_crypto_hash.c.

Function Documentation

◆ __attribute__() [1/2]

uint8_t hashInput [PIC32MZ_CRYPTO_BUFFER_SIZE] __attribute__ ( (coherent, aligned(4))  )

◆ __attribute__() [2/2]

volatile Pic32mzCryptoBufferDesc hashBufferDesc __attribute__ ( (coherent, aligned(8))  )

◆ hashProcessData()

void hashProcessData ( uint32_t  algo,
const uint8_t *  data,
size_t  length 
)

Digest a message using the specified hash algorithm.

Parameters
[in]algoHash algorithm
[in]dataPointer to the input message
[in]lengthLength of the input message, in bytes

Definition at line 94 of file pic32mz_crypto_hash.c.

◆ md5Compute()

error_t md5Compute ( const void *  data,
size_t  length,
uint8_t *  digest 
)

Digest a message using MD5.

Parameters
[in]dataPointer to the message being hashed
[in]lengthLength of the message
[out]digestPointer to the calculated digest
Returns
Error code

Definition at line 187 of file pic32mz_crypto_hash.c.

◆ sha1Compute()

error_t sha1Compute ( const void *  data,
size_t  length,
uint8_t *  digest 
)

Digest a message using SHA-1.

Parameters
[in]dataPointer to the message being hashed
[in]lengthLength of the message
[out]digestPointer to the calculated digest
Returns
Error code

Definition at line 218 of file pic32mz_crypto_hash.c.

◆ sha256Compute()

error_t sha256Compute ( const void *  data,
size_t  length,
uint8_t *  digest 
)

Digest a message using SHA-256.

Parameters
[in]dataPointer to the message being hashed
[in]lengthLength of the message
[out]digestPointer to the calculated digest
Returns
Error code

Definition at line 249 of file pic32mz_crypto_hash.c.

Variable Documentation

◆ md5EmptyDigest

const uint8_t md5EmptyDigest[]
Initial value:
=
{
0xD4, 0x1D, 0x8C, 0xD9, 0x8F, 0x00, 0xB2, 0x04,
0xE9, 0x80, 0x09, 0x98, 0xEC, 0xF8, 0x42, 0x7E
}

Definition at line 63 of file pic32mz_crypto_hash.c.

◆ sha1EmptyDigest

const uint8_t sha1EmptyDigest[]
Initial value:
=
{
0xDA, 0x39, 0xA3, 0xEE, 0x5E, 0x6B, 0x4B, 0x0D,
0x32, 0x55, 0xBF, 0xEF, 0x95, 0x60, 0x18, 0x90,
0xAF, 0xD8, 0x07, 0x09
}

Definition at line 70 of file pic32mz_crypto_hash.c.

◆ sha256EmptyDigest

const uint8_t sha256EmptyDigest[]
Initial value:
=
{
0xE3, 0xB0, 0xC4, 0x42, 0x98, 0xFC, 0x1C, 0x14,
0x9A, 0xFB, 0xF4, 0xC8, 0x99, 0x6F, 0xB9, 0x24,
0x27, 0xAE, 0x41, 0xE4, 0x64, 0x9B, 0x93, 0x4C,
0xA4, 0x95, 0x99, 0x1B, 0x78, 0x52, 0xB8, 0x55
}

Definition at line 78 of file pic32mz_crypto_hash.c.