(session, secret, label, seed, n, hash)
| 61 | } |
| 62 | |
| 63 | function PRF(session, secret, label, seed, n, hash) |
| 64 | { |
| 65 | let result; |
| 66 | label = ArrayBuffer.fromString(label).concat(seed); |
| 67 | if (session.protocolVersion <= 0x302) |
| 68 | result = Bin.xor( |
| 69 | p_hash(new Crypt.Digest("MD5"), secret.slice(0, iceil(secret.byteLength, 2)), label, n), |
| 70 | p_hash(new Crypt.Digest("SHA1"), secret.slice(Math.idiv(secret.byteLength, 2)), label, n) |
| 71 | ); |
| 72 | else { |
| 73 | if (!hash) |
| 74 | hash = session.chosenCipher.hashAlgorithm == SHA384 ? "SHA384" : "SHA256"; |
| 75 | result = p_hash(new Crypt.Digest(hash), secret, label, n); |
| 76 | } |
| 77 | result.buffer.resize(n); // p_hash > getChunk returns resizable buffer |
| 78 | return result; |
| 79 | } |
| 80 | |
| 81 | export default PRF; |
no test coverage detected