LibreOffice LibreOffice 25.8 SDK C/C++ API Reference

Loading...
Searching...
No Matches
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.
typedef enum __rtl_CipherAlgorithm | rtlCipherAlgorithm
| Cipher Algorithm type.
typedef enum __rtl_CipherMode | rtlCipherMode
| Cipher Mode type.
typedef enum __rtl_CipherDirection | rtlCipherDirection
| Cipher Direction type.
typedef enum __rtl_CipherError | rtlCipherError
| Error Code type.

## 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.
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()
| Initialize a cipher for the given direction.
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.
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.
SAL_DLLPUBLIC void | rtl_cipher_destroy (rtlCipher Cipher) SAL_THROW_EXTERN_C()
| Destroy a cipher handle.
SAL_DLLPUBLIC rtlCipher | rtl_cipher_createBF (rtlCipherMode Mode) SAL_THROW_EXTERN_C()
| Create a Blowfish cipher handle for the given mode.
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()
| Initialize a Blowfish cipher for the given direction.
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.
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.
SAL_DLLPUBLIC void | rtl_cipher_destroyBF (rtlCipher Cipher) SAL_THROW_EXTERN_C()
| Destroy a Blowfish cipher handle.
SAL_DLLPUBLIC rtlCipher | rtl_cipher_createARCFOUR (rtlCipherMode Mode) SAL_THROW_EXTERN_C()
| Create a RC4 cipher handle for the given mode.
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()
| Initialize a RC4 cipher for the given direction.
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.
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.
SAL_DLLPUBLIC void | rtl_cipher_destroyARCFOUR (rtlCipher Cipher) SAL_THROW_EXTERN_C()
| Destroy a RC4 cipher handle.

## Typedef Documentation

## ◆ rtlCipher

typedef void* rtlCipher

Cipher Handle opaque type.

## ◆ rtlCipherAlgorithm

typedef enum __rtl_CipherAlgorithm rtlCipherAlgorithm

Cipher Algorithm type.

## ◆ rtlCipherDirection

typedef enum __rtl_CipherDirection rtlCipherDirection

Cipher Direction type.

## ◆ rtlCipherError

typedef enum __rtl_CipherError rtlCipherError

Error Code type.

## ◆ rtlCipherMode

typedef enum __rtl_CipherMode rtlCipherMode

Cipher Mode type.

## Enumeration Type Documentation

## ◆ __rtl_CipherAlgorithm

enum __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

enum __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

enum __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

enum __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] | Algorithm | cipher algorithm.
  [in] | Mode | cipher 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] | Mode | cipher 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] | Cipher | cipher handle.
  [in] | pData | ciphertext buffer.
  [in] | nDatLen | ciphertext length in bytes.
  [out] | pBuffer | plaintext buffer.
  [in] | nBufLen | plaintext length in bytes.

Return values

  rtl_Cipher_E_None | upon 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.

Cipher handle destroyed and invalid.

Parameters

  [in] | Cipher | cipher handle to be destroyed.

## ◆ 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] | Cipher | cipher handle.
  [in] | pData | plaintext buffer.
  [in] | nDatLen | plaintext length in bytes.
  [out] | pBuffer | ciphertext buffer.
  [in] | nBufLen | ciphertext length in bytes.

Return values

  rtl_Cipher_E_None | upon 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 )

Initialize a cipher for the given direction.

See also
  rtlCipherDirection

Parameters

  [in] | Cipher | cipher handle.
  [in] | Direction | cipher direction.
  [in] | pKeyData | key material buffer.
  [in] | nKeyLen | key material length in bytes.
  [in] | pArgData | initialization vector buffer.
  [in] | nArgLen | initialization vector length in bytes.

Return values

  rtl_Cipher_E_None | upon 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 )

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

Initialize a Blowfish cipher for the given direction.

See also
  rtl_cipher_init()