FreeTDS API

Classes | Macros | Typedefs | Enumerations | Functions | Variables
Authentication
LibTDS API

Functions for handling authentication. More...

Collaboration diagram for Authentication:

## Classes
struct | asn1_der_iterator
struct | mpz_t
struct | names_blob_prefix_t
struct | rsa_public_key
struct | tds_answer
struct | tds_ntlm_auth

## Macros
#define | dump(b) dumpl(b, sizeof(b))
#define | dumpl(b, l) tdsdump_dump_buf(TDS_DBG_INFO1, #b, b, l)
#define | hash_func sha1
#define | HAVE_GMP 1
#define | HAVE_NETTLE 1
#define | mpz_clear(n) gcry_mpi_release((n)->num)
#define | mpz_init(n) do { (n)->num = NULL; } while(0)
#define | mpz_powm(w, n, e, m) gcry_mpi_powm((w)->num, (n)->num, (e)->num, (m)->num);

## Typedefs
typedef void | nettle_random_func(void *ctx, size_t len, uint8_t *out)
typedef struct tds_answer | TDSANSWER
typedef struct tds_ntlm_auth | TDSNTLMAUTH

## Enumerations
enum | { ASN1_SEQUENCE = ASN1_TAG_SEQUENCE }
enum | { hash_len = 20 }
enum | { key_size_max = 1024 }
enum | asn1_iterator_result { ASN1_ITERATOR_ERROR, ASN1_ITERATOR_PRIMITIVE, ASN1_ITERATOR_CONSTRUCTED, ASN1_ITERATOR_END }

## Functions
static enum asn1_iterator_result | asn1_der_iterator_first (struct asn1_der_iterator *der, int size, const void *der_buf)
static enum asn1_iterator_result | asn1_der_iterator_next (struct asn1_der_iterator *der)
static void | convert_to_upper (char *buf, size_t len)
static size_t | convert_to_usc2le_string (TDSSOCKET *tds, const char *s, size_t len, char *out)
static void | fill_names_blob_prefix (names_blob_prefix_t *prefix)
static unsigned char * | make_lm_v2_response (const unsigned char ntlm_v2_hash[16], const unsigned char *client_data, TDS_INT client_data_len, const unsigned char challenge[8])
static TDSRET | make_ntlm_hash (TDSSOCKET *tds, const char *passwd, unsigned char ntlm_hash[16])
static TDSRET | make_ntlm_v2_hash (TDSSOCKET *tds, const char *passwd, unsigned char ntlm_v2_hash[16])
static void | memxor (uint8_t *dest, const uint8_t *src, size_t len)
static void | mgf_mask (uint8_t *dest, size_t dest_len, const uint8_t *mask, size_t mask_len)
static void | nettle_mpz_get_str_256 (unsigned length, uint8_t *s, const mpz_t x)
static void | nettle_mpz_set_str_256_u (mpz_t x, unsigned length, const uint8_t *s)
static int | oaep_encrypt (size_t key_size, void *random_ctx, nettle_random_func *random, size_t length, const uint8_t *message, mpz_t m)
static void | rnd_func (void *ctx, size_t len, uint8_t *out)
static int | rsa_encrypt_oaep (const struct rsa_public_key *key, void *random_ctx, nettle_random_func *random, size_t length, const uint8_t *message, mpz_t gibberish)
static const BIGNUM * | rsa_get_n (const RSA *rsa)
static void | rsa_public_key_clear (struct rsa_public_key *key)
static int | rsa_public_key_from_der_iterator (struct rsa_public_key *key, unsigned key_bits, struct asn1_der_iterator *der)
static void | rsa_public_key_init (struct rsa_public_key *key)
static void | sha1 (uint8_t *hash, const void *data, size_t len)
TDSAUTHENTICATION * | tds5_negotiate_get_auth (TDSSOCKET *tds)
void | tds5_negotiate_set_msg_type (TDSSOCKET *tds, TDSAUTHENTICATION *tds_auth, unsigned msg_type)
static void * | tds5_rsa_encrypt (const void *key, size_t key_len, const void *nonce, size_t nonce_len, const char *pwd, size_t *em_size)
static TDSRET | tds7_send_auth (TDSSOCKET *tds, const unsigned char *challenge, TDS_UINT flags, const unsigned char *names_blob, TDS_INT names_blob_len)
static TDSRET | tds_answer_challenge (TDSSOCKET *tds, TDSLOGIN *login, const unsigned char *challenge, TDS_UINT *flags, const unsigned char *names_blob, TDS_INT names_blob_len, TDSANSWER *answer, unsigned char **ntlm_v2_response)
| Crypt a given password using schema required for NTLMv1 or NTLM2 authentication. More...
static TDSRET | tds_answer_challenge_ntlmv2 (TDSSOCKET *tds, TDSLOGIN *login, const unsigned char *challenge, TDS_UINT *flags, const unsigned char *names_blob, TDS_INT names_blob_len, TDSANSWER *answer, unsigned char **ntlm_v2_response)
static void | tds_convert_key (const unsigned char *key_56, DES_KEY *ks)
static void | tds_encrypt_answer (const unsigned char *hash, const unsigned char *challenge, unsigned char *answer)
static TDSRET | tds_ntlm_free (TDSCONNECTION *conn, TDSAUTHENTICATION *tds_auth)
TDSAUTHENTICATION * | tds_ntlm_get_auth (TDSSOCKET *tds)
| Build a NTLMSPP packet to send to server. More...
static TDSRET | tds_ntlm_handle_next (TDSSOCKET *tds, struct tds_authentication *auth, size_t len)
static void | unix_to_nt_time (TDS_UINT8 *nt, struct timeval *tv)
| put a 8 byte filetime from a time_t This takes GMT as input

## Variables
static const char | label [] = ""
static const unsigned char | ntlm_id [] = "NTLMSSP"

## Detailed Description

Functions for handling authentication.

## Function Documentation

## § tds_answer_challenge()

static TDSRET tds_answer_challenge | ( | TDSSOCKET * | tds,
|  | TDSLOGIN * | login,
|  | const unsigned char * | challenge,
|  | TDS_UINT * | flags,
|  | const unsigned char * | names_blob,
|  | TDS_INT | names_blob_len,
|  | TDSANSWER * | answer,
|  | unsigned char ** | ntlm_v2_response
| ) |  |
| static

Crypt a given password using schema required for NTLMv1 or NTLM2 authentication.

Parameters

  passwd | clear text domain password
  challenge | challenge data given by server
  flags | NTLM flags from server side
  answer | buffer where to store crypted password

Here is the call graph for this function:

## § tds_ntlm_get_auth()

TDSAUTHENTICATION* tds_ntlm_get_auth | ( | TDSSOCKET * | tds | ) |

Build a NTLMSPP packet to send to server.

Parameters

  tds | A pointer to the TDSSOCKET structure managing a client/server operation.

Returns
  authentication info

Here is the call graph for this function: