Open arun3528 opened 2 years ago
@arun3528 Hi, I have located the object construction builder in algorithms/helpers and replaced the require statement "crypto" to "crypto-js".
Any suggestions on testing within the library, might just be late, will have to come back and review.
This is the sdk we use it in https://github.com/webex/webex-js-sdk This gets used in web.webex.com for messaging
`50 results - 12 files
lib/algorithms/aes-cbc-hmac-sha2.js: 94 var name = "AES-" + size + "-CBC"; 95: var cipher = helpers.nodeCrypto.createCipheriv(name, encKey, iv); 96 var cdata = Buffer.concat([
185 var name = "AES-" + size + "-CBC"; 186: var cipher = helpers.nodeCrypto.createDecipheriv(name, encKey, iv); 187 var pdata = Buffer.concat([
lib/algorithms/aes-gcm.js: 168 try { 169: cipher = helpers.nodeCrypto.createCipheriv(alg, key, iv); 170 } catch (err) {
325 try { 326: cipher = helpers.nodeCrypto.createDecipheriv(alg, key, iv); 327 } catch(err) {
lib/algorithms/aes-kw.js: 142 B = Buffer.concat([A, R[idx]]); 143: var cipher = helpers.nodeCrypto.createCipheriv("AES" + size, key, iv); 144 B = cipher.update(B);
254 B = Buffer.concat([B, R[idx], iv]); 255: var cipher = helpers.nodeCrypto.createDecipheriv("AES" + size, key, iv); 256 B = cipher.update(B);
lib/algorithms/ecdh.js: 138 var nodejs = function(key, props) { 139: if ("function" !== typeof helpers.nodeCrypto.createECDH) { 140 throw new Error("unsupported algorithm: ECDH");
166 // {pubKey} is "buffer" 167: var ecdh = helpers.nodeCrypto.createECDH(curve); 168 // dummy call so computeSecret doesn't fail
lib/algorithms/ecdsa.js: 84 var nodeHash = hash.toLowerCase().replace("-", ""); 85: if (helpers.nodeCrypto && helpers.nodeCrypto.getHashes().indexOf(nodeHash) > -1) { 86 nodejs = function(key, pdata) {
91 var promise; 92: promise = Promise.resolve(helpers.nodeCrypto.createSign(nodeHash)); 93 promise = promise.then(function (sign) {
198 var nodeHash = hash.toLowerCase().replace("-", ""); 199: if (helpers.nodeCrypto && helpers.nodeCrypto.getHashes().indexOf(nodeHash) > -1) { 200 nodejs = function(key, pdata, mac / , props /) {
217 var promise; 218: promise = Promise.resolve(helpers.nodeCrypto.createVerify(nodeHash)); 219 promise = promise.then(function (verify) {
lib/algorithms/helpers.js: 76 }); 77: Object.defineProperty(exports, "nodeCrypto", { 78 get: function() {
80
81: if ("nodeCrypto" in supported) {
82: result = supported.nodeCrypto;
83 } else {
84: result = supported.nodeCrypto = getCryptoNodeJS();
85 }
94
95: if (nodejs && exports.nodeCrypto) {
96 impl = function main() {
lib/algorithms/hmac.js: 80 promise = promise.then(function() { 81: var hmac = helpers.nodeCrypto.createHmac(md, key); 82 hmac.update(pdata);
171
172: var hmac = helpers.nodeCrypto.createHmac(md, key);
173 hmac.update(pdata);
lib/algorithms/pbes2.js: 111 var nodejs = function(key, props) { 112: if (6 > helpers.nodeCrypto.pbkdf2.length) { 113 throw new Error("unsupported algorithm: PBKDF2-" + hash);
134 } 135: helpers.nodeCrypto.pbkdf2(key, salt, itrs, keyLen, md, cb); 136 });
lib/algorithms/rsaes.js: 18 function nodeSupportCheck(name) { 19: return helpers.nodeCrypto && helpers.nodeCrypto.constants && Object.keys(nodeSupport).indexOf(name) !== -1; 20 }
92
93: var cdata = helpers.nodeCrypto.publicEncrypt({
94 key: key,
95: padding: helpers.nodeCrypto.constants[nodeSupport[name]]
96 }, pdata);
169 key = rsaUtil.convertToPem(key, false); 170: return helpers.nodeCrypto.privateDecrypt({ 171 key: key, 172: padding: helpers.nodeCrypto.constants[nodeSupport[name]] 173 }, pdata); 174 }; 175: } else if (helpers.nodeCrypto && name === "RSA-OAEP") { // node (>= 6.0.0 && < 6.12.0) || ^7.0.0 176 nodejs = function(key, pdata) { 177 key = rsaUtil.convertToPem(key, false); 178: return helpers.nodeCrypto.privateDecrypt(key, pdata); 179 };
lib/algorithms/rsassa.js: 13 function nodePSSsupport() { 14: return helpers.nodeCrypto && helpers.nodeCrypto.constants && helpers.nodeCrypto.constants.RSA_PSS_SALTLEN_DIGEST; 15 }
68 var nodeHash = "RSA-" + hash.replace("-", ""); 69: if (helpers.nodeCrypto && helpers.nodeCrypto.getHashes().indexOf(nodeHash) > -1) { 70 nodejs = function(key, pdata) { 71: var sign = helpers.nodeCrypto.createSign(nodeHash); 72 sign.update(pdata);
139 var nodejs; 140: if (helpers.nodeCrypto && helpers.nodeCrypto.getHashes().indexOf(md) > -1) { 141 nodejs = function(key, pdata, mac) { 142: var verify = helpers.nodeCrypto.createVerify(md); 143 verify.update(pdata);
221 nodejs = function(key, pdata) { 222: var sign = helpers.nodeCrypto.createSign(nodeHash); 223 sign.update(pdata);
226 key: rsaUtil.convertToPem(key, false), 227: padding: helpers.nodeCrypto.constants.RSA_PKCS1_PSS_PADDING, 228: saltLength: helpers.nodeCrypto.constants.RSA_PSS_SALTLEN_DIGEST 229 });
307 nodejs = function(key, pdata, mac) { 308: var verify = helpers.nodeCrypto.createVerify(md); 309 verify.update(pdata);
312 key: rsaUtil.convertToPem(key, true), 313: padding: helpers.nodeCrypto.constants.RSA_PKCS1_PSS_PADDING, 314: saltLength: helpers.nodeCrypto.constants.RSA_PSS_SALTLEN_DIGEST 315 }, mac);
lib/algorithms/sha.js: 39 var nodejs = function(pdata / props /) { 40: var digest = helpers.nodeCrypto.createHash(md); 41 digest.update(pdata);
lib/jwk/rsakey.js: 9 rsau = require("../algorithms/rsa-util"), 10: nodeCrypto = require("../algorithms/helpers").nodeCrypto; 11
262
263: if (nodeCrypto) {
264 promise = new Promise(function (resolve, reject) {
`
Is there a PR to change the require from crypto to crypto-js. This is breaking when we are using the esbuild preprocessor.
@justaugustus , Is it okay to change the require from crypto to crypto-js? This line would change. https://github.com/cisco/node-jose/blob/master/lib/algorithms/helpers.js#L49
client does not have to do node pollyfills if we move to use the js version