1 /* 2 * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef _COMMON_RSA_KEYPAIR_UTIL_H 8 #define _COMMON_RSA_KEYPAIR_UTIL_H 9 10 #include <stdint.h> 11 12 #include "common_rsa_keypair.h" 13 #include "cc_pka_hw_plat_defs.h" 14 15 typedef struct { 16 uint8_t pNBuff[SB_CERT_RSA_KEY_SIZE_IN_BYTES]; 17 uint8_t pNpBuff[NP_SIZE_IN_BYTES]; 18 }DxRsaKeyNandNp_t; 19 20 /** 21 * @brief The function reads RSA key from the file and returns its N and Np. 22 * 23 * @param[in] PemEncryptedFileName_ptr - file name of the key pair 24 * @param[in] pwdFileName - file name of the password 25 * @param[out] pNbuff - N buffer 26 * @param[in/out] pNbuffSize - as input - max size of pNbuff 27 * as output - actual size of pNbuff 28 */ 29 /*********************************************************/ 30 int32_t CC_CommonGetNbuffFromKeyPair(int8_t *PemEncryptedFileName_ptr, int8_t *pwdFileName, uint8_t *pNbuff, uint32_t *pNbuffSize); 31 32 /** 33 * @brief The function reads RSA key from the file and returns its N and Np. 34 * 35 * @param[in] PemEncryptedFileName_ptr - file name of the key pair 36 * @param[in] pwdFileName - file name of the password 37 * @param[out] pNAndNp - N and Np buffer 38 * @param[in/out] pNAndNpSize - as input - max size of pNAndNp 39 * as output - actual size of pNAndNp 40 */ 41 /*********************************************************/ 42 int32_t CC_CommonGetNAndNpFromKeyPair(int8_t *PemEncryptedFileName_ptr, int8_t *pwdFileName, uint8_t *pNAndNp, uint32_t *pNAndNpSize); 43 44 45 /** 46 * @brief The function reads RSA key from the file and returns its N and Np. 47 * 48 * @param[in] pubKeyFileName_ptr - file name of the key pair 49 * @param[out] pNAndNp - N and Np buffer 50 * @param[in/out] pNAndNpSize - as input - max size of pNAndNp 51 * as output - actual size of pNAndNp 52 */ 53 /*********************************************************/ 54 int32_t CC_CommonGetNAndNpFromPubKey(int8_t *pubKeyFileName_ptr, uint8_t *pNAndNp, uint32_t *pNAndNpSize); 55 56 57 /** 58 * @brief The CC_CommonCalcHBKFromFile reads RSA key from the file using passphrase 59 * and returns its decrypted value. 60 * 61 * @param[in] pubKeyFileName_ptr - file name of the public key 62 * @param[out] pHash - hash output 63 * @param[in] hashSize - hash output size 64 */ 65 /*********************************************************/ 66 int32_t CC_CommonCalcHBKFromFile(int8_t* pubKeyFileName_ptr, uint8_t *pHash, int32_t hashSize); 67 68 69 #endif 70