|
ascii-chat 0.8.38
Real-time terminal-based video chat with ASCII art conversion
|
🔐 Core cryptography: encryption/decryption, key exchange, authentication, and session rekeying with BearSSL More...
Go to the source code of this file.
Macros | |
| #define | CRYPTO_RESULT_STRING_COUNT (sizeof(g_crypto_result_strings) / sizeof(g_crypto_result_strings[0])) |
Functions | |
| crypto_result_t | crypto_init (crypto_context_t *ctx) |
| crypto_result_t | crypto_init_with_password (crypto_context_t *ctx, const char *password) |
| void | crypto_destroy (crypto_context_t *ctx) |
| crypto_result_t | crypto_generate_keypair (crypto_context_t *ctx) |
| crypto_result_t | crypto_get_public_key (const crypto_context_t *ctx, uint8_t *public_key_out) |
| crypto_result_t | crypto_set_peer_public_key (crypto_context_t *ctx, const uint8_t *peer_public_key) |
| bool | crypto_is_ready (const crypto_context_t *ctx) |
| crypto_result_t | crypto_validate_password (const char *password) |
| crypto_result_t | crypto_derive_password_key (crypto_context_t *ctx, const char *password) |
| bool | crypto_verify_password (const crypto_context_t *ctx, const char *password) |
| crypto_result_t | crypto_derive_password_encryption_key (const char *password, uint8_t encryption_key[SECRETBOX_KEY_SIZE]) |
| crypto_result_t | crypto_encrypt (crypto_context_t *ctx, const uint8_t *plaintext, size_t plaintext_len, uint8_t *ciphertext_out, size_t ciphertext_out_size, size_t *ciphertext_len_out) |
| crypto_result_t | crypto_decrypt (crypto_context_t *ctx, const uint8_t *ciphertext, size_t ciphertext_len, uint8_t *plaintext_out, size_t plaintext_out_size, size_t *plaintext_len_out) |
| const char * | crypto_result_to_string (crypto_result_t result) |
| void | crypto_get_status (const crypto_context_t *ctx, char *status_buffer, size_t buffer_size) |
| bool | crypto_secure_compare (const uint8_t *lhs, const uint8_t *rhs, size_t len) |
| crypto_result_t | crypto_random_bytes (uint8_t *buffer, size_t len) |
| crypto_result_t | crypto_create_public_key_packet (const crypto_context_t *ctx, uint8_t *packet_out, size_t packet_size, size_t *packet_len_out) |
| crypto_result_t | crypto_process_public_key_packet (crypto_context_t *ctx, const uint8_t *packet, size_t packet_len) |
| crypto_result_t | crypto_create_encrypted_packet (crypto_context_t *ctx, const uint8_t *data, size_t data_len, uint8_t *packet_out, size_t packet_size, size_t *packet_len_out) |
| crypto_result_t | crypto_process_encrypted_packet (crypto_context_t *ctx, const uint8_t *packet, size_t packet_len, uint8_t *data_out, size_t data_size, size_t *data_len_out) |
| crypto_result_t | crypto_generate_nonce (uint8_t nonce[32]) |
| crypto_result_t | crypto_compute_hmac (crypto_context_t *ctx, const uint8_t key[32], const uint8_t data[32], uint8_t hmac[32]) |
| crypto_result_t | crypto_compute_hmac_ex (const crypto_context_t *ctx, const uint8_t key[32], const uint8_t *data, size_t data_len, uint8_t hmac[32]) |
| bool | crypto_verify_hmac (const uint8_t key[32], const uint8_t data[32], const uint8_t expected_hmac[32]) |
| bool | crypto_verify_hmac_ex (const uint8_t key[32], const uint8_t *data, size_t data_len, const uint8_t expected_hmac[32]) |
| crypto_result_t | crypto_compute_auth_response (const crypto_context_t *ctx, const uint8_t nonce[32], uint8_t hmac_out[32]) |
| bool | crypto_verify_auth_response (const crypto_context_t *ctx, const uint8_t nonce[32], const uint8_t expected_hmac[32]) |
| crypto_result_t | crypto_create_auth_challenge (const crypto_context_t *ctx, uint8_t *packet_out, size_t packet_size, size_t *packet_len_out) |
| crypto_result_t | crypto_process_auth_challenge (crypto_context_t *ctx, const uint8_t *packet, size_t packet_len) |
| crypto_result_t | crypto_process_auth_response (crypto_context_t *ctx, const uint8_t *packet, size_t packet_len) |
| asciichat_error_t | crypto_compute_password_hmac (crypto_context_t *ctx, const uint8_t *password_key, const uint8_t *nonce, const uint8_t *shared_secret, uint8_t *hmac_out) |
| asciichat_error_t | crypto_verify_peer_signature (const uint8_t *peer_public_key, const uint8_t *ephemeral_key, size_t ephemeral_key_size, const uint8_t *signature) |
| asciichat_error_t | crypto_sign_ephemeral_key (const private_key_t *private_key, const uint8_t *ephemeral_key, size_t ephemeral_key_size, uint8_t *signature_out) |
| void | crypto_combine_auth_data (const uint8_t *hmac, const uint8_t *challenge_nonce, uint8_t *combined_out) |
| void | crypto_extract_auth_data (const uint8_t *combined_data, uint8_t *hmac_out, uint8_t *challenge_out) |
| bool | crypto_should_rekey (const crypto_context_t *ctx) |
| crypto_result_t | crypto_rekey_init (crypto_context_t *ctx) |
| crypto_result_t | crypto_rekey_process_request (crypto_context_t *ctx, const uint8_t *peer_new_public_key) |
| crypto_result_t | crypto_rekey_process_response (crypto_context_t *ctx, const uint8_t *peer_new_public_key) |
| crypto_result_t | crypto_rekey_commit (crypto_context_t *ctx) |
| void | crypto_rekey_abort (crypto_context_t *ctx) |
| void | crypto_get_rekey_status (const crypto_context_t *ctx, char *status_buffer, size_t buffer_size) |
🔐 Core cryptography: encryption/decryption, key exchange, authentication, and session rekeying with BearSSL
Definition in file lib/crypto/crypto.c.
| #define CRYPTO_RESULT_STRING_COUNT (sizeof(g_crypto_result_strings) / sizeof(g_crypto_result_strings[0])) |
Definition at line 573 of file lib/crypto/crypto.c.
| void crypto_combine_auth_data | ( | const uint8_t * | hmac, |
| const uint8_t * | challenge_nonce, | ||
| uint8_t * | combined_out | ||
| ) |
Definition at line 1121 of file lib/crypto/crypto.c.
| crypto_result_t crypto_compute_auth_response | ( | const crypto_context_t * | ctx, |
| const uint8_t | nonce[32], | ||
| uint8_t | hmac_out[32] | ||
| ) |
Definition at line 877 of file lib/crypto/crypto.c.
References crypto_compute_hmac_ex().
Referenced by crypto_handshake_server_complete().
| crypto_result_t crypto_compute_hmac | ( | crypto_context_t * | ctx, |
| const uint8_t | key[32], | ||
| const uint8_t | data[32], | ||
| uint8_t | hmac[32] | ||
| ) |
Definition at line 806 of file lib/crypto/crypto.c.
| crypto_result_t crypto_compute_hmac_ex | ( | const crypto_context_t * | ctx, |
| const uint8_t | key[32], | ||
| const uint8_t * | data, | ||
| size_t | data_len, | ||
| uint8_t | hmac[32] | ||
| ) |
Definition at line 823 of file lib/crypto/crypto.c.
Referenced by crypto_compute_auth_response(), and crypto_compute_password_hmac().
| asciichat_error_t crypto_compute_password_hmac | ( | crypto_context_t * | ctx, |
| const uint8_t * | password_key, | ||
| const uint8_t * | nonce, | ||
| const uint8_t * | shared_secret, | ||
| uint8_t * | hmac_out | ||
| ) |
Definition at line 1051 of file lib/crypto/crypto.c.
References crypto_compute_hmac_ex().
| crypto_result_t crypto_create_auth_challenge | ( | const crypto_context_t * | ctx, |
| uint8_t * | packet_out, | ||
| size_t | packet_size, | ||
| size_t * | packet_len_out | ||
| ) |
Definition at line 945 of file lib/crypto/crypto.c.
References crypto_generate_nonce().
| crypto_result_t crypto_create_encrypted_packet | ( | crypto_context_t * | ctx, |
| const uint8_t * | data, | ||
| size_t | data_len, | ||
| uint8_t * | packet_out, | ||
| size_t | packet_size, | ||
| size_t * | packet_len_out | ||
| ) |
Definition at line 684 of file lib/crypto/crypto.c.
References crypto_encrypt(), and crypto_is_ready().
| crypto_result_t crypto_create_public_key_packet | ( | const crypto_context_t * | ctx, |
| uint8_t * | packet_out, | ||
| size_t | packet_size, | ||
| size_t * | packet_len_out | ||
| ) |
Definition at line 627 of file lib/crypto/crypto.c.
| crypto_result_t crypto_decrypt | ( | crypto_context_t * | ctx, |
| const uint8_t * | ciphertext, | ||
| size_t | ciphertext_len, | ||
| uint8_t * | plaintext_out, | ||
| size_t | plaintext_out_size, | ||
| size_t * | plaintext_len_out | ||
| ) |
Definition at line 495 of file lib/crypto/crypto.c.
References crypto_is_ready().
Referenced by acip_server_receive_and_dispatch(), client_decrypt_packet(), client_dispatch_thread(), crypto_handshake_decrypt_packet(), crypto_handshake_process_rekey_complete(), crypto_process_encrypted_packet(), and receive_packet_secure().
| crypto_result_t crypto_derive_password_encryption_key | ( | const char * | password, |
| uint8_t | encryption_key[SECRETBOX_KEY_SIZE] | ||
| ) |
Definition at line 385 of file lib/crypto/crypto.c.
References crypto_validate_password().
| crypto_result_t crypto_derive_password_key | ( | crypto_context_t * | ctx, |
| const char * | password | ||
| ) |
Definition at line 311 of file lib/crypto/crypto.c.
References crypto_validate_password().
Referenced by client_crypto_init(), crypto_handshake_client_auth_response(), and crypto_init_with_password().
| void crypto_destroy | ( | crypto_context_t * | ctx | ) |
Definition at line 197 of file lib/crypto/crypto.c.
Referenced by crypto_handshake_destroy(), and crypto_init_with_password().
| crypto_result_t crypto_encrypt | ( | crypto_context_t * | ctx, |
| const uint8_t * | plaintext, | ||
| size_t | plaintext_len, | ||
| uint8_t * | ciphertext_out, | ||
| size_t | ciphertext_out_size, | ||
| size_t * | ciphertext_len_out | ||
| ) |
Definition at line 429 of file lib/crypto/crypto.c.
References crypto_is_ready().
Referenced by client_encrypt_packet(), crypto_create_encrypted_packet(), crypto_handshake_encrypt_packet(), crypto_handshake_rekey_complete(), and send_packet_secure().
| void crypto_extract_auth_data | ( | const uint8_t * | combined_data, |
| uint8_t * | hmac_out, | ||
| uint8_t * | challenge_out | ||
| ) |
Definition at line 1133 of file lib/crypto/crypto.c.
| crypto_result_t crypto_generate_keypair | ( | crypto_context_t * | ctx | ) |
Definition at line 215 of file lib/crypto/crypto.c.
Referenced by crypto_init().
| crypto_result_t crypto_generate_nonce | ( | uint8_t | nonce[32] | ) |
Definition at line 791 of file lib/crypto/crypto.c.
Referenced by crypto_create_auth_challenge(), and crypto_handshake_server_auth_challenge().
| crypto_result_t crypto_get_public_key | ( | const crypto_context_t * | ctx, |
| uint8_t * | public_key_out | ||
| ) |
Definition at line 235 of file lib/crypto/crypto.c.
| void crypto_get_rekey_status | ( | const crypto_context_t * | ctx, |
| char * | status_buffer, | ||
| size_t | buffer_size | ||
| ) |
Definition at line 1344 of file lib/crypto/crypto.c.
References buffer_size, and safe_snprintf().
| void crypto_get_status | ( | const crypto_context_t * | ctx, |
| char * | status_buffer, | ||
| size_t | buffer_size | ||
| ) |
Definition at line 583 of file lib/crypto/crypto.c.
References buffer_size, and crypto_is_ready().
| crypto_result_t crypto_init | ( | crypto_context_t * | ctx | ) |
Definition at line 91 of file lib/crypto/crypto.c.
References crypto_generate_keypair(), and format_duration_s().
Referenced by crypto_handshake_init(), and crypto_init_with_password().
| crypto_result_t crypto_init_with_password | ( | crypto_context_t * | ctx, |
| const char * | password | ||
| ) |
Definition at line 167 of file lib/crypto/crypto.c.
References crypto_derive_password_key(), crypto_destroy(), and crypto_init().
Referenced by crypto_handshake_init_with_password().
| bool crypto_is_ready | ( | const crypto_context_t * | ctx | ) |
Definition at line 275 of file lib/crypto/crypto.c.
Referenced by crypto_create_encrypted_packet(), crypto_decrypt(), crypto_encrypt(), crypto_get_status(), crypto_handshake_is_ready(), crypto_process_encrypted_packet(), packet_send_error(), packet_send_remote_log(), and send_packet_secure().
| crypto_result_t crypto_process_auth_challenge | ( | crypto_context_t * | ctx, |
| const uint8_t * | packet, | ||
| size_t | packet_len | ||
| ) |
Definition at line 977 of file lib/crypto/crypto.c.
| crypto_result_t crypto_process_auth_response | ( | crypto_context_t * | ctx, |
| const uint8_t * | packet, | ||
| size_t | packet_len | ||
| ) |
Definition at line 1009 of file lib/crypto/crypto.c.
References crypto_verify_hmac().
| crypto_result_t crypto_process_encrypted_packet | ( | crypto_context_t * | ctx, |
| const uint8_t * | packet, | ||
| size_t | packet_len, | ||
| uint8_t * | data_out, | ||
| size_t | data_size, | ||
| size_t * | data_len_out | ||
| ) |
Definition at line 746 of file lib/crypto/crypto.c.
References crypto_decrypt(), and crypto_is_ready().
| crypto_result_t crypto_process_public_key_packet | ( | crypto_context_t * | ctx, |
| const uint8_t * | packet, | ||
| size_t | packet_len | ||
| ) |
Definition at line 655 of file lib/crypto/crypto.c.
References crypto_set_peer_public_key().
| crypto_result_t crypto_random_bytes | ( | uint8_t * | buffer, |
| size_t | len | ||
| ) |
Definition at line 608 of file lib/crypto/crypto.c.
| void crypto_rekey_abort | ( | crypto_context_t * | ctx | ) |
Definition at line 1322 of file lib/crypto/crypto.c.
Referenced by crypto_handshake_process_rekey_complete(), crypto_handshake_process_rekey_request(), crypto_handshake_process_rekey_response(), crypto_handshake_rekey_complete(), crypto_handshake_rekey_request(), crypto_handshake_rekey_response(), and crypto_rekey_process_response().
| crypto_result_t crypto_rekey_commit | ( | crypto_context_t * | ctx | ) |
Definition at line 1278 of file lib/crypto/crypto.c.
Referenced by crypto_handshake_process_rekey_complete(), and crypto_handshake_rekey_complete().
| crypto_result_t crypto_rekey_init | ( | crypto_context_t * | ctx | ) |
Definition at line 1183 of file lib/crypto/crypto.c.
References format_duration_s().
Referenced by crypto_handshake_process_rekey_request(), and crypto_handshake_rekey_request().
| crypto_result_t crypto_rekey_process_request | ( | crypto_context_t * | ctx, |
| const uint8_t * | peer_new_public_key | ||
| ) |
Definition at line 1227 of file lib/crypto/crypto.c.
Referenced by crypto_handshake_process_rekey_request().
| crypto_result_t crypto_rekey_process_response | ( | crypto_context_t * | ctx, |
| const uint8_t * | peer_new_public_key | ||
| ) |
Definition at line 1255 of file lib/crypto/crypto.c.
References crypto_rekey_abort().
Referenced by crypto_handshake_process_rekey_response().
| const char * crypto_result_to_string | ( | crypto_result_t | result | ) |
Definition at line 575 of file lib/crypto/crypto.c.
References CRYPTO_RESULT_STRING_COUNT.
Referenced by acip_server_receive_and_dispatch(), client_crypto_init(), client_dispatch_thread(), crypto_handshake_client_auth_response(), crypto_handshake_client_key_exchange(), crypto_handshake_decrypt_packet(), crypto_handshake_encrypt_packet(), crypto_handshake_init(), crypto_handshake_init_with_password(), crypto_handshake_process_rekey_complete(), crypto_handshake_process_rekey_request(), crypto_handshake_process_rekey_response(), crypto_handshake_rekey_complete(), crypto_handshake_rekey_request(), crypto_handshake_server_auth_challenge(), crypto_handshake_server_complete(), receive_packet_secure(), and send_packet_secure().
| bool crypto_secure_compare | ( | const uint8_t * | lhs, |
| const uint8_t * | rhs, | ||
| size_t | len | ||
| ) |
Definition at line 601 of file lib/crypto/crypto.c.
| crypto_result_t crypto_set_peer_public_key | ( | crypto_context_t * | ctx, |
| const uint8_t * | peer_public_key | ||
| ) |
Definition at line 249 of file lib/crypto/crypto.c.
Referenced by crypto_handshake_client_key_exchange(), crypto_handshake_server_auth_challenge(), and crypto_process_public_key_packet().
| bool crypto_should_rekey | ( | const crypto_context_t * | ctx | ) |
Definition at line 1149 of file lib/crypto/crypto.c.
Referenced by crypto_handshake_should_rekey().
| asciichat_error_t crypto_sign_ephemeral_key | ( | const private_key_t * | private_key, |
| const uint8_t * | ephemeral_key, | ||
| size_t | ephemeral_key_size, | ||
| uint8_t * | signature_out | ||
| ) |
Definition at line 1097 of file lib/crypto/crypto.c.
| crypto_result_t crypto_validate_password | ( | const char * | password | ) |
Definition at line 288 of file lib/crypto/crypto.c.
Referenced by crypto_derive_password_encryption_key(), and crypto_derive_password_key().
| bool crypto_verify_auth_response | ( | const crypto_context_t * | ctx, |
| const uint8_t | nonce[32], | ||
| const uint8_t | expected_hmac[32] | ||
| ) |
Definition at line 909 of file lib/crypto/crypto.c.
References crypto_verify_hmac_ex().
Referenced by crypto_handshake_client_complete(), and crypto_handshake_server_complete().
| bool crypto_verify_hmac | ( | const uint8_t | key[32], |
| const uint8_t | data[32], | ||
| const uint8_t | expected_hmac[32] | ||
| ) |
Definition at line 841 of file lib/crypto/crypto.c.
Referenced by crypto_process_auth_response().
| bool crypto_verify_hmac_ex | ( | const uint8_t | key[32], |
| const uint8_t * | data, | ||
| size_t | data_len, | ||
| const uint8_t | expected_hmac[32] | ||
| ) |
Definition at line 856 of file lib/crypto/crypto.c.
Referenced by crypto_verify_auth_response().
| bool crypto_verify_password | ( | const crypto_context_t * | ctx, |
| const char * | password | ||
| ) |
Definition at line 350 of file lib/crypto/crypto.c.
| asciichat_error_t crypto_verify_peer_signature | ( | const uint8_t * | peer_public_key, |
| const uint8_t * | ephemeral_key, | ||
| size_t | ephemeral_key_size, | ||
| const uint8_t * | signature | ||
| ) |
Definition at line 1078 of file lib/crypto/crypto.c.