|
Greenbone Vulnerability Management Libraries 22.32.0
|
Data stream validation. More...
#include "streamvalidator.h"#include "authutils.h"#include <assert.h>#include <gcrypt.h>#include <glib.h>#include <stdint.h>#include <string.h>
Go to the source code of this file.
Data Structures | |
| struct | gvm_stream_validator |
| Data stream validator structure. More... | |
Functions | |
| const char * | gvm_stream_validator_return_str (gvm_stream_validator_return_t value) |
| Gets a string representation of a gvm_stream_validator_return_t. | |
| gvm_stream_validator_return_t | gvm_stream_validator_new (const char *expected_hash_str, gvm_stream_validator_t *validator_out) |
| Allocate and initialize a checksum-only stream validator. | |
| gvm_stream_validator_return_t | gvm_stream_validator_with_size_new (const char *expected_hash_str, size_t expected_size, gvm_stream_validator_t *validator_out) |
| Allocate and initialize a new data stream validator. | |
| void | gvm_stream_validator_rewind (gvm_stream_validator_t validator) |
| Rewind the validation state of a stream validator while keeping the expected hash and data size. | |
| void | gvm_stream_validator_free (gvm_stream_validator_t validator) |
| Free a stream validator and all of its fields. | |
| gvm_stream_validator_return_t | gvm_stream_validator_write (gvm_stream_validator_t validator, const char *data, size_t length) |
| Write data to a validator, updating the hash state and current size. | |
| gvm_stream_validator_return_t | gvm_stream_validator_end (gvm_stream_validator_t validator) |
| Signal the end of data input into a validator and produce the result of the validation. | |
Data stream validation.
Definition in file streamvalidator.c.
| gvm_stream_validator_return_t gvm_stream_validator_end | ( | gvm_stream_validator_t | validator | ) |
Signal the end of data input into a validator and produce the result of the validation.
| [in] | validator | The validator to signal the end of data input of. |
Definition at line 260 of file streamvalidator.c.
References gvm_stream_validator::algorithm, gvm_stream_validator::current_size, digest_hex(), gvm_stream_validator::expected_hash_hex, gvm_stream_validator::expected_size, gvm_stream_validator::gcrypt_md_hd, GVM_STREAM_VALIDATOR_DATA_TOO_LONG, GVM_STREAM_VALIDATOR_DATA_TOO_SHORT, GVM_STREAM_VALIDATOR_HASH_MISMATCH, GVM_STREAM_VALIDATOR_OK, and gvm_stream_validator::size_enforced.
Referenced by Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), and Ensure().


| void gvm_stream_validator_free | ( | gvm_stream_validator_t | validator | ) |
Free a stream validator and all of its fields.
| [in] | validator | The validator to free. |
Definition at line 216 of file streamvalidator.c.
References gvm_stream_validator::expected_hash_hex, gvm_stream_validator::expected_hash_str, and gvm_stream_validator::gcrypt_md_hd.
Referenced by Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), and Ensure().

| gvm_stream_validator_return_t gvm_stream_validator_new | ( | const char * | expected_hash_str, |
| gvm_stream_validator_t * | validator_out ) |
Allocate and initialize a checksum-only stream validator.
| [in] | expected_hash_str | Expected hash / checksum string consisting of an algorithm name or OID as recognized by gcrypt, followed by a colon and the hex-encoded hash, e.g. "md5:70165459812a0d38851a4a4c3e4124c9". |
| [out] | validator_out | Pointer to output location of the newly allocated validator. |
Definition at line 87 of file streamvalidator.c.
References GVM_STREAM_VALIDATOR_NO_SIZE, and gvm_stream_validator_with_size_new().
Referenced by Ensure(), Ensure(), and Ensure().


| const char * gvm_stream_validator_return_str | ( | gvm_stream_validator_return_t | value | ) |
Gets a string representation of a gvm_stream_validator_return_t.
| [in] | value | The value to get a string representation of. |
Definition at line 44 of file streamvalidator.c.
References GVM_STREAM_VALIDATOR_DATA_TOO_LONG, GVM_STREAM_VALIDATOR_DATA_TOO_SHORT, GVM_STREAM_VALIDATOR_HASH_MISMATCH, GVM_STREAM_VALIDATOR_INTERNAL_ERROR, GVM_STREAM_VALIDATOR_INVALID_HASH_ALGORITHM, GVM_STREAM_VALIDATOR_INVALID_HASH_SYNTAX, GVM_STREAM_VALIDATOR_INVALID_HASH_VALUE, and GVM_STREAM_VALIDATOR_OK.
Referenced by Ensure(), Ensure(), and Ensure().

| void gvm_stream_validator_rewind | ( | gvm_stream_validator_t | validator | ) |
Rewind the validation state of a stream validator while keeping the expected hash and data size.
| [in] | validator | The validator to rewind. |
Definition at line 204 of file streamvalidator.c.
References gvm_stream_validator::current_size, and gvm_stream_validator::gcrypt_md_hd.
Referenced by Ensure().

| gvm_stream_validator_return_t gvm_stream_validator_with_size_new | ( | const char * | expected_hash_str, |
| size_t | expected_size, | ||
| gvm_stream_validator_t * | validator_out ) |
Allocate and initialize a new data stream validator.
| [in] | expected_hash_str | Expected hash / checksum string consisting of an algorithm name or OID as recognized by gcrypt, followed by a colon and the hex-encoded hash, e.g. "md5:70165459812a0d38851a4a4c3e4124c9". |
| [in] | expected_size | The number of bytes expected to be sent. Pass (size_t)-1 to disable size enforcement and validate by hash only. |
| [out] | validator_out | Pointer to output location of the newly allocated validator. |
Definition at line 117 of file streamvalidator.c.
References GVM_STREAM_VALIDATOR_INTERNAL_ERROR, GVM_STREAM_VALIDATOR_INVALID_HASH_ALGORITHM, GVM_STREAM_VALIDATOR_INVALID_HASH_SYNTAX, GVM_STREAM_VALIDATOR_INVALID_HASH_VALUE, GVM_STREAM_VALIDATOR_NO_SIZE, and GVM_STREAM_VALIDATOR_OK.
Referenced by Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), and gvm_stream_validator_new().

| gvm_stream_validator_return_t gvm_stream_validator_write | ( | gvm_stream_validator_t | validator, |
| const char * | data, | ||
| size_t | length ) |
Write data to a validator, updating the hash state and current size.
Will fail if the total data size exceeds the expected size.
| [in] | validator | The validator to handle the data |
| [in] | data | The data to write. |
| [in] | length | Length of the data. |
Definition at line 236 of file streamvalidator.c.
References gvm_stream_validator::current_size, gvm_stream_validator::expected_size, gvm_stream_validator::gcrypt_md_hd, GVM_STREAM_VALIDATOR_DATA_TOO_LONG, GVM_STREAM_VALIDATOR_OK, and gvm_stream_validator::size_enforced.
Referenced by Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), and Ensure().
