LibreOffice
LibreOffice 7.4 SDK C/C++ API Reference
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

◆ rtlCipher

typedef void* rtlCipher

Cipher Handle opaque type.

◆ rtlCipherAlgorithm

Cipher Algorithm type.

◆ rtlCipherDirection

Cipher Direction type.

◆ rtlCipherError

Error Code type.

◆ rtlCipherMode

Cipher Mode type.

Enumeration Type Documentation

◆ __rtl_CipherAlgorithm

Cipher Algorithm enumeration.

See also
rtl_cipher_create()
Enumerator
rtl_Cipher_AlgorithmBF 
rtl_Cipher_AlgorithmARCFOUR 
rtl_Cipher_AlgorithmInvalid 
rtl_Cipher_Algorithm_FORCE_EQUAL_SIZE 

◆ __rtl_CipherDirection

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 

◆ __rtl_CipherError

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 

◆ __rtl_CipherMode

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

◆ rtl_cipher_create()

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
[in]Algorithmcipher algorithm.
[in]Modecipher mode.
Returns
Cipher handle, or 0 upon failure.

◆ rtl_cipher_createARCFOUR()

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
[in]Modecipher mode. Must be rtl_Cipher_ModeStream.
Returns
Cipher handle, or 0 upon failure.

◆ rtl_cipher_createBF()

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()

◆ rtl_cipher_decode()

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
[in]Ciphercipher handle.
[in]pDataciphertext buffer.
[in]nDatLenciphertext length in bytes.
[out]pBufferplaintext buffer.
[in]nBufLenplaintext length in bytes.
Return values
rtl_Cipher_E_Noneupon success.

◆ rtl_cipher_decodeARCFOUR()

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()

◆ rtl_cipher_decodeBF()

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()

◆ rtl_cipher_destroy()

SAL_DLLPUBLIC void rtl_cipher_destroy ( rtlCipher  Cipher)

Destroy a cipher handle.

Parameters
[in]Ciphercipher handle to be destroyed.
Returns
None. Cipher handle destroyed and invalid.

◆ rtl_cipher_destroyARCFOUR()

SAL_DLLPUBLIC void rtl_cipher_destroyARCFOUR ( rtlCipher  Cipher)

Destroy a RC4 cipher handle.

See also
rtl_cipher_destroy()

◆ rtl_cipher_destroyBF()

SAL_DLLPUBLIC void rtl_cipher_destroyBF ( rtlCipher  Cipher)

Destroy a Blowfish cipher handle.

See also
rtl_cipher_destroy()

◆ rtl_cipher_encode()

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
[in]Ciphercipher handle.
[in]pDataplaintext buffer.
[in]nDatLenplaintext length in bytes.
[out]pBufferciphertext buffer.
[in]nBufLenciphertext length in bytes.
Return values
rtl_Cipher_E_Noneupon success.

◆ rtl_cipher_encodeARCFOUR()

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()

◆ rtl_cipher_encodeBF()

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()

◆ rtl_cipher_init()

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
[in]Ciphercipher handle.
[in]Directioncipher direction.
[in]pKeyDatakey material buffer.
[in]nKeyLenkey material length in bytes.
[in]pArgDatainitialization vector buffer.
[in]nArgLeninitialization vector length in bytes.
Return values
rtl_Cipher_E_Noneupon success.

◆ rtl_cipher_initARCFOUR()

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()

◆ rtl_cipher_initBF()

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()