OpenVAS Manager
7.0.3~git
|
#include <glib.h>
#include <glib/gstdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdint.h>
#include <openvas/base/gpgme_util.h>
#include "lsc_crypt.h"
Go to the source code of this file.
Data Structures | |
struct | namelist_s |
A linked list to help caching results. More... | |
struct | lsc_crypt_ctx_s |
The context object for encryption operations. More... | |
Macros | |
#define | G_LOG_DOMAIN "md crypt" |
GLib log domain. More... | |
#define | ENCRYPTION_KEY_UID "OpenVAS Credential Encryption" |
The name of the encryption key. More... | |
#define | MAX_VALUE_LENGTH (128 * 1024) |
The maximum size of an encrypted value. More... | |
#define | GPG_ERR_AMBIGUOUS GPG_ERR_AMBIGUOUS_NAME |
Functions | |
lsc_crypt_ctx_t | lsc_crypt_new () |
Return a new context for LSC encryption. More... | |
void | lsc_crypt_release (lsc_crypt_ctx_t ctx) |
Release an LSC encryption context. More... | |
int | lsc_crypt_create_key () |
Create the standard credential encryption key. More... | |
void | lsc_crypt_flush (lsc_crypt_ctx_t ctx) |
Flush an LSC encryption context. More... | |
char * | lsc_crypt_encrypt (lsc_crypt_ctx_t ctx, const char *first_name,...) |
Encrypt a list of name/value pairs. More... | |
const char * | lsc_crypt_decrypt (lsc_crypt_ctx_t ctx, const char *ciphertext, const char *name) |
Return an encrypted value in the clear. More... | |
const char * | lsc_crypt_get_password (lsc_crypt_ctx_t ctx, const char *ciphertext) |
Return an encrypted password in the clear. More... | |
const char * | lsc_crypt_get_private_key (lsc_crypt_ctx_t ctx, const char *ciphertext) |
Return an encrypted private key in the clear. More... | |
#define ENCRYPTION_KEY_UID "OpenVAS Credential Encryption" |
The name of the encryption key.
Note that the code will use the "=" prefix flag to indicate an exact search. Thus when creating the key it should not have a comment or email address part.
Definition at line 50 of file lsc_crypt.c.
#define G_LOG_DOMAIN "md crypt" |
GLib log domain.
Definition at line 41 of file lsc_crypt.c.
#define GPG_ERR_AMBIGUOUS GPG_ERR_AMBIGUOUS_NAME |
Definition at line 63 of file lsc_crypt.c.
#define MAX_VALUE_LENGTH (128 * 1024) |
The maximum size of an encrypted value.
To avoid excessive memory allocations we put a limit on the size of values stored in a name/value pair.
Definition at line 58 of file lsc_crypt.c.
int lsc_crypt_create_key | ( | ) |
Create the standard credential encryption key.
This function creates a standard encryption key if such a key does not yet exists. Note, that in general an encryption key is created on-the-fly.
Definition at line 549 of file lsc_crypt.c.
References lsc_crypt_new().
const char* lsc_crypt_decrypt | ( | lsc_crypt_ctx_t | ctx, |
const char * | ciphertext, | ||
const char * | name | ||
) |
Return an encrypted value in the clear.
This function returns the encrypted value in the clear. The clear value may also be NULL , if no value is available. If a decryption has not yet been done, the passed ciphertext value is first decrypted. Thus a changed value of ciphertext may not have an effect. To force a decryption a call to lsc_crypt_flush is required.
[in] | ctx | The context |
[in] | ciphertext | The base64 encoded ciphertext. |
[in] | name | Name of the value to get. |
Definition at line 693 of file lsc_crypt.c.
References disable_encrypted_credentials, namelist_s::name, and lsc_crypt_ctx_s::plaintext.
Referenced by lsc_crypt_get_password(), and lsc_crypt_get_private_key().
char* lsc_crypt_encrypt | ( | lsc_crypt_ctx_t | ctx, |
const char * | first_name, | ||
... | |||
) |
Encrypt a list of name/value pairs.
[in] | ctx | The context |
[in] | first_name | The name of the first name/value pair. This must be followed by a string value and optionaly followed by more name and value pairs. This list is terminated by a single NULL instead of a name. |
Definition at line 616 of file lsc_crypt.c.
References namelist_s::name, and namelist_s::value.
Referenced by migrate_156_to_157(), migrate_158_to_159(), migrate_160_to_161(), and migrate_165_to_166().
void lsc_crypt_flush | ( | lsc_crypt_ctx_t | ctx | ) |
Flush an LSC encryption context.
This function is used to flush the context. The flushing invalidates returned strings and internal caches. Basically this is the same as releasing and creating the context but it is optimized to keep some internal state.
[in] | ctx | The context or NULL |
Definition at line 586 of file lsc_crypt.c.
References lsc_crypt_ctx_s::namelist, namelist_s::next, lsc_crypt_ctx_s::plaintext, and namelist_s::value.
Referenced by lsc_crypt_release(), and next().
const char* lsc_crypt_get_password | ( | lsc_crypt_ctx_t | ctx, |
const char * | ciphertext | ||
) |
Return an encrypted password in the clear.
This function returns the encrypted password in the clear. The clear value may also be NULL , if no password is available. If a decryption has not yet been done, the passed ciphertext value is first decrypted. Thus a changed value of ciphertext may not have an effect. To force a decryption a call to lsc_crypt_flush is required.
[in] | ctx | The context |
[in] | ciphertext | The base64 encoded ciphertext. |
Definition at line 840 of file lsc_crypt.c.
References lsc_crypt_decrypt().
Referenced by migrate_160_to_161().
const char* lsc_crypt_get_private_key | ( | lsc_crypt_ctx_t | ctx, |
const char * | ciphertext | ||
) |
Return an encrypted private key in the clear.
This function returns the encrypted private key in the clear. The clear value may also be NULL , if no private key is available. If a decryption has not yet been done, the passed ciphertext value is first decrypted. Thus a changed value of ciphertext may not have an effect. To force a decryption a call to lsc_crypt_flush is required.
[in] | ctx | The context |
[in] | ciphertext | The base64 encoded ciphertext. |
Definition at line 864 of file lsc_crypt.c.
References lsc_crypt_decrypt().
Referenced by migrate_153_to_154().
lsc_crypt_ctx_t lsc_crypt_new | ( | ) |
Return a new context for LSC encryption.
Definition at line 507 of file lsc_crypt.c.
References lsc_crypt_ctx_s::encctx.
Referenced by lsc_crypt_create_key(), migrate_153_to_154(), migrate_156_to_157(), migrate_158_to_159(), migrate_160_to_161(), and migrate_165_to_166().
void lsc_crypt_release | ( | lsc_crypt_ctx_t | ctx | ) |
Release an LSC encryption context.
[in] | ctx | The context or NULL |
Definition at line 528 of file lsc_crypt.c.
References lsc_crypt_ctx_s::encctx, and lsc_crypt_flush().
Referenced by cleanup_iterator(), and migrate_160_to_161().