crypt.h 1.54 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/*
 * Copyright (c) Edward Thomson.  All rights reserved.
 *
 * This file is part of ntlmclient, distributed under the MIT license.
 * For full terms and copyright information, and for third-party
 * copyright information, see the included LICENSE.txt file.
 */

#ifndef PRIVATE_CRYPT_COMMON_H__
#define PRIVATE_CRYPT_COMMON_H__

12 13 14
#include "ntlmclient.h"
#include "ntlm.h"

15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#if defined(CRYPT_OPENSSL)
# include "crypt_openssl.h"
#elif defined(CRYPT_MBEDTLS)
# include "crypt_mbedtls.h"
#elif defined(CRYPT_COMMONCRYPTO)
# include "crypt_commoncrypto.h"
#else
# error "no crypto support"
#endif

#define CRYPT_DES_BLOCKSIZE 8
#define CRYPT_MD4_DIGESTSIZE 16
#define CRYPT_MD5_DIGESTSIZE 16

typedef unsigned char ntlm_des_block[CRYPT_DES_BLOCKSIZE];

31 32 33 34
typedef struct ntlm_crypt_ctx ntlm_crypt_ctx;

extern bool ntlm_crypt_init(ntlm_client *ntlm);

35 36
extern bool ntlm_random_bytes(
	unsigned char *out,
37
	ntlm_client *ntlm,
38 39 40 41
	size_t len);

extern bool ntlm_des_encrypt(
	ntlm_des_block *out,
42
	ntlm_client *ntlm,
43 44 45 46 47
	ntlm_des_block *plaintext,
	ntlm_des_block *key);

extern bool ntlm_md4_digest(
	unsigned char out[CRYPT_MD4_DIGESTSIZE],
48
	ntlm_client *ntlm,
49 50 51 52
	const unsigned char *in,
	size_t in_len);

extern bool ntlm_hmac_md5_init(
53
	ntlm_client *ntlm,
54 55 56 57
	const unsigned char *key,
	size_t key_len);

extern bool ntlm_hmac_md5_update(
58
	ntlm_client *ntlm,
59 60 61 62 63 64
	const unsigned char *data,
	size_t data_len);

extern bool ntlm_hmac_md5_final(
	unsigned char *out,
	size_t *out_len,
65
	ntlm_client *ntlm);
66

67
extern void ntlm_crypt_shutdown(ntlm_client *ntlm);
68 69

#endif /* PRIVATE_CRYPT_COMMON_H__ */