MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / p_hash

Function p_hash

modules/crypt/ssl/ssl_prf.js:49–61  ·  view source on GitHub ↗
(hash, secret, seed, sz)

Source from the content-addressed store, hash-verified

47}
48
49function p_hash(hash, secret, seed, sz)
50{
51 sz = iceil(sz, hash.outputSize);
52 const hmac = new HMAC(hash, secret);
53 let A = hmac.process(seed); // start from A(1) = hmac(seed)
54 let p = new SSLStream;
55 while (--sz >= 0) {
56 p.writeChunk(hmac.process(A, seed));
57 if (sz > 0)
58 A = hmac.process(A);
59 }
60 return p.getChunk();
61}
62
63function PRF(session, secret, label, seed, n, hash)
64{

Callers 1

PRFFunction · 0.85

Calls 4

processMethod · 0.95
writeChunkMethod · 0.95
getChunkMethod · 0.95
iceilFunction · 0.85

Tested by

no test coverage detected