| 1 |
/* This is a generated file */ |
| 2 |
#ifndef __heimntlm_protos_h__ |
| 3 |
#define __heimntlm_protos_h__ |
| 4 |
#ifndef DOXY |
| 5 |
|
| 6 |
#include <stdarg.h> |
| 7 |
|
| 8 |
#ifdef __cplusplus |
| 9 |
extern "C" { |
| 10 |
#endif |
| 11 |
|
| 12 |
/** |
| 13 |
* Generates an NTLMv1 session random with assosited session master key. |
| 14 |
* |
| 15 |
* @param key the ntlm v1 key |
| 16 |
* @param len length of key |
| 17 |
* @param session generated session nonce, should be freed with heim_ntlm_free_buf(). |
| 18 |
* @param master calculated session master key, should be freed with heim_ntlm_free_buf(). |
| 19 |
* |
| 20 |
* @return In case of success 0 is return, an errors, a errno in what |
| 21 |
* went wrong. |
| 22 |
* |
| 23 |
* @ingroup ntlm_core |
| 24 |
*/ |
| 25 |
|
| 26 |
int |
| 27 |
heim_ntlm_build_ntlm1_master ( |
| 28 |
void */*key*/, |
| 29 |
size_t /*len*/, |
| 30 |
struct ntlm_buf */*session*/, |
| 31 |
struct ntlm_buf */*master*/); |
| 32 |
|
| 33 |
/** |
| 34 |
* Generates an NTLMv2 session random with associated session master key. |
| 35 |
* |
| 36 |
* @param key the NTLMv2 key |
| 37 |
* @param len length of key |
| 38 |
* @param blob the NTLMv2 "blob" |
| 39 |
* @param session generated session nonce, should be freed with heim_ntlm_free_buf(). |
| 40 |
* @param master calculated session master key, should be freed with heim_ntlm_free_buf(). |
| 41 |
* |
| 42 |
* @return In case of success 0 is return, an errors, a errno in what |
| 43 |
* went wrong. |
| 44 |
* |
| 45 |
* @ingroup ntlm_core |
| 46 |
*/ |
| 47 |
|
| 48 |
int |
| 49 |
heim_ntlm_build_ntlm2_master ( |
| 50 |
void */*key*/, |
| 51 |
size_t /*len*/, |
| 52 |
struct ntlm_buf */*blob*/, |
| 53 |
struct ntlm_buf */*session*/, |
| 54 |
struct ntlm_buf */*master*/); |
| 55 |
|
| 56 |
/** |
| 57 |
* Calculate LMv2 response |
| 58 |
* |
| 59 |
* @param key the ntlm key |
| 60 |
* @param len length of key |
| 61 |
* @param username name of the user, as sent in the message, assumed to be in UTF8. |
| 62 |
* @param target the name of the target, assumed to be in UTF8. |
| 63 |
* @param serverchallenge challenge as sent by the server in the type2 message. |
| 64 |
* @param ntlmv2 calculated session key |
| 65 |
* @param answer ntlm response answer, should be freed with heim_ntlm_free_buf(). |
| 66 |
* |
| 67 |
* @return In case of success 0 is return, an errors, a errno in what |
| 68 |
* went wrong. |
| 69 |
* |
| 70 |
* @ingroup ntlm_core |
| 71 |
*/ |
| 72 |
|
| 73 |
int |
| 74 |
heim_ntlm_calculate_lm2 ( |
| 75 |
const void */*key*/, |
| 76 |
size_t /*len*/, |
| 77 |
const char */*username*/, |
| 78 |
const char */*target*/, |
| 79 |
const unsigned char serverchallenge[8], |
| 80 |
unsigned char ntlmv2[16], |
| 81 |
struct ntlm_buf */*answer*/); |
| 82 |
|
| 83 |
/** |
| 84 |
* Calculate NTLMv1 response hash |
| 85 |
* |
| 86 |
* @param key the ntlm v1 key |
| 87 |
* @param len length of key |
| 88 |
* @param challenge sent by the server |
| 89 |
* @param answer calculated answer, should be freed with heim_ntlm_free_buf(). |
| 90 |
* |
| 91 |
* @return In case of success 0 is return, an errors, a errno in what |
| 92 |
* went wrong. |
| 93 |
* |
| 94 |
* @ingroup ntlm_core |
| 95 |
*/ |
| 96 |
|
| 97 |
int |
| 98 |
heim_ntlm_calculate_ntlm1 ( |
| 99 |
void */*key*/, |
| 100 |
size_t /*len*/, |
| 101 |
unsigned char challenge[8], |
| 102 |
struct ntlm_buf */*answer*/); |
| 103 |
|
| 104 |
/** |
| 105 |
* Calculate NTLMv2 response |
| 106 |
* |
| 107 |
* @param key the ntlm key |
| 108 |
* @param len length of key |
| 109 |
* @param username name of the user, as sent in the message, assumed to be in UTF8. |
| 110 |
* @param target the name of the target, assumed to be in UTF8. |
| 111 |
* @param serverchallenge challenge as sent by the server in the type2 message. |
| 112 |
* @param infotarget infotarget as sent by the server in the type2 message. |
| 113 |
* @param ntlmv2 calculated session key |
| 114 |
* @param answer ntlm response answer, should be freed with heim_ntlm_free_buf(). |
| 115 |
* |
| 116 |
* @return In case of success 0 is return, an errors, a errno in what |
| 117 |
* went wrong. |
| 118 |
* |
| 119 |
* @ingroup ntlm_core |
| 120 |
*/ |
| 121 |
|
| 122 |
int |
| 123 |
heim_ntlm_calculate_ntlm2 ( |
| 124 |
const void */*key*/, |
| 125 |
size_t /*len*/, |
| 126 |
const char */*username*/, |
| 127 |
const char */*target*/, |
| 128 |
const unsigned char serverchallenge[8], |
| 129 |
const struct ntlm_buf */*infotarget*/, |
| 130 |
unsigned char ntlmv2[16], |
| 131 |
struct ntlm_buf */*answer*/); |
| 132 |
|
| 133 |
/** |
| 134 |
* Third check with empty domain. |
| 135 |
*/ |
| 136 |
|
| 137 |
int |
| 138 |
heim_ntlm_calculate_ntlm2_sess ( |
| 139 |
const unsigned char clnt_nonce[8], |
| 140 |
const unsigned char svr_chal[8], |
| 141 |
const unsigned char ntlm_hash[16], |
| 142 |
struct ntlm_buf */*lm*/, |
| 143 |
struct ntlm_buf */*ntlm*/); |
| 144 |
|
| 145 |
int |
| 146 |
heim_ntlm_calculate_ntlm2_sess_hash ( |
| 147 |
const unsigned char clnt_nonce[8], |
| 148 |
const unsigned char svr_chal[8], |
| 149 |
unsigned char verifier[8]); |
| 150 |
|
| 151 |
/** |
| 152 |
* Decodes an NTLM targetinfo message |
| 153 |
* |
| 154 |
* @param data input data buffer with the encode NTLM targetinfo message |
| 155 |
* @param ucs2 if the strings should be encoded with ucs2 (selected by flag in message). |
| 156 |
* @param ti the decoded target info, should be freed with heim_ntlm_free_targetinfo(). |
| 157 |
* |
| 158 |
* @return In case of success 0 is return, an errors, a errno in what |
| 159 |
* went wrong. |
| 160 |
* |
| 161 |
* @ingroup ntlm_core |
| 162 |
*/ |
| 163 |
|
| 164 |
int |
| 165 |
heim_ntlm_decode_targetinfo ( |
| 166 |
const struct ntlm_buf */*data*/, |
| 167 |
int /*ucs2*/, |
| 168 |
struct ntlm_targetinfo */*ti*/); |
| 169 |
|
| 170 |
int |
| 171 |
heim_ntlm_decode_type1 ( |
| 172 |
const struct ntlm_buf */*buf*/, |
| 173 |
struct ntlm_type1 */*data*/); |
| 174 |
|
| 175 |
int |
| 176 |
heim_ntlm_decode_type2 ( |
| 177 |
const struct ntlm_buf */*buf*/, |
| 178 |
struct ntlm_type2 */*type2*/); |
| 179 |
|
| 180 |
int |
| 181 |
heim_ntlm_decode_type3 ( |
| 182 |
const struct ntlm_buf */*buf*/, |
| 183 |
int /*ucs2*/, |
| 184 |
struct ntlm_type3 */*type3*/); |
| 185 |
|
| 186 |
void |
| 187 |
heim_ntlm_derive_ntlm2_sess ( |
| 188 |
const unsigned char sessionkey[16], |
| 189 |
const unsigned char */*clnt_nonce*/, |
| 190 |
size_t /*clnt_nonce_length*/, |
| 191 |
const unsigned char svr_chal[8], |
| 192 |
unsigned char derivedkey[16]); |
| 193 |
|
| 194 |
/** |
| 195 |
* Encodes a ntlm_targetinfo message. |
| 196 |
* |
| 197 |
* @param ti the ntlm_targetinfo message to encode. |
| 198 |
* @param ucs2 ignored |
| 199 |
* @param data is the return buffer with the encoded message, should be |
| 200 |
* freed with heim_ntlm_free_buf(). |
| 201 |
* |
| 202 |
* @return In case of success 0 is return, an errors, a errno in what |
| 203 |
* went wrong. |
| 204 |
* |
| 205 |
* @ingroup ntlm_core |
| 206 |
*/ |
| 207 |
|
| 208 |
int |
| 209 |
heim_ntlm_encode_targetinfo ( |
| 210 |
const struct ntlm_targetinfo */*ti*/, |
| 211 |
int /*ucs2*/, |
| 212 |
struct ntlm_buf */*data*/); |
| 213 |
|
| 214 |
/** |
| 215 |
* Encodes an ntlm_type1 message. |
| 216 |
* |
| 217 |
* @param type1 the ntlm_type1 message to encode. |
| 218 |
* @param data is the return buffer with the encoded message, should be |
| 219 |
* freed with heim_ntlm_free_buf(). |
| 220 |
* |
| 221 |
* @return In case of success 0 is return, an errors, a errno in what |
| 222 |
* went wrong. |
| 223 |
* |
| 224 |
* @ingroup ntlm_core |
| 225 |
*/ |
| 226 |
|
| 227 |
int |
| 228 |
heim_ntlm_encode_type1 ( |
| 229 |
const struct ntlm_type1 */*type1*/, |
| 230 |
struct ntlm_buf */*data*/); |
| 231 |
|
| 232 |
/** |
| 233 |
* Encodes an ntlm_type2 message. |
| 234 |
* |
| 235 |
* @param type2 the ntlm_type2 message to encode. |
| 236 |
* @param data is the return buffer with the encoded message, should be |
| 237 |
* freed with heim_ntlm_free_buf(). |
| 238 |
* |
| 239 |
* @return In case of success 0 is return, an errors, a errno in what |
| 240 |
* went wrong. |
| 241 |
* |
| 242 |
* @ingroup ntlm_core |
| 243 |
*/ |
| 244 |
|
| 245 |
int |
| 246 |
heim_ntlm_encode_type2 ( |
| 247 |
const struct ntlm_type2 */*type2*/, |
| 248 |
struct ntlm_buf */*data*/); |
| 249 |
|
| 250 |
/** |
| 251 |
* Encodes an ntlm_type3 message. |
| 252 |
* |
| 253 |
* @param type3 the ntlm_type3 message to encode. |
| 254 |
* @param data is the return buffer with the encoded message, should be |
| 255 |
* @param[out] mic_offset offset of message integrity code |
| 256 |
* freed with heim_ntlm_free_buf(). |
| 257 |
* |
| 258 |
* @return In case of success 0 is return, an errors, a errno in what |
| 259 |
* went wrong. |
| 260 |
* |
| 261 |
* @ingroup ntlm_core |
| 262 |
*/ |
| 263 |
|
| 264 |
int |
| 265 |
heim_ntlm_encode_type3 ( |
| 266 |
const struct ntlm_type3 */*type3*/, |
| 267 |
struct ntlm_buf */*data*/, |
| 268 |
size_t */*mic_offset*/); |
| 269 |
|
| 270 |
/** |
| 271 |
* heim_ntlm_free_buf frees the ntlm buffer |
| 272 |
* |
| 273 |
* @param p buffer to be freed |
| 274 |
* |
| 275 |
* @ingroup ntlm_core |
| 276 |
*/ |
| 277 |
|
| 278 |
void |
| 279 |
heim_ntlm_free_buf (struct ntlm_buf */*p*/); |
| 280 |
|
| 281 |
/** |
| 282 |
* Frees the ntlm_targetinfo message |
| 283 |
* |
| 284 |
* @param ti targetinfo to be freed |
| 285 |
* |
| 286 |
* @ingroup ntlm_core |
| 287 |
*/ |
| 288 |
|
| 289 |
void |
| 290 |
heim_ntlm_free_targetinfo (struct ntlm_targetinfo */*ti*/); |
| 291 |
|
| 292 |
/** |
| 293 |
* Frees the ntlm_type1 message |
| 294 |
* |
| 295 |
* @param data message to be freed |
| 296 |
* |
| 297 |
* @ingroup ntlm_core |
| 298 |
*/ |
| 299 |
|
| 300 |
void |
| 301 |
heim_ntlm_free_type1 (struct ntlm_type1 */*data*/); |
| 302 |
|
| 303 |
/** |
| 304 |
* Frees the ntlm_type2 message |
| 305 |
* |
| 306 |
* @param data message to be freed |
| 307 |
* |
| 308 |
* @ingroup ntlm_core |
| 309 |
*/ |
| 310 |
|
| 311 |
void |
| 312 |
heim_ntlm_free_type2 (struct ntlm_type2 */*data*/); |
| 313 |
|
| 314 |
/** |
| 315 |
* Frees the ntlm_type3 message |
| 316 |
* |
| 317 |
* @param data message to be freed |
| 318 |
* |
| 319 |
* @ingroup ntlm_core |
| 320 |
*/ |
| 321 |
|
| 322 |
void |
| 323 |
heim_ntlm_free_type3 (struct ntlm_type3 */*data*/); |
| 324 |
|
| 325 |
/** |
| 326 |
* Given a key and encrypted session, unwrap the session key |
| 327 |
* |
| 328 |
* @param baseKey the sessionBaseKey |
| 329 |
* @param encryptedSession encrypted session, type3.session field. |
| 330 |
* @param session generated session nonce, should be freed with heim_ntlm_free_buf(). |
| 331 |
* |
| 332 |
* @return In case of success 0 is return, an errors, a errno in what |
| 333 |
* went wrong. |
| 334 |
* |
| 335 |
* @ingroup ntlm_core |
| 336 |
*/ |
| 337 |
|
| 338 |
int |
| 339 |
heim_ntlm_keyex_unwrap ( |
| 340 |
struct ntlm_buf */*baseKey*/, |
| 341 |
struct ntlm_buf */*encryptedSession*/, |
| 342 |
struct ntlm_buf */*session*/); |
| 343 |
|
| 344 |
int |
| 345 |
heim_ntlm_keyex_wrap ( |
| 346 |
struct ntlm_buf */*base_session*/, |
| 347 |
struct ntlm_buf */*session*/, |
| 348 |
struct ntlm_buf */*encryptedSession*/); |
| 349 |
|
| 350 |
/** |
| 351 |
* Calculate the NTLM key, the password is assumed to be in UTF8. |
| 352 |
* |
| 353 |
* @param password password to calcute the key for. |
| 354 |
* @param key calcuted key, should be freed with heim_ntlm_free_buf(). |
| 355 |
* |
| 356 |
* @return In case of success 0 is return, an errors, a errno in what |
| 357 |
* went wrong. |
| 358 |
* |
| 359 |
* @ingroup ntlm_core |
| 360 |
*/ |
| 361 |
|
| 362 |
int |
| 363 |
heim_ntlm_nt_key ( |
| 364 |
const char */*password*/, |
| 365 |
struct ntlm_buf */*key*/); |
| 366 |
|
| 367 |
/** |
| 368 |
* Generates an NTLMv2 session key. |
| 369 |
* |
| 370 |
* @param key the ntlm key |
| 371 |
* @param len length of key |
| 372 |
* @param username name of the user, as sent in the message, assumed to be in UTF8. |
| 373 |
* @param target the name of the target, assumed to be in UTF8. |
| 374 |
* @param upper_case_target upper case the target, should not be used only for legacy systems |
| 375 |
* @param ntlmv2 the ntlmv2 session key |
| 376 |
* |
| 377 |
* @return 0 on success, or an error code on failure. |
| 378 |
* |
| 379 |
* @ingroup ntlm_core |
| 380 |
*/ |
| 381 |
|
| 382 |
int |
| 383 |
heim_ntlm_ntlmv2_key ( |
| 384 |
const void */*key*/, |
| 385 |
size_t /*len*/, |
| 386 |
const char */*username*/, |
| 387 |
const char */*target*/, |
| 388 |
int /*upper_case_target*/, |
| 389 |
unsigned char ntlmv2[16]); |
| 390 |
|
| 391 |
time_t |
| 392 |
heim_ntlm_ts2unixtime (uint64_t /*t*/); |
| 393 |
|
| 394 |
uint64_t |
| 395 |
heim_ntlm_unix2ts_time (time_t /*unix_time*/); |
| 396 |
|
| 397 |
/** |
| 398 |
@defgroup ntlm_core Heimdal NTLM library * |
| 399 |
* The NTLM core functions implement the string2key generation |
| 400 |
* function, message encode and decode function, and the hash function |
| 401 |
* functions. |
| 402 |
*/ |
| 403 |
|
| 404 |
size_t |
| 405 |
heim_ntlm_unparse_flags ( |
| 406 |
uint32_t /*flags*/, |
| 407 |
char */*s*/, |
| 408 |
size_t /*len*/); |
| 409 |
|
| 410 |
int |
| 411 |
heim_ntlm_v1_base_session ( |
| 412 |
void */*key*/, |
| 413 |
size_t /*len*/, |
| 414 |
struct ntlm_buf */*session*/); |
| 415 |
|
| 416 |
int |
| 417 |
heim_ntlm_v2_base_session ( |
| 418 |
void */*key*/, |
| 419 |
size_t /*len*/, |
| 420 |
struct ntlm_buf */*ntlmResponse*/, |
| 421 |
struct ntlm_buf */*session*/); |
| 422 |
|
| 423 |
/** |
| 424 |
* Verify NTLMv2 response. |
| 425 |
* |
| 426 |
* @param key the ntlm key |
| 427 |
* @param len length of key |
| 428 |
* @param username name of the user, as sent in the message, assumed to be in UTF8. |
| 429 |
* @param target the name of the target, assumed to be in UTF8. |
| 430 |
* @param now the time now (0 if the library should pick it up itself) |
| 431 |
* @param serverchallenge challenge as sent by the server in the type2 message. |
| 432 |
* @param answer ntlm response answer, should be freed with heim_ntlm_free_buf(). |
| 433 |
* @param infotarget infotarget as sent by the server in the type2 message. |
| 434 |
* @param ntlmv2 calculated session key |
| 435 |
* |
| 436 |
* @return In case of success 0 is return, an errors, a errno in what |
| 437 |
* went wrong. |
| 438 |
* |
| 439 |
* @ingroup ntlm_core |
| 440 |
*/ |
| 441 |
|
| 442 |
int |
| 443 |
heim_ntlm_verify_ntlm2 ( |
| 444 |
const void */*key*/, |
| 445 |
size_t /*len*/, |
| 446 |
const char */*username*/, |
| 447 |
const char */*target*/, |
| 448 |
time_t /*now*/, |
| 449 |
const unsigned char serverchallenge[8], |
| 450 |
const struct ntlm_buf */*answer*/, |
| 451 |
struct ntlm_buf */*infotarget*/, |
| 452 |
unsigned char ntlmv2[16]); |
| 453 |
|
| 454 |
#ifdef __cplusplus |
| 455 |
} |
| 456 |
#endif |
| 457 |
|
| 458 |
#endif /* DOXY */ |
| 459 |
#endif /* __heimntlm_protos_h__ */ |