MCPcopy Create free account
hub / github.com/mscdex/ssh2 / bigIntToBuffer

Function bigIntToBuffer

lib/protocol/keyParser.js:143–158  ·  view source on GitHub ↗
(bn)

Source from the content-addressed store, hash-verified

141 }
142
143 function bigIntToBuffer(bn) {
144 let hex = bn.toString(16);
145 if ((hex.length & 1) !== 0) {
146 hex = `0${hex}`;
147 } else {
148 const sigbit = hex.charCodeAt(0);
149 // BER/DER integers require leading zero byte to denote a positive value
150 // when first byte >= 0x80
151 if (sigbit === 56/* '8' */
152 || sigbit === 57/* '9' */
153 || (sigbit >= 97/* 'a' */ && sigbit <= 102/* 'f' */)) {
154 hex = `00${hex}`;
155 }
156 }
157 return Buffer.from(hex, 'hex');
158 }
159
160 return function genOpenSSLRSAPriv(n, e, d, iqmp, p, q) {
161 const bn_d = bigIntFromBuffer(d);

Callers 1

keyParser.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…