Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// now check signature ....
const chunk = binaryStream.buffer;
const signatureIsOK = verifyChunkSignatureWithDerivedKeys(chunk, derivedKeys);
if (!signatureIsOK) {
this._report_error("_decrypt_MSG : Sign and Encrypt : Invalid packet signature");
return false;
}
// remove signature
binaryStream.buffer = reduceLength(binaryStream.buffer, derivedKeys.signatureLength);
if (this.securityMode === MessageSecurityMode.SignAndEncrypt) {
// remove padding
binaryStream.buffer = removePadding(binaryStream.buffer);
}
return true;
}
// now check signature ....
const chunk = binaryStream._buffer;
const signatureIsOK = crypto_utils.verifyChunkSignatureWithDerivedKeys(chunk, derivedKeys);
if (!signatureIsOK) {
this._report_error("SIGN and ENCRYPT : Invalid packet signature");
return false;
}
// remove signature
binaryStream._buffer = crypto_utils.reduceLength(binaryStream._buffer, derivedKeys.signatureLength);
if (this.securityMode === MessageSecurityMode.SIGNANDENCRYPT) {
// remove padding
binaryStream._buffer = crypto_utils.removePadding(binaryStream._buffer);
}
return true;
};
if (!signatureIsOK) {
/* istanbul ignore next */
if (doDebug) {
debugLog(hexDump(binaryStream.buffer));
}
this._report_error("Sign and Encrypt asymmetricVerify : Invalid packet signature");
return false;
}
// remove signature
binaryStream.buffer = reduceLength(binaryStream.buffer, signatureLength);
// remove padding
if (asymmetricAlgorithmSecurityHeader.receiverCertificateThumbprint) {
binaryStream.buffer = removePadding(binaryStream.buffer);
}
return true; // success
}