TinyDTLS class

ffi binding to the tinydtls library.

Constructors

TinyDTLS(DynamicLibrary dynamicLibrary)
The symbols are looked up in dynamicLibrary.
TinyDTLS.fromLookup(Pointer<T> lookup<T extends NativeType>(String symbolName))
The symbols are looked up with lookup.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

dtls_check_retransmit(Pointer<dtls_context_t> context, Pointer<clock_time_t> next) → void
Checks sendqueue of given DTLS context object for any outstanding packets to be transmitted.
dtls_close(Pointer<dtls_context_t> ctx, Pointer<session_t> remote) int
Closes the DTLS connection associated with @p remote. This function returns zero on success, and a value less than zero on error.
dtls_connect(Pointer<dtls_context_t> ctx, Pointer<session_t> dst) int
Establishes a DTLS channel with the specified remote peer @p dst. This function returns @c 0 if that channel already exists, a value greater than zero when a new ClientHello message was sent, and a value less than zero on error.
dtls_connect_peer(Pointer<dtls_context_t> ctx, Pointer<dtls_peer_t> peer) int
Establishes a DTLS channel with the specified remote peer. This function returns @c 0 if that channel already exists and a renegotiate was initiated, a value greater than zero when a new ClientHello message was sent, and a value less than zero on error.
dtls_decrypt(Pointer<Uint8> src, int length, Pointer<Uint8> buf, Pointer<Uint8> nonce, Pointer<Uint8> key, int keylen, Pointer<Uint8> a_data, int a_data_length) int
Decrypts the given buffer \p src of given \p length, writing the result to \p buf. The function returns \c -1 in case of an error, or the number of bytes written. Note that for block ciphers, \p length must be a multiple of the cipher's block size. A return value between \c 0 and the actual length indicates that only \c n-1 block have been processed. The provided \p src and \p buf may overlap.
dtls_decrypt_params(Pointer<dtls_ccm_params_t> params, Pointer<Uint8> src, int length, Pointer<Uint8> buf, Pointer<Uint8> key, int keylen, Pointer<Uint8> aad, int aad_length) int
Decrypts the given buffer \p src of given \p length, writing the result to \p buf. The function returns \c -1 in case of an error, or the number of bytes written. Note that for block ciphers, \p length must be a multiple of the cipher's block size. A return value between \c 0 and the actual length indicates that only \c n-1 block have been processed. The provided \p src and \p buf may overlap.
dtls_ec_key_asn1_from_uint32(Pointer<Uint32> key, int key_size, Pointer<Uint8> buf) int
dtls_ecdh_pre_master_secret(Pointer<Uint8> priv_key, Pointer<Uint8> pub_key_x, Pointer<Uint8> pub_key_y, int key_size, Pointer<Uint8> result, int result_len) int
dtls_ecdsa_create_sig(Pointer<Uint8> priv_key, int key_size, Pointer<Uint8> client_random, int client_random_size, Pointer<Uint8> server_random, int server_random_size, Pointer<Uint8> keyx_params, int keyx_params_size, Pointer<Uint32> point_r, Pointer<Uint32> point_s) → void
dtls_ecdsa_create_sig_hash(Pointer<Uint8> priv_key, int key_size, Pointer<Uint8> sign_hash, int sign_hash_size, Pointer<Uint32> point_r, Pointer<Uint32> point_s) → void
dtls_ecdsa_generate_key(Pointer<Uint8> priv_key, Pointer<Uint8> pub_key_x, Pointer<Uint8> pub_key_y, int key_size) → void
dtls_ecdsa_verify_sig(Pointer<Uint8> pub_key_x, Pointer<Uint8> pub_key_y, int key_size, Pointer<Uint8> client_random, int client_random_size, Pointer<Uint8> server_random, int server_random_size, Pointer<Uint8> keyx_params, int keyx_params_size, Pointer<Uint8> result_r, Pointer<Uint8> result_s) int
dtls_ecdsa_verify_sig_hash(Pointer<Uint8> pub_key_x, Pointer<Uint8> pub_key_y, int key_size, Pointer<Uint8> sign_hash, int sign_hash_size, Pointer<Uint8> result_r, Pointer<Uint8> result_s) int
dtls_encrypt(Pointer<Uint8> src, int length, Pointer<Uint8> buf, Pointer<Uint8> nonce, Pointer<Uint8> key, int keylen, Pointer<Uint8> aad, int aad_length) int
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.
dtls_encrypt_params(Pointer<dtls_ccm_params_t> params, Pointer<Uint8> src, int length, Pointer<Uint8> buf, Pointer<Uint8> key, int keylen, Pointer<Uint8> aad, int aad_length) int
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.
dtls_free_context(Pointer<dtls_context_t> ctx) → void
Releases any storage that has been allocated for \p ctx.
dtls_free_session(Pointer<session_t> sess) → void
Frees memory allocated for a session using ::dtls_new_session.
dtls_get_peer(Pointer<dtls_context_t> context, Pointer<session_t> session) Pointer<dtls_peer_t>
Check if @p session is associated with a peer object in @p context. This function returns a pointer to the peer if found, NULL otherwise.
dtls_handle_message(Pointer<dtls_context_t> ctx, Pointer<session_t> session, Pointer<uint8> msg, int msglen) int
Handles incoming data as DTLS message from given peer.
dtls_handshake_free(Pointer<dtls_handshake_parameters_t> handshake) → void
dtls_handshake_new() Pointer<dtls_handshake_parameters_t>
dtls_init() → void
This function initializes the tinyDTLS memory management and must be called first.
dtls_mac(Pointer<dtls_hmac_context_t> hmac_ctx, Pointer<Uint8> record, Pointer<Uint8> packet, int length, Pointer<Uint8> buf) → void
Calculates MAC for record + cleartext packet and places the result in \p buf. The given \p hmac_ctx must be initialized with the HMAC function to use and the proper secret. As the DTLS mac calculation requires data from the record header, \p record must point to a buffer of at least \c sizeof(dtls_record_header_t) bytes. Usually, the remaining packet will be encrypted, therefore, the cleartext is passed separately in \p packet.
dtls_new_context(Pointer<Void> app_data) Pointer<dtls_context_t>
Creates a new context object. The storage allocated for the new object must be released with dtls_free_context().
dtls_new_session(Pointer<sockaddr> addr, int addrlen) Pointer<session_t>
Creates a new ::session_t for the given address.
dtls_p_hash(int h, Pointer<Uint8> key, int keylen, Pointer<Uint8> label, int labellen, Pointer<Uint8> random1, int random1len, Pointer<Uint8> random2, int random2len, Pointer<Uint8> buf, int buflen) int
Expands the secret and key to a block of DTLS_HMAC_MAX size according to the algorithm specified in section 5 of RFC 4346.
dtls_prf(Pointer<Uint8> key, int keylen, Pointer<Uint8> label, int labellen, Pointer<Uint8> random1, int random1len, Pointer<Uint8> random2, int random2len, Pointer<Uint8> buf, int buflen) int
This function implements the TLS PRF for DTLS_VERSION. For version 1.0, the PRF is P_MD5 ^ P_SHA1 while version 1.2 uses P_SHA256. Currently, the actual PRF is selected at compile time.
dtls_psk_pre_master_secret(Pointer<Uint8> key, int keylen, Pointer<Uint8> result, int result_len) int
Generates pre_master_sercet from given PSK and fills the result according to the "plain PSK" case in section 2 of RFC 4279. Diffie-Hellman and RSA key exchange are currently not supported.
dtls_renegotiate(Pointer<dtls_context_t> ctx, Pointer<session_t> dst) int
Renegotiates a DTLS channel based on the specified session. This function returns a value greater than zero when a new ClientHello message was sent, and a value less than zero on error.
dtls_reset_peer(Pointer<dtls_context_t> context, Pointer<dtls_peer_t> peer) → void
Resets all connections with @p peer.
dtls_security_free(Pointer<dtls_security_parameters_t> security) → void
dtls_security_new() Pointer<dtls_security_parameters_t>
dtls_session_addr(Pointer<session_t> sess, Pointer<socklen_t> addrlen) Pointer<sockaddr>
Extracts the address of the given ::session_t.
dtls_session_equals(Pointer<session_t> a, Pointer<session_t> b) int
Compares the given session objects. This function returns @c 0 when @p a and @p b differ, @c 1 otherwise.
dtls_session_init(Pointer<session_t> sess) → void
Resets the given session_t object @p sess to its default values. In particular, the member rlen must be initialized to the available size for storing addresses.
dtls_write(Pointer<dtls_context_t> ctx, Pointer<session_t> session, Pointer<uint8> buf, int len) int
Writes the application data given in @p buf to the peer specified by @p session.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited