#include "nasl_lex_ctxt.h"
#include <gpg-error.h>
Go to the source code of this file.
|
| void * | hmac_md5_for_prf (const void *key, int keylen, const void *buf, int buflen) |
| |
| void * | hmac_sha1 (const void *key, int keylen, const void *buf, int buflen) |
| |
| void * | hmac_sha256 (const void *key, int keylen, const void *buf, int buflen) |
| |
| void * | hmac_sha384 (const void *key, int keylen, const void *buf, int buflen) |
| |
| tree_cell * | nasl_smb_sign (const int algo, lex_ctxt *lexic) |
| |
| gpg_err_code_t | mac (const char *key, const size_t key_len, const char *data, const size_t data_len, const char *iv, const size_t iv_len, int algo, int flags, char **out, size_t *out_len) |
| |
◆ hmac_md5_for_prf()
| void* hmac_md5_for_prf |
( |
const void * |
key, |
|
|
int |
keylen, |
|
|
const void * |
buf, |
|
|
int |
buflen |
|
) |
| |
Definition at line 20 of file nasl_crypt_helper.c.
22 void *signature = g_malloc0 (16);
26 hmac = g_hmac_new (G_CHECKSUM_MD5, key, keylen);
27 g_hmac_update (hmac, buf, buflen);
28 g_hmac_get_digest (hmac, signature, &signlen);
Referenced by tls_prf().
◆ hmac_sha1()
| void* hmac_sha1 |
( |
const void * |
key, |
|
|
int |
keylen, |
|
|
const void * |
buf, |
|
|
int |
buflen |
|
) |
| |
Definition at line 34 of file nasl_crypt_helper.c.
36 void *signature = g_malloc0 (20);
40 hmac = g_hmac_new (G_CHECKSUM_SHA1, key, keylen);
41 g_hmac_update (hmac, buf, buflen);
42 g_hmac_get_digest (hmac, signature, &signlen);
Referenced by tls_prf().
◆ hmac_sha256()
| void* hmac_sha256 |
( |
const void * |
key, |
|
|
int |
keylen, |
|
|
const void * |
buf, |
|
|
int |
buflen |
|
) |
| |
Definition at line 48 of file nasl_crypt_helper.c.
50 void *signature = g_malloc0 (32);
54 hmac = g_hmac_new (G_CHECKSUM_SHA256, key, keylen);
55 g_hmac_update (hmac, buf, buflen);
56 g_hmac_get_digest (hmac, signature, &signlen);
Referenced by nasl_hmac_sha256(), smb_sign(), and tls_prf().
◆ hmac_sha384()
| void* hmac_sha384 |
( |
const void * |
key, |
|
|
int |
keylen, |
|
|
const void * |
buf, |
|
|
int |
buflen |
|
) |
| |
Definition at line 62 of file nasl_crypt_helper.c.
68 if (!buf || buflen <= 0)
71 err = gcry_md_open (&hd, GCRY_MD_SHA384, key ? GCRY_MD_FLAG_HMAC : 0);
74 g_message (
"nasl_gcrypt_hash(): gcry_md_open failed: %s/%s",
75 gcry_strsource (err), gcry_strerror (err));
81 err = gcry_md_setkey (hd, key, keylen);
84 g_message (
"nasl_gcrypt_hash(): gcry_md_setkey failed: %s/%s",
85 gcry_strsource (err), gcry_strerror (err));
90 gcry_md_write (hd, buf, buflen);
91 ret = g_memdup2 (gcry_md_read (hd, 0), 48);
Referenced by tls_prf().
◆ mac()
| gpg_err_code_t mac |
( |
const char * |
key, |
|
|
const size_t |
key_len, |
|
|
const char * |
data, |
|
|
const size_t |
data_len, |
|
|
const char * |
iv, |
|
|
const size_t |
iv_len, |
|
|
int |
algo, |
|
|
int |
flags, |
|
|
char ** |
out, |
|
|
size_t * |
out_len |
|
) |
| |
Definition at line 97 of file nasl_crypt_helper.c.
102 gpg_err_code_t result = 0;
104 if (key == NULL || key_len < 1)
105 return GPG_ERR_MISSING_KEY;
106 if (data == NULL || data_len < 1)
107 return GPG_ERR_MISSING_VALUE;
110 return GPG_ERR_GENERAL;
112 if ((result = gcry_mac_open (&hd, algo, flags, NULL)))
114 if ((result = gcry_mac_setkey (hd, key, key_len)))
116 if (iv && (result = gcry_mac_setiv (hd, iv, iv_len)))
118 if ((result = gcry_mac_write (hd, data, data_len)))
121 *out_len = gcry_mac_get_algo_maclen (algo);
122 if ((*out = g_malloc0 (*out_len *
sizeof (*out))) == NULL)
124 result = GPG_ERR_ENOMEM;
127 if ((result = gcry_mac_read (hd, *out, out_len)))
Referenced by get_local_mac_address_from_ip(), nasl_get_local_mac_address_from_ip(), nasl_mac(), nasl_send_arp_request(), smb_sign(), and socket_get_ssl_ciphersuite().
◆ nasl_smb_sign()
Definition at line 179 of file nasl_crypt_helper.c.
181 char *key, *buf, *iv, *res;
182 int keylen, buflen, ivlen;
193 switch ((error =
smb_sign (algo, key, keylen, buf, buflen, iv, ivlen, &res)))
195 case GPG_ERR_NO_ERROR:
200 case GPG_ERR_MISSING_KEY:
201 case GPG_ERR_MISSING_VALUE:
202 nasl_perror (lexic,
"Syntax: nasl_mac: Missing key, or data argument");
205 nasl_perror (lexic,
"Internal: %s.", gcry_strerror (error));
References alloc_typed_cell(), CONST_DATA, get_str_var_by_name(), get_var_size_by_name(), nasl_perror(), TC::size, smb_sign(), TC::str_val, and TC::x.
Referenced by nasl_get_smb2_sign(), nasl_smb_cmac_aes_sign(), and nasl_smb_gmac_aes_sign().