/* Psuedo-random function. TLS uses this for key generation and hashing */ int32 prf2(unsigned char *sec, uint32 secLen, unsigned char *seed, uint32 seedLen, unsigned char *out, uint32 outLen, uint32 flags) { unsigned char sha2out[SSL_MAX_KEY_BLOCK_SIZE]; uint32 i; psAssert(outLen <= SSL_MAX_KEY_BLOCK_SIZE); pSha2(sec, secLen, seed, seedLen, sha2out, outLen, flags); for (i = 0; i < outLen; i++) { out[i] = sha2out[i]; } return outLen; }
/* Psuedo-random function. TLS uses this for key generation and hashing */ int32_t prf2(const unsigned char *sec, uint16_t secLen, const unsigned char *seed, uint16_t seedLen, unsigned char *out, uint16_t outLen, uint32_t flags) { unsigned char sha2out[SSL_MAX_KEY_BLOCK_SIZE]; int32_t rc; uint16_t i; psAssert(outLen <= SSL_MAX_KEY_BLOCK_SIZE); if ((rc = pSha2(sec, secLen, seed, seedLen, sha2out, outLen, flags)) < 0) { return rc; } /* Copy out of tmp buffer because outLen typically less than multiple of prf block size */ for (i = 0; i < outLen; i++) { out[i] = sha2out[i]; } memzero_s(sha2out, SSL_MAX_KEY_BLOCK_SIZE); return outLen; }