NodeOPCUA API Documentation
    Preparing search index...

    Interface CryptoFactory

    interface CryptoFactory {
        asymmetricDecrypt: (buffer: Buffer, privateKey: PrivateKey) => Buffer;
        asymmetricEncrypt: (buffer: Buffer, publicKey: KeyObject) => Buffer;
        asymmetricEncryption?: boolean;
        asymmetricEncryptionAlgorithm: string;
        asymmetricKeyType?: "rsa" | "ec";
        asymmetricSign: (buffer: Buffer, privateKey: PrivateKey) => Buffer;
        asymmetricSignatureAlgorithm: string;
        asymmetricVerify: (
            buffer: Buffer,
            signature: Signature,
            certificate: DER,
        ) => boolean;
        asymmetricVerifyChunk: (
            self: CryptoFactory,
            chunk: Buffer,
            certificate: DER,
        ) => { signatureIsOK: boolean; signatureLength: number };
        authenticatedEncryption?: boolean;
        blockPaddingSize: number;
        certificateCurves?: readonly string[];
        certificateThumbprintHash?: "sha256" | "sha384";
        decryptParams?: AsymmetricDecryptParams;
        derivedEncryptionKeyLength: number;
        derivedSignatureKeyLength: number;
        ecdsaSignParams?: EcdsaSignParams;
        encryptingBlockSize: number;
        ephemeralKeyCurve?: string;
        keyDerivationHash?: "SHA-256" | "SHA-384";
        legacySequenceNumbers?: boolean;
        maximumAsymmetricKeyLength: number;
        minimumAsymmetricKeyLength: number;
        secureChannelEnhancements?: boolean;
        secureChannelNonceLength?: number;
        securityPolicy: SecurityPolicy;
        sha1or256: "SHA1" | "SHA256";
        signatureLength: number;
        signParams?: AsymmetricSignParams;
        symmetricEncryptionAlgorithm:
            | "aes-128-gcm"
            | "chacha20-poly1305"
            | "aes-256-cbc"
            | "aes-128-cbc";
        symmetricKeyLength: number;
    }
    Index
    asymmetricDecrypt: (buffer: Buffer, privateKey: PrivateKey) => Buffer

    raw-key decryption is superseded by the opaque key-operations path: declare decryptParams and decrypt through asymmetricDecryptWithKeyOps(+Sync). Still populated and functional; a removal candidate for the next major.

    asymmetricEncrypt: (buffer: Buffer, publicKey: KeyObject) => Buffer
    asymmetricEncryption?: boolean

    false for a policy with no asymmetric encryption: its OpenSecureChannel message is signed and not encrypted. A factory that does not say it has asymmetric encryption: read it with hasAsymmetricEncryption.

    A factory that sets it to false gives an CryptoFactory.asymmetricEncrypt and an CryptoFactory.asymmetricDecrypt that throw, and a CryptoFactory.blockPaddingSize of 0. The password of a user is not encrypted with such a policy.

    asymmetricEncryptionAlgorithm: string

    for info only

    asymmetricKeyType?: "rsa" | "ec"

    The family of the key of an application certificate under this policy. A factory that does not say it is for RSA keys: read it with getAsymmetricKeyType.

    For "ec" the policy also gives CryptoFactory.ecdsaSignParams and CryptoFactory.certificateCurves.

    asymmetricSign: (buffer: Buffer, privateKey: PrivateKey) => Buffer

    raw-key signing is superseded by the opaque key-operations path: declare signParams and sign through an IKeyOperations (see computeSignatureAsync / the OPN builders). Still populated and functional; a removal candidate for the next major.

    asymmetricSignatureAlgorithm: string

    for info only

    asymmetricVerify: (
        buffer: Buffer,
        signature: Signature,
        certificate: DER,
    ) => boolean
    asymmetricVerifyChunk: (
        self: CryptoFactory,
        chunk: Buffer,
        certificate: DER,
    ) => { signatureIsOK: boolean; signatureLength: number }
    authenticatedEncryption?: boolean

    true when the chunks of the channel are sealed in one step: the encryption and the signature are one algorithm (AES-GCM or ChaCha20-Poly1305), with a tag in place of a signature, no padding, and an initialization vector made for each chunk (OPC 10000-6, 6.7.2 and 6.8.1). A factory that does not say it signs with a HMAC and then encrypts: read it with usesAuthenticatedEncryption.

    blockPaddingSize: number
    certificateCurves?: readonly string[]

    The curves that the key of an application certificate can be on under this policy, with their OpenSSL names. Only for a policy whose CryptoFactory.asymmetricKeyType is "ec".

    certificateThumbprintHash?: "sha256" | "sha384"

    The hash that HASH() of the signatures bound to the channel uses (OPC 10000-4, 6.1.8): the CertificateThumbprintAlgorithm of the policy. It is given by a policy with CryptoFactory.secureChannelEnhancements.

    decryptParams?: AsymmetricDecryptParams

    Same as signParams, for asymmetricDecrypt.

    derivedEncryptionKeyLength: number
    derivedSignatureKeyLength: number
    ecdsaSignParams?: EcdsaSignParams

    How to sign with a key on an elliptic curve: the twin of CryptoFactory.signParams for a policy whose CryptoFactory.asymmetricKeyType is "ec".

    encryptingBlockSize: number

    The length of the derived initialization vector: 16 for AES-CBC, where it is the cipher block, and 12 for AES-GCM, where the cipher block is 16.

    ephemeralKeyCurve?: string

    The curve of the ephemeral key of each side, with its OpenSSL name, for a policy whose channel keys come from a key agreement: the nonce is then the public key of that ephemeral key, and the keys come from ECDH and HKDF (OPC 10000-6, 6.8.1). A factory that does not give it derives the keys from the two nonces.

    keyDerivationHash?: "SHA-256" | "SHA-384"

    The hash of the HKDF of a policy that gives CryptoFactory.ephemeralKeyCurve.

    legacySequenceNumbers?: boolean

    false when the sequence numbers of the chunks start at 0 and go back to 0 after the largest UInt32 (OPC 10000-6, 6.7.2.4). A factory that does not say it has the earlier rule, with numbers that go back below 1024: read it with usesLegacySequenceNumbers.

    maximumAsymmetricKeyLength: number

    for info only

    minimumAsymmetricKeyLength: number

    for info only

    secureChannelEnhancements?: boolean

    true for a policy with SecureChannelEnhancements (OPC 10000-6, 6.7.5): the ChannelThumbprint, the chaining of the keys on a renewal, and the signatures of a session bound to the channel. A factory that does not say it has the legacy calculations: read it with usesSecureChannelEnhancements.

    secureChannelNonceLength?: number

    The length in bytes of the nonce of an OpenSecureChannel message: the SecureChannelNonceLength of the policy. A factory that does not say it uses CryptoFactory.symmetricKeyLength, as the five RSA policies do: read it with getSecureChannelNonceLength.

    securityPolicy: SecurityPolicy
    sha1or256: "SHA1" | "SHA256"
    signatureLength: number
    signParams?: AsymmetricSignParams

    The policy's asymmetric signature scheme as parameters an opaque IKeyOperations provider understands — the algorithm-URI-free twin of asymmetricSign. Optional so third-party factory literals predating it stay valid; using an opaque key against a factory that lacks it fails with a clear error (see getSignParams).

    symmetricEncryptionAlgorithm:
        | "aes-128-gcm"
        | "chacha20-poly1305"
        | "aes-256-cbc"
        | "aes-128-cbc"
    symmetricKeyLength: number