1 /* 2 * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #define CC_PAL_LOG_CUR_COMPONENT CC_LOG_MASK_CC_API 8 9 #include "mbedtls_cc_srp.h" 10 11 12 uint32_t SRP_InitAndkMultiplierCalc(mbedtls_srp_context *pSrpCtx); 13 14 uint32_t SRP_uScrambleCalc(mbedtls_srp_modulus ephemPubA, 15 mbedtls_srp_modulus ephemPubB, 16 mbedtls_srp_digest uScramble, 17 mbedtls_srp_context *pCtx); 18 19 // credDigest = SHA(U|:|P) 20 uint32_t SRP_UserCredDigCalc(uint8_t *pUserName, 21 size_t userNameSize, 22 uint8_t *pPwd, 23 size_t pwdSize, 24 mbedtls_srp_context *pCtx); 25 26 27 // calc x = SHA(pSalt | pCtx->credDigest) 28 uint32_t SRP_xBuffCalc(uint8_t *pSalt, 29 size_t saltSize, 30 mbedtls_srp_digest xBuff, // out 31 mbedtls_srp_context *pCtx); 32 33 //SHA(U) 34 uint32_t SRP_UserNameDigCalc(uint8_t *pUserName, 35 size_t userNameSize, 36 mbedtls_srp_context *pCtx); 37 38 // SHA(SHA(N)^=SHA(g) | SHA(U)|s|A|B|K) 39 uint32_t SRP_UserProofCalc2(uint8_t *pSalt, 40 size_t saltSize, 41 mbedtls_srp_modulus userPubKeyA, 42 mbedtls_srp_modulus hostPubKeyB, 43 mbedtls_srp_sessionKey sessionKey, 44 mbedtls_srp_digest userProof, 45 mbedtls_srp_context *pCtx); 46 47 // SHA(A|M1|K) 48 uint32_t SRP_HostProofCalc(mbedtls_srp_modulus userPubKeyA, 49 mbedtls_srp_digest userProof, 50 mbedtls_srp_sessionKey sessionKey, 51 mbedtls_srp_digest hostProof, // out 52 mbedtls_srp_context *pCtx); 53 54 55 // Sha_interleave 56 uint32_t SRP_SessionKeyCalc(uint8_t *pInBuff, /* in buff to hash*/ 57 size_t inBuffSize, /* in buffer size */ 58 mbedtls_srp_sessionKey sessionKey, 59 mbedtls_srp_context *pCtx); 60 61 62 // Secure mem compare comes to prevent timing attacks on pwd comparison. 63 uint32_t SRP_SecureMemCmp( const uint8_t* aTarget, /*!< [in] The target buffer to compare. */ 64 const uint8_t* aSource, /*!< [in] The Source buffer to compare to. */ 65 size_t aSize /*!< [in] Number of bytes to compare. */); 66