(bn)
| 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); |
no outgoing calls
no test coverage detected
searching dependent graphs…