CryptoGenerateAsymmetricKeyPair (FUN) ¶ FUNCTION CryptoGenerateAsymmetricKeyPair : RTS_IEC_RESULT Generate an asymmetric key pair that can be used by the specivied algorithm. InOut: Scope Name Type Comment Return CryptoGenerateAsymmetricKeyPair RTS_IEC_RESULT Result of the operation Input hAlgo RTS_IEC_HANDLE Handle to the algorithm. ui32KeyLen UDINT Lenght of the key in bytes. May be omitted on ECC keys. pKeyPair POINTER TO RtsCryptoKey The generated key pair. Can be used for public or private key operations. xPrivateKeyExportable BOOL Define if the private key should be exportable using CrpyotExportAsymmetricKey
CryptoGetAsymmetricKeyLength (FUN) ¶ FUNCTION CryptoGetAsymmetricKeyLength : UDINT Get the asymmetric key size in bits. InOut: Scope Name Type Comment Return CryptoGetAsymmetricKeyLength UDINT Size of the asymmetric key in bits Input asymmetricKey RtsCryptoKey Asymmetric key of intrest. pResult POINTER TO RTS_IEC_RESULT Operation Result
CryptoImportAsymmetricKey (FUN) ¶ FUNCTION CryptoImportAsymmetricKey : RTS_IEC_RESULT This function can be used to import asymmtric keys from different formats. InOut: Scope Name Type Comment Return CryptoImportAsymmetricKey RTS_IEC_RESULT Result of the operation Input data RtsByteString The buffer to be imported. xBase64 BOOL Import the key in BASE64 encoding. Otherwise ASN.1 will be used. xPrivateKey BOOL TRUE: Import a private key. FLASE: Import a public key. pKey POINTER TO RtsCryptoKey The imported public key.
CryptoImportRawAsymmetricKey (FUN) ¶ FUNCTION CryptoImportRawAsymmetricKey : RTS_IEC_RESULT Imports a asymmetric key from raw format. This means that no additional data like ASN.1 or BASE64 encoding is needed. Not all asymmetric algorithms can import this format.</description> InOut: Scope Name Type Comment Return CryptoImportRawAsymmetricKey RTS_IEC_RESULT Operation result. ERR_OK: The key was imported. ERR_FAILED: Storage of the key failed. ERR_INVALID_STATE: The component is not in a valid state to do this operation. RTS_INVALID_HANDLE: The hAlgo was not one of the needed types. ERR_PARAMETER: keyData is not valid or pKey was NULL. ERR_NOT_SUPPORTED: The given key does not support raw import. Input hAlgo RTS_IEC_HANDLE The desired algorithm the key is needed for. Must be one of the following key types: RTSCRYPTOTYPE_ASYMMETRIC, RTSCRYPTOTYPE_SIGNATURE, RTSCRYPTOTYPE_KEYAGREEMENT. keyData RtsByteString A bytestring containting the raw data. xPrivateKey BOOL TRUE: Import a private key. FALSE: Import a public key. pPublicKey POINTER TO RtsCryptoKey A pointer to the key for storage of the imported key.
CryptoKeyAgreement (FUN) ¶ FUNCTION CryptoKeyAgreement : RTS_IEC_RESULT This function can be used to run asymmetric key agreement protocols like Diffie-Hellman (DH) or elliptic curve Diffie-Hellman (ECDH). These procols can be used to agree on secret keys via an insecure channel. The algorithm can not guarantee authenticity of the communication partner. Therefore, a man in the middle attack can not be detected or prevented during execution of the protocol. The strength of the new key depends on the chosen algorithm. It is recommended to derive a session key from this secret key. InOut: Scope Name Type Comment Return CryptoKeyAgreement RTS_IEC_RESULT Operation result ERR_OK: Key agreement was successful. ERR_INVALID_STATE: The component is not in a valid state to do this operation. RTS_INVALID_HANDLE: The hAlgo was not of type RTSCRYPTOTYPE_KEYAGREEMENT. ERR_PARAMETER: The given keys where invalid or pSharedSecret was NULL. ERR_SIZE_MISMATCH: The given bytestring is too small. ERR_FAILED: The operation failed of some internal error. ERR_NOT_SUPPORTED: The given algorithm or key does not support this operation. Input hAlgo RTS_IEC_HANDLE Handle of the used algorithm. Should be one of the RTSCRYPTOTYPE_KEYAGREEMENT algorithms. privateKey RtsCryptoKey The local private key to run the operation. peerPublicKey RtsCryptoKey The public key of the communication partner. pSharedSecret POINTER TO RtsByteString The calculated shared secret key.
CryptoLoadPrivateKey (FUN) ¶ FUNCTION CryptoLoadPrivateKey : RTS_IEC_RESULT This function can be used to load a private key from the components internal data store. InOut: Scope Name Type Comment Return CryptoLoadPrivateKey RTS_IEC_RESULT Result of the operation Input keyIdentifier RtsByteString The identifier of the key got from CryptoStorePrivateKey. pKey POINTER TO RtsCryptoKey The private key retrieved from the internal storage.
CryptoSignatureGenerate (FUN) ¶ FUNCTION CryptoSignatureGenerate : RTS_IEC_RESULT Sign the data using a specific message digest and the private key. InOut: Scope Name Type Comment Return CryptoSignatureGenerate RTS_IEC_RESULT Result of the operation. Input hAlgo RTS_IEC_HANDLE Handle to the algorithm. pData POINTER TO RtsByteString Data to be signed. privateKey RtsCryptoKey Key to be used signing. Has to be a private key. pSignature POINTER TO RtsByteString Calculated signature of the data.
CryptoSignatureVerify (FUN) ¶ FUNCTION CryptoSignatureVerify : RTS_IEC_RESULT Verify a recieved signature InOut: Scope Name Type Comment Return CryptoSignatureVerify RTS_IEC_RESULT unction returns ERR_OK if the signature is valid. Input hAlgo RTS_IEC_HANDLE Handle to the algorithm. pData POINTER TO RtsByteString Data to verify. publicKey RtsCryptoKey Public key of the sender. pSignature POINTER TO RtsByteString Received signature.
CryptoStorePrivateKey (FUN) ¶ FUNCTION CryptoStorePrivateKey : RTS_IEC_RESULT This function can be used to store a private key that was imported or generated within the components internal data store. InOut: Scope Name Type Comment Return CryptoStorePrivateKey RTS_IEC_RESULT Result of the operation Input key RtsCryptoKey The private key to be stored. pKeyIdentifier POINTER TO RtsByteString A bytestring where the key identifier is stored. This identifier can be used to access the key later. The identifier does not contain any sensitive data.
Functions ¶ CryptoGenerateRandomNumber (Function) CryptoGetAlgorithmById (Function) CryptoGetFirstAlgorithm (Function) CryptoGetNextAlgorithm (Function) CryptoRtsByteStringExit (Function) CryptoRtsByteStringInit (Function) CryptoRtsByteStringInit2 (Function)