STM32WL public-key hardware accelerator (PKA) More...
#include "stm32wlxx.h"
#include "stm32wlxx_hal.h"
#include "core/crypto.h"
#include "hardware/stm32wlxx/stm32wlxx_crypto.h"
#include "hardware/stm32wlxx/stm32wlxx_crypto_pkc.h"
#include "pkc/rsa.h"
#include "ecc/ec.h"
#include "ecc/ecdsa.h"
#include "ecc/curve25519.h"
#include "ecc/curve448.h"
#include "debug.h"
Go to the source code of this file.
Macros | |
#define | TRACE_LEVEL CRYPTO_TRACE_LEVEL |
Functions | |
error_t | pkaInit (void) |
PKA module initialization. More... | |
void | pkaImportArray (const uint8_t *src, size_t srcLen, uint_t destLen, uint_t offset) |
Import byte array. More... | |
void | pkaImportMpi (const Mpi *a, uint_t length, uint_t offset) |
Import multiple-precision integer. More... | |
error_t | pkaExportMpi (Mpi *r, uint_t length, uint_t offset) |
Export multiple-precision integer. More... | |
error_t | pkaModExp (Mpi *r, const Mpi *a, const Mpi *e, const Mpi *p) |
Modular exponentiation. More... | |
error_t | pkaRsaCrtExp (const RsaPrivateKey *key, const Mpi *c, Mpi *m) |
Modular exponentiation with CRT. More... | |
error_t | rsaep (const RsaPublicKey *key, const Mpi *m, Mpi *c) |
RSA encryption primitive. More... | |
error_t | rsadp (const RsaPrivateKey *key, const Mpi *c, Mpi *m) |
RSA decryption primitive. More... | |
error_t | ecMult (const EcDomainParameters *params, EcPoint *r, const Mpi *d, const EcPoint *s) |
Scalar multiplication. More... | |
error_t | ecdsaGenerateSignature (const PrngAlgo *prngAlgo, void *prngContext, const EcDomainParameters *params, const EcPrivateKey *privateKey, const uint8_t *digest, size_t digestLen, EcdsaSignature *signature) |
ECDSA signature generation. More... | |
error_t | ecdsaVerifySignature (const EcDomainParameters *params, const EcPublicKey *publicKey, const uint8_t *digest, size_t digestLen, const EcdsaSignature *signature) |
ECDSA signature verification. More... | |
void | curve25519Mul (uint32_t *r, const uint32_t *a, const uint32_t *b) |
Modular multiplication. More... | |
void | curve448Mul (uint32_t *r, const uint32_t *a, const uint32_t *b) |
Modular multiplication. More... | |
Detailed Description
STM32WL public-key hardware accelerator (PKA)
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.
- Version
- 2.4.4
Definition in file stm32wlxx_crypto_pkc.c.
Macro Definition Documentation
◆ TRACE_LEVEL
#define TRACE_LEVEL CRYPTO_TRACE_LEVEL |
Definition at line 32 of file stm32wlxx_crypto_pkc.c.
Function Documentation
◆ curve25519Mul()
void curve25519Mul | ( | uint32_t * | r, |
const uint32_t * | a, | ||
const uint32_t * | b | ||
) |
Modular multiplication.
- Parameters
-
[out] r Resulting integer R = (A * B) mod p [in] a An integer such as 0 <= A < p [in] b An integer such as 0 <= B < p
Definition at line 848 of file stm32wlxx_crypto_pkc.c.
◆ curve448Mul()
void curve448Mul | ( | uint32_t * | r, |
const uint32_t * | a, | ||
const uint32_t * | b | ||
) |
Modular multiplication.
- Parameters
-
[out] r Resulting integer R = (A * B) mod p [in] a An integer such as 0 <= A < p [in] b An integer such as 0 <= B < p
Definition at line 970 of file stm32wlxx_crypto_pkc.c.
◆ ecdsaGenerateSignature()
error_t ecdsaGenerateSignature | ( | const PrngAlgo * | prngAlgo, |
void * | prngContext, | ||
const EcDomainParameters * | params, | ||
const EcPrivateKey * | privateKey, | ||
const uint8_t * | digest, | ||
size_t | digestLen, | ||
EcdsaSignature * | signature | ||
) |
ECDSA signature generation.
- Parameters
-
[in] prngAlgo PRNG algorithm [in] prngContext Pointer to the PRNG context [in] params EC domain parameters [in] privateKey Signer's EC private key [in] digest Digest of the message to be signed [in] digestLen Length in octets of the digest [out] signature (R, S) integer pair
- Returns
- Error code
Definition at line 609 of file stm32wlxx_crypto_pkc.c.
◆ ecdsaVerifySignature()
error_t ecdsaVerifySignature | ( | const EcDomainParameters * | params, |
const EcPublicKey * | publicKey, | ||
const uint8_t * | digest, | ||
size_t | digestLen, | ||
const EcdsaSignature * | signature | ||
) |
ECDSA signature verification.
- Parameters
-
[in] params EC domain parameters [in] publicKey Signer's EC public key [in] digest Digest of the message whose signature is to be verified [in] digestLen Length in octets of the digest [in] signature (R, S) integer pair
- Returns
- Error code
Definition at line 734 of file stm32wlxx_crypto_pkc.c.
◆ ecMult()
error_t ecMult | ( | const EcDomainParameters * | params, |
EcPoint * | r, | ||
const Mpi * | d, | ||
const EcPoint * | s | ||
) |
Scalar multiplication.
- Parameters
-
[in] params EC domain parameters [out] r Resulting point R = d.S [in] d An integer d such as 0 <= d < p [in] s EC point
- Returns
- Error code
Definition at line 513 of file stm32wlxx_crypto_pkc.c.
◆ pkaExportMpi()
Export multiple-precision integer.
- Parameters
-
[out] r Pointer to the multiple-precision integer [in] length Length of the operand, in bits [in] offset PKA ram offset
- Returns
- Error code
Definition at line 183 of file stm32wlxx_crypto_pkc.c.
◆ pkaImportArray()
Import byte array.
- Parameters
-
[in] src Pointer to the byte array [in] srcLen Length of the array to be copied, in bytes [in] destLen Length of the operand, in bits [in] offset PKA ram offset
Definition at line 86 of file stm32wlxx_crypto_pkc.c.
◆ pkaImportMpi()
Import multiple-precision integer.
- Parameters
-
[in] a Pointer to the multiple-precision integer [in] length Length of the operand, in bits [in] offset PKA ram offset
Definition at line 147 of file stm32wlxx_crypto_pkc.c.
◆ pkaInit()
error_t pkaInit | ( | void | ) |
◆ pkaModExp()
Modular exponentiation.
- Parameters
-
[out] r Resulting integer R = A ^ E mod P [in] a Pointer to a multiple precision integer [in] e Exponent [in] p Modulus
- Returns
- Error code
Definition at line 233 of file stm32wlxx_crypto_pkc.c.
◆ pkaRsaCrtExp()
error_t pkaRsaCrtExp | ( | const RsaPrivateKey * | key, |
const Mpi * | c, | ||
Mpi * | m | ||
) |
Modular exponentiation with CRT.
- Parameters
-
[in] key RSA public key [in] m Message representative [out] c Ciphertext representative
- Returns
- Error code
Definition at line 313 of file stm32wlxx_crypto_pkc.c.
◆ rsadp()
error_t rsadp | ( | const RsaPrivateKey * | key, |
const Mpi * | c, | ||
Mpi * | m | ||
) |
RSA decryption primitive.
- Parameters
-
[in] key RSA private key [in] c Ciphertext representative [out] m Message representative
- Returns
- Error code
Definition at line 472 of file stm32wlxx_crypto_pkc.c.
◆ rsaep()
error_t rsaep | ( | const RsaPublicKey * | key, |
const Mpi * | m, | ||
Mpi * | c | ||
) |
RSA encryption primitive.
- Parameters
-
[in] key RSA public key [in] m Message representative [out] c Ciphertext representative
- Returns
- Error code
Definition at line 442 of file stm32wlxx_crypto_pkc.c.