CryptoDeriveKey (FUN) ¶ FUNCTION CryptoDeriveKey : RTS_IEC_RESULT This Function derives a new key FROM an existing secret (key) AND an corresponding salt. The functions generates keys of the requested size which is given in pDerivedKey->ui32MaxLen. If setup properly this function provides a secure way to store passwords within the file system. By now two classes of algorithms can be use: 1. P_SHA(1, 256): This algorithm can be used to derive session keys from some kind of secret data. If this algorithm is used the pSpecificParameters is not evaluated an should be NULL. This algorithm is quite fast. 2. SCRYPT: This algorithm can be used to generate strong keys from weak passwords, or to store passwords in a secure way within the file system. This algorithm makes use of the pSpecificParameters and requires this parameter. Depending on the configuration given in pSpecificParameters this algorithm is time and memory consuming. For details see RFC-7914. InOut: Scope Name Type Comment Return CryptoDeriveKey RTS_IEC_RESULT Result of the operation. ERR_OK: The key was derived successfully. ERR_INVALID_HANDLE: hAlgo was not a valid handle to derive keys. ERR_PARAMETER: One of the other parameters was invalid. ERR_FAILED: some internal error happend. Input hAlgo RTS_IEC_HANDLE Handle of the used algoritm. Should be one of RTSCRYPTOID_KDF_* algorithms. pKey POINTER TO RtsByteString The key that should be derived. The function reads pKey->ui32Len bytes of the given buffer. pSalt POINTER TO RtsByteString The SALT that should be used to derive the key. The function reads pSalt->ui32Len bytes of the given buffer. pSpecificParameters POINTER TO RtsKdfParameter Some additional algorithm specific parameters. By now only used for scrypt. pDerivedKey POINTER TO RtsByteString Destination where to store the derived key. The function generates a key with the size of pDerivedKey->ui32MaxLen. The size of the derived key will be stored in pDerivedKey->ui32Len.
Key Handling ¶ CryptoKeyExit (Function) CryptoKeyInit (Function)
CryptoKeyExit (FUN) ¶ FUNCTION CryptoKeyExit : RTS_IEC_RESULT InOut: Scope Name Type Return CryptoKeyExit RTS_IEC_RESULT Input pKey POINTER TO RtsCryptoKey
CryptoKeyInit (FUN) ¶ FUNCTION CryptoKeyInit : RTS_IEC_RESULT InOut: Scope Name Type Return CryptoKeyInit RTS_IEC_RESULT Input pKey POINTER TO RtsCryptoKey key RtsCryptoKeyStorage keyType RtsCryptoKeyType
Symmetric Cryptography ¶ CryptoGenerateHash (Function) CryptoHMACSign (Function) CryptoHMACVerify (Function) CryptoSymmetricDecrypt (Function) CryptoSymmetricEncrypt (Function)
CryptoGenerateHash (FUN) ¶ FUNCTION CryptoGenerateHash : RTS_IEC_RESULT Calculate the message digest of the given data. InOut: Scope Name Type Comment Return CryptoGenerateHash RTS_IEC_RESULT Result of the operation Input hAlgo RTS_IEC_HANDLE Handle to the algorithm. pData POINTER TO RtsByteString Data to calculate the message digest. pHash POINTER TO RtsByteString Calculated message digest.
CryptoHMACSign (FUN) ¶ FUNCTION CryptoHMACSign : RTS_IEC_RESULT Generate a hashed message authentication code (HMAC) OF the given data AND key. InOut: Scope Name Type Comment Return CryptoHMACSign RTS_IEC_RESULT Result of the operation Input hAlgo RTS_IEC_HANDLE Handle to the algorithm. pData POINTER TO RtsByteString Data to calculate the HMAC. key RtsCryptoKey Key to be used for the HMAC calcuation pSignature POINTER TO RtsByteString Calculated HMAC
CryptoHMACVerify (FUN) ¶ FUNCTION CryptoHMACVerify : RTS_IEC_RESULT Verify a recieved hashed message authentication code (HMAC). InOut: Scope Name Type Comment Return CryptoHMACVerify RTS_IEC_RESULT Function returns ERR_OK if the HMAC is valid. Input hAlgo RTS_IEC_HANDLE Handle to the algorithm. pData POINTER TO RtsByteString Data to calculate the HMAC. key RtsCryptoKey Key to be used for the HMAC calcuation pSignature POINTER TO RtsByteString Recieved HMAC
CryptoSymmetricDecrypt (FUN) ¶ FUNCTION CryptoSymmetricDecrypt : RTS_IEC_RESULT Perform a symmetric decryption using the algorithm handle. InOut: Scope Name Type Comment Return CryptoSymmetricDecrypt RTS_IEC_RESULT Result of the operation Input hAlgo RTS_IEC_HANDLE Handle to the algorithm. pCipherText POINTER TO RtsByteString Data to be decrypted key RtsCryptoKey Key to decrypt the data. Has to be a KeyType_Key key. pInitVector POINTER TO RtsByteString Init vector of the decrypt. xEnablePadding BOOL Enables padding. If this is not enabled the ciphertext length has to match a multiple of the block length. pPlainText POINTER TO RtsByteString Decrypted data.
CryptoSymmetricEncrypt (FUN) ¶ FUNCTION CryptoSymmetricEncrypt : RTS_IEC_RESULT Perform a symmetric encryption using the algorithm handle. InOut: Scope Name Type Comment Return CryptoSymmetricEncrypt RTS_IEC_RESULT Result of the operation Input hAlgo RTS_IEC_HANDLE Handle to the algorithm. pPlainText POINTER TO RtsByteString Data to be encrypted key RtsCryptoKey Key to encrypt the data. Has to be a KeyType_Key key. pInitVector POINTER TO RtsByteString Init vector of the ecryption xEnablePadding BOOL Enables padding. If this is not enabled the plaintext length has to match a multiple of the block length. pCipherText POINTER TO RtsByteString Encrypted data.