Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
crys_rsa_build.h
00001 /************************************************************************************** 00002 * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved * 00003 * * 00004 * This file and the related binary are licensed under the following license: * 00005 * * 00006 * ARM Object Code and Header Files License, v1.0 Redistribution. * 00007 * * 00008 * Redistribution and use of object code, header files, and documentation, without * 00009 * modification, are permitted provided that the following conditions are met: * 00010 * * 00011 * 1) Redistributions must reproduce the above copyright notice and the * 00012 * following disclaimer in the documentation and/or other materials * 00013 * provided with the distribution. * 00014 * * 00015 * 2) Unless to the extent explicitly permitted by law, no reverse * 00016 * engineering, decompilation, or disassembly of is permitted. * 00017 * * 00018 * 3) Redistribution and use is permitted solely for the purpose of * 00019 * developing or executing applications that are targeted for use * 00020 * on an ARM-based product. * 00021 * * 00022 * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * 00023 * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * 00024 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, * 00025 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 00026 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * 00027 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * 00028 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 00029 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 00030 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 00031 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 00032 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 00033 **************************************************************************************/ 00034 00035 00036 00037 #ifndef CRYS_RSA_BUILD_H 00038 #define CRYS_RSA_BUILD_H 00039 00040 00041 #include "crys_error.h" 00042 #include "crys_rsa_types.h" 00043 00044 #ifdef __cplusplus 00045 extern "C" 00046 { 00047 #endif 00048 00049 /*! 00050 @defgroup crys_rsa CryptoCell RSA APIs 00051 @{ 00052 @ingroup cryptocell_api 00053 @brief This group is the cryptocell ECC root group 00054 @} 00055 00056 @file 00057 @brief This module defines some utility functions for working with RSA cryptography. 00058 @defgroup crys_rsa_build CryptoCell RSA Utility APIs 00059 @{ 00060 @ingroup crys_rsa 00061 */ 00062 00063 /******************************************************************************************/ 00064 /*! 00065 @brief Builds a ::CRYSRSAPubKey_t public key structure with the provided modulus and exponent. 00066 00067 @return CRYS_OK on success. 00068 @return A non-zero value from crys_rsa_error.h on failure. 00069 */ 00070 CIMPORT_C CRYSError_t CRYS_RSA_Build_PubKey( 00071 CRYS_RSAUserPubKey_t *UserPubKey_ptr, /*!< [out] Pointer to the public key structure. */ 00072 uint8_t *Exponent_ptr, /*!< [in] Pointer to the exponent stream of bytes (Big-Endian format). */ 00073 uint16_t ExponentSize, /*!< [in] The size of the exponent (in bytes). */ 00074 uint8_t *Modulus_ptr, /*!< [in] Pointer to the modulus stream of bytes (Big-Endian format). 00075 The most significant bit (MSB) must be set to '1'. */ 00076 uint16_t ModulusSize /*!< [in] The modulus size in bytes. Supported sizes are 64, 128, 256, 384 and 512. */ 00077 ); 00078 00079 00080 /******************************************************************************************/ 00081 /*! 00082 @brief Builds a ::CRYSRSAPrivKey_t private key structure with the provided modulus and exponent, marking the key as a non-CRT key. 00083 00084 @return CRYS_OK on success. 00085 @return A non-zero value from crys_rsa_error.h on failure. 00086 */ 00087 CIMPORT_C CRYSError_t CRYS_RSA_Build_PrivKey( 00088 CRYS_RSAUserPrivKey_t *UserPrivKey_ptr, /*!< [out] Pointer to the public key structure.*/ 00089 uint8_t *PrivExponent_ptr, /*!< [in] Pointer to the private exponent stream of bytes (Big-Endian format). */ 00090 uint16_t PrivExponentSize, /*!< [in] The size of the private exponent (in bytes). */ 00091 uint8_t *PubExponent_ptr, /*!< [in] Pointer to the public exponent stream of bytes (Big-Endian format). */ 00092 uint16_t PubExponentSize, /*!< [in] The size of the public exponent (in bytes). */ 00093 uint8_t *Modulus_ptr, /*!< [in] Pointer to the modulus stream of bytes (Big-Endian format). 00094 The most significant bit must be set to '1'. */ 00095 uint16_t ModulusSize /*!< [in] The modulus size in bytes. Supported sizes are 64, 128, 256, 384 and 512. */ 00096 ); 00097 00098 /******************************************************************************************/ 00099 /*! 00100 @brief Builds a ::CRYSRSAPrivKey_t private key structure with the provided parameters, marking the key as a CRT key. 00101 00102 @return CRYS_OK on success. 00103 @return A non-zero value from crys_rsa_error.h on failure. 00104 */ 00105 CIMPORT_C CRYSError_t CRYS_RSA_Build_PrivKeyCRT( 00106 CRYS_RSAUserPrivKey_t *UserPrivKey_ptr, /*!< [out] Pointer to the public key structure. */ 00107 uint8_t *P_ptr, /*!< [in] Pointer to the first factor stream of bytes (Big-Endian format). */ 00108 uint16_t PSize, /*!< [in] The size of the first factor (in bytes). */ 00109 uint8_t *Q_ptr, /*!< [in] Pointer to the second factor stream of bytes (Big-Endian format). */ 00110 uint16_t QSize, /*!< [in] The size of the second factor (in bytes). */ 00111 uint8_t *dP_ptr, /*!< [in] Pointer to the first factor's CRT exponent stream of bytes 00112 (Big-Endian format). */ 00113 uint16_t dPSize, /*!< [in] The size of the first factor's CRT exponent (in bytes). */ 00114 uint8_t *dQ_ptr, /*!< [in] Pointer to the second factor's CRT exponent stream of bytes 00115 (Big-Endian format). */ 00116 uint16_t dQSize, /*!< [in] The size of the second factor's CRT exponent (in bytes). */ 00117 uint8_t *qInv_ptr, /*!< [in] Pointer to the first CRT coefficient stream of bytes (Big-Endian format). */ 00118 uint16_t qInvSize /*!< [in] The size of the first CRT coefficient (in bytes). */ 00119 ); 00120 00121 00122 /******************************************************************************************/ 00123 /*! 00124 @brief The function gets the e,n public key parameters from the input 00125 CRYS_RSAUserPubKey_t structure. The function can also be used to retrieve the 00126 modulus and exponent sizes only (Exponent_ptr AND Modulus_ptr must be set to 00127 NULL). 00128 00129 \note All members of input UserPubKey_ptr structure must be initialized. 00130 00131 @return CRYS_OK on success. 00132 @return A non-zero value from crys_rsa_error.h on failure. 00133 */ 00134 CIMPORT_C CRYSError_t CRYS_RSA_Get_PubKey( 00135 CRYS_RSAUserPubKey_t *UserPubKey_ptr, /*!< [in] A pointer to the public key structure. */ 00136 uint8_t *Exponent_ptr, /*!< [out] A pointer to the exponent stream of bytes (Big-Endian format). */ 00137 uint16_t *ExponentSize_ptr, /*!< [in/out] the size of the exponent buffer in bytes, 00138 it is updated to the actual size of the exponent, in bytes. */ 00139 uint8_t *Modulus_ptr, /*!< [out] A pointer to the modulus stream of bytes (Big-Endian format). 00140 The MS (most significant) bit must be set to '1'. */ 00141 uint16_t *ModulusSize_ptr /*!< [in/out] the size of the modulus buffer in bytes, it is updated to the actual 00142 size of the modulus, in bytes. */ 00143 ); 00144 00145 00146 #ifdef __cplusplus 00147 } 00148 #endif 00149 /** 00150 @} 00151 */ 00152 #endif
Generated on Tue Jul 12 2022 13:54:15 by
1.7.2