dtls_encrypt method

int dtls_encrypt(
  1. Pointer<Uint8> src,
  2. int length,
  3. Pointer<Uint8> buf,
  4. Pointer<Uint8> nonce,
  5. Pointer<Uint8> key,
  6. int keylen,
  7. Pointer<Uint8> aad,
  8. int aad_length,
)

Encrypts the specified \p src of given \p length, writing the result to \p buf. The cipher implementation may add more data to the result buffer such as an initialization vector or padding (e.g. for block ciphers in CBC mode). The caller therefore must ensure that \p buf provides sufficient storage to hold the result. Usually this means ( 2 + \p length / blocksize ) * blocksize. The function returns a value less than zero on error or otherwise the number of bytes written. The provided \p src and \p buf may overlap.

\param src The data to encrypt. \param length The actual size of of \p src. \param buf The result buffer. \param nonce The nonce used for encryption. Must be exactly 13 bytes, because L is set to 2. \param aad additional data for AEAD ciphers \param aad_length actual size of @p aad \return The number of encrypted bytes on success, less than zero otherwise.

\deprecated dtls_encrypt() always sets M=8, L=2. Use dtls_encrypt_params() instead.

Implementation

int dtls_encrypt(
  ffi.Pointer<ffi.Uint8> src,
  int length,
  ffi.Pointer<ffi.Uint8> buf,
  ffi.Pointer<ffi.Uint8> nonce,
  ffi.Pointer<ffi.Uint8> key,
  int keylen,
  ffi.Pointer<ffi.Uint8> aad,
  int aad_length,
) {
  return _dtls_encrypt(
    src,
    length,
    buf,
    nonce,
    key,
    keylen,
    aad,
    aad_length,
  );
}