0001 TPDECRYPT(3)
0002 ============
0003 :doctype: manpage
0004
0005
0006 NAME
0007 ----
0008 tpdecrypt - Decrypt data block
0009
0010
0011 SYNOPSIS
0012 --------
0013 #include <atmi.h>
0014
0015
0016 int tpdecrypt(char *'input', long 'ilen', char *'output', long *'olen', long 'flags');
0017
0018 For XATMI client link with '-latmiclt -latmi -lubf -lnstd -lpthread -lrt -lm'
0019
0020 For XATMI server link with '-latmisrv|-latmisrvnomain|-latmisrvinteg -latmi -lubf -lnstd -lpthread -lrt -lm'
0021
0022 DESCRIPTION
0023 -----------
0024 Data decrypt function. Function provides access to Enduro/X built-in
0025 encryption engine. AES-128 in CBC mode algorithm is used. By default encryption key is
0026 composed from current hostname and username, but key could be retrieved
0027 from other resources by plugin interface, if configured.
0028
0029 'input' buffer contains encrypted data with corresponding data length in 'ilen'
0030 (number of bytes). 'output' buffer is used for clear data with corresponding
0031 data length in 'olen' (number of bytes in/out).
0032
0033 Function may work in binary mode (the input data and output data is binary).
0034 The other mode is string mode with flag *TPEX_STRING*, where 'input' is expected
0035 to be Base64 encoded data and 'output' is 0x00 terminated string.
0036
0037 In string mode 'ilen' is ignored, in binary mode 'ilen' is required and must be >*0*.
0038 'olen' is used for checking output buffer sizes. In case if there is no space,
0039 the error *TPELIMIT* is returned, and 'olen' variable is set to estimated space
0040 required.
0041
0042 In the result of function 'olen' is set to number bytes written to 'output' buffer.
0043
0044 *Valid flags*
0045
0046 *TPEX_STRING* In this mode expected input is EOS terminated string (base64 string).
0047 On success output will contain zero byte terminated string data.
0048
0049 RETURN VALUE
0050 ------------
0051 On success, *tpencrypt()* return zero; on error, -1 is returned, with
0052 *tperrno* set to indicate the error.
0053
0054 ERRORS
0055 ------
0056 Note that *tpstrerror()* returns generic error message plus custom message
0057 with debug info from last function call.
0058
0059 *TPEINVAL* Invalid arguments to function. 'input', 'ilen', 'output' or 'olen'
0060 is *NULL*. For non string mode 'ilen' is <= *0*. Additionally in *TPEX_STRING*
0061 mode this error is if 'input' data does not correspond to Base64 format or
0062 if decrypted data length does not match the string length (i.e. string is
0063 shorter - includes binary 0x00).
0064
0065 *TPELIMIT* There is not enough space in 'output' buffer. Estimate is returned
0066 in 'olen'.
0067
0068 *TPEOS* Operating system error occurred. E.g. cannot allocate temporary buffers.
0069
0070 EXAMPLE
0071 -------
0072 See *atmitest/test043_encrypt/atmiclt43_tp.c* for sample code.
0073
0074 BUGS
0075 ----
0076 Report bugs to support@mavimax.com
0077
0078 SEE ALSO
0079 --------
0080 *tpencrypt(3)* *ex_env(5)* *exencrypt(8)* *exdecrypt(8)* *ex_devguide(guides)*
0081
0082 COPYING
0083 -------
0084 (C) Mavimax, Ltd
0085