LibreOffice
LibreOffice 5.3 SDK C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Typedefs | Enumerations | Functions
cipher.h File Reference
#include <sal/config.h>
#include <sal/saldllapi.h>
#include <sal/types.h>

Go to the source code of this file.

Typedefs

typedef void * rtlCipher
 Cipher Handle opaque type. More...
 
typedef enum __rtl_CipherAlgorithm rtlCipherAlgorithm
 Cipher Algorithm type. More...
 
typedef enum __rtl_CipherMode rtlCipherMode
 Cipher Mode type. More...
 
typedef enum __rtl_CipherDirection rtlCipherDirection
 Cipher Direction type. More...
 
typedef enum __rtl_CipherError rtlCipherError
 Error Code type. More...
 

Enumerations

enum  __rtl_CipherAlgorithm { rtl_Cipher_AlgorithmBF, rtl_Cipher_AlgorithmARCFOUR, rtl_Cipher_AlgorithmInvalid, rtl_Cipher_Algorithm_FORCE_EQUAL_SIZE = SAL_MAX_ENUM }
 Cipher Algorithm enumeration. More...
 
enum  __rtl_CipherMode {
  rtl_Cipher_ModeECB, rtl_Cipher_ModeCBC, rtl_Cipher_ModeStream, rtl_Cipher_ModeInvalid,
  rtl_Cipher_Mode_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
}
 Cipher Mode enumeration. More...
 
enum  __rtl_CipherDirection {
  rtl_Cipher_DirectionBoth, rtl_Cipher_DirectionDecode, rtl_Cipher_DirectionEncode, rtl_Cipher_DirectionInvalid,
  rtl_Cipher_Direction_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
}
 Cipher Direction enumeration. More...
 
enum  __rtl_CipherError {
  rtl_Cipher_E_None, rtl_Cipher_E_Argument, rtl_Cipher_E_Algorithm, rtl_Cipher_E_Direction,
  rtl_Cipher_E_Mode, rtl_Cipher_E_BufferSize, rtl_Cipher_E_Memory, rtl_Cipher_E_Unknown,
  rtl_Cipher_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
}
 Error Code enumeration. More...
 

Functions

SAL_DLLPUBLIC rtlCipher rtl_cipher_create (rtlCipherAlgorithm Algorithm, rtlCipherMode Mode) SAL_THROW_EXTERN_C()
 Create a cipher handle for the given algorithm and mode. More...
 
SAL_DLLPUBLIC rtlCipherError rtl_cipher_init (rtlCipher Cipher, rtlCipherDirection Direction, const sal_uInt8 *pKeyData, sal_Size nKeyLen, const sal_uInt8 *pArgData, sal_Size nArgLen) SAL_THROW_EXTERN_C()
 Inititialize a cipher for the given direction. More...
 
SAL_DLLPUBLIC rtlCipherError rtl_cipher_encode (rtlCipher Cipher, const void *pData, sal_Size nDatLen, sal_uInt8 *pBuffer, sal_Size nBufLen) SAL_THROW_EXTERN_C()
 Encode a buffer under a given cipher algorithm. More...
 
SAL_DLLPUBLIC rtlCipherError rtl_cipher_decode (rtlCipher Cipher, const void *pData, sal_Size nDatLen, sal_uInt8 *pBuffer, sal_Size nBufLen) SAL_THROW_EXTERN_C()
 Decode a buffer under a given cipher algorithm. More...
 
SAL_DLLPUBLIC void rtl_cipher_destroy (rtlCipher Cipher) SAL_THROW_EXTERN_C()
 Destroy a cipher handle. More...
 
SAL_DLLPUBLIC rtlCipher rtl_cipher_createBF (rtlCipherMode Mode) SAL_THROW_EXTERN_C()
 Create a Blowfish cipher handle for the given mode. More...
 
SAL_DLLPUBLIC rtlCipherError rtl_cipher_initBF (rtlCipher Cipher, rtlCipherDirection Direction, const sal_uInt8 *pKeyData, sal_Size nKeyLen, const sal_uInt8 *pArgData, sal_Size nArgLen) SAL_THROW_EXTERN_C()
 Inititialize a Blowfish cipher for the given direction. More...
 
SAL_DLLPUBLIC rtlCipherError rtl_cipher_encodeBF (rtlCipher Cipher, const void *pData, sal_Size nDatLen, sal_uInt8 *pBuffer, sal_Size nBufLen) SAL_THROW_EXTERN_C()
 Encode a buffer under the Blowfish cipher algorithm. More...
 
SAL_DLLPUBLIC rtlCipherError rtl_cipher_decodeBF (rtlCipher Cipher, const void *pData, sal_Size nDatLen, sal_uInt8 *pBuffer, sal_Size nBufLen) SAL_THROW_EXTERN_C()
 Decode a buffer under the Blowfish cipher algorithm. More...
 
SAL_DLLPUBLIC void rtl_cipher_destroyBF (rtlCipher Cipher) SAL_THROW_EXTERN_C()
 Destroy a Blowfish cipher handle. More...
 
SAL_DLLPUBLIC rtlCipher rtl_cipher_createARCFOUR (rtlCipherMode Mode) SAL_THROW_EXTERN_C()
 Create a RC4 cipher handle for the given mode. More...
 
SAL_DLLPUBLIC rtlCipherError rtl_cipher_initARCFOUR (rtlCipher Cipher, rtlCipherDirection Direction, const sal_uInt8 *pKeyData, sal_Size nKeyLen, const sal_uInt8 *pArgData, sal_Size nArgLen) SAL_THROW_EXTERN_C()
 Inititialize a RC4 cipher for the given direction. More...
 
SAL_DLLPUBLIC rtlCipherError rtl_cipher_encodeARCFOUR (rtlCipher Cipher, const void *pData, sal_Size nDatLen, sal_uInt8 *pBuffer, sal_Size nBufLen) SAL_THROW_EXTERN_C()
 Encode a buffer under the RC4 cipher algorithm. More...
 
SAL_DLLPUBLIC rtlCipherError rtl_cipher_decodeARCFOUR (rtlCipher Cipher, const void *pData, sal_Size nDatLen, sal_uInt8 *pBuffer, sal_Size nBufLen) SAL_THROW_EXTERN_C()
 Decode a buffer under the RC4 cipher algorithm. More...
 
SAL_DLLPUBLIC void rtl_cipher_destroyARCFOUR (rtlCipher Cipher) SAL_THROW_EXTERN_C()
 Destroy a RC4 cipher handle. More...
 

Typedef Documentation

typedef void* rtlCipher

Cipher Handle opaque type.

Cipher Algorithm type.

Cipher Direction type.

Error Code type.

Cipher Mode type.

Enumeration Type Documentation

Cipher Algorithm enumeration.

See Also
rtl_cipher_create()
Enumerator
rtl_Cipher_AlgorithmBF 
rtl_Cipher_AlgorithmARCFOUR 
rtl_Cipher_AlgorithmInvalid 
rtl_Cipher_Algorithm_FORCE_EQUAL_SIZE 

Cipher Direction enumeration.

See Also
rtl_cipher_init()
Enumerator
rtl_Cipher_DirectionBoth 
rtl_Cipher_DirectionDecode 
rtl_Cipher_DirectionEncode 
rtl_Cipher_DirectionInvalid 
rtl_Cipher_Direction_FORCE_EQUAL_SIZE 

Error Code enumeration.

Enumerator
rtl_Cipher_E_None 
rtl_Cipher_E_Argument 
rtl_Cipher_E_Algorithm 
rtl_Cipher_E_Direction 
rtl_Cipher_E_Mode 
rtl_Cipher_E_BufferSize 
rtl_Cipher_E_Memory 
rtl_Cipher_E_Unknown 
rtl_Cipher_E_FORCE_EQUAL_SIZE 

Cipher Mode enumeration.

See Also
rtl_cipher_create()
Enumerator
rtl_Cipher_ModeECB 
rtl_Cipher_ModeCBC 
rtl_Cipher_ModeStream 
rtl_Cipher_ModeInvalid 
rtl_Cipher_Mode_FORCE_EQUAL_SIZE 

Function Documentation

SAL_DLLPUBLIC rtlCipher rtl_cipher_create ( rtlCipherAlgorithm  Algorithm,
rtlCipherMode  Mode 
)

Create a cipher handle for the given algorithm and mode.

See Also
rtlCipherAlgorithm
rtlCipherMode
Parameters
Algorithm[in] cipher algorithm.
Mode[in] cipher mode.
Returns
Cipher handle, or 0 upon failure.
SAL_DLLPUBLIC rtlCipher rtl_cipher_createARCFOUR ( rtlCipherMode  Mode)

Create a RC4 cipher handle for the given mode.

The RC4 symmetric stream cipher algorithm is specified in Bruce Schneier: Applied Cryptography, 2nd edition, ch. 17.1

See Also
rtl_cipher_create()
Parameters
Mode[in] cipher mode. Must be rtl_Cipher_ModeStream.
Returns
Cipher handle, or 0 upon failure.
SAL_DLLPUBLIC rtlCipher rtl_cipher_createBF ( rtlCipherMode  Mode)

Create a Blowfish cipher handle for the given mode.

The Blowfish block cipher algorithm is specified in Bruce Schneier: Applied Cryptography, 2nd edition, ch. 14.3

See Also
rtl_cipher_create()
SAL_DLLPUBLIC rtlCipherError rtl_cipher_decode ( rtlCipher  Cipher,
const void *  pData,
sal_Size  nDatLen,
sal_uInt8 pBuffer,
sal_Size  nBufLen 
)

Decode a buffer under a given cipher algorithm.

Precondition
Initialized for a compatible cipher direction.
See Also
rtl_cipher_init()
Parameters
Cipher[in] cipher handle.
pData[in] ciphertext buffer.
nDatLen[in] ciphertext length in bytes.
pBuffer[out] plaintext buffer.
nBufLen[in] plaintext length in bytes.
Returns
rtl_Cipher_E_None upon success.
SAL_DLLPUBLIC rtlCipherError rtl_cipher_decodeARCFOUR ( rtlCipher  Cipher,
const void *  pData,
sal_Size  nDatLen,
sal_uInt8 pBuffer,
sal_Size  nBufLen 
)

Decode a buffer under the RC4 cipher algorithm.

See Also
rtl_cipher_decode()
SAL_DLLPUBLIC rtlCipherError rtl_cipher_decodeBF ( rtlCipher  Cipher,
const void *  pData,
sal_Size  nDatLen,
sal_uInt8 pBuffer,
sal_Size  nBufLen 
)

Decode a buffer under the Blowfish cipher algorithm.

See Also
rtl_cipher_decode()
SAL_DLLPUBLIC void rtl_cipher_destroy ( rtlCipher  Cipher)

Destroy a cipher handle.

Parameters
Cipher[in] cipher handle to be destroyed.
Returns
None. Cipher handle destroyed and invalid.
SAL_DLLPUBLIC void rtl_cipher_destroyARCFOUR ( rtlCipher  Cipher)

Destroy a RC4 cipher handle.

See Also
rtl_cipher_destroy()
SAL_DLLPUBLIC void rtl_cipher_destroyBF ( rtlCipher  Cipher)

Destroy a Blowfish cipher handle.

See Also
rtl_cipher_destroy()
SAL_DLLPUBLIC rtlCipherError rtl_cipher_encode ( rtlCipher  Cipher,
const void *  pData,
sal_Size  nDatLen,
sal_uInt8 pBuffer,
sal_Size  nBufLen 
)

Encode a buffer under a given cipher algorithm.

Precondition
Initialized for a compatible cipher direction.
See Also
rtl_cipher_init()
Parameters
Cipher[in] cipher handle.
pData[in] plaintext buffer.
nDatLen[in] plaintext length in bytes.
pBuffer[out] ciphertext buffer.
nBufLen[in] ciphertext length in bytes.
Returns
rtl_Cipher_E_None upon success.
SAL_DLLPUBLIC rtlCipherError rtl_cipher_encodeARCFOUR ( rtlCipher  Cipher,
const void *  pData,
sal_Size  nDatLen,
sal_uInt8 pBuffer,
sal_Size  nBufLen 
)

Encode a buffer under the RC4 cipher algorithm.

See Also
rtl_cipher_encode()
SAL_DLLPUBLIC rtlCipherError rtl_cipher_encodeBF ( rtlCipher  Cipher,
const void *  pData,
sal_Size  nDatLen,
sal_uInt8 pBuffer,
sal_Size  nBufLen 
)

Encode a buffer under the Blowfish cipher algorithm.

See Also
rtl_cipher_encode()
SAL_DLLPUBLIC rtlCipherError rtl_cipher_init ( rtlCipher  Cipher,
rtlCipherDirection  Direction,
const sal_uInt8 pKeyData,
sal_Size  nKeyLen,
const sal_uInt8 pArgData,
sal_Size  nArgLen 
)

Inititialize a cipher for the given direction.

See Also
rtlCipherDirection
Parameters
Cipher[in] cipher handle.
Direction[in] cipher direction.
pKeyData[in] key material buffer.
nKeyLen[in] key material length in bytes.
pArgData[in] initialization vector buffer.
nArgLen[in] initialization vector length in bytes.
Returns
rtl_Cipher_E_None upon success.
SAL_DLLPUBLIC rtlCipherError rtl_cipher_initARCFOUR ( rtlCipher  Cipher,
rtlCipherDirection  Direction,
const sal_uInt8 pKeyData,
sal_Size  nKeyLen,
const sal_uInt8 pArgData,
sal_Size  nArgLen 
)

Inititialize a RC4 cipher for the given direction.

See Also
rtl_cipher_init()
SAL_DLLPUBLIC rtlCipherError rtl_cipher_initBF ( rtlCipher  Cipher,
rtlCipherDirection  Direction,
const sal_uInt8 pKeyData,
sal_Size  nKeyLen,
const sal_uInt8 pArgData,
sal_Size  nArgLen 
)

Inititialize a Blowfish cipher for the given direction.

See Also
rtl_cipher_init()