0001 TPENCRYPT(3)
0002 ============
0003 :doctype: manpage
0004
0005
0006 NAME
0007 ----
0008 tpencrypt - Encrypt data block
0009
0010
0011 SYNOPSIS
0012 --------
0013 #include <atmi.h>
0014
0015
0016 int tpencrypt(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 encrypt 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 from current hostname and username, but key could be retrieved from other
0027 resources by plugin interface, if configured.
0028
0029 Function may work in binary mode (the input data and output data is binary).
0030 The other mode is string mode with flag *TPEX_STRING*, where 'input' is expected
0031 to be 0x00 terminated string and 'output' will be Base64 encoded.
0032
0033 'input' buffer contains clear data with corresponding data length in 'ilen'
0034 (number of bytes). 'output' buffer is used for encrypted data with corresponding
0035 data length in 'olen' (number of bytes in/out).
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 bytes written to 'output' buffer.
0043
0044 For string encryption, function internally uses temporary buffer which size
0045 is set by *NDRX_MSGSIZEMAX* env variable, thus encrypted output data (
0046 non Base64) shall not be larger than 'NDRX_MSGSIZEMAX' value.
0047
0048 *Valid flags*
0049
0050 *TPEX_STRING* In this mode expected input is EOS terminated string. On success
0051 output will contain Base64 encoded binary data.
0052
0053 RETURN VALUE
0054 ------------
0055 On success, *tpencrypt()* return zero; on error, -1 is returned, with
0056 *tperrno* set to indicate the error.
0057
0058 ERRORS
0059 ------
0060 Note that *tpstrerror()* returns generic error message plus custom message
0061 with debug info from last function call.
0062
0063 *TPEINVAL* Invalid arguments to function. 'input', 'ilen', 'output' or 'olen'
0064 is *NULL*. For non string mode 'ilen' is <= *0*.
0065
0066 *TPELIMIT* There is not enough space in 'output' buffer. Estimate is returned
0067 in 'olen'.
0068
0069 EXAMPLE
0070 -------
0071 See *atmitest/test043_encrypt/atmiclt43_tp.c* for sample code.
0072
0073 BUGS
0074 ----
0075 Report bugs to support@mavimax.com
0076
0077 SEE ALSO
0078 --------
0079 *tpdecrypt(3)* *ex_env(5)* *exencrypt(8)* *exdecrypt(8)* *ex_devguide(guides)*
0080
0081 COPYING
0082 -------
0083 (C) Mavimax, Ltd
0084