compute TLSv1 PRF (pseudo random function using HMAC)
| 690 | |
| 691 | // compute TLSv1 PRF (pseudo random function using HMAC) |
| 692 | void PRF(byte* digest, uint digLen, const byte* secret, uint secLen, |
| 693 | const byte* label, uint labLen, const byte* seed, uint seedLen) |
| 694 | { |
| 695 | uint half = (secLen + 1) / 2; |
| 696 | |
| 697 | output_buffer md5_half(half); |
| 698 | output_buffer sha_half(half); |
| 699 | output_buffer labelSeed(labLen + seedLen); |
| 700 | |
| 701 | md5_half.write(secret, half); |
| 702 | sha_half.write(secret + half - secLen % 2, half); |
| 703 | labelSeed.write(label, labLen); |
| 704 | labelSeed.write(seed, seedLen); |
| 705 | |
| 706 | output_buffer md5_result(digLen); |
| 707 | output_buffer sha_result(digLen); |
| 708 | |
| 709 | p_hash(md5_result, md5_half, labelSeed, md5); |
| 710 | p_hash(sha_result, sha_half, labelSeed, sha); |
| 711 | |
| 712 | md5_result.set_current(0); |
| 713 | sha_result.set_current(0); |
| 714 | get_xor(digest, digLen, md5_result, sha_result); |
| 715 | } |
| 716 | |
| 717 | |
| 718 | // build certificate hashes |
no test coverage detected