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