Comparing version 2.1.91 to 2.1.92
@@ -64,2 +64,6 @@ "use strict"; | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } | ||
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } | ||
//************************************************************************************** | ||
@@ -375,3 +379,4 @@ | ||
if ("kdfAlgorithm" in encryptionParameters === false) encryptionParameters.kdfAlgorithm = "SHA-512"; | ||
if ("kekEncryptionLength" in encryptionParameters === false) encryptionParameters.kekEncryptionLength = 256; //endregion | ||
if ("kekEncryptionLength" in encryptionParameters === false) encryptionParameters.kekEncryptionLength = 256; | ||
if ("useOAEP" in encryptionParameters === false) encryptionParameters.useOAEP = true; //endregion | ||
//region Add new "recipient" depends on "variant" and certificate type | ||
@@ -383,27 +388,42 @@ | ||
{ | ||
//region keyEncryptionAlgorithm | ||
const oaepOID = (0, _common.getOIDByAlgorithm)({ | ||
name: "RSA-OAEP" | ||
}); | ||
if (oaepOID === "") throw new Error("Can not find OID for OAEP"); //endregion | ||
//region RSAES-OAEP-params | ||
let algorithmId; | ||
let algorithmParams; | ||
const hashOID = (0, _common.getOIDByAlgorithm)({ | ||
name: encryptionParameters.oaepHashAlgorithm | ||
}); | ||
if (hashOID === "") throw new Error(`Unknown OAEP hash algorithm: ${encryptionParameters.oaepHashAlgorithm}`); | ||
const hashAlgorithm = new _AlgorithmIdentifier.default({ | ||
algorithmId: hashOID, | ||
algorithmParams: new asn1js.Null() | ||
}); | ||
const rsaOAEPParams = new _RSAESOAEPParams.default({ | ||
hashAlgorithm, | ||
maskGenAlgorithm: new _AlgorithmIdentifier.default({ | ||
algorithmId: "1.2.840.113549.1.1.8", | ||
// id-mgf1 | ||
algorithmParams: hashAlgorithm.toSchema() | ||
}) | ||
}); //endregion | ||
//region KeyTransRecipientInfo | ||
if (encryptionParameters.useOAEP === true) { | ||
//region keyEncryptionAlgorithm | ||
algorithmId = (0, _common.getOIDByAlgorithm)({ | ||
name: "RSA-OAEP" | ||
}); | ||
if (algorithmId === "") throw new Error("Can not find OID for RSA-OAEP"); //endregion | ||
//region RSAES-OAEP-params | ||
const hashOID = (0, _common.getOIDByAlgorithm)({ | ||
name: encryptionParameters.oaepHashAlgorithm | ||
}); | ||
if (hashOID === "") throw new Error(`Unknown OAEP hash algorithm: ${encryptionParameters.oaepHashAlgorithm}`); | ||
const hashAlgorithm = new _AlgorithmIdentifier.default({ | ||
algorithmId: hashOID, | ||
algorithmParams: new asn1js.Null() | ||
}); | ||
const rsaOAEPParams = new _RSAESOAEPParams.default({ | ||
hashAlgorithm, | ||
maskGenAlgorithm: new _AlgorithmIdentifier.default({ | ||
algorithmId: "1.2.840.113549.1.1.8", | ||
// id-mgf1 | ||
algorithmParams: hashAlgorithm.toSchema() | ||
}) | ||
}); | ||
algorithmParams = rsaOAEPParams.toSchema(); //endregion | ||
} else // Use old RSAES-PKCS1-v1_5 schema instead | ||
{ | ||
//region keyEncryptionAlgorithm | ||
algorithmId = (0, _common.getOIDByAlgorithm)({ | ||
name: "RSAES-PKCS1-v1_5" | ||
}); | ||
if (algorithmId === "") throw new Error("Can not find OID for RSAES-PKCS1-v1_5"); //endregion | ||
algorithmParams = new asn1js.Null(); | ||
} //region KeyTransRecipientInfo | ||
const keyInfo = new _KeyTransRecipientInfo.default({ | ||
@@ -416,4 +436,4 @@ version: 0, | ||
keyEncryptionAlgorithm: new _AlgorithmIdentifier.default({ | ||
algorithmId: oaepOID, | ||
algorithmParams: rsaOAEPParams.toSchema() | ||
algorithmId, | ||
algorithmParams | ||
}), | ||
@@ -882,48 +902,38 @@ recipientCertificate: certificate // "encryptedKey" will be calculated in "encrypt" function | ||
function SubKeyTransRecipientInfo(index) { | ||
//region Initial variables | ||
let currentSequence = Promise.resolve(); //endregion | ||
//region Get recipient's public key | ||
function SubKeyTransRecipientInfo(_x) { | ||
return _SubKeyTransRecipientInfo.apply(this, arguments); | ||
} | ||
currentSequence = currentSequence.then(() => { | ||
//region Check we have a correct algorithm here | ||
const oaepOID = (0, _common.getOIDByAlgorithm)({ | ||
name: "RSA-OAEP" | ||
}); | ||
if (oaepOID === "") throw new Error("Can not find OID for OAEP"); | ||
if (_this.recipientInfos[index].value.keyEncryptionAlgorithm.algorithmId !== oaepOID) throw new Error("Not supported encryption scheme, only RSA-OAEP is supported for key transport encryption scheme"); //endregion | ||
//region Get current used SHA algorithm | ||
function _SubKeyTransRecipientInfo() { | ||
_SubKeyTransRecipientInfo = _asyncToGenerator(function* (index) { | ||
const algorithmParameters = (0, _common.getAlgorithmByOID)(_this.recipientInfos[index].value.keyEncryptionAlgorithm.algorithmId); | ||
if ("name" in algorithmParameters === false) throw new Error(`Unknown keyEncryptionAlgorithm: ${_this.recipientInfos[index].value.keyEncryptionAlgorithm.algorithmId}`); //region RSA-OAEP case | ||
const schema = _this.recipientInfos[index].value.keyEncryptionAlgorithm.algorithmParams; | ||
const rsaOAEPParams = new _RSAESOAEPParams.default({ | ||
schema | ||
}); | ||
const hashAlgorithm = (0, _common.getAlgorithmByOID)(rsaOAEPParams.hashAlgorithm.algorithmId); | ||
if ("name" in hashAlgorithm === false) return Promise.reject(`Incorrect OID for hash algorithm: ${rsaOAEPParams.hashAlgorithm.algorithmId}`); //endregion | ||
if (algorithmParameters.name === "RSA-OAEP") { | ||
const schema = _this.recipientInfos[index].value.keyEncryptionAlgorithm.algorithmParams; | ||
const rsaOAEPParams = new _RSAESOAEPParams.default({ | ||
schema | ||
}); | ||
algorithmParameters.hash = (0, _common.getAlgorithmByOID)(rsaOAEPParams.hashAlgorithm.algorithmId); | ||
if ("name" in algorithmParameters.hash === false) throw new Error(`Incorrect OID for hash algorithm: ${rsaOAEPParams.hashAlgorithm.algorithmId}`); | ||
} //endregion | ||
return _this.recipientInfos[index].value.recipientCertificate.getPublicKey({ | ||
algorithm: { | ||
try { | ||
const publicKey = yield _this.recipientInfos[index].value.recipientCertificate.getPublicKey({ | ||
algorithm: { | ||
name: "RSA-OAEP", | ||
hash: { | ||
name: hashAlgorithm.name | ||
} | ||
}, | ||
usages: ["encrypt", "wrapKey"] | ||
} | ||
}); | ||
}, error => Promise.reject(error)); //endregion | ||
//region Encrypt early exported session key on recipient's public key | ||
algorithm: algorithmParameters, | ||
usages: ["encrypt", "wrapKey"] | ||
} | ||
}); | ||
const encryptedKey = yield crypto.encrypt(publicKey.algorithm, publicKey, exportedSessionKey); //region RecipientEncryptedKey | ||
currentSequence = currentSequence.then(result => crypto.encrypt(result.algorithm, result, exportedSessionKey), error => Promise.reject(error)); //endregion | ||
//region Append all neccessary data to current CMS_RECIPIENT_INFO object | ||
currentSequence = currentSequence.then(result => { | ||
//region RecipientEncryptedKey | ||
_this.recipientInfos[index].value.encryptedKey = new asn1js.OctetString({ | ||
valueHex: result | ||
}); //endregion | ||
}, error => Promise.reject(error)); //endregion | ||
return currentSequence; | ||
_this.recipientInfos[index].value.encryptedKey = new asn1js.OctetString({ | ||
valueHex: encryptedKey | ||
}); //endregion | ||
} catch (ex) { | ||
const jjj = 0; | ||
} | ||
}); | ||
return _SubKeyTransRecipientInfo.apply(this, arguments); | ||
} | ||
@@ -1233,38 +1243,31 @@ | ||
function SubKeyTransRecipientInfo(index) { | ||
//region Initial variables | ||
let currentSequence = Promise.resolve(); //endregion | ||
//region Import recipient's private key | ||
function SubKeyTransRecipientInfo(_x2) { | ||
return _SubKeyTransRecipientInfo2.apply(this, arguments); | ||
} | ||
currentSequence = currentSequence.then(() => { | ||
if ("recipientPrivateKey" in decryptionParameters === false) return Promise.reject("Parameter \"recipientPrivateKey\" is mandatory for \"KeyTransRecipientInfo\""); //region Get current used SHA algorithm | ||
function _SubKeyTransRecipientInfo2() { | ||
_SubKeyTransRecipientInfo2 = _asyncToGenerator(function* (index) { | ||
if ("recipientPrivateKey" in decryptionParameters === false) throw new Error("Parameter \"recipientPrivateKey\" is mandatory for \"KeyTransRecipientInfo\""); | ||
const algorithmParameters = (0, _common.getAlgorithmByOID)(_this.recipientInfos[index].value.keyEncryptionAlgorithm.algorithmId); | ||
if ("name" in algorithmParameters === false) throw new Error(`Unknown keyEncryptionAlgorithm: ${_this.recipientInfos[index].value.keyEncryptionAlgorithm.algorithmId}`); //region RSA-OAEP case | ||
const schema = _this.recipientInfos[index].value.keyEncryptionAlgorithm.algorithmParams; | ||
const rsaOAEPParams = new _RSAESOAEPParams.default({ | ||
schema | ||
}); | ||
const hashAlgorithm = (0, _common.getAlgorithmByOID)(rsaOAEPParams.hashAlgorithm.algorithmId); | ||
if ("name" in hashAlgorithm === false) return Promise.reject(`Incorrect OID for hash algorithm: ${rsaOAEPParams.hashAlgorithm.algorithmId}`); //endregion | ||
if (algorithmParameters.name === "RSA-OAEP") { | ||
const schema = _this.recipientInfos[index].value.keyEncryptionAlgorithm.algorithmParams; | ||
const rsaOAEPParams = new _RSAESOAEPParams.default({ | ||
schema | ||
}); | ||
algorithmParameters.hash = (0, _common.getAlgorithmByOID)(rsaOAEPParams.hashAlgorithm.algorithmId); | ||
if ("name" in algorithmParameters.hash === false) throw new Error(`Incorrect OID for hash algorithm: ${rsaOAEPParams.hashAlgorithm.algorithmId}`); | ||
} //endregion | ||
return crypto.importKey("pkcs8", decryptionParameters.recipientPrivateKey, { | ||
name: "RSA-OAEP", | ||
hash: { | ||
name: hashAlgorithm.name | ||
} | ||
}, true, ["decrypt"]); | ||
}, error => Promise.reject(error)); //endregion | ||
//region Decrypt encrypted session key | ||
currentSequence = currentSequence.then(result => crypto.decrypt(result.algorithm, result, _this.recipientInfos[index].value.encryptedKey.valueBlock.valueHex), error => Promise.reject(error)); //endregion | ||
//region Import decrypted session key | ||
const privateKey = yield crypto.importKey("pkcs8", decryptionParameters.recipientPrivateKey, algorithmParameters, true, ["decrypt"]); | ||
const sessionKey = yield crypto.decrypt(privateKey.algorithm, privateKey, _this.recipientInfos[index].value.encryptedKey.valueBlock.valueHex); //region Get WebCrypto form of content encryption algorithm | ||
currentSequence = currentSequence.then(result => { | ||
//region Get WebCrypto form of content encryption algorithm | ||
const contentEncryptionAlgorithm = (0, _common.getAlgorithmByOID)(_this.encryptedContentInfo.contentEncryptionAlgorithm.algorithmId); | ||
if ("name" in contentEncryptionAlgorithm === false) return Promise.reject(`Incorrect "contentEncryptionAlgorithm": ${_this.encryptedContentInfo.contentEncryptionAlgorithm.algorithmId}`); //endregion | ||
if ("name" in contentEncryptionAlgorithm === false) throw new Error(`Incorrect "contentEncryptionAlgorithm": ${_this.encryptedContentInfo.contentEncryptionAlgorithm.algorithmId}`); //endregion | ||
return crypto.importKey("raw", result, contentEncryptionAlgorithm, true, ["decrypt"]); | ||
}, error => Promise.reject(error)); //endregion | ||
return currentSequence; | ||
return crypto.importKey("raw", sessionKey, contentEncryptionAlgorithm, true, ["decrypt"]); | ||
}); | ||
return _SubKeyTransRecipientInfo2.apply(this, arguments); | ||
} | ||
@@ -1271,0 +1274,0 @@ |
@@ -108,3 +108,3 @@ { | ||
"name": "pkijs", | ||
"version": "2.1.91", | ||
"version": "2.1.92", | ||
"license": "BSD-3-Clause", | ||
@@ -111,0 +111,0 @@ "esdoc": { |
@@ -357,3 +357,6 @@ import * as asn1js from "asn1js"; | ||
encryptionParameters.kekEncryptionLength = 256; | ||
//endregion | ||
if(("useOAEP" in encryptionParameters) === false) | ||
encryptionParameters.useOAEP = true; | ||
//endregion | ||
@@ -365,31 +368,51 @@ //region Add new "recipient" depends on "variant" and certificate type | ||
{ | ||
//region keyEncryptionAlgorithm | ||
const oaepOID = getOIDByAlgorithm({ | ||
name: "RSA-OAEP" | ||
}); | ||
if(oaepOID === "") | ||
throw new Error("Can not find OID for OAEP"); | ||
//endregion | ||
let algorithmId; | ||
let algorithmParams; | ||
//region RSAES-OAEP-params | ||
const hashOID = getOIDByAlgorithm({ | ||
name: encryptionParameters.oaepHashAlgorithm | ||
}); | ||
if(hashOID === "") | ||
throw new Error(`Unknown OAEP hash algorithm: ${encryptionParameters.oaepHashAlgorithm}`); | ||
const hashAlgorithm = new AlgorithmIdentifier({ | ||
algorithmId: hashOID, | ||
algorithmParams: new asn1js.Null() | ||
}); | ||
const rsaOAEPParams = new RSAESOAEPParams({ | ||
hashAlgorithm, | ||
maskGenAlgorithm: new AlgorithmIdentifier({ | ||
algorithmId: "1.2.840.113549.1.1.8", // id-mgf1 | ||
algorithmParams: hashAlgorithm.toSchema() | ||
}) | ||
}); | ||
//endregion | ||
if(encryptionParameters.useOAEP === true) | ||
{ | ||
//region keyEncryptionAlgorithm | ||
algorithmId = getOIDByAlgorithm({ | ||
name: "RSA-OAEP" | ||
}); | ||
if(algorithmId === "") | ||
throw new Error("Can not find OID for RSA-OAEP"); | ||
//endregion | ||
//region RSAES-OAEP-params | ||
const hashOID = getOIDByAlgorithm({ | ||
name: encryptionParameters.oaepHashAlgorithm | ||
}); | ||
if(hashOID === "") | ||
throw new Error(`Unknown OAEP hash algorithm: ${encryptionParameters.oaepHashAlgorithm}`); | ||
const hashAlgorithm = new AlgorithmIdentifier({ | ||
algorithmId: hashOID, | ||
algorithmParams: new asn1js.Null() | ||
}); | ||
const rsaOAEPParams = new RSAESOAEPParams({ | ||
hashAlgorithm, | ||
maskGenAlgorithm: new AlgorithmIdentifier({ | ||
algorithmId: "1.2.840.113549.1.1.8", // id-mgf1 | ||
algorithmParams: hashAlgorithm.toSchema() | ||
}) | ||
}); | ||
algorithmParams = rsaOAEPParams.toSchema(); | ||
//endregion | ||
} | ||
else // Use old RSAES-PKCS1-v1_5 schema instead | ||
{ | ||
//region keyEncryptionAlgorithm | ||
algorithmId = getOIDByAlgorithm({ | ||
name: "RSAES-PKCS1-v1_5" | ||
}); | ||
if(algorithmId === "") | ||
throw new Error("Can not find OID for RSAES-PKCS1-v1_5"); | ||
//endregion | ||
algorithmParams = new asn1js.Null(); | ||
} | ||
//region KeyTransRecipientInfo | ||
@@ -403,4 +426,4 @@ const keyInfo = new KeyTransRecipientInfo({ | ||
keyEncryptionAlgorithm: new AlgorithmIdentifier({ | ||
algorithmId: oaepOID, | ||
algorithmParams: rsaOAEPParams.toSchema() | ||
algorithmId, | ||
algorithmParams | ||
}), | ||
@@ -947,66 +970,40 @@ recipientCertificate: certificate | ||
} | ||
function SubKeyTransRecipientInfo(index) | ||
async function SubKeyTransRecipientInfo(index) | ||
{ | ||
//region Initial variables | ||
let currentSequence = Promise.resolve(); | ||
//endregion | ||
//region Get recipient's public key | ||
currentSequence = currentSequence.then(() => | ||
const algorithmParameters = getAlgorithmByOID(_this.recipientInfos[index].value.keyEncryptionAlgorithm.algorithmId); | ||
if("name" in algorithmParameters === false) | ||
throw new Error(`Unknown keyEncryptionAlgorithm: ${_this.recipientInfos[index].value.keyEncryptionAlgorithm.algorithmId}`); | ||
//region RSA-OAEP case | ||
if(algorithmParameters.name === "RSA-OAEP") | ||
{ | ||
//region Check we have a correct algorithm here | ||
const oaepOID = getOIDByAlgorithm({ | ||
name: "RSA-OAEP" | ||
}); | ||
if(oaepOID === "") | ||
throw new Error("Can not find OID for OAEP"); | ||
const schema = _this.recipientInfos[index].value.keyEncryptionAlgorithm.algorithmParams; | ||
const rsaOAEPParams = new RSAESOAEPParams({ schema }); | ||
if(_this.recipientInfos[index].value.keyEncryptionAlgorithm.algorithmId !== oaepOID) | ||
throw new Error("Not supported encryption scheme, only RSA-OAEP is supported for key transport encryption scheme"); | ||
//endregion | ||
algorithmParameters.hash = getAlgorithmByOID(rsaOAEPParams.hashAlgorithm.algorithmId); | ||
if(("name" in algorithmParameters.hash) === false) | ||
throw new Error(`Incorrect OID for hash algorithm: ${rsaOAEPParams.hashAlgorithm.algorithmId}`); | ||
} | ||
//endregion | ||
//region Get current used SHA algorithm | ||
const schema = _this.recipientInfos[index].value.keyEncryptionAlgorithm.algorithmParams; | ||
const rsaOAEPParams = new RSAESOAEPParams({ schema }); | ||
const hashAlgorithm = getAlgorithmByOID(rsaOAEPParams.hashAlgorithm.algorithmId); | ||
if(("name" in hashAlgorithm) === false) | ||
return Promise.reject(`Incorrect OID for hash algorithm: ${rsaOAEPParams.hashAlgorithm.algorithmId}`); | ||
//endregion | ||
return _this.recipientInfos[index].value.recipientCertificate.getPublicKey({ | ||
try | ||
{ | ||
const publicKey = await _this.recipientInfos[index].value.recipientCertificate.getPublicKey({ | ||
algorithm: { | ||
algorithm: { | ||
name: "RSA-OAEP", | ||
hash: { | ||
name: hashAlgorithm.name | ||
} | ||
}, | ||
algorithm: algorithmParameters, | ||
usages: ["encrypt", "wrapKey"] | ||
} | ||
}); | ||
}, error => | ||
Promise.reject(error)); | ||
//endregion | ||
//region Encrypt early exported session key on recipient's public key | ||
currentSequence = currentSequence.then(result => | ||
crypto.encrypt(result.algorithm, result, exportedSessionKey), | ||
error => | ||
Promise.reject(error) | ||
); | ||
//endregion | ||
//region Append all neccessary data to current CMS_RECIPIENT_INFO object | ||
currentSequence = currentSequence.then(result => | ||
{ | ||
const encryptedKey = await crypto.encrypt(publicKey.algorithm, publicKey, exportedSessionKey); | ||
//region RecipientEncryptedKey | ||
_this.recipientInfos[index].value.encryptedKey = new asn1js.OctetString({ valueHex: result }); | ||
_this.recipientInfos[index].value.encryptedKey = new asn1js.OctetString({valueHex: encryptedKey}); | ||
//endregion | ||
}, error => | ||
Promise.reject(error) | ||
); | ||
//endregion | ||
return currentSequence; | ||
} | ||
catch(ex) | ||
{ | ||
const jjj = 0; | ||
} | ||
} | ||
@@ -1431,68 +1428,50 @@ | ||
} | ||
function SubKeyTransRecipientInfo(index) | ||
async function SubKeyTransRecipientInfo(index) | ||
{ | ||
//region Initial variables | ||
let currentSequence = Promise.resolve(); | ||
//endregion | ||
//region Import recipient's private key | ||
currentSequence = currentSequence.then(() => | ||
if(("recipientPrivateKey" in decryptionParameters) === false) | ||
throw new Error("Parameter \"recipientPrivateKey\" is mandatory for \"KeyTransRecipientInfo\""); | ||
const algorithmParameters = getAlgorithmByOID(_this.recipientInfos[index].value.keyEncryptionAlgorithm.algorithmId); | ||
if("name" in algorithmParameters === false) | ||
throw new Error(`Unknown keyEncryptionAlgorithm: ${_this.recipientInfos[index].value.keyEncryptionAlgorithm.algorithmId}`); | ||
//region RSA-OAEP case | ||
if(algorithmParameters.name === "RSA-OAEP") | ||
{ | ||
if(("recipientPrivateKey" in decryptionParameters) === false) | ||
return Promise.reject("Parameter \"recipientPrivateKey\" is mandatory for \"KeyTransRecipientInfo\""); | ||
//region Get current used SHA algorithm | ||
const schema = _this.recipientInfos[index].value.keyEncryptionAlgorithm.algorithmParams; | ||
const rsaOAEPParams = new RSAESOAEPParams({ schema }); | ||
const hashAlgorithm = getAlgorithmByOID(rsaOAEPParams.hashAlgorithm.algorithmId); | ||
if(("name" in hashAlgorithm) === false) | ||
return Promise.reject(`Incorrect OID for hash algorithm: ${rsaOAEPParams.hashAlgorithm.algorithmId}`); | ||
//endregion | ||
return crypto.importKey("pkcs8", | ||
decryptionParameters.recipientPrivateKey, | ||
{ | ||
name: "RSA-OAEP", | ||
hash: { | ||
name: hashAlgorithm.name | ||
} | ||
}, | ||
true, | ||
["decrypt"]); | ||
}, error => | ||
Promise.reject(error) | ||
); | ||
algorithmParameters.hash = getAlgorithmByOID(rsaOAEPParams.hashAlgorithm.algorithmId); | ||
if(("name" in algorithmParameters.hash) === false) | ||
throw new Error(`Incorrect OID for hash algorithm: ${rsaOAEPParams.hashAlgorithm.algorithmId}`); | ||
} | ||
//endregion | ||
//region Decrypt encrypted session key | ||
currentSequence = currentSequence.then(result => | ||
crypto.decrypt(result.algorithm, | ||
result, | ||
_this.recipientInfos[index].value.encryptedKey.valueBlock.valueHex | ||
), error => | ||
Promise.reject(error) | ||
const privateKey = await crypto.importKey( | ||
"pkcs8", | ||
decryptionParameters.recipientPrivateKey, | ||
algorithmParameters, | ||
true, | ||
["decrypt"] | ||
); | ||
const sessionKey = await crypto.decrypt( | ||
privateKey.algorithm, | ||
privateKey, | ||
_this.recipientInfos[index].value.encryptedKey.valueBlock.valueHex | ||
); | ||
//region Get WebCrypto form of content encryption algorithm | ||
const contentEncryptionAlgorithm = getAlgorithmByOID(_this.encryptedContentInfo.contentEncryptionAlgorithm.algorithmId); | ||
if(("name" in contentEncryptionAlgorithm) === false) | ||
throw new Error(`Incorrect "contentEncryptionAlgorithm": ${_this.encryptedContentInfo.contentEncryptionAlgorithm.algorithmId}`); | ||
//endregion | ||
//region Import decrypted session key | ||
currentSequence = currentSequence.then(result => | ||
{ | ||
//region Get WebCrypto form of content encryption algorithm | ||
const contentEncryptionAlgorithm = getAlgorithmByOID(_this.encryptedContentInfo.contentEncryptionAlgorithm.algorithmId); | ||
if(("name" in contentEncryptionAlgorithm) === false) | ||
return Promise.reject(`Incorrect "contentEncryptionAlgorithm": ${_this.encryptedContentInfo.contentEncryptionAlgorithm.algorithmId}`); | ||
//endregion | ||
return crypto.importKey("raw", | ||
result, | ||
contentEncryptionAlgorithm, | ||
true, | ||
["decrypt"] | ||
); | ||
}, error => | ||
Promise.reject(error) | ||
return crypto.importKey("raw", | ||
sessionKey, | ||
contentEncryptionAlgorithm, | ||
true, | ||
["decrypt"] | ||
); | ||
//endregion | ||
return currentSequence; | ||
} | ||
@@ -1499,0 +1478,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4494494
62793