/** * \file rsa_alt.h * * \brief This file provides an API for the RSA public-key cryptosystem. * * The RSA public-key cryptosystem is defined in <em>Public-Key * Cryptography Standards (PKCS) #1 v1.5: RSA Encryption</em> * and <em>Public-Key Cryptography Standards (PKCS) #1 v2.1: * RSA Cryptography Specifications</em>. * */ /* * Copyright The Mbed TLS Contributors * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef MBEDTLS_RSA_ALT_H #define MBEDTLS_RSA_ALT_H #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include "mbedtls/bignum.h" #include "mbedtls/md.h" #if defined(MBEDTLS_THREADING_C) #include "mbedtls/threading.h" #endif #ifdef __cplusplus extern "C" { #endif #if defined(MBEDTLS_RSA_ALT) // Regular implementation // /* Enable Nuvoton's Crypto RSA H/W */ #define NU_CRYPTO_RSA_ENABLE /** * \brief The RSA context structure. * * \note Direct manipulation of the members of this structure * is deprecated. All manipulation should instead be done through * the public interface functions. */ typedef struct mbedtls_rsa_context { int ver; /*!< Always 0.*/ size_t len; /*!< The size of \p N in Bytes. */ mbedtls_mpi N; /*!< The public modulus. */ mbedtls_mpi E; /*!< The public exponent. */ mbedtls_mpi D; /*!< The private exponent. */ mbedtls_mpi P; /*!< The first prime factor. */ mbedtls_mpi Q; /*!< The second prime factor. */ mbedtls_mpi DP; /*!< <code>D % (P - 1)</code>. */ mbedtls_mpi DQ; /*!< <code>D % (Q - 1)</code>. */ mbedtls_mpi QP; /*!< <code>1 / (Q % P)</code>. */ mbedtls_mpi RN; /*!< cached <code>R^2 mod N</code>. */ mbedtls_mpi RP; /*!< cached <code>R^2 mod P</code>. */ mbedtls_mpi RQ; /*!< cached <code>R^2 mod Q</code>. */ mbedtls_mpi Vi; /*!< The cached blinding value. */ mbedtls_mpi Vf; /*!< The cached un-blinding value. */ int padding; /*!< Selects padding mode: #MBEDTLS_RSA_PKCS_V15 for 1.5 padding and #MBEDTLS_RSA_PKCS_V21 for OAEP or PSS. */ int hash_id; /*!< Hash identifier of mbedtls_md_type_t type, as specified in md.h for use in the MGF mask generating function used in the EME-OAEP and EMSA-PSS encodings. */ #if defined(MBEDTLS_THREADING_C) mbedtls_threading_mutex_t mutex; /*!< Thread-safety mutex. */ #endif #if defined(NU_CRYPTO_RSA_ENABLE) int hw_init; /*!< Initialized Crypto RSA H/W or not. */ #endif } mbedtls_rsa_context; #endif /* MBEDTLS_RSA_ALT */ #ifdef __cplusplus } #endif #endif /* rsa_alt.h */