Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!senderNonce || !senderCertificate) {
return null;
}
const crypto_factory = getCryptoFactory(securityPolicy);
if (!crypto_factory) {
return null;
}
// This parameter is calculated by appending the clientNonce to the clientCertificate
const buffer = Buffer.concat([senderCertificate, senderNonce]);
// ... and signing the resulting sequence of bytes.
const signature = crypto_factory.asymmetricSign(buffer, receiverPrivatekey);
return new SignatureData({
// This is a signature generated with the private key associated with a Certificate
signature: signature,
// A string containing the URI of the algorithm.
// The URI string values are defined as part of the security profiles specified in Part 7.
// (The SignatureAlgorithm shall be the AsymmetricSignatureAlgorithm specified in the
// SecurityPolicy for the Endpoint)
algorithm: crypto_factory.asymmetricSignatureAlgorithm // "http://www.w3.org/2000/09/xmldsig#rsa-sha1"
});
}
if (!senderNonce || !senderCertificate || !receiverPrivateKey) {
return undefined;
}
const cryptoFactory = getCryptoFactory(securityPolicy);
if (!cryptoFactory) {
return undefined;
}
// This parameter is calculated by appending the clientNonce to the clientCertificate
const dataToSign = Buffer.concat([senderCertificate, senderNonce]);
// ... and signing the resulting sequence of bytes.
const signature = cryptoFactory.asymmetricSign(dataToSign, receiverPrivateKey);
return new SignatureData({
// A string containing the URI of the algorithm.
// The URI string values are defined as part of the security profiles specified in Part 7.
// (The SignatureAlgorithm shall be the AsymmetricSignatureAlgorithm specified in the
// SecurityPolicy for the Endpoint)
// for instance "http://www.w3.org/2000/09/xmldsig#rsa-sha1"
algorithm: cryptoFactory.asymmetricSignatureAlgorithm,
// This is a signature generated with the private key associated with a Certificate
signature,
});
}