How to use the node-opcua-service-secure-channel.SignatureData function in node-opcua-service-secure-channel

To help you get started, we’ve selected a few node-opcua-service-secure-channel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-opcua / node-opcua / packages / node-opcua-secure-channel / src / security_policy.js View on Github external
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"
    });
}
github node-opcua / node-opcua / packages / node-opcua-secure-channel / source / security_policy.ts View on Github external
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,
    });
}