~ubuntu-branches/ubuntu/precise/krb5/precise-updates

« back to all changes in this revision

Viewing changes to src/include/krb5/krb5.hin

  • Committer: Package Import Robot
  • Author(s): Sam Hartman
  • Date: 2011-12-01 19:34:41 UTC
  • mfrom: (28.1.14 sid)
  • Revision ID: package-import@ubuntu.com-20111201193441-9tipg3aru1jsidyv
Tags: 1.10+dfsg~alpha1-6
* Fix segfault with unknown hostnames in krb5_sname_to_principal,
  Closes: #650671
* Indicate that this library breaks libsmbclient versions that depend on
  krb5_locate_kdc, Closes: #650603, #650611

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
 
/* include/krb5.h
3
 
 *
4
 
 * Copyright 1989,1990,1995,2001, 2003, 2007  by the Massachusetts Institute of Technology.
5
 
 * All Rights Reserved.
 
2
/* General definitions for Kerberos version 5. */
 
3
/*
 
4
 * Copyright 1989, 1990, 1995, 2001, 2003, 2007, 2011 by the Massachusetts
 
5
 * Institute of Technology.  All Rights Reserved.
6
6
 *
7
7
 * Export of this software from the United States of America may
8
8
 *   require a specific license from the United States Government.
22
22
 * M.I.T. makes no representations about the suitability of
23
23
 * this software for any purpose.  It is provided "as is" without express
24
24
 * or implied warranty.
25
 
 *
26
 
 *
27
 
 * General definitions for Kerberos version 5.
28
25
 */
29
 
 
30
26
/*
31
27
 * Copyright (C) 1998 by the FundsXpress, INC.
32
28
 *
232
228
typedef struct krb5_principal_data {
233
229
    krb5_magic magic;
234
230
    krb5_data realm;
235
 
    krb5_data *data;            /* An array of strings */
 
231
    krb5_data *data;            /**< An array of strings */
236
232
    krb5_int32 length;
237
233
    krb5_int32 type;
238
234
} krb5_principal_data;
271
267
/* NT 4 style name and SID */
272
268
#define KRB5_NT_ENT_PRINCIPAL_AND_ID    -130
273
269
 
274
 
/* constant version thereof: */
 
270
/** Constant version of krb5_principal_data */
275
271
typedef const krb5_principal_data *krb5_const_principal;
276
272
 
277
273
#define krb5_princ_realm(context, princ) (&(princ)->realm)
286
282
     ? (princ)->data + (i)                      \
287
283
     : NULL)
288
284
 
289
 
/*
290
 
 * Constants for realm referrals.
291
 
 */
 
285
/** Constant for realm referrals. */
292
286
#define        KRB5_REFERRAL_REALM      ""
293
287
 
294
288
/*
295
289
 * Referral-specific functions.
296
290
 */
297
 
krb5_boolean KRB5_CALLCONV krb5_is_referral_realm(const krb5_data *);
298
 
 
299
 
/* Both these functions return constant storage that must not be freed. */
300
 
const krb5_data *KRB5_CALLCONV krb5_anonymous_realm(void);
301
 
krb5_const_principal KRB5_CALLCONV krb5_anonymous_principal(void);
 
291
 
 
292
/**
 
293
 * Check for a match with KRB5_REFERRAL_REALM.
 
294
 *
 
295
 * @param [in] r                Realm to check
 
296
 *
 
297
 * @return @c TRUE if @a r is zero-length, @c FALSE otherwise
 
298
 */
 
299
krb5_boolean KRB5_CALLCONV
 
300
krb5_is_referral_realm(const krb5_data *r);
 
301
 
 
302
/**
 
303
 * Return an anonymous realm data.
 
304
 *
 
305
 * This function returns constant storage that must not be freed.
 
306
 *
 
307
 * @sa #KRB5_ANONYMOUS_REALMSTR
 
308
 */
 
309
const krb5_data *KRB5_CALLCONV
 
310
krb5_anonymous_realm(void);
 
311
 
 
312
/**
 
313
 * Build an anonymous principal.
 
314
 *
 
315
 * This function returns constant storage that must not be freed.
 
316
 *
 
317
 * @sa KRB5_ANONYMOUS_PRINCSTR
 
318
 */
 
319
krb5_const_principal KRB5_CALLCONV
 
320
krb5_anonymous_principal(void);
302
321
 
303
322
#define KRB5_ANONYMOUS_REALMSTR "WELLKNOWN:ANONYMOUS"
304
323
#define KRB5_ANONYMOUS_PRINCSTR "ANONYMOUS" /* wellknown name type */
310
329
 * begin "hostaddr.h"
311
330
 */
312
331
 
313
 
/* structure for address */
 
332
/** Structure for address */
314
333
typedef struct _krb5_address {
315
334
    krb5_magic magic;
316
335
    krb5_addrtype addrtype;
350
369
 * begin "encryption.h"
351
370
 */
352
371
 
353
 
/* Exposed contents of a key. */
 
372
/** Exposed contents of a key. */
354
373
typedef struct _krb5_keyblock {
355
374
    krb5_magic magic;
356
375
    krb5_enctype enctype;
358
377
    krb5_octet *contents;
359
378
} krb5_keyblock;
360
379
 
361
 
/*
362
 
 * Opaque identifier for a key.  Use with the krb5_k APIs for better
363
 
 * performance for repeated operations with the same key usage.  Key
364
 
 * identifiers must not be used simultaneously within multiple
365
 
 * threads, as they may contain mutable internal state and are not
366
 
 * mutex-protected.
367
 
 */
368
380
struct krb5_key_st;
 
381
/**
 
382
 * Opaque identifier for a key.
 
383
 *
 
384
 * Use with the krb5_k APIs for better performance for repeated operations with
 
385
 * the same key and usage.  Key identifiers must not be used simultaneously
 
386
 * within multiple threads, as they may contain mutable internal state and are
 
387
 * not mutex-protected.
 
388
 */
369
389
typedef struct krb5_key_st *krb5_key;
370
390
 
371
391
#ifdef KRB5_OLD_CRYPTO
392
412
    krb5_data ciphertext;
393
413
} krb5_enc_data;
394
414
 
 
415
/**
 
416
 * Structure to describe a region of text to be encrypted or decrypted.
 
417
 *
 
418
 * The @a flags member describes the type of the iov.
 
419
 * The @a data member points to the memory that will be manipulated.
 
420
 * All iov APIs take a pointer to the first element of an array of krb5_crypto_iov's
 
421
 * along with the size of that array. Buffer contents are manipulated in-place;
 
422
 * data is overwritten. Callers must allocate the right number of krb5_crypto_iov
 
423
 * structures before calling into an iov API.
 
424
 */
395
425
typedef struct _krb5_crypto_iov {
396
 
    krb5_cryptotype flags;
 
426
    krb5_cryptotype flags; /**< @ref KRB5_CRYPTO_TYPE type of the iov */
397
427
    krb5_data data;
398
428
} krb5_crypto_iov;
399
429
 
400
430
/* per Kerberos v5 protocol spec */
401
431
#define ENCTYPE_NULL            0x0000
402
 
#define ENCTYPE_DES_CBC_CRC     0x0001  /* DES cbc mode with CRC-32 */
403
 
#define ENCTYPE_DES_CBC_MD4     0x0002  /* DES cbc mode with RSA-MD4 */
404
 
#define ENCTYPE_DES_CBC_MD5     0x0003  /* DES cbc mode with RSA-MD5 */
405
 
#define ENCTYPE_DES_CBC_RAW     0x0004  /* DES cbc mode raw */
406
 
/* XXX deprecated? */
407
 
#define ENCTYPE_DES3_CBC_SHA    0x0005  /* DES-3 cbc mode with NIST-SHA */
408
 
#define ENCTYPE_DES3_CBC_RAW    0x0006  /* DES-3 cbc mode raw */
409
 
#define ENCTYPE_DES_HMAC_SHA1   0x0008
 
432
#define ENCTYPE_DES_CBC_CRC     0x0001  /**< DES cbc mode with CRC-32 */
 
433
#define ENCTYPE_DES_CBC_MD4     0x0002  /**< DES cbc mode with RSA-MD4 */
 
434
#define ENCTYPE_DES_CBC_MD5     0x0003  /**< DES cbc mode with RSA-MD5 */
 
435
#define ENCTYPE_DES_CBC_RAW     0x0004  /**< @deprecated DES cbc mode raw */
 
436
#define ENCTYPE_DES3_CBC_SHA    0x0005  /**< @deprecated DES-3 cbc with SHA1 */
 
437
#define ENCTYPE_DES3_CBC_RAW    0x0006  /**< @deprecated DES-3 cbc mode raw */
 
438
#define ENCTYPE_DES_HMAC_SHA1   0x0008  /**< @deprecated */
410
439
/* PKINIT */
411
 
#define ENCTYPE_DSA_SHA1_CMS    0x0009  /* DSA with SHA1, CMS signature */
412
 
#define ENCTYPE_MD5_RSA_CMS     0x000a  /* MD5 with RSA, CMS signature */
413
 
#define ENCTYPE_SHA1_RSA_CMS    0x000b  /* SHA1 with RSA, CMS signature */
414
 
#define ENCTYPE_RC2_CBC_ENV     0x000c  /* RC2 cbc mode, CMS enveloped data */
415
 
#define ENCTYPE_RSA_ENV         0x000d  /* RSA encryption, CMS enveloped data */
416
 
#define ENCTYPE_RSA_ES_OAEP_ENV 0x000e  /* RSA w/OEAP encryption, CMS enveloped data */
417
 
#define ENCTYPE_DES3_CBC_ENV    0x000f  /* DES-3 cbc mode, CMS enveloped data */
 
440
#define ENCTYPE_DSA_SHA1_CMS    0x0009  /**< DSA with SHA1, CMS signature */
 
441
#define ENCTYPE_MD5_RSA_CMS     0x000a  /**< MD5 with RSA, CMS signature */
 
442
#define ENCTYPE_SHA1_RSA_CMS    0x000b  /**< SHA1 with RSA, CMS signature */
 
443
#define ENCTYPE_RC2_CBC_ENV     0x000c  /**< RC2 cbc mode, CMS enveloped data */
 
444
#define ENCTYPE_RSA_ENV         0x000d  /**< RSA encryption, CMS enveloped data */
 
445
#define ENCTYPE_RSA_ES_OAEP_ENV 0x000e  /**< RSA w/OEAP encryption, CMS enveloped data */
 
446
#define ENCTYPE_DES3_CBC_ENV    0x000f  /**< DES-3 cbc mode, CMS enveloped data */
418
447
 
419
 
#define ENCTYPE_DES3_CBC_SHA1   0x0010
420
 
#define ENCTYPE_AES128_CTS_HMAC_SHA1_96 0x0011
421
 
#define ENCTYPE_AES256_CTS_HMAC_SHA1_96 0x0012
422
 
#define ENCTYPE_ARCFOUR_HMAC    0x0017
423
 
#define ENCTYPE_ARCFOUR_HMAC_EXP 0x0018
424
 
#define ENCTYPE_UNKNOWN         0x01ff
 
448
#define ENCTYPE_DES3_CBC_SHA1           0x0010
 
449
#define ENCTYPE_AES128_CTS_HMAC_SHA1_96 0x0011 /**< RFC 3962 */
 
450
#define ENCTYPE_AES256_CTS_HMAC_SHA1_96 0x0012 /**< RFC 3962 */
 
451
#define ENCTYPE_ARCFOUR_HMAC            0x0017
 
452
#define ENCTYPE_ARCFOUR_HMAC_EXP        0x0018
 
453
#define ENCTYPE_UNKNOWN                 0x01ff
425
454
 
426
455
#define CKSUMTYPE_CRC32         0x0001
427
456
#define CKSUMTYPE_RSA_MD4       0x0002
432
461
#define CKSUMTYPE_RSA_MD5       0x0007
433
462
#define CKSUMTYPE_RSA_MD5_DES   0x0008
434
463
#define CKSUMTYPE_NIST_SHA      0x0009
435
 
#define CKSUMTYPE_HMAC_SHA1_DES3        0x000c
436
 
#define CKSUMTYPE_HMAC_SHA1_96_AES128   0x000f
437
 
#define CKSUMTYPE_HMAC_SHA1_96_AES256   0x0010
 
464
#define CKSUMTYPE_HMAC_SHA1_DES3      0x000c
 
465
#define CKSUMTYPE_HMAC_SHA1_96_AES128 0x000f /**< RFC 3962. Used with
 
466
                                                ENCTYPE_AES128_CTS_HMAC_SHA1_96 */
 
467
#define CKSUMTYPE_HMAC_SHA1_96_AES256 0x0010 /**< RFC 3962. Used with
 
468
                                                ENCTYPE_AES256_CTS_HMAC_SHA1_96 */
438
469
#define CKSUMTYPE_MD5_HMAC_ARCFOUR -137 /*Microsoft netlogon cksumtype*/
439
470
#define CKSUMTYPE_HMAC_MD5_ARCFOUR -138 /*Microsoft md5 hmac cksumtype*/
440
471
 
441
 
/* The following are entropy source designations. Whenever
442
 
 * krb5_C_random_add_entropy is called, one of these source  ids is passed
443
 
 * in.  This  allows the library  to better estimate bits of
444
 
 * entropy in the sample and to keep track of what sources of entropy have
445
 
 * contributed enough entropy.  Sources marked internal MUST NOT be
446
 
 * used by applications outside the Kerberos library
 
472
/*
 
473
 * The following are entropy source designations. Whenever
 
474
 * krb5_C_random_add_entropy is called, one of these source ids is passed in.
 
475
 * This allows the library to better estimate bits of entropy in the sample and
 
476
 * to keep track of what sources of entropy have contributed enough entropy.
 
477
 * Sources marked internal MUST NOT be used by applications outside the
 
478
 * Kerberos library
447
479
 */
448
480
 
449
481
enum {
450
482
    KRB5_C_RANDSOURCE_OLDAPI = 0, /*calls to krb5_C_RANDOM_SEED (INTERNAL)*/
451
483
    KRB5_C_RANDSOURCE_OSRAND = 1, /* /dev/random or equivalent (internal)*/
452
484
    KRB5_C_RANDSOURCE_TRUSTEDPARTY = 2, /* From KDC or other trusted party*/
453
 
    /*This source should be used carefully; data in this category
 
485
    /*
 
486
     * This source should be used carefully; data in this category
454
487
     * should be from a third party trusted to give random bits
455
488
     * For example keys issued by the KDC in the application server.
456
489
     */
474
507
#define krb5_xc(ptr,args) ((*(ptr)) args)
475
508
#endif
476
509
 
 
510
/**
 
511
 * Encrypt data using a key (operates on keyblock).
 
512
 *
 
513
 * @param [in]     context      Library context
 
514
 * @param [in]     key          Encryption key
 
515
 * @param [in]     usage        Key usage (see @ref KRB5_KEYUSAGE types)
 
516
 * @param [in,out] cipher_state Cipher state; specify NULL if not needed
 
517
 * @param [in]     input        Data to be encrypted
 
518
 * @param [out]    output       Encrypted data
 
519
 *
 
520
 * This function encrypts the data block @a input and stores the output into @a
 
521
 * output.  The actual encryption key will be derived from @a key and @a usage
 
522
 * if key derivation is specified for the encryption type.  If non-null, @a
 
523
 * cipher_state specifies the beginning state for the encryption operation, and
 
524
 * is updated with the state to be passed as input to the next operation.
 
525
 *
 
526
 * @note The caller must initialize @a output and allocate at least enough
 
527
 * space for the result (using krb5_c_encrypt_length() to determine the amount
 
528
 * of space needed).  @a output->length will be set to the actual length of the
 
529
 * ciphertext.
 
530
 *
 
531
 * @retval 0 Success; otherwise - Kerberos error codes
 
532
 */
477
533
krb5_error_code KRB5_CALLCONV
478
534
krb5_c_encrypt(krb5_context context, const krb5_keyblock *key,
479
535
               krb5_keyusage usage, const krb5_data *cipher_state,
480
536
               const krb5_data *input, krb5_enc_data *output);
481
537
 
 
538
/**
 
539
 * Decrypt data using a key (operates on keyblock).
 
540
 *
 
541
 * @param [in]     context      Library context
 
542
 * @param [in]     key          Encryption key
 
543
 * @param [in]     usage        Key usage (see @ref KRB5_KEYUSAGE types)
 
544
 * @param [in,out] cipher_state Cipher state; specify NULL if not needed
 
545
 * @param [in]     input        Encrypted data
 
546
 * @param [out]    output       Decrypted data
 
547
 *
 
548
 * This function decrypts the data block @a input and stores the output into @a
 
549
 * output. The actual decryption key will be derived from @a key and @a usage
 
550
 * if key derivation is specified for the encryption type.  If non-null, @a
 
551
 * cipher_state specifies the beginning state for the decryption operation, and
 
552
 * is updated with the state to be passed as input to the next operation.
 
553
 *
 
554
 * @note The caller must initialize @a output and allocate at least enough
 
555
 * space for the result.  The usual practice is to allocate an output buffer as
 
556
 * long as the ciphertext, and let krb5_c_decrypt() trim @a output->length.
 
557
 * For some enctypes, the resulting @a output->length may include padding
 
558
 * bytes.
 
559
 *
 
560
 * @retval 0 Success; otherwise - Kerberos error codes
 
561
 */
482
562
krb5_error_code KRB5_CALLCONV
483
563
krb5_c_decrypt(krb5_context context, const krb5_keyblock *key,
484
564
               krb5_keyusage usage, const krb5_data *cipher_state,
485
565
               const krb5_enc_data *input, krb5_data *output);
486
566
 
 
567
/**
 
568
 * Compute encrypted data length.
 
569
 *
 
570
 * @param [in]  context         Library context
 
571
 * @param [in]  enctype         Encryption type
 
572
 * @param [in]  inputlen        Length of the data to be encrypted
 
573
 * @param [out] length          Length of the encrypted data
 
574
 *
 
575
 * This function computes the length of the ciphertext produced by encrypting
 
576
 * @a inputlen bytes including padding, confounder, and checksum.
 
577
 *
 
578
 * @retval 0 Success; otherwise - Kerberos error codes
 
579
 */
487
580
krb5_error_code KRB5_CALLCONV
488
581
krb5_c_encrypt_length(krb5_context context, krb5_enctype enctype,
489
582
                      size_t inputlen, size_t *length);
490
583
 
 
584
/**
 
585
 * Return cipher block size.
 
586
 *
 
587
 * @param [in]  context         Library context
 
588
 * @param [in]  enctype         Encryption type
 
589
 * @param [out] blocksize       Block size for @a enctype
 
590
 *
 
591
 * @retval 0 Success; otherwise - Kerberos error codes
 
592
 */
491
593
krb5_error_code KRB5_CALLCONV
492
594
krb5_c_block_size(krb5_context context, krb5_enctype enctype,
493
595
                  size_t *blocksize);
494
596
 
 
597
/**
 
598
 * Return length of the specified key in bytes.
 
599
 *
 
600
 * @param [in]  context         Library context
 
601
 * @param [in]  enctype         Encryption type
 
602
 * @param [out] keybytes        Number of bytes required to make a key
 
603
 * @param [out] keylength       Length of final key
 
604
 *
 
605
 * @retval 0 Success; otherwise - Kerberos error codes
 
606
 */
495
607
krb5_error_code KRB5_CALLCONV
496
608
krb5_c_keylengths(krb5_context context, krb5_enctype enctype,
497
609
                  size_t *keybytes, size_t *keylength);
498
610
 
 
611
/**
 
612
 * Initialize a new cipher state.
 
613
 *
 
614
 * @param [in]  context         Library context
 
615
 * @param [in]  key             Key
 
616
 * @param [in]  usage           Key usage (see @ref KRB5_KEYUSAGE types)
 
617
 * @param [out] new_state       New cipher state
 
618
 *
 
619
 * @retval 0 Success; otherwise - Kerberos error codes
 
620
 */
499
621
krb5_error_code KRB5_CALLCONV
500
622
krb5_c_init_state(krb5_context context, const krb5_keyblock *key,
501
623
                  krb5_keyusage usage, krb5_data *new_state);
502
624
 
 
625
/**
 
626
 * Free a cipher state previously allocated by krb5_c_init_state().
 
627
 *
 
628
 * @param [in] context          Library context
 
629
 * @param [in] key              Key
 
630
 * @param [in] state            Cipher state to be freed
 
631
 *
 
632
 * @retval 0 Success; otherwise - Kerberos error codes
 
633
 */
503
634
krb5_error_code KRB5_CALLCONV
504
635
krb5_c_free_state(krb5_context context, const krb5_keyblock *key,
505
636
                  krb5_data *state);
506
637
 
507
 
krb5_error_code KRB5_CALLCONV
508
 
krb5_c_prf(krb5_context, const krb5_keyblock *, krb5_data *in, krb5_data *out);
509
 
 
510
 
krb5_error_code KRB5_CALLCONV
511
 
krb5_c_prf_length(krb5_context, krb5_enctype, size_t *outlen);
512
 
 
 
638
/**
 
639
 * Generate enctype-specific pseudo-random bytes.
 
640
 *
 
641
 * @param [in]  context         Library context
 
642
 * @param [in]  keyblock        Key
 
643
 * @param [in]  input           Input data
 
644
 * @param [out] output          Output data
 
645
 *
 
646
 * This function selects a pseudo-random function based on @a keyblock and
 
647
 * computes its value over @a input, placing the result into @a output.
 
648
 * The caller must preinitialize @a output and allocate space for the
 
649
 * result, using krb5_c_prf_length() to determine the required length.
 
650
 *
 
651
 * @retval 0 Success; otherwise - Kerberos error codes
 
652
 */
 
653
krb5_error_code KRB5_CALLCONV
 
654
krb5_c_prf(krb5_context context, const krb5_keyblock *keyblock,
 
655
           krb5_data *input, krb5_data *output);
 
656
 
 
657
/**
 
658
 * Get the output length of pseudo-random functions for an encryption type.
 
659
 *
 
660
 * @param [in]  context         Library context
 
661
 * @param [in]  enctype         Encryption type
 
662
 * @param [out] len             Length of PRF output
 
663
 *
 
664
 * @retval 0 Success; otherwise - Kerberos error codes
 
665
 */
 
666
krb5_error_code KRB5_CALLCONV
 
667
krb5_c_prf_length(krb5_context context, krb5_enctype enctype, size_t *len);
 
668
 
 
669
/**
 
670
 * Compute the KRB-FX-CF2 combination of two keys and pepper strings.
 
671
 *
 
672
 * @param [in]  context         Library context
 
673
 * @param [in]  k1              KDC contribution key
 
674
 * @param [in]  pepper1         String "PKINIT"
 
675
 * @param [in]  k2              Reply key
 
676
 * @param [in]  pepper2         String "KeyExchange"
 
677
 * @param [out] out             Output key
 
678
 *
 
679
 * This function computes the KRB-FX-CF2 function over its inputs and places
 
680
 * the results in a newly allocated keyblock.  This function is simple in that
 
681
 * it assumes that @a pepper1 and @a pepper2 are C strings with no internal
 
682
 * nulls and that the enctype of the result will be the same as that of @a k1.
 
683
 * @a k1 and @a k2 may be of different enctypes.
 
684
 *
 
685
 * @retval 0 Success; otherwise - Kerberos error codes
 
686
 */
513
687
krb5_error_code KRB5_CALLCONV
514
688
krb5_c_fx_cf2_simple(krb5_context context,
515
689
                     krb5_keyblock *k1, const char *pepper1,
516
690
                     krb5_keyblock *k2, const char *pepper2,
517
691
                     krb5_keyblock **out);
518
 
/* Returns KRB-FX-CF2 in a newly allocated
519
 
 * keyblock on success or an error code on error.
520
 
 * This function is simple in that it assumes
521
 
 * pepper1 and pepper2 are C strings with no
522
 
 * internal nulls and that the enctype of the
523
 
 * result will be the same as that of k1.  Both
524
 
 * of these assumptions are true of current
525
 
 * specs.
 
692
 
 
693
/**
 
694
 * Generate an enctype-specific random encryption key.
 
695
 *
 
696
 * @param [in]  context         Library context
 
697
 * @param [in]  enctype         Encryption type of the generated key
 
698
 * @param [out] k5_random_key   An allocated and initialized keyblock
 
699
 *
 
700
 * Use krb5_free_keyblock_contents() to free @a k5_random_key when
 
701
 * no longer needed.
 
702
 *
 
703
 * @retval 0 Success; otherwise - Kerberos error codes
526
704
 */
527
 
 
528
705
krb5_error_code KRB5_CALLCONV
529
706
krb5_c_make_random_key(krb5_context context, krb5_enctype enctype,
530
707
                       krb5_keyblock *k5_random_key);
531
708
 
 
709
/**
 
710
 * Generate an enctype-specific key from random data.
 
711
 *
 
712
 * @param [in]  context         Library context
 
713
 * @param [in]  enctype         Encryption type
 
714
 * @param [in]  random_data     Random input data
 
715
 * @param [out] k5_random_key   Resulting key
 
716
 *
 
717
 * This function takes random input data @a random_data and produces a valid
 
718
 * key @a k5_random_key for a given @a enctype.
 
719
 *
 
720
 * @note It is assumed that @a k5_random_key has already been initialized and
 
721
 * @a k5_random_key->contents has been allocated with the correct length.
 
722
 *
 
723
 * @sa krb5_c_keylengths()
 
724
 *
 
725
 * @retval 0 Success; otherwise - Kerberos error codes
 
726
 */
532
727
krb5_error_code KRB5_CALLCONV
533
728
krb5_c_random_to_key(krb5_context context, krb5_enctype enctype,
534
729
                     krb5_data *random_data, krb5_keyblock *k5_random_key);
535
730
 
536
 
/*
537
 
 *  Register a new entropy sample with the PRNG. may cause the PRNG to be
538
 
 * reseeded, although this is not guaranteed.  See previous randsource
539
 
 * definitions for information on how each source should be used.
 
731
/**
 
732
 * Add entropy to the pseudo-random number generator.
 
733
 *
 
734
 * @param [in] context          Library context
 
735
 * @param [in] randsource       Entropy source (see KRB5_RANDSOURCE types)
 
736
 * @param [in] data             Data
 
737
 *
 
738
 * Contribute entropy to the PRNG used by krb5 crypto operations.  This may or
 
739
 * may not affect the output of the next crypto operation requiring random
 
740
 * data.
 
741
 *
 
742
 * @retval 0 Success; otherwise - Kerberos error codes
540
743
 */
541
744
krb5_error_code KRB5_CALLCONV
542
 
krb5_c_random_add_entropy(krb5_context context, unsigned int randsource_id,
 
745
krb5_c_random_add_entropy(krb5_context context, unsigned int randsource,
543
746
                          const krb5_data *data);
544
747
 
 
748
/**
 
749
 * Generate pseudo-random bytes.
 
750
 *
 
751
 * @param [in]  context         Library context
 
752
 * @param [out] data            Random data
 
753
 *
 
754
 * Fills in @a data with bytes from the PRNG used by krb5 crypto operations.
 
755
 * The caller must preinitialize @a data and allocate the desired amount of
 
756
 * space.
 
757
 *
 
758
 * @retval 0 Success; otherwise - Kerberos error codes
 
759
 */
545
760
krb5_error_code KRB5_CALLCONV
546
761
krb5_c_random_make_octets(krb5_context context, krb5_data *data);
547
762
 
548
 
/*
549
 
 * Collect entropy from the OS if possible. strong requests that as strong
550
 
 * of a source of entropy  as available be used.  Setting strong may
551
 
 * increase the probability of blocking and should not  be used for normal
552
 
 * applications.  Good uses include seeding the PRNG for kadmind
553
 
 * and realm setup.
554
 
 * If successful is non-null, then successful is set to 1 if the OS provided
555
 
 * entropy else zero.
 
763
/**
 
764
 * Collect entropy from the OS if possible.
 
765
 *
 
766
 * @param [in]  context         Library context
 
767
 * @param [in]  strong          Strongest available source of entropy
 
768
 * @param [out] success         1 if OS provides entropy, 0 otherwise
 
769
 *
 
770
 * If @a strong is non-zero, this function attempts to use the strongest
 
771
 * available source of entropy.  Setting this flag may cause the function to
 
772
 * block on some operating systems.  Good uses include seeding the PRNG for
 
773
 * kadmind and realm setup.
 
774
 *
 
775
 * @retval 0 Success; otherwise - Kerberos error codes
556
776
 */
557
777
krb5_error_code KRB5_CALLCONV
558
778
krb5_c_random_os_entropy(krb5_context context, int strong, int *success);
559
779
 
560
 
/*deprecated*/ krb5_error_code KRB5_CALLCONV
 
780
/** @deprecated Replaced by krb5_c_ API family. */
 
781
krb5_error_code KRB5_CALLCONV
561
782
krb5_c_random_seed(krb5_context context, krb5_data *data);
562
783
 
 
784
/**
 
785
 * Convert a string (such a password) to a key.
 
786
 *
 
787
 * @param [in]  context         Library context
 
788
 * @param [in]  enctype         Encryption type
 
789
 * @param [in]  string          String to be converted
 
790
 * @param [in]  salt            Salt value
 
791
 * @param [out] key             Generated key
 
792
 *
 
793
 * This function converts @a string to a @a key of encryption type @a enctype,
 
794
 * using the specified @a salt.  The newly created @a key must be released by
 
795
 * calling krb5_free_keyblock_contents() when it is no longer needed.
 
796
 *
 
797
 * @retval 0 Success; otherwise - Kerberos error codes
 
798
 */
563
799
krb5_error_code KRB5_CALLCONV
564
800
krb5_c_string_to_key(krb5_context context, krb5_enctype enctype,
565
801
                     const krb5_data *string, const krb5_data *salt,
566
802
                     krb5_keyblock *key);
567
803
 
 
804
/**
 
805
 * Convert a string (such as a password) to a key with additional parameters.
 
806
 *
 
807
 * @param [in]  context         Library context
 
808
 * @param [in]  enctype         Encryption type
 
809
 * @param [in]  string          String to be converted
 
810
 * @param [in]  salt            Salt value
 
811
 * @param [in]  params          Parameters
 
812
 * @param [out] key             Generated key
 
813
 *
 
814
 * This function is similar to krb5_c_string_to_key(), but also takes
 
815
 * parameters which may affect the algorithm in an enctype-dependent way.  The
 
816
 * newly created @a key must be released by calling
 
817
 * krb5_free_keyblock_contents() when it is no longer needed.
 
818
 *
 
819
 * @retval 0 Success; otherwise - Kerberos error codes
 
820
 */
568
821
krb5_error_code KRB5_CALLCONV
569
822
krb5_c_string_to_key_with_params(krb5_context context,
570
823
                                 krb5_enctype enctype,
573
826
                                 const krb5_data *params,
574
827
                                 krb5_keyblock *key);
575
828
 
 
829
/**
 
830
 * Compare two encryption types.
 
831
 *
 
832
 * @param [in]  context         Library context
 
833
 * @param [in]  e1              First encryption type
 
834
 * @param [in]  e2              Second encryption type
 
835
 * @param [out] similar         @c TRUE if types are similar, @c FALSE if not
 
836
 *
 
837
 * This function determines whether two encryption types use the same kind of
 
838
 * keys.
 
839
 *
 
840
 * @retval 0 Success; otherwise - Kerberos error codes
 
841
 */
576
842
krb5_error_code KRB5_CALLCONV
577
843
krb5_c_enctype_compare(krb5_context context, krb5_enctype e1, krb5_enctype e2,
578
844
                       krb5_boolean *similar);
579
845
 
 
846
/**
 
847
 * Compute a checksum (operates on keyblock).
 
848
 *
 
849
 * @param [in]  context         Library context
 
850
 * @param [in]  cksumtype       Checksum type (0 for mandatory type)
 
851
 * @param [in]  key             Encryption key for a keyed checksum
 
852
 * @param [in]  usage           Key usage (see @ref KRB5_KEYUSAGE types)
 
853
 * @param [in]  input           Input data
 
854
 * @param [out] cksum           Generated checksum
 
855
 *
 
856
 * This function computes a checksum of type @a cksumtype over @a input, using
 
857
 * @a key if the checksum type is a keyed checksum.  If @a cksumtype is 0 and
 
858
 * @a key is non-null, the checksum type will be the mandatory-to-implement
 
859
 * checksum type for the key's encryption type.  The actual checksum key will
 
860
 * be derived from @a key and @a usage if key derivation is specified for the
 
861
 * checksum type.  The newly created @a cksum must be released by calling
 
862
 * krb5_free_checksum_contents() when it is no longer needed.
 
863
 *
 
864
 * @note This function is similar to krb5_k_make_checksum(), but operates
 
865
 * on keyblock @a key.
 
866
 *
 
867
 * @sa krb5_c_verify_checksum()
 
868
 *
 
869
 * @retval 0 Success; otherwise - Kerberos error codes
 
870
 */
580
871
krb5_error_code KRB5_CALLCONV
581
872
krb5_c_make_checksum(krb5_context context, krb5_cksumtype cksumtype,
582
873
                     const krb5_keyblock *key, krb5_keyusage usage,
583
874
                     const krb5_data *input, krb5_checksum *cksum);
584
875
 
 
876
/**
 
877
 * Verify a checksum (operates on keyblock).
 
878
 *
 
879
 * @param [in]  context         Library context
 
880
 * @param [in]  key             Encryption key for a keyed checksum
 
881
 * @param [in]  usage           @a key usage
 
882
 * @param [in]  data            Data to be used to compute a new checksum
 
883
 *                              using @a key to compare @a cksum against
 
884
 * @param [in]  cksum           Checksum to be verified
 
885
 * @param [out] valid           Non-zero for success, zero for failure
 
886
 *
 
887
 * This function verifies that @a cksum is a valid checksum for @a data.  If
 
888
 * the checksum type of @a cksum is a keyed checksum, @a key is used to verify
 
889
 * the checksum.  The actual checksum key will be derived from @a key and @a
 
890
 * usage if key derivation is specified for the checksum type.
 
891
 *
 
892
 * @note This function is similar to krb5_k_verify_checksum(), but operates
 
893
 * on keyblock @a key.
 
894
 *
 
895
 * @retval 0 Success; otherwise - Kerberos error codes
 
896
 */
585
897
krb5_error_code KRB5_CALLCONV
586
898
krb5_c_verify_checksum(krb5_context context, const krb5_keyblock *key,
587
899
                       krb5_keyusage usage, const krb5_data *data,
588
900
                       const krb5_checksum *cksum, krb5_boolean *valid);
589
901
 
 
902
/**
 
903
 * Return the length of checksums for a checksum type.
 
904
 *
 
905
 * @param [in]  context         Library context
 
906
 * @param [in]  cksumtype       Checksum type
 
907
 * @param [out] length          Checksum length
 
908
 *
 
909
 * @retval 0 Success; otherwise - Kerberos error codes
 
910
 */
590
911
krb5_error_code KRB5_CALLCONV
591
912
krb5_c_checksum_length(krb5_context context, krb5_cksumtype cksumtype,
592
913
                       size_t *length);
593
914
 
 
915
/**
 
916
 * Return a list of keyed checksum types usable with an encryption type.
 
917
 *
 
918
 * @param [in]  context         Library context
 
919
 * @param [in]  enctype         Encryption type
 
920
 * @param [out] count           Count of allowable checksum types
 
921
 * @param [out] cksumtypes      Array of allowable checksum types
 
922
 *
 
923
 * Use krb5_free_cksumtypes() to free @a cksumtypes when it is no longer
 
924
 * needed.
 
925
 *
 
926
 * @retval 0 Success; otherwise - Kerberos error codes
 
927
 */
594
928
krb5_error_code KRB5_CALLCONV
595
929
krb5_c_keyed_checksum_types(krb5_context context, krb5_enctype enctype,
596
930
                            unsigned int *count, krb5_cksumtype **cksumtypes);
597
931
 
 
932
/** @defgroup KRB5_KEYUSAGE KRB5_KEYUSAGE
 
933
 * @{
 
934
 */
598
935
#define KRB5_KEYUSAGE_AS_REQ_PA_ENC_TS          1
599
936
#define KRB5_KEYUSAGE_KDC_REP_TICKET            2
600
937
#define KRB5_KEYUSAGE_AS_REP_ENCPART            3
630
967
#define KRB5_KEYUSAGE_PA_SAM_RESPONSE           27
631
968
 
632
969
/* Defined in KDC referrals draft */
 
970
/*
 
971
 * @note There is a conflict with the value of @c KRB5_KEYUSAGE_PA_REFERRAL:
 
972
 * it is used for hardware Pre-athentication @a and KDC referrals.
 
973
 */
633
974
#define KRB5_KEYUSAGE_PA_REFERRAL               26 /* XXX note conflict with above */
634
975
 
635
976
/* Defined in [MS-SFU] */
647
988
#define KRB5_KEYUSAGE_ENC_CHALLENGE_CLIENT 54
648
989
#define KRB5_KEYUSAGE_ENC_CHALLENGE_KDC 55
649
990
#define KRB5_KEYUSAGE_AS_REQ 56
650
 
 
651
 
krb5_boolean KRB5_CALLCONV krb5_c_valid_enctype(krb5_enctype ktype);
652
 
krb5_boolean KRB5_CALLCONV krb5_c_valid_cksumtype(krb5_cksumtype ctype);
653
 
krb5_boolean KRB5_CALLCONV krb5_c_is_coll_proof_cksum(krb5_cksumtype ctype);
654
 
krb5_boolean KRB5_CALLCONV krb5_c_is_keyed_cksum(krb5_cksumtype ctype);
 
991
/** @} */ /* end of KRB5_KEYUSAGE group */
 
992
 
 
993
/**
 
994
 * Verify that a specified encryption type is a valid Kerberos encryption type.
 
995
 *
 
996
 * @param [in] ktype            Encryption type
 
997
 *
 
998
 * @return @c TRUE if @a ktype is valid, @c FALSE if not
 
999
 */
 
1000
krb5_boolean KRB5_CALLCONV
 
1001
krb5_c_valid_enctype(krb5_enctype ktype);
 
1002
 
 
1003
/**
 
1004
 * Verify that specified checksum type is a valid Kerberos checksum type.
 
1005
 *
 
1006
 * @param [in] ctype            Checksum type
 
1007
 *
 
1008
 * @return @c TRUE if @a ctype is valid, @c FALSE if not
 
1009
 */
 
1010
krb5_boolean KRB5_CALLCONV
 
1011
krb5_c_valid_cksumtype(krb5_cksumtype ctype);
 
1012
 
 
1013
/**
 
1014
 * Test whether a checksum type is collision-proof.
 
1015
 *
 
1016
 * @param [in] ctype            Checksum type
 
1017
 *
 
1018
 * @return @c TRUE if @a ctype is collision-proof, @c FALSE if it is not
 
1019
 * collision-proof or not a valid checksum type.
 
1020
 */
 
1021
krb5_boolean KRB5_CALLCONV
 
1022
krb5_c_is_coll_proof_cksum(krb5_cksumtype ctype);
 
1023
 
 
1024
/**
 
1025
 * Test whether a checksum type is keyed.
 
1026
 *
 
1027
 * @param [in] ctype            Checksum type
 
1028
 *
 
1029
 * @return @c TRUE if @a ctype is a keyed checksum type, @c FALSE otherwise.
 
1030
 */
 
1031
krb5_boolean KRB5_CALLCONV
 
1032
krb5_c_is_keyed_cksum(krb5_cksumtype ctype);
655
1033
 
656
1034
/* AEAD APIs */
657
 
#define KRB5_CRYPTO_TYPE_EMPTY      0   /* [in] ignored */
658
 
#define KRB5_CRYPTO_TYPE_HEADER     1   /* [out] header */
659
 
#define KRB5_CRYPTO_TYPE_DATA       2   /* [in, out] plaintext */
660
 
#define KRB5_CRYPTO_TYPE_SIGN_ONLY  3   /* [in] associated data */
661
 
#define KRB5_CRYPTO_TYPE_PADDING    4   /* [out] padding */
662
 
#define KRB5_CRYPTO_TYPE_TRAILER    5   /* [out] checksum for encrypt */
663
 
#define KRB5_CRYPTO_TYPE_CHECKSUM   6   /* [out] checksum for MIC */
664
 
#define KRB5_CRYPTO_TYPE_STREAM     7   /* [in] entire message */
 
1035
/** @defgroup KRB5_CRYPTO_TYPE KRB5_CRYPTO_TYPE
 
1036
 * @{
 
1037
 */
 
1038
#define KRB5_CRYPTO_TYPE_EMPTY      0   /**< [in] ignored */
 
1039
#define KRB5_CRYPTO_TYPE_HEADER     1   /**< [out] header */
 
1040
#define KRB5_CRYPTO_TYPE_DATA       2   /**< [in, out] plaintext */
 
1041
#define KRB5_CRYPTO_TYPE_SIGN_ONLY  3   /**< [in] associated data */
 
1042
#define KRB5_CRYPTO_TYPE_PADDING    4   /**< [out] padding */
 
1043
#define KRB5_CRYPTO_TYPE_TRAILER    5   /**< [out] checksum for encrypt */
 
1044
#define KRB5_CRYPTO_TYPE_CHECKSUM   6   /**< [out] checksum for MIC */
 
1045
#define KRB5_CRYPTO_TYPE_STREAM     7   /**< [in] entire message without
 
1046
                                           decomposing the structure into
 
1047
                                           header, data and trailer buffers */
 
1048
/** @} */ /* end of KRB5_CRYPTO_TYPE group */
665
1049
 
 
1050
/**
 
1051
 * Fill in a checksum element in IOV array (operates on keyblock)
 
1052
 *
 
1053
 * @param [in]     context         Library context
 
1054
 * @param [in]     cksumtype       Checksum type (0 for mandatory type)
 
1055
 * @param [in]     key             Encryption key for a keyed checksum
 
1056
 * @param [in]     usage           Key usage (see @ref KRB5_KEYUSAGE types)
 
1057
 * @param [in,out] data            IOV array
 
1058
 * @param [in]     num_data        Size of @a data
 
1059
 *
 
1060
 * Create a checksum in the #KRB5_CRYPTO_TYPE_CHECKSUM element over
 
1061
 * #KRB5_CRYPTO_TYPE_DATA and #KRB5_CRYPTO_TYPE_SIGN_ONLY chunks in @a data.
 
1062
 * Only the #KRB5_CRYPTO_TYPE_CHECKSUM region is modified.
 
1063
 *
 
1064
 * @note This function is similar to krb5_k_make_checksum_iov(), but operates
 
1065
 * on keyblock @a key.
 
1066
 *
 
1067
 * @sa krb5_c_verify_checksum_iov()
 
1068
 *
 
1069
 * @retval 0 Success; otherwise - Kerberos error codes
 
1070
 */
666
1071
krb5_error_code KRB5_CALLCONV
667
1072
krb5_c_make_checksum_iov(krb5_context context, krb5_cksumtype cksumtype,
668
1073
                         const krb5_keyblock *key, krb5_keyusage usage,
669
1074
                         krb5_crypto_iov *data, size_t num_data);
670
1075
 
 
1076
/**
 
1077
 * Validate a checksum element in IOV array (operates on keyblock).
 
1078
 *
 
1079
 * @param [in]     context         Library context
 
1080
 * @param [in]     cksumtype       Checksum type (0 for mandatory type)
 
1081
 * @param [in]     key             Encryption key for a keyed checksum
 
1082
 * @param [in]     usage           Key usage (see @ref KRB5_KEYUSAGE types)
 
1083
 * @param [in]     data            IOV array
 
1084
 * @param [in]     num_data        Size of @a data
 
1085
 * @param [out]    valid           Non-zero for success, zero for failure
 
1086
 *
 
1087
 * Confirm that the checksum in the #KRB5_CRYPTO_TYPE_CHECKSUM element is a
 
1088
 * valid checksum of the #KRB5_CRYPTO_TYPE_DATA and #KRB5_CRYPTO_TYPE_SIGN_ONLY
 
1089
 * regions in the iov.
 
1090
 *
 
1091
 * @note This function is similar to krb5_k_verify_checksum_iov(), but operates
 
1092
 * on keyblock @a key.
 
1093
 *
 
1094
 * @sa krb5_c_make_checksum_iov()
 
1095
 *
 
1096
 * @retval 0 Success; otherwise - Kerberos error codes
 
1097
 */
671
1098
krb5_error_code KRB5_CALLCONV
672
1099
krb5_c_verify_checksum_iov(krb5_context context, krb5_cksumtype cksumtype,
673
1100
                           const krb5_keyblock *key, krb5_keyusage usage,
674
1101
                           const krb5_crypto_iov *data, size_t num_data,
675
1102
                           krb5_boolean *valid);
676
1103
 
677
 
krb5_error_code KRB5_CALLCONV
678
 
krb5_c_encrypt_iov(krb5_context context, const krb5_keyblock *key,
679
 
                   krb5_keyusage usage, const krb5_data *cipher_state,
680
 
                   krb5_crypto_iov *data, size_t num_data);
681
 
 
682
 
krb5_error_code KRB5_CALLCONV
683
 
krb5_c_decrypt_iov(krb5_context context, const krb5_keyblock *key,
684
 
                   krb5_keyusage usage, const krb5_data *cipher_state,
685
 
                   krb5_crypto_iov *data, size_t num_data);
686
 
 
 
1104
/**
 
1105
 * Encrypt data in place supporting AEAD (operates on keyblock).
 
1106
 *
 
1107
 * @param [in]     context         Library context
 
1108
 * @param [in]     keyblock        Encryption key
 
1109
 * @param [in]     usage           Key usage (see @ref KRB5_KEYUSAGE types)
 
1110
 * @param [in]     cipher_state    Cipher state; specify NULL if not needed
 
1111
 * @param [in,out] data            IOV array. Modified in-place.
 
1112
 * @param [in]     num_data        Size of @a data
 
1113
 *
 
1114
 * This function encrypts the data block @a data and stores the output in-place.
 
1115
 * The actual encryption key will be derived from @a keyblock and @a usage
 
1116
 * if key derivation is specified for the encryption type.  If non-null, @a
 
1117
 * cipher_state specifies the beginning state for the encryption operation, and
 
1118
 * is updated with the state to be passed as input to the next operation.
 
1119
 * The caller must allocate the right number of krb5_crypto_iov
 
1120
 * structures before calling into this API.
 
1121
 *
 
1122
 * @note On return from a krb5_c_encrypt_iov() call, the @a data->length in the
 
1123
 * iov structure are adjusted to reflect actual lengths of the ciphertext used.
 
1124
 * For example, if the padding length is too large, the length will be reduced.
 
1125
 * Lengths are never increased.
 
1126
 *
 
1127
 * @note This function is similar to krb5_k_encrypt_iov(), but operates
 
1128
 * on keyblock @a keyblock.
 
1129
 *
 
1130
 * @sa krb5_c_decrypt_iov()
 
1131
 *
 
1132
 * @retval 0 Success; otherwise - Kerberos error codes
 
1133
 */
 
1134
krb5_error_code KRB5_CALLCONV
 
1135
krb5_c_encrypt_iov(krb5_context context, const krb5_keyblock *keyblock,
 
1136
                   krb5_keyusage usage, const krb5_data *cipher_state,
 
1137
                   krb5_crypto_iov *data, size_t num_data);
 
1138
 
 
1139
/**
 
1140
 * Decrypt data in place supporting AEAD (operates on keyblock).
 
1141
 *
 
1142
 * @param [in]     context         Library context
 
1143
 * @param [in]     keyblock        Encryption key
 
1144
 * @param [in]     usage           Key usage (see @ref KRB5_KEYUSAGE types)
 
1145
 * @param [in]     cipher_state    Cipher state; specify NULL if not needed
 
1146
 * @param [in,out] data            IOV array. Modified in-place.
 
1147
 * @param [in]     num_data        Size of @a data
 
1148
 *
 
1149
 * This function decrypts the data block @a data and stores the output in-place.
 
1150
 * The actual decryption key will be derived from @a keyblock and @a usage
 
1151
 * if key derivation is specified for the encryption type.  If non-null, @a
 
1152
 * cipher_state specifies the beginning state for the decryption operation, and
 
1153
 * is updated with the state to be passed as input to the next operation.
 
1154
 * The caller must allocate the right number of krb5_crypto_iov
 
1155
 * structures before calling into this API.
 
1156
 *
 
1157
 * @note On return from a krb5_c_decrypt_iov() call, the @a data->length in the
 
1158
 * iov structure are adjusted to reflect actual lengths of the ciphertext used.
 
1159
 * For example, if the padding length is too large, the length will be reduced.
 
1160
 * Lengths are never increased.
 
1161
 *
 
1162
 * @note This function is similar to krb5_k_decrypt_iov(), but operates
 
1163
 * on keyblock @a keyblock.
 
1164
 *
 
1165
 * @sa krb5_c_decrypt_iov()
 
1166
 *
 
1167
 * @retval 0 Success; otherwise - Kerberos error codes
 
1168
 */
 
1169
krb5_error_code KRB5_CALLCONV
 
1170
krb5_c_decrypt_iov(krb5_context context, const krb5_keyblock *keyblock,
 
1171
                   krb5_keyusage usage, const krb5_data *cipher_state,
 
1172
                   krb5_crypto_iov *data, size_t num_data);
 
1173
 
 
1174
/**
 
1175
 * Return a length of a message field specific to the encryption type.
 
1176
 *
 
1177
 * @param [in]  context      Library context
 
1178
 * @param [in]  enctype      Encryption type
 
1179
 * @param [in]  type         Type field (See @ref KRB5_CRYPTO_TYPE types)
 
1180
 * @param [out] size         Length of the @a type specific to @a enctype
 
1181
 *
 
1182
 * @retval 0 Success; otherwise - Kerberos error codes
 
1183
 */
687
1184
krb5_error_code KRB5_CALLCONV
688
1185
krb5_c_crypto_length(krb5_context context, krb5_enctype enctype,
689
1186
                     krb5_cryptotype type, unsigned int *size);
690
1187
 
 
1188
/**
 
1189
 * Fill in lengths for header, trailer and padding in a IOV array.
 
1190
 *
 
1191
 * @param [in]      context      Library context
 
1192
 * @param [in]      enctype      Encryption type
 
1193
 * @param [in,out]  data         IOV array
 
1194
 * @param [in]      num_data     Size of @a data
 
1195
 *
 
1196
 * Padding is set to the actual padding required based on the provided
 
1197
 * @a data buffers. Typically this API is used after setting up the data
 
1198
 * buffers and #KRB5_CRYPTO_TYPE_SIGN_ONLY buffers, but before actually
 
1199
 * allocating header, trailer and padding.
 
1200
 *
 
1201
 * @retval 0 Success; otherwise - Kerberos error codes
 
1202
 */
691
1203
krb5_error_code KRB5_CALLCONV
692
1204
krb5_c_crypto_length_iov(krb5_context context, krb5_enctype enctype,
693
1205
                         krb5_crypto_iov *data, size_t num_data);
694
1206
 
 
1207
/**
 
1208
 * Return a number of padding octets.
 
1209
 *
 
1210
 * @param [in]  context      Library context
 
1211
 * @param [in]  enctype      Encryption type
 
1212
 * @param [in]  data_length  Length of the plaintext to pad
 
1213
 * @param [out] size         Number of padding octets
 
1214
 *
 
1215
 * This function returns the number of the padding octets required to pad
 
1216
 * @a data_length octets of plaintext.
 
1217
 *
 
1218
 * @retval 0 Success; otherwise - KRB5_BAD_ENCTYPE
 
1219
 */
695
1220
krb5_error_code KRB5_CALLCONV
696
1221
krb5_c_padding_length(krb5_context context, krb5_enctype enctype,
697
1222
                      size_t data_length, unsigned int *size);
698
1223
 
 
1224
/**
 
1225
 * Create a krb5_key from the enctype and key data in a keyblock.
 
1226
 *
 
1227
 * @param [in]  context      Library context
 
1228
 * @param [in]  key_data     Keyblock
 
1229
 * @param [out] out          Opaque key
 
1230
 *
 
1231
 * The reference count on a key @a out is set to 1.
 
1232
 * Use krb5_k_free_key() to free @a out when it is no longer needed.
 
1233
 *
 
1234
 * @retval 0 Success; otherwise - KRB5_BAD_ENCTYPE
 
1235
 */
699
1236
krb5_error_code KRB5_CALLCONV
700
1237
krb5_k_create_key(krb5_context context, const krb5_keyblock *key_data,
701
1238
                  krb5_key *out);
702
1239
 
703
 
/* Keys are logically immutable and can be "copied" by reference count. */
704
 
void KRB5_CALLCONV krb5_k_reference_key(krb5_context context, krb5_key key);
705
 
 
706
 
/* Decrement the reference count on a key and free it if it hits zero. */
707
 
void KRB5_CALLCONV krb5_k_free_key(krb5_context context, krb5_key key);
708
 
 
 
1240
/** Increment the reference count on a key. */
 
1241
void KRB5_CALLCONV
 
1242
krb5_k_reference_key(krb5_context context, krb5_key key);
 
1243
 
 
1244
/** Decrement the reference count on a key and free it if it hits zero. */
 
1245
void KRB5_CALLCONV
 
1246
krb5_k_free_key(krb5_context context, krb5_key key);
 
1247
 
 
1248
/** Retrieve a copy of the keyblock from a krb5_key structure. */
709
1249
krb5_error_code KRB5_CALLCONV
710
1250
krb5_k_key_keyblock(krb5_context context, krb5_key key,
711
1251
                    krb5_keyblock **key_data);
712
1252
 
 
1253
/** Retrieve the enctype of a krb5_key structure. */
713
1254
krb5_enctype KRB5_CALLCONV
714
1255
krb5_k_key_enctype(krb5_context context, krb5_key key);
715
1256
 
 
1257
/**
 
1258
 * Encrypt data using a key (operates on opaque key).
 
1259
 *
 
1260
 * @param [in]     context      Library context
 
1261
 * @param [in]     key          Encryption key
 
1262
 * @param [in]     usage        Key usage (see @ref KRB5_KEYUSAGE types)
 
1263
 * @param [in,out] cipher_state Cipher state; specify NULL if not needed
 
1264
 * @param [in]     input        Data to be encrypted
 
1265
 * @param [out]    output       Encrypted data
 
1266
 *
 
1267
 * This function encrypts the data block @a input and stores the output into @a
 
1268
 * output.  The actual encryption key will be derived from @a key and @a usage
 
1269
 * if key derivation is specified for the encryption type.  If non-null, @a
 
1270
 * cipher_state specifies the beginning state for the encryption operation, and
 
1271
 * is updated with the state to be passed as input to the next operation.
 
1272
 *
 
1273
 * @note The caller must initialize @a output and allocate at least enough
 
1274
 * space for the result (using krb5_c_encrypt_length() to determine the amount
 
1275
 * of space needed).  @a output->length will be set to the actual length of the
 
1276
 * ciphertext.
 
1277
 *
 
1278
 * @retval 0 Success; otherwise - Kerberos error codes
 
1279
 */
716
1280
krb5_error_code KRB5_CALLCONV
717
1281
krb5_k_encrypt(krb5_context context, krb5_key key, krb5_keyusage usage,
718
1282
               const krb5_data *cipher_state, const krb5_data *input,
719
1283
               krb5_enc_data *output);
720
1284
 
 
1285
/**
 
1286
 * Encrypt data in place supporting AEAD (operates on opaque key).
 
1287
 *
 
1288
 * @param [in]     context         Library context
 
1289
 * @param [in]     key             Encryption key
 
1290
 * @param [in]     usage           Key usage (see @ref KRB5_KEYUSAGE types)
 
1291
 * @param [in]     cipher_state    Cipher state; specify NULL if not needed
 
1292
 * @param [in,out] data            IOV array. Modified in-place.
 
1293
 * @param [in]     num_data        Size of @a data
 
1294
 *
 
1295
 * This function encrypts the data block @a data and stores the output in-place.
 
1296
 * The actual encryption key will be derived from @a key and @a usage
 
1297
 * if key derivation is specified for the encryption type.  If non-null, @a
 
1298
 * cipher_state specifies the beginning state for the encryption operation, and
 
1299
 * is updated with the state to be passed as input to the next operation.
 
1300
 * The caller must allocate the right number of krb5_crypto_iov
 
1301
 * structures before calling into this API.
 
1302
 *
 
1303
 * @note On return from a krb5_c_encrypt_iov() call, the @a data->length in the
 
1304
 * iov structure are adjusted to reflect actual lengths of the ciphertext used.
 
1305
 * For example, if the padding length is too large, the length will be reduced.
 
1306
 * Lengths are never increased.
 
1307
 *
 
1308
 * @note This function is similar to krb5_c_encrypt_iov(), but operates
 
1309
 * on opaque key @a key.
 
1310
 *
 
1311
 * @sa krb5_k_decrypt_iov()
 
1312
 *
 
1313
 * @retval 0 Success; otherwise - Kerberos error codes
 
1314
 */
721
1315
krb5_error_code KRB5_CALLCONV
722
1316
krb5_k_encrypt_iov(krb5_context context, krb5_key key, krb5_keyusage usage,
723
1317
                   const krb5_data *cipher_state, krb5_crypto_iov *data,
724
1318
                   size_t num_data);
725
1319
 
 
1320
/**
 
1321
 * Decrypt data using a key (operates on opaque key).
 
1322
 *
 
1323
 * @param [in]     context      Library context
 
1324
 * @param [in]     key          Encryption key
 
1325
 * @param [in]     usage        Key usage (see @ref KRB5_KEYUSAGE types)
 
1326
 * @param [in,out] cipher_state Cipher state; specify NULL if not needed
 
1327
 * @param [in]     input        Encrypted data
 
1328
 * @param [out]    output       Decrypted data
 
1329
 *
 
1330
 * This function decrypts the data block @a input and stores the output into @a
 
1331
 * output. The actual decryption key will be derived from @a key and @a usage
 
1332
 * if key derivation is specified for the encryption type.  If non-null, @a
 
1333
 * cipher_state specifies the beginning state for the decryption operation, and
 
1334
 * is updated with the state to be passed as input to the next operation.
 
1335
 *
 
1336
 * @note The caller must initialize @a output and allocate at least enough
 
1337
 * space for the result.  The usual practice is to allocate an output buffer as
 
1338
 * long as the ciphertext, and let krb5_c_decrypt() trim @a output->length.
 
1339
 * For some enctypes, the resulting @a output->length may include padding
 
1340
 * bytes.
 
1341
 *
 
1342
 * @retval 0 Success; otherwise - Kerberos error codes
 
1343
 */
726
1344
krb5_error_code KRB5_CALLCONV
727
1345
krb5_k_decrypt(krb5_context context, krb5_key key, krb5_keyusage usage,
728
1346
               const krb5_data *cipher_state, const krb5_enc_data *input,
729
1347
               krb5_data *output);
730
1348
 
 
1349
/**
 
1350
 * Decrypt data in place supporting AEAD (operates on opaque key).
 
1351
 *
 
1352
 * @param [in]     context         Library context
 
1353
 * @param [in]     key             Encryption key
 
1354
 * @param [in]     usage           Key usage (see @ref KRB5_KEYUSAGE types)
 
1355
 * @param [in]     cipher_state    Cipher state; specify NULL if not needed
 
1356
 * @param [in,out] data            IOV array. Modified in-place.
 
1357
 * @param [in]     num_data        Size of @a data
 
1358
 *
 
1359
 * This function decrypts the data block @a data and stores the output in-place.
 
1360
 * The actual decryption key will be derived from @a key and @a usage
 
1361
 * if key derivation is specified for the encryption type.  If non-null, @a
 
1362
 * cipher_state specifies the beginning state for the decryption operation, and
 
1363
 * is updated with the state to be passed as input to the next operation.
 
1364
 * The caller must allocate the right number of krb5_crypto_iov
 
1365
 * structures before calling into this API.
 
1366
 *
 
1367
 * @note On return from a krb5_c_decrypt_iov() call, the @a data->length in the
 
1368
 * iov structure are adjusted to reflect actual lengths of the ciphertext used.
 
1369
 * For example, if the padding length is too large, the length will be reduced.
 
1370
 * Lengths are never increased.
 
1371
 *
 
1372
 * @note This function is similar to krb5_c_decrypt_iov(), but operates
 
1373
 * on opaque key @a key.
 
1374
 *
 
1375
 * @sa krb5_k_encrypt_iov()
 
1376
 *
 
1377
 * @retval 0 Success; otherwise - Kerberos error codes
 
1378
 */
731
1379
krb5_error_code KRB5_CALLCONV
732
1380
krb5_k_decrypt_iov(krb5_context context, krb5_key key, krb5_keyusage usage,
733
1381
                   const krb5_data *cipher_state, krb5_crypto_iov *data,
734
1382
                   size_t num_data);
735
 
 
 
1383
/**
 
1384
 * Compute a checksum (operates on opaque key).
 
1385
 *
 
1386
 * @param [in]  context         Library context
 
1387
 * @param [in]  cksumtype       Checksum type (0 for mandatory type)
 
1388
 * @param [in]  key             Encryption key for a keyed checksum
 
1389
 * @param [in]  usage           Key usage (see @ref KRB5_KEYUSAGE types)
 
1390
 * @param [in]  input           Input data
 
1391
 * @param [out] cksum           Generated checksum
 
1392
 *
 
1393
 * This function computes a checksum of type @a cksumtype over @a input, using
 
1394
 * @a key if the checksum type is a keyed checksum.  If @a cksumtype is 0 and
 
1395
 * @a key is non-null, the checksum type will be the mandatory-to-implement
 
1396
 * checksum type for the key's encryption type.  The actual checksum key will
 
1397
 * be derived from @a key and @a usage if key derivation is specified for the
 
1398
 * checksum type.  The newly created @a cksum must be released by calling
 
1399
 * krb5_free_checksum_contents() when it is no longer needed.
 
1400
 *
 
1401
 * @note This function is similar to krb5_c_make_checksum(), but operates
 
1402
 * on opaque @a key.
 
1403
 *
 
1404
 * @sa krb5_c_verify_checksum()
 
1405
 *
 
1406
 * @retval 0 Success; otherwise - Kerberos error codes
 
1407
 */
736
1408
krb5_error_code KRB5_CALLCONV
737
1409
krb5_k_make_checksum(krb5_context context, krb5_cksumtype cksumtype,
738
1410
                     krb5_key key, krb5_keyusage usage, const krb5_data *input,
739
1411
                     krb5_checksum *cksum);
740
1412
 
 
1413
/**
 
1414
 * Fill in a checksum element in IOV array (operates on opaque key)
 
1415
 *
 
1416
 * @param [in]     context         Library context
 
1417
 * @param [in]     cksumtype       Checksum type (0 for mandatory type)
 
1418
 * @param [in]     key             Encryption key for a keyed checksum
 
1419
 * @param [in]     usage           Key usage (see @ref KRB5_KEYUSAGE types)
 
1420
 * @param [in,out] data            IOV array
 
1421
 * @param [in]     num_data        Size of @a data
 
1422
 *
 
1423
 * Create a checksum in the #KRB5_CRYPTO_TYPE_CHECKSUM element over
 
1424
 * #KRB5_CRYPTO_TYPE_DATA and #KRB5_CRYPTO_TYPE_SIGN_ONLY chunks in @a data.
 
1425
 * Only the #KRB5_CRYPTO_TYPE_CHECKSUM region is modified.
 
1426
 *
 
1427
 * @note This function is similar to krb5_c_make_checksum_iov(), but operates
 
1428
 * on opaque @a key.
 
1429
 *
 
1430
 * @sa krb5_k_verify_checksum_iov()
 
1431
 *
 
1432
 * @retval 0 Success; otherwise - Kerberos error codes
 
1433
 */
741
1434
krb5_error_code KRB5_CALLCONV
742
1435
krb5_k_make_checksum_iov(krb5_context context, krb5_cksumtype cksumtype,
743
1436
                         krb5_key key, krb5_keyusage usage,
744
1437
                         krb5_crypto_iov *data, size_t num_data);
745
1438
 
 
1439
/**
 
1440
 * Verify a checksum (operates on opaque key).
 
1441
 *
 
1442
 * @param [in]  context         Library context
 
1443
 * @param [in]  key             Encryption key for a keyed checksum
 
1444
 * @param [in]  usage           @a key usage
 
1445
 * @param [in]  data            Data to be used to compute a new checksum
 
1446
 *                              using @a key to compare @a cksum against
 
1447
 * @param [in]  cksum           Checksum to be verified
 
1448
 * @param [out] valid           Non-zero for success, zero for failure
 
1449
 *
 
1450
 * This function verifies that @a cksum is a valid checksum for @a data.  If
 
1451
 * the checksum type of @a cksum is a keyed checksum, @a key is used to verify
 
1452
 * the checksum.  The actual checksum key will be derived from @a key and @a
 
1453
 * usage if key derivation is specified for the checksum type.
 
1454
 *
 
1455
 * @note This function is similar to krb5_c_verify_checksum(), but operates
 
1456
 * on opaque @a key.
 
1457
 *
 
1458
 * @retval 0 Success; otherwise - Kerberos error codes
 
1459
 */
746
1460
krb5_error_code KRB5_CALLCONV
747
1461
krb5_k_verify_checksum(krb5_context context, krb5_key key, krb5_keyusage usage,
748
1462
                       const krb5_data *data, const krb5_checksum *cksum,
749
1463
                       krb5_boolean *valid);
750
1464
 
 
1465
/**
 
1466
 * Validate a checksum element in IOV array (operates on opaque key).
 
1467
 *
 
1468
 * @param [in]     context         Library context
 
1469
 * @param [in]     cksumtype       Checksum type (0 for mandatory type)
 
1470
 * @param [in]     key             Encryption key for a keyed checksum
 
1471
 * @param [in]     usage           Key usage (see @ref KRB5_KEYUSAGE types)
 
1472
 * @param [in]     data            IOV array
 
1473
 * @param [in]     num_data        Size of @a data
 
1474
 * @param [out]    valid           Non-zero for success, zero for failure
 
1475
 *
 
1476
 * Confirm that the checksum in the #KRB5_CRYPTO_TYPE_CHECKSUM element is a
 
1477
 * valid checksum of the #KRB5_CRYPTO_TYPE_DATA and #KRB5_CRYPTO_TYPE_SIGN_ONLY
 
1478
 * regions in the iov.
 
1479
 *
 
1480
 * @note This function is similar to krb5_c_verify_checksum_iov(), but operates
 
1481
 * on opaque @a key.
 
1482
 *
 
1483
 * @sa krb5_k_make_checksum_iov()
 
1484
 *
 
1485
 * @retval 0 Success; otherwise - Kerberos error codes
 
1486
 */
751
1487
krb5_error_code KRB5_CALLCONV
752
1488
krb5_k_verify_checksum_iov(krb5_context context, krb5_cksumtype cksumtype,
753
1489
                           krb5_key key, krb5_keyusage usage,
754
1490
                           const krb5_crypto_iov *data, size_t num_data,
755
1491
                           krb5_boolean *valid);
756
1492
 
 
1493
/**
 
1494
 * Generate enctype-specific pseudo-random bytes (operates on opaque key).
 
1495
 *
 
1496
 * @param [in]  context      Library context
 
1497
 * @param [in]  key          Key
 
1498
 * @param [in]  input        Input data
 
1499
 * @param [out] output       Output data
 
1500
 *
 
1501
 * This function selects a pseudo-random function based on @a key and
 
1502
 * computes its value over @a input, placing the result into @a output.
 
1503
 * The caller must preinitialize @a output and allocate space for the
 
1504
 * result.
 
1505
 *
 
1506
 * @note This function is similar to krb5_c_prf(), but operates
 
1507
 * on opaque @a key.
 
1508
 *
 
1509
 * @retval 0 Success; otherwise - Kerberos error codes
 
1510
 */
757
1511
krb5_error_code KRB5_CALLCONV
758
 
krb5_k_prf(krb5_context context, krb5_key key, krb5_data *in, krb5_data *out);
 
1512
krb5_k_prf(krb5_context context, krb5_key key, krb5_data *input, krb5_data *output);
759
1513
 
760
1514
#ifdef KRB5_OLD_CRYPTO
761
1515
/*
762
1516
 * old cryptosystem routine prototypes.  These are now layered
763
1517
 * on top of the functions above.
764
1518
 */
 
1519
/** @deprecated Replaced by krb5_c_ API family.*/
765
1520
krb5_error_code KRB5_CALLCONV
766
1521
krb5_encrypt(krb5_context context, krb5_const_pointer inptr,
767
1522
             krb5_pointer outptr, size_t size, krb5_encrypt_block *eblock,
768
1523
             krb5_pointer ivec);
769
1524
 
 
1525
/** @deprecated Replaced by krb5_c_ API family. */
770
1526
krb5_error_code KRB5_CALLCONV
771
1527
krb5_decrypt(krb5_context context, krb5_const_pointer inptr,
772
1528
             krb5_pointer outptr, size_t size, krb5_encrypt_block *eblock,
773
1529
             krb5_pointer ivec);
774
1530
 
 
1531
/** @deprecated Replaced by krb5_c_ API family. */
775
1532
krb5_error_code KRB5_CALLCONV
776
1533
krb5_process_key(krb5_context context, krb5_encrypt_block *eblock,
777
1534
                 const krb5_keyblock * key);
778
1535
 
 
1536
/** @deprecated Replaced by krb5_c_ API family. */
779
1537
krb5_error_code KRB5_CALLCONV
780
1538
krb5_finish_key(krb5_context context, krb5_encrypt_block * eblock);
781
1539
 
 
1540
/** @deprecated See krb5_c_string_to_key() */
782
1541
krb5_error_code KRB5_CALLCONV
783
1542
krb5_string_to_key(krb5_context context, const krb5_encrypt_block *eblock,
784
1543
                   krb5_keyblock * keyblock, const krb5_data *data,
785
1544
                   const krb5_data *salt);
786
1545
 
 
1546
/** @deprecated Replaced by krb5_c_ API family. */
787
1547
krb5_error_code KRB5_CALLCONV
788
1548
krb5_init_random_key(krb5_context context, const krb5_encrypt_block *eblock,
789
1549
                     const krb5_keyblock *keyblock, krb5_pointer *ptr);
790
1550
 
 
1551
/** @deprecated Replaced by krb5_c_ API family. */
791
1552
krb5_error_code KRB5_CALLCONV
792
1553
krb5_finish_random_key(krb5_context context, const krb5_encrypt_block *eblock,
793
1554
                       krb5_pointer *ptr);
794
1555
 
 
1556
/** @deprecated Replaced by krb5_c_ API family. */
795
1557
krb5_error_code KRB5_CALLCONV
796
1558
krb5_random_key(krb5_context context, const krb5_encrypt_block *eblock,
797
1559
                krb5_pointer ptr, krb5_keyblock **keyblock);
798
1560
 
 
1561
/** @deprecated Replaced by krb5_c_ API family. */
799
1562
krb5_enctype KRB5_CALLCONV
800
1563
krb5_eblock_enctype(krb5_context context, const krb5_encrypt_block *eblock);
801
1564
 
 
1565
/** @deprecated Replaced by krb5_c_ API family. */
802
1566
krb5_error_code KRB5_CALLCONV
803
1567
krb5_use_enctype(krb5_context context, krb5_encrypt_block *eblock,
804
1568
                 krb5_enctype enctype);
805
1569
 
 
1570
/** @deprecated Replaced by krb5_c_ API family. */
806
1571
size_t KRB5_CALLCONV
807
1572
krb5_encrypt_size(size_t length, krb5_enctype crypto);
808
1573
 
 
1574
/** @deprecated See krb5_c_checksum_length() */
809
1575
size_t KRB5_CALLCONV
810
1576
krb5_checksum_size(krb5_context context, krb5_cksumtype ctype);
811
1577
 
 
1578
/** @deprecated See krb5_c_make_checksum() */
812
1579
krb5_error_code KRB5_CALLCONV
813
1580
krb5_calculate_checksum(krb5_context context, krb5_cksumtype ctype,
814
1581
                        krb5_const_pointer in, size_t in_length,
815
1582
                        krb5_const_pointer seed, size_t seed_length,
816
1583
                        krb5_checksum * outcksum);
817
1584
 
 
1585
/** @deprecated See krb5_c_verify_checksum() */
818
1586
krb5_error_code KRB5_CALLCONV
819
1587
krb5_verify_checksum(krb5_context context, krb5_cksumtype ctype,
820
1588
                     const krb5_checksum * cksum, krb5_const_pointer in,
877
1645
#define KDC_TKT_COMMON_MASK             0x54800000
878
1646
 
879
1647
/* definitions for ap_options fields */
880
 
/* ap_options are 32 bits; each host is responsible to put the 4 bytes
881
 
   representing these bits into net order before transmission */
882
 
#define AP_OPTS_RESERVED                0x80000000
883
 
#define AP_OPTS_USE_SESSION_KEY         0x40000000
884
 
#define AP_OPTS_MUTUAL_REQUIRED         0x20000000
 
1648
 
 
1649
/** @defgroup AP_OPTS AP_OPTS
 
1650
 *
 
1651
 * ap_options are 32 bits; each host is responsible to put the 4 bytes
 
1652
 * representing these bits into net order before transmission
 
1653
 * @{
 
1654
 */
 
1655
#define AP_OPTS_RESERVED           0x80000000
 
1656
#define AP_OPTS_USE_SESSION_KEY    0x40000000 /**< Use session key */
 
1657
#define AP_OPTS_MUTUAL_REQUIRED    0x20000000 /**< Perform a mutual
 
1658
                                                 authentication exchange */
 
1659
#define AP_OPTS_ETYPE_NEGOTIATION  0x00000002
 
1660
#define AP_OPTS_USE_SUBKEY         0x00000001 /**< Generate a subsession key
 
1661
                                                 from the current session key
 
1662
                                                 obtained from the
 
1663
                                                 credentials */
885
1664
/* #define      AP_OPTS_RESERVED        0x10000000 */
886
1665
/* #define      AP_OPTS_RESERVED        0x08000000 */
887
1666
/* #define      AP_OPTS_RESERVED        0x04000000 */
909
1688
/* #define      AP_OPTS_RESERVED        0x00000010 */
910
1689
/* #define      AP_OPTS_RESERVED        0x00000008 */
911
1690
/* #define      AP_OPTS_RESERVED        0x00000004 */
912
 
#define AP_OPTS_ETYPE_NEGOTIATION       0x00000002
913
 
#define AP_OPTS_USE_SUBKEY              0x00000001
 
1691
 
914
1692
 
915
1693
#define AP_OPTS_WIRE_MASK               0xfffffff0
 
1694
/** @} */ /* end of AP_OPTS group */
916
1695
 
917
1696
/* definitions for ad_type fields. */
918
1697
#define AD_TYPE_RESERVED        0x8000
973
1752
 * begin "proto.h"
974
1753
 */
975
1754
 
976
 
/* Protocol version number */
 
1755
/** Protocol version number */
977
1756
#define KRB5_PVNO       5
978
1757
 
979
1758
/* Message types */
980
1759
 
981
 
#define KRB5_AS_REQ     ((krb5_msgtype)10) /* Req for initial authentication */
982
 
#define KRB5_AS_REP     ((krb5_msgtype)11) /* Response to KRB_AS_REQ request */
983
 
#define KRB5_TGS_REQ    ((krb5_msgtype)12) /* TGS request to server */
984
 
#define KRB5_TGS_REP    ((krb5_msgtype)13) /* Response to KRB_TGS_REQ req */
985
 
#define KRB5_AP_REQ     ((krb5_msgtype)14) /* application request to server */
986
 
#define KRB5_AP_REP     ((krb5_msgtype)15) /* Response to KRB_AP_REQ_MUTUAL */
987
 
#define KRB5_SAFE       ((krb5_msgtype)20) /* Safe application message */
988
 
#define KRB5_PRIV       ((krb5_msgtype)21) /* Private application message */
989
 
#define KRB5_CRED       ((krb5_msgtype)22) /* Credential forwarding message */
990
 
#define KRB5_ERROR      ((krb5_msgtype)30) /* Error response */
 
1760
#define KRB5_AS_REQ   ((krb5_msgtype)10) /**< Initial authentication request */
 
1761
#define KRB5_AS_REP   ((krb5_msgtype)11) /**< Response to AS request */
 
1762
#define KRB5_TGS_REQ  ((krb5_msgtype)12) /**< Ticket granting server request */
 
1763
#define KRB5_TGS_REP  ((krb5_msgtype)13) /**< Response to TGS request */
 
1764
#define KRB5_AP_REQ   ((krb5_msgtype)14) /**< Auth req to application server */
 
1765
#define KRB5_AP_REP   ((krb5_msgtype)15) /**< Response to mutual AP request */
 
1766
#define KRB5_SAFE     ((krb5_msgtype)20) /**< Safe application message */
 
1767
#define KRB5_PRIV     ((krb5_msgtype)21) /**< Private application message */
 
1768
#define KRB5_CRED     ((krb5_msgtype)22) /**< Cred forwarding message */
 
1769
#define KRB5_ERROR    ((krb5_msgtype)30) /**< Error response */
991
1770
 
992
1771
/* LastReq types */
993
1772
#define KRB5_LRQ_NONE                   0
1015
1794
#if 0                           /* Not used */
1016
1795
#define KRB5_PADATA_ENC_ENCKEY          4  /* Key encrypted within itself */
1017
1796
#endif
1018
 
#define KRB5_PADATA_ENC_UNIX_TIME       5  /* timestamp encrypted in key */
1019
 
#define KRB5_PADATA_ENC_SANDIA_SECURID  6  /* SecurId passcode */
1020
 
#define KRB5_PADATA_SESAME              7  /* Sesame project */
1021
 
#define KRB5_PADATA_OSF_DCE             8  /* OSF DCE */
1022
 
#define KRB5_CYBERSAFE_SECUREID         9  /* Cybersafe */
1023
 
#define KRB5_PADATA_AFS3_SALT           10 /* Cygnus */
1024
 
#define KRB5_PADATA_ETYPE_INFO          11 /* Etype info for preauth */
1025
 
#define KRB5_PADATA_SAM_CHALLENGE       12 /* draft challenge system */
1026
 
#define KRB5_PADATA_SAM_RESPONSE        13 /* draft challenge system response */
1027
 
#define KRB5_PADATA_PK_AS_REQ_OLD       14 /* PKINIT */
1028
 
#define KRB5_PADATA_PK_AS_REP_OLD       15 /* PKINIT */
1029
 
#define KRB5_PADATA_PK_AS_REQ           16 /* PKINIT */
1030
 
#define KRB5_PADATA_PK_AS_REP           17 /* PKINIT */
 
1797
#define KRB5_PADATA_ENC_UNIX_TIME       5  /**< timestamp encrypted in key */
 
1798
#define KRB5_PADATA_ENC_SANDIA_SECURID  6  /**< SecurId passcode */
 
1799
#define KRB5_PADATA_SESAME              7  /**< Sesame project */
 
1800
#define KRB5_PADATA_OSF_DCE             8  /**< OSF DCE */
 
1801
#define KRB5_CYBERSAFE_SECUREID         9  /**< Cybersafe */
 
1802
#define KRB5_PADATA_AFS3_SALT           10 /**< Cygnus */
 
1803
#define KRB5_PADATA_ETYPE_INFO          11 /**< Etype info for preauth */
 
1804
#define KRB5_PADATA_SAM_CHALLENGE       12 /**< draft challenge system */
 
1805
#define KRB5_PADATA_SAM_RESPONSE        13 /**< draft challenge system response */
 
1806
#define KRB5_PADATA_PK_AS_REQ_OLD       14 /**< PKINIT */
 
1807
#define KRB5_PADATA_PK_AS_REP_OLD       15 /**< PKINIT */
 
1808
#define KRB5_PADATA_PK_AS_REQ           16 /**< PKINIT */
 
1809
#define KRB5_PADATA_PK_AS_REP           17 /**< PKINIT */
1031
1810
#define KRB5_PADATA_ETYPE_INFO2         19
1032
1811
#define KRB5_PADATA_USE_SPECIFIED_KVNO  20
1033
 
#define KRB5_PADATA_SVR_REFERRAL_INFO   20 /* Windows 2000 referrals */
 
1812
#define KRB5_PADATA_SVR_REFERRAL_INFO   20 /**< Windows 2000 referrals */
1034
1813
#define KRB5_PADATA_SAM_REDIRECT        21
1035
1814
#define KRB5_PADATA_GET_FROM_TYPED_DATA 22
1036
 
#define KRB5_PADATA_REFERRAL            25 /* draft referral system */
1037
 
#define KRB5_PADATA_SAM_CHALLENGE_2     30 /* draft challenge system, updated */
1038
 
#define KRB5_PADATA_SAM_RESPONSE_2      31 /* draft challenge system, updated */
1039
 
#define KRB5_PADATA_PAC_REQUEST         128 /* include Windows PAC */
1040
 
#define KRB5_PADATA_FOR_USER            129 /* username protocol transition request */
1041
 
#define KRB5_PADATA_S4U_X509_USER       130 /* certificate protocol transition request */
1042
 
#define KRB5_PADATA_FX_COOKIE 133
1043
 
#define KRB5_PADATA_FX_FAST  136
1044
 
#define KRB5_PADATA_FX_ERROR 137
 
1815
#define KRB5_PADATA_REFERRAL            25 /**< draft referral system */
 
1816
#define KRB5_PADATA_SAM_CHALLENGE_2     30 /**< draft challenge system, updated */
 
1817
#define KRB5_PADATA_SAM_RESPONSE_2      31 /**< draft challenge system, updated */
 
1818
#define KRB5_PADATA_PAC_REQUEST         128 /**< include Windows PAC */
 
1819
#define KRB5_PADATA_FOR_USER            129 /**< username protocol transition request */
 
1820
#define KRB5_PADATA_S4U_X509_USER       130 /**< certificate protocol transition request */
 
1821
#define KRB5_PADATA_FX_COOKIE           133
 
1822
#define KRB5_PADATA_FX_FAST             136
 
1823
#define KRB5_PADATA_FX_ERROR            137
1045
1824
#define KRB5_PADATA_ENCRYPTED_CHALLENGE 138
1046
1825
#define KRB5_PADATA_PKINIT_KX 147
1047
1826
#define KRB5_ENCPADATA_REQ_ENC_PA_REP 149
1050
1829
#define KRB5_SAM_SEND_ENCRYPTED_SAD     0x40000000
1051
1830
#define KRB5_SAM_MUST_PK_ENCRYPT_SAD    0x20000000 /* currently must be zero */
1052
1831
 
1053
 
/* Reserved for SPX pre-authentication. */
1054
 
#define KRB5_PADATA_DASS                16
1055
 
 
1056
 
/* Transited encoding types */
1057
 
#define KRB5_DOMAIN_X500_COMPRESS       1
1058
 
 
1059
 
/* alternate authentication types */
 
1832
/** Transited encoding types */
 
1833
#define KRB5_DOMAIN_X500_COMPRESS               1
 
1834
 
 
1835
/** alternate authentication types */
1060
1836
#define KRB5_ALTAUTH_ATT_CHALLENGE_RESPONSE     64
1061
1837
 
1062
 
/* authorization data types */
 
1838
/* authorization data types. See RFC 4120 section 5.2.6 */
 
1839
 
 
1840
/** @defgroup KRB5_AUTHDATA KRB5_AUTHDATA
 
1841
 * @{
 
1842
 */
1063
1843
#define KRB5_AUTHDATA_IF_RELEVANT   1
1064
1844
#define KRB5_AUTHDATA_KDC_ISSUED    4
1065
1845
#define KRB5_AUTHDATA_AND_OR        5
1069
1849
#define KRB5_AUTHDATA_SESAME    65
1070
1850
#define KRB5_AUTHDATA_WIN2K_PAC 128
1071
1851
#define KRB5_AUTHDATA_ETYPE_NEGOTIATION 129     /* RFC 4537 */
1072
 
#define KRB5_AUTHDATA_SIGNTICKET        512     /* formerly 142 in krb5 1.8 */
 
1852
#define KRB5_AUTHDATA_SIGNTICKET        512     /**< formerly 142 in krb5 1.8 */
1073
1853
#define KRB5_AUTHDATA_FX_ARMOR 71
 
1854
/** @} */ /* end of KRB5_AUTHDATA group */
 
1855
 
1074
1856
/* password change constants */
1075
 
 
1076
1857
#define KRB5_KPASSWD_SUCCESS            0
1077
1858
#define KRB5_KPASSWD_MALFORMED          1
1078
1859
#define KRB5_KPASSWD_HARDERROR          2
1089
1870
 */
1090
1871
 
1091
1872
/* Time set */
 
1873
/** Ticket start time, end time, and renewal duration. */
1092
1874
typedef struct _krb5_ticket_times {
1093
 
    krb5_timestamp authtime; /* XXX ? should ktime in KDC_REP == authtime
1094
 
                                in ticket? otherwise client can't get this */
1095
 
    krb5_timestamp starttime;           /* optional in ticket, if not present,
1096
 
                                           use authtime */
1097
 
    krb5_timestamp endtime;
1098
 
    krb5_timestamp renew_till;
 
1875
    krb5_timestamp authtime;    /**< Time at which KDC issued the initial ticket that corresponds to this ticket */
 
1876
    /* XXX ? should ktime in KDC_REP == authtime
 
1877
       in ticket? otherwise client can't get this */
 
1878
    krb5_timestamp starttime;   /**< optional in ticket, if not present, use @a authtime */
 
1879
    krb5_timestamp endtime;     /**< Ticket expiration time */
 
1880
    krb5_timestamp renew_till;  /**< Latest time at which renewal of ticket can be valid */
1099
1881
} krb5_ticket_times;
1100
1882
 
1101
 
/* structure for auth data */
 
1883
/** Structure for auth data */
1102
1884
typedef struct _krb5_authdata {
1103
1885
    krb5_magic magic;
1104
 
    krb5_authdatatype ad_type;
1105
 
    unsigned int length;
1106
 
    krb5_octet *contents;
 
1886
    krb5_authdatatype ad_type; /**< ADTYPE */
 
1887
    unsigned int length;       /**< Length of data  */
 
1888
    krb5_octet *contents;      /**< Data */
1107
1889
} krb5_authdata;
1108
1890
 
1109
 
/* structure for transited encoding */
 
1891
/** Structure for transited encoding */
1110
1892
typedef struct _krb5_transited {
1111
1893
    krb5_magic magic;
1112
 
    krb5_octet tr_type;
1113
 
    krb5_data tr_contents;
 
1894
    krb5_octet tr_type;     /**< Transited encoding type */
 
1895
    krb5_data tr_contents;  /**< Contents */
1114
1896
} krb5_transited;
1115
1897
 
 
1898
/** Encrypted part of ticket. */
1116
1899
typedef struct _krb5_enc_tkt_part {
1117
1900
    krb5_magic magic;
1118
1901
    /* to-be-encrypted portion */
1119
 
    krb5_flags flags;                   /* flags */
1120
 
    krb5_keyblock *session;             /* session key: includes enctype */
1121
 
    krb5_principal client;              /* client name/realm */
1122
 
    krb5_transited transited;           /* list of transited realms */
1123
 
    krb5_ticket_times times;            /* auth, start, end, renew_till */
1124
 
    krb5_address **caddrs;      /* array of ptrs to addresses */
1125
 
    krb5_authdata **authorization_data; /* auth data */
 
1902
    krb5_flags flags;                   /**< flags */
 
1903
    krb5_keyblock *session;             /**< session key: includes enctype */
 
1904
    krb5_principal client;              /**< client name/realm */
 
1905
    krb5_transited transited;           /**< list of transited realms */
 
1906
    krb5_ticket_times times;            /**< auth, start, end, renew_till */
 
1907
    krb5_address **caddrs;              /**< array of ptrs to addresses */
 
1908
    krb5_authdata **authorization_data; /**< auth data */
1126
1909
} krb5_enc_tkt_part;
1127
1910
 
 
1911
/**
 
1912
 * Ticket structure.
 
1913
 *
 
1914
 * The C representation of the ticket message, with a pointer to the
 
1915
 * C representation of the encrypted part.
 
1916
 */
1128
1917
typedef struct _krb5_ticket {
1129
1918
    krb5_magic magic;
1130
1919
    /* cleartext portion */
1131
 
    krb5_principal server;              /* server name/realm */
1132
 
    krb5_enc_data enc_part;             /* encryption type, kvno, encrypted
1133
 
                                           encoding */
1134
 
    krb5_enc_tkt_part *enc_part2;       /* ptr to decrypted version, if
1135
 
                                           available */
 
1920
    krb5_principal server;              /**< server name/realm */
 
1921
    krb5_enc_data enc_part;             /**< encryption type, kvno, encrypted encoding */
 
1922
    krb5_enc_tkt_part *enc_part2;       /**< ptr to decrypted version, if available */
1136
1923
} krb5_ticket;
1137
1924
 
1138
1925
/* the unencrypted version */
 
1926
/**
 
1927
 * Ticket authenticator.
 
1928
 *
 
1929
 * The C representation of an unencrypted authenticator.
 
1930
 */
1139
1931
typedef struct _krb5_authenticator {
1140
1932
    krb5_magic magic;
1141
 
    krb5_principal client;              /* client name/realm */
1142
 
    krb5_checksum *checksum;    /* checksum, includes type, optional */
1143
 
    krb5_int32 cusec;                   /* client usec portion */
1144
 
    krb5_timestamp ctime;               /* client sec portion */
1145
 
    krb5_keyblock *subkey;              /* true session key, optional */
1146
 
    krb5_ui_4 seq_number;               /* sequence #, optional */
1147
 
    krb5_authdata **authorization_data; /* New add by Ari, auth data */
 
1933
    krb5_principal client;              /**< client name/realm */
 
1934
    krb5_checksum *checksum;            /**< checksum, includes type, optional */
 
1935
    krb5_int32 cusec;                   /**< client usec portion */
 
1936
    krb5_timestamp ctime;               /**< client sec portion */
 
1937
    krb5_keyblock *subkey;              /**< true session key, optional */
 
1938
    krb5_ui_4 seq_number;               /**< sequence #, optional */
 
1939
    krb5_authdata **authorization_data; /**< authoriazation data */
1148
1940
} krb5_authenticator;
1149
1941
 
 
1942
/** Ticket authentication data. */
1150
1943
typedef struct _krb5_tkt_authent {
1151
1944
    krb5_magic magic;
1152
1945
    krb5_ticket *ticket;
1154
1947
    krb5_flags ap_options;
1155
1948
} krb5_tkt_authent;
1156
1949
 
1157
 
/* credentials:  Ticket, session key, etc. */
 
1950
/** Credentials structure including ticket, session key, and lifetime info. */
1158
1951
typedef struct _krb5_creds {
1159
1952
    krb5_magic magic;
1160
 
    krb5_principal client;              /* client's principal identifier */
1161
 
    krb5_principal server;              /* server's principal identifier */
1162
 
    krb5_keyblock keyblock;             /* session encryption key info */
1163
 
    krb5_ticket_times times;            /* lifetime info */
1164
 
    krb5_boolean is_skey;               /* true if ticket is encrypted in
 
1953
    krb5_principal client;              /**< client's principal identifier */
 
1954
    krb5_principal server;              /**< server's principal identifier */
 
1955
    krb5_keyblock keyblock;             /**< session encryption key info */
 
1956
    krb5_ticket_times times;            /**< lifetime info */
 
1957
    krb5_boolean is_skey;               /**< true if ticket is encrypted in
1165
1958
                                           another ticket's skey */
1166
 
    krb5_flags ticket_flags;            /* flags in ticket */
1167
 
    krb5_address **addresses;   /* addrs in ticket */
1168
 
    krb5_data ticket;                   /* ticket string itself */
1169
 
    krb5_data second_ticket;            /* second ticket, if related to
 
1959
    krb5_flags ticket_flags;            /**< flags in ticket */
 
1960
    krb5_address **addresses;           /**< addrs in ticket */
 
1961
    krb5_data ticket;                   /**< ticket string itself */
 
1962
    krb5_data second_ticket;            /**< second ticket, if related to
1170
1963
                                           ticket (via DUPLICATE-SKEY or
1171
1964
                                           ENC-TKT-IN-SKEY) */
1172
 
    krb5_authdata **authdata;   /* authorization data */
 
1965
    krb5_authdata **authdata;           /**< authorization data */
1173
1966
} krb5_creds;
1174
1967
 
1175
 
/* Last request fields */
 
1968
/** Last request entry */
1176
1969
typedef struct _krb5_last_req_entry {
1177
1970
    krb5_magic magic;
1178
 
    krb5_int32 lr_type;
1179
 
    krb5_timestamp value;
 
1971
    krb5_int32 lr_type;         /**< LR type */
 
1972
    krb5_timestamp value;       /**< Timestamp */
1180
1973
} krb5_last_req_entry;
1181
1974
 
1182
 
/* pre-authentication data */
 
1975
/** Pre-authentication data */
1183
1976
typedef struct _krb5_pa_data {
1184
1977
    krb5_magic magic;
1185
 
    krb5_preauthtype  pa_type;
1186
 
    unsigned int length;
1187
 
    krb5_octet *contents;
 
1978
    krb5_preauthtype pa_type;   /**< Preauthentication data type */
 
1979
    unsigned int length;        /**< Length of data */
 
1980
    krb5_octet *contents;       /**< Data */
1188
1981
} krb5_pa_data;
1189
1982
 
1190
 
/* typed data */
1191
1983
/*
1192
 
 * The FAST error handling logic currently assumes that this structure and
1193
 
 * krb5_pa_data * can be safely cast to each other if this structure changes,
1194
 
 * that code needs to be updated to copy.
 
1984
 * The FAST error handling logic currently assumes that pointers to this
 
1985
 * structure and krb5_pa_data can be safely cast to each other.  If this
 
1986
 * structure changes, that code needs to be updated to copy.
1195
1987
 */
 
1988
/** Typed data */
1196
1989
typedef struct _krb5_typed_data {
1197
1990
    krb5_magic magic;
1198
 
    krb5_int32  type;
 
1991
    krb5_int32 type;
1199
1992
    unsigned int length;
1200
1993
    krb5_octet *data;
1201
1994
} krb5_typed_data;
1202
1995
 
 
1996
/** C representation of KDC-REQ protocol message, including KDC-REQ-BODY */
1203
1997
typedef struct _krb5_kdc_req {
1204
1998
    krb5_magic magic;
1205
 
    krb5_msgtype msg_type;              /* AS_REQ or TGS_REQ? */
1206
 
    krb5_pa_data **padata;      /* e.g. encoded AP_REQ */
 
1999
    krb5_msgtype msg_type;      /**< KRB5_AS_REQ or KRB5_TGS_REQ */
 
2000
    krb5_pa_data **padata;      /**< Preauthentication data */
1207
2001
    /* real body */
1208
 
    krb5_flags kdc_options;             /* requested options */
1209
 
    krb5_principal client;              /* includes realm; optional */
1210
 
    krb5_principal server;              /* includes realm (only used if no
1211
 
                                           client) */
1212
 
    krb5_timestamp from;                /* requested starttime */
1213
 
    krb5_timestamp till;                /* requested endtime */
1214
 
    krb5_timestamp rtime;               /* (optional) requested renew_till */
1215
 
    krb5_int32 nonce;                   /* nonce to match request/response */
1216
 
    int nktypes;                        /* # of ktypes, must be positive */
1217
 
    krb5_enctype *ktype;                /* requested enctype(s) */
1218
 
    krb5_address **addresses;   /* requested addresses, optional */
1219
 
    krb5_enc_data authorization_data;   /* encrypted auth data; OPTIONAL */
1220
 
    krb5_authdata **unenc_authdata; /* unencrypted auth data,
1221
 
                                       if available */
1222
 
    krb5_ticket **second_ticket;/* second ticket array; OPTIONAL */
1223
 
    /* the following field is added in March 2009; it is a hack so
1224
 
     * that FAST state can be carried to pre-authentication plugins.
1225
 
     * A new plugin interface may be a better long-term approach.  It
1226
 
     * is believed to be safe to extend this structure because it is
1227
 
     * not found in any public APIs.
1228
 
     */
1229
 
    void * kdc_state;
 
2002
    krb5_flags kdc_options;     /**< Requested options */
 
2003
    krb5_principal client;      /**< Client principal and realm */
 
2004
    krb5_principal server;      /**< Server principal and realm */
 
2005
    krb5_timestamp from;        /**< Requested start time */
 
2006
    krb5_timestamp till;        /**< Requested end time */
 
2007
    krb5_timestamp rtime;       /**< Requested renewable end time */
 
2008
    krb5_int32 nonce;           /**< Nonce to match request andresponse */
 
2009
    int nktypes;                /**< Number of enctypes */
 
2010
    krb5_enctype *ktype;        /**< Requested enctypes */
 
2011
    krb5_address **addresses;   /**< Requested addresses (optional) */
 
2012
    krb5_enc_data authorization_data;  /**< Encrypted authz data (optional) */
 
2013
    krb5_authdata **unenc_authdata;    /**< Unencrypted authz data */
 
2014
    krb5_ticket **second_ticket;       /**< Second ticket array (optional) */
1230
2015
} krb5_kdc_req;
1231
2016
 
 
2017
/**
 
2018
 * C representation of @c EncKDCRepPart protocol message.
 
2019
 *
 
2020
 * This is the cleartext message that is encrypted and inserted in @c KDC-REP.
 
2021
 */
1232
2022
typedef struct _krb5_enc_kdc_rep_part {
1233
2023
    krb5_magic magic;
1234
2024
    /* encrypted part: */
1235
 
    krb5_msgtype msg_type;              /* krb5 message type */
1236
 
    krb5_keyblock *session;             /* session key */
1237
 
    krb5_last_req_entry **last_req; /* array of ptrs to entries */
1238
 
    krb5_int32 nonce;                   /* nonce from request */
1239
 
    krb5_timestamp key_exp;             /* expiration date */
1240
 
    krb5_flags flags;                   /* ticket flags */
1241
 
    krb5_ticket_times times;            /* lifetime info */
1242
 
    krb5_principal server;              /* server's principal identifier */
1243
 
    krb5_address **caddrs;      /* array of ptrs to addresses,
1244
 
                                   optional */
1245
 
    krb5_pa_data **enc_padata;          /* Windows 2000 compat */
 
2025
    krb5_msgtype msg_type;           /**< krb5 message type */
 
2026
    krb5_keyblock *session;          /**< Session key */
 
2027
    krb5_last_req_entry **last_req;  /**< Array of pointers to entries */
 
2028
    krb5_int32 nonce;                /**< Nonce from request */
 
2029
    krb5_timestamp key_exp;          /**< Expiration date */
 
2030
    krb5_flags flags;                /**< Ticket flags */
 
2031
    krb5_ticket_times times;         /**< Lifetime info */
 
2032
    krb5_principal server;           /**< Server's principal identifier */
 
2033
    krb5_address **caddrs;           /**< Array of ptrs to addrs, optional */
 
2034
    krb5_pa_data **enc_padata;       /**< Encrypted preauthentication data */
1246
2035
} krb5_enc_kdc_rep_part;
1247
2036
 
 
2037
/** Representation of the @c KDC-REP protocol message. */
1248
2038
typedef struct _krb5_kdc_rep {
1249
2039
    krb5_magic magic;
1250
2040
    /* cleartext part: */
1251
 
    krb5_msgtype msg_type;              /* AS_REP or KDC_REP? */
1252
 
    krb5_pa_data **padata;      /* preauthentication data from KDC */
1253
 
    krb5_principal client;              /* client's principal identifier */
1254
 
    krb5_ticket *ticket;                /* ticket */
1255
 
    krb5_enc_data enc_part;             /* encryption type, kvno, encrypted
1256
 
                                           encoding */
1257
 
    krb5_enc_kdc_rep_part *enc_part2;/* unencrypted version, if available */
 
2041
    krb5_msgtype msg_type;            /**< KRB5_AS_REP or KRB5_KDC_REP */
 
2042
    krb5_pa_data **padata;            /**< Preauthentication data from KDC */
 
2043
    krb5_principal client;            /**< Client principal and realm */
 
2044
    krb5_ticket *ticket;              /**< Ticket */
 
2045
    krb5_enc_data enc_part;           /**< Encrypted part of reply */
 
2046
    krb5_enc_kdc_rep_part *enc_part2; /**< Unencrypted version, if available */
1258
2047
} krb5_kdc_rep;
1259
2048
 
1260
 
/* error message structure */
 
2049
/** Error message structure */
1261
2050
typedef struct _krb5_error {
1262
2051
    krb5_magic magic;
1263
2052
    /* some of these may be meaningless in certain contexts */
1264
 
    krb5_timestamp ctime;               /* client sec portion; optional */
1265
 
    krb5_int32 cusec;                   /* client usec portion; optional */
1266
 
    krb5_int32 susec;                   /* server usec portion */
1267
 
    krb5_timestamp stime;               /* server sec portion */
1268
 
    krb5_ui_4 error;                    /* error code (protocol error #'s) */
1269
 
    krb5_principal client;              /* client's principal identifier;
1270
 
                                           optional */
1271
 
    krb5_principal server;              /* server's principal identifier */
1272
 
    krb5_data text;                     /* descriptive text */
1273
 
    krb5_data e_data;                   /* additional error-describing data */
 
2053
    krb5_timestamp ctime;       /**< Client sec portion; optional */
 
2054
    krb5_int32 cusec;           /**< Client usec portion; optional */
 
2055
    krb5_int32 susec;           /**< Server usec portion */
 
2056
    krb5_timestamp stime;       /**< Server sec portion */
 
2057
    krb5_ui_4 error;            /**< Error code (protocol error #'s) */
 
2058
    krb5_principal client;      /**< Client principal and realm */
 
2059
    krb5_principal server;      /**< Server principal and realm */
 
2060
    krb5_data text;             /**< Descriptive text */
 
2061
    krb5_data e_data;           /**< Additional error-describing data */
1274
2062
} krb5_error;
1275
2063
 
 
2064
/** Authentication header. */
1276
2065
typedef struct _krb5_ap_req {
1277
2066
    krb5_magic magic;
1278
 
    krb5_flags ap_options;              /* requested options */
1279
 
    krb5_ticket *ticket;                /* ticket */
1280
 
    krb5_enc_data authenticator;        /* authenticator (already encrypted) */
 
2067
    krb5_flags ap_options;        /**< Requested options */
 
2068
    krb5_ticket *ticket;          /**< Ticket */
 
2069
    krb5_enc_data authenticator;  /**< Encrypted authenticator */
1281
2070
} krb5_ap_req;
1282
2071
 
 
2072
/**
 
2073
 * C representaton of AP-REP message.
 
2074
 *
 
2075
 * The server's response to a client's request for mutual authentication.
 
2076
 */
1283
2077
typedef struct _krb5_ap_rep {
1284
2078
    krb5_magic magic;
1285
 
    krb5_enc_data enc_part;
 
2079
    krb5_enc_data enc_part;     /**< Ciphertext of ApRepEncPart */
1286
2080
} krb5_ap_rep;
1287
2081
 
 
2082
/** Cleartext that is encrypted and put into @c _krb5_ap_rep.  */
1288
2083
typedef struct _krb5_ap_rep_enc_part {
1289
2084
    krb5_magic magic;
1290
 
    krb5_timestamp ctime;               /* client time, seconds portion */
1291
 
    krb5_int32 cusec;                   /* client time, microseconds portion */
1292
 
    krb5_keyblock *subkey;              /* true session key, optional */
1293
 
    krb5_ui_4 seq_number;               /* sequence #, optional */
 
2085
    krb5_timestamp ctime;       /**< Client time, seconds portion */
 
2086
    krb5_int32 cusec;           /**< Client time, microseconds portion */
 
2087
    krb5_keyblock *subkey;      /**< Subkey (optional) */
 
2088
    krb5_ui_4 seq_number;       /**< Sequence number */
1294
2089
} krb5_ap_rep_enc_part;
1295
2090
 
 
2091
/* Unused */
1296
2092
typedef struct _krb5_response {
1297
2093
    krb5_magic magic;
1298
2094
    krb5_octet message_type;
1299
2095
    krb5_data response;
1300
 
    krb5_int32 expected_nonce;  /* The expected nonce for KDC_REP messages */
1301
 
    krb5_timestamp request_time;   /* When we made the request */
 
2096
    krb5_int32 expected_nonce;
 
2097
    krb5_timestamp request_time;
1302
2098
} krb5_response;
1303
2099
 
 
2100
/** Credentials information inserted into @c EncKrbCredPart. */
1304
2101
typedef struct _krb5_cred_info {
1305
2102
    krb5_magic magic;
1306
 
    krb5_keyblock *session;             /* session key used to encrypt */
1307
 
                                        /* ticket */
1308
 
    krb5_principal client;              /* client name/realm, optional */
1309
 
    krb5_principal server;              /* server name/realm, optional */
1310
 
    krb5_flags flags;                   /* ticket flags, optional */
1311
 
    krb5_ticket_times times;            /* auth, start, end, renew_till, */
1312
 
                                        /* optional */
1313
 
    krb5_address **caddrs;      /* array of ptrs to addresses */
 
2103
    krb5_keyblock *session;     /**< Session key used to encrypt ticket */
 
2104
    krb5_principal client;      /**< Client principal and realm */
 
2105
    krb5_principal server;      /**< Server principal and realm */
 
2106
    krb5_flags flags;           /**< Ticket flags */
 
2107
    krb5_ticket_times times;    /**< Auth, start, end, renew_till */
 
2108
    krb5_address **caddrs;      /**< Array of pointers to addrs (optional) */
1314
2109
} krb5_cred_info;
1315
2110
 
 
2111
/** Cleartext credentials information.  */
1316
2112
typedef struct _krb5_cred_enc_part {
1317
2113
    krb5_magic magic;
1318
 
    krb5_int32 nonce;                   /* nonce, optional */
1319
 
    krb5_timestamp timestamp;           /* client time */
1320
 
    krb5_int32 usec;                    /* microsecond portion of time */
1321
 
    krb5_address *s_address;    /* sender address, optional */
1322
 
    krb5_address *r_address;    /* recipient address, optional */
 
2114
    krb5_int32 nonce;           /**< Nonce (optional) */
 
2115
    krb5_timestamp timestamp;   /**< Generation time, seconds portion */
 
2116
    krb5_int32 usec;            /**< Generation time, microseconds portion */
 
2117
    krb5_address *s_address;    /**< Sender address (optional) */
 
2118
    krb5_address *r_address;    /**< Recipient address (optional) */
1323
2119
    krb5_cred_info **ticket_info;
1324
2120
} krb5_cred_enc_part;
1325
2121
 
 
2122
/** Credentials data structure.*/
1326
2123
typedef struct _krb5_cred {
1327
2124
    krb5_magic magic;
1328
 
    krb5_ticket **tickets;      /* tickets */
1329
 
    krb5_enc_data enc_part;             /* encrypted part */
1330
 
    krb5_cred_enc_part *enc_part2;      /* unencrypted version, if available*/
 
2125
    krb5_ticket **tickets;          /**< Tickets */
 
2126
    krb5_enc_data enc_part;         /**< Encrypted part */
 
2127
    krb5_cred_enc_part *enc_part2;  /**< Unencrypted version, if available */
1331
2128
} krb5_cred;
1332
2129
 
1333
 
/* Sandia password generation structures */
 
2130
/*
 
2131
 * Sandia password generation structure
 
2132
 * Used by internal functions only
 
2133
 */
1334
2134
typedef struct _passwd_phrase_element {
1335
2135
    krb5_magic magic;
1336
2136
    krb5_data *passwd;
1337
2137
    krb5_data *phrase;
1338
2138
} passwd_phrase_element;
1339
2139
 
 
2140
/*
 
2141
 * Password data.
 
2142
 * Used by internal functions only
 
2143
 */
1340
2144
typedef struct _krb5_pwd_data {
1341
2145
    krb5_magic magic;
1342
2146
    int sequence_count;
1349
2153
 * in the enc_padata field of the krb5_enc_kdc_rep_part.
1350
2154
 */
1351
2155
typedef struct _krb5_pa_svr_referral_data {
1352
 
    /* Referred name, only realm is required */
 
2156
    /** Referred name, only realm is required */
1353
2157
    krb5_principal     principal;
1354
2158
} krb5_pa_svr_referral_data;
1355
2159
 
1362
2166
} krb5_pa_server_referral_data;
1363
2167
 
1364
2168
typedef struct _krb5_pa_pac_req {
1365
 
    /* TRUE if a PAC should be included in TGS-REP */
 
2169
    /** TRUE if a PAC should be included in TGS-REP */
1366
2170
    krb5_boolean       include_pac;
1367
2171
} krb5_pa_pac_req;
1368
2172
 
1370
2174
 * begin "safepriv.h"
1371
2175
 */
1372
2176
 
1373
 
#define KRB5_AUTH_CONTEXT_DO_TIME       0x00000001
 
2177
/** @defgroup KRB5_AUTH_CONTEXT KRB5_AUTH_CONTEXT
 
2178
 * @{
 
2179
 */
 
2180
#define KRB5_AUTH_CONTEXT_DO_TIME       0x00000001 /**< set timestamp in the message */
1374
2181
#define KRB5_AUTH_CONTEXT_RET_TIME      0x00000002
1375
 
#define KRB5_AUTH_CONTEXT_DO_SEQUENCE   0x00000004
 
2182
#define KRB5_AUTH_CONTEXT_DO_SEQUENCE   0x00000004 /**< set sequence number in the message */
1376
2183
#define KRB5_AUTH_CONTEXT_RET_SEQUENCE  0x00000008
1377
2184
#define KRB5_AUTH_CONTEXT_PERMIT_ALL    0x00000010
1378
2185
#define KRB5_AUTH_CONTEXT_USE_SUBKEY    0x00000020
 
2186
/** @} */ /* end of KRB5_AUTH_CONTEXT group */
1379
2187
 
 
2188
/**
 
2189
 * Replay data.
 
2190
 *
 
2191
 * Sequence number and timestamp information output by krb5_rd_priv() and
 
2192
 * krb5_rd_safe().
 
2193
 */
1380
2194
typedef struct krb5_replay_data {
1381
 
    krb5_timestamp      timestamp;
1382
 
    krb5_int32          usec;
1383
 
    krb5_ui_4           seq;
 
2195
    krb5_timestamp      timestamp;  /**< Timestamp, seconds portion */
 
2196
    krb5_int32          usec;       /**< Timestamp, microseconds portion */
 
2197
    krb5_ui_4           seq;        /**< Sequence number  */
1384
2198
} krb5_replay_data;
1385
2199
 
1386
 
/* flags for krb5_auth_con_genaddrs() */
1387
 
#define KRB5_AUTH_CONTEXT_GENERATE_LOCAL_ADDR           0x00000001
1388
 
#define KRB5_AUTH_CONTEXT_GENERATE_REMOTE_ADDR          0x00000002
1389
 
#define KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR      0x00000004
1390
 
#define KRB5_AUTH_CONTEXT_GENERATE_REMOTE_FULL_ADDR     0x00000008
1391
 
 
1392
 
/* type of function used as a callback to generate checksum data for
1393
 
 * mk_req */
1394
 
 
 
2200
/* Flags for krb5_auth_con_genaddrs(). */
 
2201
 
 
2202
/** Generate the local network address. */
 
2203
#define KRB5_AUTH_CONTEXT_GENERATE_LOCAL_ADDR       0x00000001
 
2204
/** Generate the remote network address.  */
 
2205
#define KRB5_AUTH_CONTEXT_GENERATE_REMOTE_ADDR      0x00000002
 
2206
/** Generate the local network address and the local port. */
 
2207
#define KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR  0x00000004
 
2208
/** Generate the remote network address and the remote port. */
 
2209
#define KRB5_AUTH_CONTEXT_GENERATE_REMOTE_FULL_ADDR 0x00000008
 
2210
 
 
2211
/** Type of function used as a callback to generate checksum data for mk_req */
1395
2212
typedef krb5_error_code
1396
 
(KRB5_CALLCONV * krb5_mk_req_checksum_func) (krb5_context, krb5_auth_context , void *,
1397
 
                                             krb5_data **);
 
2213
(KRB5_CALLCONV * krb5_mk_req_checksum_func)(krb5_context, krb5_auth_context,
 
2214
                                            void *, krb5_data **);
1398
2215
 
1399
2216
/*
1400
2217
 * end "safepriv.h"
1405
2222
 * begin "ccache.h"
1406
2223
 */
1407
2224
 
1408
 
typedef krb5_pointer    krb5_cc_cursor; /* cursor for sequential lookup */
 
2225
/** Cursor for sequential lookup */
 
2226
typedef krb5_pointer    krb5_cc_cursor;
1409
2227
 
1410
2228
struct _krb5_ccache;
1411
2229
typedef struct _krb5_ccache *krb5_ccache;
1412
2230
struct _krb5_cc_ops;
1413
2231
typedef struct _krb5_cc_ops krb5_cc_ops;
1414
2232
 
1415
 
/*
1416
 
 * Cursor for iterating over all ccaches
1417
 
 */
1418
2233
struct _krb5_cccol_cursor;
 
2234
/** Cursor for iterating over all ccaches */
1419
2235
typedef struct _krb5_cccol_cursor *krb5_cccol_cursor;
1420
2236
 
1421
 
/* for retrieve_cred */
1422
 
#define KRB5_TC_MATCH_TIMES             0x00000001
1423
 
#define KRB5_TC_MATCH_IS_SKEY           0x00000002
1424
 
#define KRB5_TC_MATCH_FLAGS             0x00000004
1425
 
#define KRB5_TC_MATCH_TIMES_EXACT       0x00000008
1426
 
#define KRB5_TC_MATCH_FLAGS_EXACT       0x00000010
1427
 
#define KRB5_TC_MATCH_AUTHDATA          0x00000020
1428
 
#define KRB5_TC_MATCH_SRV_NAMEONLY      0x00000040
1429
 
#define KRB5_TC_MATCH_2ND_TKT           0x00000080
1430
 
#define KRB5_TC_MATCH_KTYPE             0x00000100
1431
 
#define KRB5_TC_SUPPORTED_KTYPES        0x00000200
1432
 
 
1433
 
/* for set_flags and other functions */
1434
 
#define KRB5_TC_OPENCLOSE               0x00000001
1435
 
#define KRB5_TC_NOTICKET                0x00000002
1436
 
 
1437
 
/** Retrieve the name but not type of a credential cache.
1438
 
 *
1439
 
 * @return The name of the credential cache as an alias that should not be
1440
 
 * freed or modified by the caller.  This name does not include the type
1441
 
 * portion, so cannot be used as input to krb5_cc_resolve().
 
2237
/* Flags for krb5_cc_retrieve_cred. */
 
2238
/** The requested lifetime must be at least as great as the time specified. */
 
2239
#define KRB5_TC_MATCH_TIMES        0x00000001
 
2240
/** The is_skey field must match exactly. */
 
2241
#define KRB5_TC_MATCH_IS_SKEY      0x00000002
 
2242
/** All the flags set in the match credentials must be set. */
 
2243
#define KRB5_TC_MATCH_FLAGS        0x00000004
 
2244
/** All the time fields must match exactly. */
 
2245
#define KRB5_TC_MATCH_TIMES_EXACT  0x00000008
 
2246
/** All the flags must match exactly. */
 
2247
#define KRB5_TC_MATCH_FLAGS_EXACT  0x00000010
 
2248
/** The authorization data must match. */
 
2249
#define KRB5_TC_MATCH_AUTHDATA     0x00000020
 
2250
/** Only the name portion of the principal name must match. */
 
2251
#define KRB5_TC_MATCH_SRV_NAMEONLY 0x00000040
 
2252
/** The second ticket must match. */
 
2253
#define KRB5_TC_MATCH_2ND_TKT      0x00000080
 
2254
/** The encryption key type must match. */
 
2255
#define KRB5_TC_MATCH_KTYPE        0x00000100
 
2256
/** The supported key types must match. */
 
2257
#define KRB5_TC_SUPPORTED_KTYPES   0x00000200
 
2258
 
 
2259
/* Flags for krb5_cc_set_flags and similar. */
 
2260
/** Open and close the file for each cache operation. */
 
2261
#define KRB5_TC_OPENCLOSE          0x00000001
 
2262
#define KRB5_TC_NOTICKET           0x00000002
 
2263
 
 
2264
/**
 
2265
 * Retrieve the name, but not type of a credential cache.
 
2266
 *
 
2267
 * @param [in] context          Library context
 
2268
 * @param [in] cache            Credential cache handle
 
2269
 *
 
2270
 * @warning Returns the name of the credential cache.  The result is an alias
 
2271
 * into @a cache and should not be freed or modified by the caller.  This name
 
2272
 * does not include the cache type, so should not be used as input to
 
2273
 * krb5_cc_resolve().
 
2274
 *
 
2275
 * @return
 
2276
 * On success - the name of the credential cache.
1442
2277
 */
1443
2278
const char * KRB5_CALLCONV
1444
2279
krb5_cc_get_name(krb5_context context, krb5_ccache cache);
1445
2280
 
1446
 
krb5_error_code KRB5_CALLCONV
1447
 
krb5_cc_gen_new (krb5_context context, krb5_ccache *cache);
1448
 
 
 
2281
/**
 
2282
 * Retrieve the full name of a credential cache.
 
2283
 *
 
2284
 * @param [in]  context         Library context
 
2285
 * @param [in]  cache           Credential cache handle
 
2286
 * @param [out] fullname_out    Full name of cache
 
2287
 *
 
2288
 */
 
2289
krb5_error_code KRB5_CALLCONV
 
2290
krb5_cc_get_full_name(krb5_context context, krb5_ccache cache,
 
2291
                      char **fullname_out);
 
2292
 
 
2293
#if KRB5_DEPRECATED
 
2294
krb5_error_code KRB5_CALLCONV
 
2295
krb5_cc_gen_new(krb5_context context, krb5_ccache *cache);
 
2296
#endif /* KRB5_DEPRECATED */
 
2297
 
 
2298
/**
 
2299
 * Initialize a credential cache.
 
2300
 *
 
2301
 * @param [in] context          Library context
 
2302
 * @param [in] cache            Credential cache handle
 
2303
 * @param [in] principal        Default principal name
 
2304
 *
 
2305
 * Destroy any existing contents of @a cache and initialize it for the default
 
2306
 * principal @a principal.
 
2307
 *
 
2308
 * @retval
 
2309
 *  0  Success
 
2310
 * @return
 
2311
 *  System errors; Permission errors; Kerberos error codes
 
2312
 */
1449
2313
krb5_error_code KRB5_CALLCONV
1450
2314
krb5_cc_initialize(krb5_context context, krb5_ccache cache,
1451
2315
                   krb5_principal principal);
1452
2316
 
 
2317
/**
 
2318
 * Destroy a credential cache.
 
2319
 *
 
2320
 * @param [in] context          Library context
 
2321
 * @param [in] cache            Credential cache handle
 
2322
 *
 
2323
 * This function destroys any existing contents of @a cache and closes the
 
2324
 * handle to it.
 
2325
 *
 
2326
 * @retval
 
2327
 * 0  Success
 
2328
 * @return
 
2329
 * Permission errors
 
2330
 */
1453
2331
krb5_error_code KRB5_CALLCONV
1454
2332
krb5_cc_destroy(krb5_context context, krb5_ccache cache);
1455
2333
 
 
2334
/**
 
2335
 * Close a credential cache handle.
 
2336
 *
 
2337
 * @param [in] context          Library context
 
2338
 * @param [in] cache            Credential cache handle
 
2339
 *
 
2340
 * This function closes a credential cache handle @a cache without affecting
 
2341
 * the contents of the cache.
 
2342
 *
 
2343
 * @retval
 
2344
 * 0  Success
 
2345
 * @return
 
2346
 * Kerberos error codes
 
2347
 */
1456
2348
krb5_error_code KRB5_CALLCONV
1457
2349
krb5_cc_close(krb5_context context, krb5_ccache cache);
1458
2350
 
 
2351
/**
 
2352
 * Store credentials in a credential cache.
 
2353
 *
 
2354
 * @param [in]     context      Library context
 
2355
 * @param [in,out] cache        Credential cache handle
 
2356
 * @param [in]     creds        Credentials to be stored in cache
 
2357
 *
 
2358
 * This function stores @a creds into @a cache.  If @a creds->server and the
 
2359
 * server in the decoded ticket @a creds->ticket differ, the credentials will
 
2360
 * be stored under both server principal names.
 
2361
 *
 
2362
 * @retval
 
2363
 *  0  Success
 
2364
 * @return Permission errors; storage failure errors; Kerberos error codes
 
2365
 */
1459
2366
krb5_error_code KRB5_CALLCONV
1460
2367
krb5_cc_store_cred(krb5_context context, krb5_ccache cache, krb5_creds *creds);
1461
2368
 
 
2369
/**
 
2370
 * Retrieve a specified credentials from a credential cache.
 
2371
 *
 
2372
 * @param [in]  context         Library context
 
2373
 * @param [in]  cache           Credential cache handle
 
2374
 * @param [in]  flags           Flags bit mask
 
2375
 * @param [in]  mcreds          Credentials to match
 
2376
 * @param [out] creds           Credentials matching the requested value
 
2377
 *
 
2378
 * This function searches a credential cache for credentials matching @a mcreds
 
2379
 * and returns it if found.
 
2380
 *
 
2381
 * Valid values for @a flags are:
 
2382
 *
 
2383
 * @li #KRB5_TC_MATCH_TIMES        The requested lifetime must be at least as
 
2384
 *                                 great as in @a mcreds .
 
2385
 * @li #KRB5_TC_MATCH_IS_SKEY      The @a is_skey field much match exactly.
 
2386
 * @li #KRB5_TC_MATCH_FLAGS        Flags set in @a mcreds must be set.
 
2387
 * @li #KRB5_TC_MATCH_TIMES_EXACT  The requested lifetime must match exactly.
 
2388
 * @li #KRB5_TC_MATCH_FLAGS_EXACT  Flags must match exactly.
 
2389
 * @li #KRB5_TC_MATCH_AUTHDATA     The authorization data must match.
 
2390
 * @li #KRB5_TC_MATCH_SRV_NAMEONLY Only the name portion of the principal
 
2391
 *                                 name must match, not the realm.
 
2392
 * @li #KRB5_TC_MATCH_2ND_TKT      The second tickets must match.
 
2393
 * @li #KRB5_TC_MATCH_KTYPE        The encryption key types must match.
 
2394
 * @li #KRB5_TC_SUPPORTED_KTYPES   Check all matching entries that have any
 
2395
 *                                 supported encryption type and return the
 
2396
 *                                 one with the encryption type listed earliest.
 
2397
 *
 
2398
 * Use krb5_free_cred_contents() to free @a creds when it is no longer needed.
 
2399
 *
 
2400
 * @retval 0 Success; otherwise - Kerberos error codes
 
2401
 */
1462
2402
krb5_error_code KRB5_CALLCONV
1463
2403
krb5_cc_retrieve_cred(krb5_context context, krb5_ccache cache,
1464
2404
                      krb5_flags flags, krb5_creds *mcreds,
1465
2405
                      krb5_creds *creds);
1466
2406
 
 
2407
/**
 
2408
 * Get the default principal of a credential cache.
 
2409
 *
 
2410
 * @param [in]  context         Library context
 
2411
 * @param [in]  cache           Credential cache handle
 
2412
 * @param [out] principal       Primary principal
 
2413
 *
 
2414
 * Returns the default client principal of a credential cache as set by
 
2415
 * krb5_cc_initialize().
 
2416
 *
 
2417
 * Use krb5_free_principal() to free @a principal when it is no longer needed.
 
2418
 *
 
2419
 * @retval
 
2420
 * 0  Success
 
2421
 * @return
 
2422
 * Kerberos error codes
 
2423
 */
1467
2424
krb5_error_code KRB5_CALLCONV
1468
2425
krb5_cc_get_principal(krb5_context context, krb5_ccache cache,
1469
2426
                      krb5_principal *principal);
1470
2427
 
 
2428
/**
 
2429
 * Prepare to sequentially read every credential in a credential cache.
 
2430
 *
 
2431
 * @param [in]  context         Library context
 
2432
 * @param [in]  cache           Credential cache handle
 
2433
 * @param [out] cursor          Cursor
 
2434
 *
 
2435
 * krb5_cc_end_seq_get() must be called to complete the retrieve operation.
 
2436
 *
 
2437
 * @note If @a cache is modified between the time of the call to this function
 
2438
 * and the time of the final krb5_cc_end_seq_get(), the results are undefined.
 
2439
 *
 
2440
 * @retval 0  Success; otherwise - Kerberos error codes
 
2441
 */
1471
2442
krb5_error_code KRB5_CALLCONV
1472
2443
krb5_cc_start_seq_get(krb5_context context, krb5_ccache cache,
1473
2444
                      krb5_cc_cursor *cursor);
1474
2445
 
 
2446
/**
 
2447
 * Retrieve the next entry from the credential cache.
 
2448
 *
 
2449
 * @param [in]     context      Library context
 
2450
 * @param [in]     cache        Credential cache handle
 
2451
 * @param [in,out] cursor       Cursor
 
2452
 * @param [out]    creds        Next credential cache entry
 
2453
 *
 
2454
 * This function fills in @a creds with the next entry in @a cache and advances
 
2455
 * @a cursor.
 
2456
 *
 
2457
 * Use krb5_free_cred_contents() to free @a creds when it is no longer needed.
 
2458
 *
 
2459
 * @sa krb5_cc_start_seq_get(), krb5_end_seq_get()
 
2460
 *
 
2461
 * @retval 0 Success; otherwise - Kerberos error codes
 
2462
 */
1475
2463
krb5_error_code KRB5_CALLCONV
1476
2464
krb5_cc_next_cred(krb5_context context, krb5_ccache cache,
1477
2465
                  krb5_cc_cursor *cursor, krb5_creds *creds);
1478
2466
 
 
2467
/**
 
2468
 * Finish a series of sequential processing credential cache entries.
 
2469
 *
 
2470
 * @param [in]     context      Library context
 
2471
 * @param [in]     cache        Credential cache handle
 
2472
 * @param [in,out] cursor       Cursor
 
2473
 *
 
2474
 * This function finishes processing credential cache entries and invalidates
 
2475
 * @a cursor.
 
2476
 *
 
2477
 * @sa krb5_cc_start_seq_get(), krb5_cc_next_cred()
 
2478
 *
 
2479
 * @retval 0 (always)
 
2480
 */
1479
2481
krb5_error_code KRB5_CALLCONV
1480
2482
krb5_cc_end_seq_get(krb5_context context, krb5_ccache cache,
1481
2483
                    krb5_cc_cursor *cursor);
1482
2484
 
 
2485
/**
 
2486
 * Remove credentials from a credential cache.
 
2487
 *
 
2488
 * @param [in] context          Library context
 
2489
 * @param [in] cache            Credential cache handle
 
2490
 * @param [in] flags            Bitwise-ORed search flags
 
2491
 * @param [in] creds            Credentials to be matched
 
2492
 *
 
2493
 * @warning This function is not implemented for some cache types.
 
2494
 *
 
2495
 * This function accepts the same flag values as krb5_cc_retrieve_cred().
 
2496
 *
 
2497
 * @retval KRB5_CC_NOSUPP Not implemented for this cache type
 
2498
 * @return No matches found; Data cannot be deleted; Kerberos error codes
 
2499
 */
1483
2500
krb5_error_code KRB5_CALLCONV
1484
2501
krb5_cc_remove_cred(krb5_context context, krb5_ccache cache, krb5_flags flags,
1485
2502
                    krb5_creds *creds);
1486
2503
 
 
2504
/**
 
2505
 * Set options flags on a credential cache.
 
2506
 *
 
2507
 * @param [in]     context      Library context
 
2508
 * @param [in,out] cache        Credential cache handle
 
2509
 * @param [in]     flags        Flag bit mask
 
2510
 *
 
2511
 * This function resets @a cache flags to @a flags.
 
2512
 *
 
2513
 * @retval 0 Success; otherwise - Kerberos error codes
 
2514
 */
1487
2515
krb5_error_code KRB5_CALLCONV
1488
2516
krb5_cc_set_flags(krb5_context context, krb5_ccache cache, krb5_flags flags);
1489
2517
 
 
2518
/**
 
2519
 * Retrieve flags from a credential cache structure.
 
2520
 *
 
2521
 * @param [in]  context         Library context
 
2522
 * @param [in]  cache           Credential cache handle
 
2523
 * @param [out] flags           Flag bit mask
 
2524
 *
 
2525
 * @warning For memory credential cache always returns a flag mask of 0.
 
2526
 *
 
2527
 * @retval 0 Success; otherwise - Kerberos error codes
 
2528
 */
1490
2529
krb5_error_code KRB5_CALLCONV
1491
2530
krb5_cc_get_flags(krb5_context context, krb5_ccache cache, krb5_flags *flags);
1492
2531
 
1493
 
/** Retrieve the type of a credential cache.
1494
 
 *
1495
 
 * @return The type of a credential cache as an alias that should not be
1496
 
 * modified or freed by the caller.
 
2532
/**
 
2533
 * Retrieve the type of a credential cache.
 
2534
 *
 
2535
 * @param [in] context          Library context
 
2536
 * @param [in] cache            Credential cache handle
 
2537
 *
 
2538
 * @return The type of a credential cache as an alias that must not be modified
 
2539
 * or freed by the caller.
1497
2540
 */
1498
2541
const char * KRB5_CALLCONV
1499
2542
krb5_cc_get_type(krb5_context context, krb5_ccache cache);
1500
2543
 
 
2544
/**
 
2545
 * Move a credential cache.
 
2546
 *
 
2547
 * @param [in] context          Library context
 
2548
 * @param [in] src              The credential cache to move the content from
 
2549
 * @param [in] dst              The credential cache to move the content to
 
2550
 *
 
2551
 * This function reinitializes @a dst and populates it with the credentials and
 
2552
 * default principal of @a src; then, if successful, destroys @a src.
 
2553
 *
 
2554
 * @retval
 
2555
 * 0 Success; @a src is closed.
 
2556
 * @return
 
2557
 * Kerberos error codes; @a src is still allocated.
 
2558
 */
1501
2559
krb5_error_code KRB5_CALLCONV
1502
2560
krb5_cc_move(krb5_context context, krb5_ccache src, krb5_ccache dst);
1503
2561
 
 
2562
/**
 
2563
 * Return a timestamp of the last modification to a credential cache.
 
2564
 *
 
2565
 * @param [in]  context         Library context
 
2566
 * @param [in]  ccache          Credential cache handle
 
2567
 * @param [out] change_time     The last change time of @a ccache
 
2568
 *
 
2569
 * If an error occurs, @a change_time is set to 0.
 
2570
 */
1504
2571
krb5_error_code KRB5_CALLCONV
1505
2572
krb5_cc_last_change_time(krb5_context context, krb5_ccache ccache,
1506
2573
                         krb5_timestamp *change_time);
1507
2574
 
 
2575
/**
 
2576
 * Lock a credential cache.
 
2577
 *
 
2578
 * @param [in]  context         Library context
 
2579
 * @param [in]  ccache          Credential cache handle
 
2580
 *
 
2581
 * Use krb5_cc_unlock() to unlock the lock.
 
2582
 *
 
2583
 * @retval 0 Success; otherwise - Kerberos error codes
 
2584
 */
1508
2585
krb5_error_code KRB5_CALLCONV
1509
2586
krb5_cc_lock(krb5_context context, krb5_ccache ccache);
1510
2587
 
 
2588
/**
 
2589
 * Unlock a credential cache.
 
2590
 *
 
2591
 * @param [in]  context         Library context
 
2592
 * @param [in]  ccache          Credential cache handle
 
2593
 *
 
2594
 * This function unlocks the @a ccache locked by krb5_cc_lock().
 
2595
 *
 
2596
 * @retval 0 Success; otherwise - Kerberos error codes
 
2597
 */
1511
2598
krb5_error_code KRB5_CALLCONV
1512
2599
krb5_cc_unlock(krb5_context context, krb5_ccache ccache);
1513
2600
 
 
2601
/**
 
2602
 * Prepare to iterate over the collection of known credential caches.
 
2603
 *
 
2604
 * @param [in]     context      Library context
 
2605
 * @param [in,out] cursor       Cursor
 
2606
 *
 
2607
 * Get a new cache iteration @a cursor that will iterate over all known
 
2608
 * credential caches independent of type.
 
2609
 *
 
2610
 * Use krb5_cccol_cursor_free() to release @a cursor when it is no longer
 
2611
 * needed.
 
2612
 *
 
2613
 * @sa krb5_cccol_cursor_next()
 
2614
 *
 
2615
 * @retval 0 Success; otherwise - Kerberos error codes
 
2616
 */
1514
2617
krb5_error_code KRB5_CALLCONV
1515
2618
krb5_cccol_cursor_new(krb5_context context, krb5_cccol_cursor *cursor);
1516
2619
 
 
2620
/**
 
2621
 * Get the next credential cache in the collection.
 
2622
 *
 
2623
 * @param [in]     context      Library context
 
2624
 * @param [in,out] cursor       Cursor
 
2625
 * @param [out]    ccache       Credential cache handle
 
2626
 *
 
2627
 * @note When all caches are iterated over and the end of the list is reached,
 
2628
 * @a ccache is set to NULL.
 
2629
 *
 
2630
 * Use krb5_cc_close() to close @a ccache when it is no longer needed.
 
2631
 *
 
2632
 * @sa krb5_cccol_cursor_new(), krb5_cccol_cursor_free()
 
2633
 *
 
2634
 * @retval 0 Success; otherwise - Kerberos error codes
 
2635
 */
1517
2636
krb5_error_code KRB5_CALLCONV
1518
2637
krb5_cccol_cursor_next(krb5_context context, krb5_cccol_cursor cursor,
1519
2638
                       krb5_ccache *ccache);
1520
2639
 
 
2640
/**
 
2641
 * Free a credential cache collection cursor.
 
2642
 *
 
2643
 * @param [in] context          Library context
 
2644
 * @param [in] cursor           Cursor
 
2645
 *
 
2646
 * @sa krb5_cccol_cursor_new(), krb5_cccol_cursor_next()
 
2647
 *
 
2648
 * @retval 0 Success; otherwise - Kerberos error codes
 
2649
 */
1521
2650
krb5_error_code KRB5_CALLCONV
1522
2651
krb5_cccol_cursor_free(krb5_context context, krb5_cccol_cursor *cursor);
1523
2652
 
 
2653
/**
 
2654
 * Return a timestamp of the last modification of any known credential cache.
 
2655
 *
 
2656
 * @param [in]  context         Library context
 
2657
 * @param [out] change_time     Last modification timestamp
 
2658
 *
 
2659
 * This function returns the most recent modification time of any known
 
2660
 * credential cache, ignoring any caches which cannot supply a last
 
2661
 * modification time.
 
2662
 *
 
2663
 * If there are no known credential caches, @a change_time is set to 0.
 
2664
 *
 
2665
 * @retval 0 Success; otherwise - Kerberos error codes
 
2666
 */
1524
2667
krb5_error_code KRB5_CALLCONV
1525
2668
krb5_cccol_last_change_time(krb5_context context, krb5_timestamp *change_time);
1526
2669
 
 
2670
/**
 
2671
 * Acquire a global lock for credential caches.
 
2672
 *
 
2673
 * @param [in]  context         Library context
 
2674
 *
 
2675
 * This function locks the global credential cache collection, ensuring
 
2676
 * that no ccaches are added to or removed from it until the collection
 
2677
 * lock is released.
 
2678
 *
 
2679
 * Use krb5_cccol_unlock() to unlock the lock.
 
2680
 *
 
2681
 * @retval 0 Success; otherwise - Kerberos error codes
 
2682
 */
 
2683
 
1527
2684
krb5_error_code KRB5_CALLCONV
1528
2685
krb5_cccol_lock(krb5_context context);
1529
2686
 
 
2687
/**
 
2688
 * Release a global lock for credential caches.
 
2689
 *
 
2690
 * @param [in]  context         Library context
 
2691
 *
 
2692
 * This function unlocks the lock from krb5_cccol_lock().
 
2693
 *
 
2694
 * @retval 0 Success; otherwise - Kerberos error codes
 
2695
 */
1530
2696
krb5_error_code KRB5_CALLCONV
1531
2697
krb5_cccol_unlock(krb5_context context);
1532
2698
 
 
2699
/**
 
2700
 * Create a new credential cache of the specified type with a unique name.
 
2701
 *
 
2702
 * @param [in]  context         Library context
 
2703
 * @param [in]  type            Credential cache type name
 
2704
 * @param [in]  hint            Unused
 
2705
 * @param [out] id              Credential cache handle
 
2706
 *
 
2707
 * @retval
 
2708
 * 0 Success
 
2709
 * @return
 
2710
 * Kerberos error codes
 
2711
 */
1533
2712
krb5_error_code KRB5_CALLCONV
1534
2713
krb5_cc_new_unique(krb5_context context, const char *type, const char *hint,
1535
2714
                   krb5_ccache *id);
1557
2736
/* XXX */
1558
2737
#define MAX_KEYTAB_NAME_LEN 1100 /* Long enough for MAXPATHLEN + some extra */
1559
2738
 
1560
 
typedef krb5_pointer krb5_kt_cursor;    /* XXX */
 
2739
typedef krb5_pointer krb5_kt_cursor;
1561
2740
 
 
2741
/** A key table entry. */
1562
2742
typedef struct krb5_keytab_entry_st {
1563
2743
    krb5_magic magic;
1564
 
    krb5_principal principal;   /* principal of this key */
1565
 
    krb5_timestamp timestamp;   /* time entry written to keytable */
1566
 
    krb5_kvno vno;              /* key version number */
1567
 
    krb5_keyblock key;          /* the secret key */
 
2744
    krb5_principal principal;   /**< Principal of this key */
 
2745
    krb5_timestamp timestamp;   /**< Time entry written to keytable */
 
2746
    krb5_kvno vno;              /**< Key version number */
 
2747
    krb5_keyblock key;          /**< The secret key */
1568
2748
} krb5_keytab_entry;
1569
2749
 
1570
2750
struct _krb5_kt;
1571
2751
typedef struct _krb5_kt *krb5_keytab;
1572
2752
 
 
2753
/**
 
2754
 * Return the type of a key table.
 
2755
 *
 
2756
 * @param [in] context          Library context
 
2757
 * @param [in] keytab           Key table handle
 
2758
 *
 
2759
 * @return The type of a key table as an alias that must not be modified or
 
2760
 * freed by the caller.
 
2761
 */
1573
2762
const char * KRB5_CALLCONV
1574
 
krb5_kt_get_type(krb5_context, krb5_keytab keytab);
 
2763
krb5_kt_get_type(krb5_context context, krb5_keytab keytab);
1575
2764
 
 
2765
/**
 
2766
 * Get a key table name.
 
2767
 *
 
2768
 * @param [in]  context         Library context
 
2769
 * @param [in]  keytab          Key table handle
 
2770
 * @param [out] name            Key table name
 
2771
 * @param [in]  namelen         Maximum length to fill in name
 
2772
 *
 
2773
 * Fills in @a with the name of @a keytab including the type and delimiter.
 
2774
 *
 
2775
 * @sa MAX_KEYTAB_NAME_LEN
 
2776
 *
 
2777
 * @retval
 
2778
 * 0 Success
 
2779
 * @retval
 
2780
 * KRB5_KT_NAME_TOOLONG  Key table name does not fit in @a namelen bytes
 
2781
 *
 
2782
 * @return
 
2783
 * Kerberos error codes
 
2784
 */
1576
2785
krb5_error_code KRB5_CALLCONV
1577
2786
krb5_kt_get_name(krb5_context context, krb5_keytab keytab, char *name,
1578
2787
                 unsigned int namelen);
1579
2788
 
 
2789
/**
 
2790
 * Close a key table handle.
 
2791
 *
 
2792
 * @param [in] context          Library context
 
2793
 * @param [in] keytab           Key table handle
 
2794
 *
 
2795
 * @retval 0
 
2796
 */
1580
2797
krb5_error_code KRB5_CALLCONV
1581
2798
krb5_kt_close(krb5_context context, krb5_keytab keytab);
1582
2799
 
 
2800
/**
 
2801
 * Get an entry from a key table.
 
2802
 *
 
2803
 * @param [in]  context         Library context
 
2804
 * @param [in]  keytab          Key table handle
 
2805
 * @param [in]  principal       Principal name
 
2806
 * @param [in]  vno             Key version number (0 for highest available)
 
2807
 * @param [in]  enctype         Encryption type (0 zero for any enctype)
 
2808
 * @param [out] entry           Returned entry from key table
 
2809
 *
 
2810
 * Retrieve an entry from a key table which matches the @a keytab, @a
 
2811
 * principal, @a vno, and @a enctype.  If @a vno is zero, retrieve the
 
2812
 * highest-numbered kvno matching the other fields.  If @a enctype is 0, match
 
2813
 * any enctype.
 
2814
 *
 
2815
 * Use krb5_free_keytab_entry_contents() to free @a entry when it is no longer
 
2816
 * needed.
 
2817
 *
 
2818
 * @note If @a vno is zero, the function retrieves the highest-numbered-kvno
 
2819
 * entry that matches the specified principal.
 
2820
 *
 
2821
 * @retval
 
2822
 * 0 Success
 
2823
 * @retval
 
2824
 * Kerberos error codes on failure
 
2825
 */
1583
2826
krb5_error_code KRB5_CALLCONV
1584
2827
krb5_kt_get_entry(krb5_context context, krb5_keytab keytab,
1585
2828
                  krb5_const_principal principal, krb5_kvno vno,
1586
2829
                  krb5_enctype enctype, krb5_keytab_entry *entry);
1587
2830
 
 
2831
/**
 
2832
 * Start a sequential retrieval of key table entries.
 
2833
 *
 
2834
 * @param [in]  context         Library context
 
2835
 * @param [in]  keytab          Key table handle
 
2836
 * @param [out] cursor          Cursor
 
2837
 *
 
2838
 * Prepare to read sequentially every key in the specified key table.  Use
 
2839
 * krb5_kt_end_seq_get() to release the cursor when it is no longer needed.
 
2840
 *
 
2841
 * @sa krb5_kt_next_entry(), krb5_kt_end_seq_get()
 
2842
 *
 
2843
 * @retval
 
2844
 * 0 Success
 
2845
 * @return
 
2846
 * Kerberos error codes
 
2847
 */
1588
2848
krb5_error_code KRB5_CALLCONV
1589
2849
krb5_kt_start_seq_get(krb5_context context, krb5_keytab keytab,
1590
2850
                      krb5_kt_cursor *cursor);
1591
2851
 
 
2852
/**
 
2853
 * Retrieve the next entry from the key table.
 
2854
 *
 
2855
 * @param [in]  context         Library context
 
2856
 * @param [in]  keytab          Key table handle
 
2857
 * @param [out] entry           Returned key table entry
 
2858
 * @param [in,out] cursor       Key table cursor
 
2859
 *
 
2860
 * Return the next sequential entry in @a keytab and advance @a cursor.
 
2861
 *
 
2862
 * @sa krb5_kt_start_seq_get(), krb5_kt_end_seq_get()
 
2863
 *
 
2864
 * @retval
 
2865
 * 0 Success
 
2866
 * @retval
 
2867
 * KRB5_KT_END - if the last entry was reached
 
2868
 * @return
 
2869
 * Kerberos error codes
 
2870
 */
1592
2871
krb5_error_code KRB5_CALLCONV
1593
2872
krb5_kt_next_entry(krb5_context context, krb5_keytab keytab,
1594
2873
                   krb5_keytab_entry *entry, krb5_kt_cursor *cursor);
1595
2874
 
 
2875
/**
 
2876
 * Release a keytab cursor.
 
2877
 *
 
2878
 * @param [in]  context         Library context
 
2879
 * @param [in]  keytab          Key table handle
 
2880
 * @param [out] cursor          Cursor
 
2881
 *
 
2882
 * This function should be called to release the cursor created by
 
2883
 * krb5_kt_start_seq_get().
 
2884
 *
 
2885
 * @retval
 
2886
 * 0 Success
 
2887
 * @return
 
2888
 * Kerberos error codes
 
2889
 */
1596
2890
krb5_error_code KRB5_CALLCONV
1597
2891
krb5_kt_end_seq_get(krb5_context context, krb5_keytab keytab,
1598
2892
                    krb5_kt_cursor *cursor);
1605
2899
 * begin "func-proto.h"
1606
2900
 */
1607
2901
 
1608
 
krb5_error_code KRB5_CALLCONV krb5_init_context(krb5_context *);
1609
 
krb5_error_code KRB5_CALLCONV krb5_init_secure_context(krb5_context *);
1610
 
void KRB5_CALLCONV krb5_free_context(krb5_context);
1611
 
krb5_error_code KRB5_CALLCONV krb5_copy_context(krb5_context, krb5_context *);
1612
 
 
1613
 
krb5_error_code KRB5_CALLCONV
1614
 
krb5_set_default_tgs_enctypes(krb5_context, const krb5_enctype *);
1615
 
 
1616
 
krb5_error_code KRB5_CALLCONV
1617
 
krb5_get_permitted_enctypes(krb5_context, krb5_enctype **);
1618
 
 
1619
 
krb5_boolean KRB5_CALLCONV krb5_is_thread_safe(void);
 
2902
#define KRB5_INIT_CONTEXT_SECURE 0x1 /**< Use secure context configuration */
 
2903
#define KRB5_INIT_CONTEXT_KDC    0x2 /**< Use KDC configuration if available */
 
2904
 
 
2905
/**
 
2906
 * Create a krb5 library context.
 
2907
 *
 
2908
 * @param [out] context         Library context
 
2909
 *
 
2910
 * The @a context must be released by calling krb5_free_context() when
 
2911
 * it is no longer needed.
 
2912
 *
 
2913
 * @warning Any program or module that needs the Kerberos code to not trust the
 
2914
 * environment must use krb5_init_secure_context(), or clean out the
 
2915
 * environment.
 
2916
 *
 
2917
 * @retval
 
2918
 * 0 Success
 
2919
 * @return
 
2920
 * Kerberos error codes
 
2921
 */
 
2922
krb5_error_code KRB5_CALLCONV
 
2923
krb5_init_context(krb5_context *context);
 
2924
 
 
2925
/**
 
2926
 * Create a krb5 library context using only configuration files.
 
2927
 *
 
2928
 * @param [out] context         Library context
 
2929
 *
 
2930
 * Create a context structure, using only system configuration files.  All
 
2931
 * information passed through the environment variables is ignored.
 
2932
 *
 
2933
 * The @a context must be released by calling krb5_free_context() when
 
2934
 * it is no longer needed.
 
2935
 *
 
2936
 * @retval
 
2937
 * 0 Success
 
2938
 * @return
 
2939
 * Kerberos error codes
 
2940
 */
 
2941
krb5_error_code KRB5_CALLCONV
 
2942
krb5_init_secure_context(krb5_context *context);
 
2943
 
 
2944
/**
 
2945
 * Create a krb5 library context using a specified profile.
 
2946
 *
 
2947
 * @param [in]  profile         Profile object (NULL to create default profile)
 
2948
 * @param [in]  flags           Context initialization flags
 
2949
 * @param [out] context         Library context
 
2950
 *
 
2951
 * Create a context structure, optionally using a specified profile and
 
2952
 * initialization flags.  If @a profile is NULL, the default profile will be
 
2953
 * created from config files.  If @a profile is non-null, a copy of it will be
 
2954
 * made for the new context; the caller should still clean up its copy.  Valid
 
2955
 * flag values are:
 
2956
 *
 
2957
 * @li #KRB5_INIT_CONTEXT_SECURE Ignore environment variables
 
2958
 * @li #KRB5_INIT_CONTEXT_KDC    Use KDC configuration if creating profile
 
2959
 */
 
2960
krb5_error_code KRB5_CALLCONV
 
2961
krb5_init_context_profile(struct _profile_t *profile, krb5_flags flags,
 
2962
                          krb5_context *context);
 
2963
 
 
2964
/**
 
2965
 * Free a krb5 library context.
 
2966
 *
 
2967
 * @param [in] context          Library context
 
2968
 *
 
2969
 * This function frees a @a context that was created by krb5_init_context()
 
2970
 * or krb5_init_secure_context().
 
2971
 */
 
2972
void KRB5_CALLCONV
 
2973
krb5_free_context(krb5_context context);
 
2974
 
 
2975
/**
 
2976
 * Copy a krb5_context structure.
 
2977
 *
 
2978
 * @param [in]  ctx             Library context
 
2979
 * @param [out] nctx_out        New context structure
 
2980
 *
 
2981
 * The newly created context must be released by calling krb5_free_context()
 
2982
 * when it is no longer needed.
 
2983
 *
 
2984
 * @retval
 
2985
 * 0 Success
 
2986
 * @return
 
2987
 * Kerberos error codes
 
2988
 */
 
2989
krb5_error_code KRB5_CALLCONV
 
2990
krb5_copy_context(krb5_context ctx, krb5_context *nctx_out);
 
2991
 
 
2992
/**
 
2993
 * Set default TGS encryption types in a krb5_context structure.
 
2994
 *
 
2995
 * @param [in,out] context      Library context
 
2996
 * @param [in]     etypes       Encryption type(s) to set
 
2997
 *
 
2998
 * This function sets the default enctype list for TGS requests
 
2999
 * made using @a context to @a etypes.
 
3000
 *
 
3001
 * @note This overrides the default list (from config file or built-in).
 
3002
 *
 
3003
 * @retval
 
3004
 *  0    Success
 
3005
 * @retval
 
3006
 *  KRB5_PROG_ETYPE_NOSUPP Program lacks support for encryption type
 
3007
 * @return
 
3008
 * Kerberos error codes
 
3009
 */
 
3010
krb5_error_code KRB5_CALLCONV
 
3011
krb5_set_default_tgs_enctypes(krb5_context context, const krb5_enctype *etypes);
 
3012
 
 
3013
/**
 
3014
 * Return a list of encryption types permitted for session keys.
 
3015
 *
 
3016
 * @param [in]  context         Library context
 
3017
 * @param [out] ktypes          Zero-terminated list of encryption types
 
3018
 *
 
3019
 * This function returns the list of encryption types permitted for session
 
3020
 * keys within @a context, as determined by configuration or by a previous call
 
3021
 * to krb5_set_default_tgs_enctypes().
 
3022
 *
 
3023
 * @retval 0 Success; otherwise - Kerberos error codes
 
3024
 */
 
3025
krb5_error_code KRB5_CALLCONV
 
3026
krb5_get_permitted_enctypes(krb5_context context, krb5_enctype **ktypes);
 
3027
 
 
3028
/**
 
3029
 * Test whether the Kerberos library was built with multithread support.
 
3030
 *
 
3031
 * @retval
 
3032
 * TRUE if the library is threadsafe; FALSE otherwise
 
3033
 */
 
3034
krb5_boolean KRB5_CALLCONV
 
3035
krb5_is_thread_safe(void);
1620
3036
 
1621
3037
/* libkrb.spec */
1622
3038
 
 
3039
/**
 
3040
 * Decrypt a ticket using the specified key table.
 
3041
 *
 
3042
 * @param [in]     context      Library context
 
3043
 * @param [in]     kt           Key table
 
3044
 * @param [in,out] ticket       Ticket to be decrypted
 
3045
 *
 
3046
 * This function takes a @a ticket as input and decrypts it using
 
3047
 * key data from @a kt.  The result is placed into @a ticket->enc_part2.
 
3048
 *
 
3049
 * @retval 0 Success; otherwise - Kerberos error codes
 
3050
 */
1623
3051
krb5_error_code KRB5_CALLCONV
1624
3052
krb5_server_decrypt_ticket_keytab(krb5_context context, const krb5_keytab kt,
1625
3053
                                  krb5_ticket *ticket);
1626
3054
 
1627
 
void KRB5_CALLCONV krb5_free_tgt_creds(krb5_context, krb5_creds **);
1628
 
 
1629
 
#define KRB5_GC_USER_USER       1       /* want user-user ticket */
1630
 
#define KRB5_GC_CACHED          2       /* want cached ticket only */
1631
 
#define KRB5_GC_CANONICALIZE    4       /* set canonicalize KDC option */
1632
 
#define KRB5_GC_NO_STORE        8       /* do not store in credentials cache */
1633
 
#define KRB5_GC_FORWARDABLE             16  /* acquire forwardable tickets */
1634
 
#define KRB5_GC_NO_TRANSIT_CHECK        32  /* disable transited check */
1635
 
#define KRB5_GC_CONSTRAINED_DELEGATION  64  /* constrained delegation */
1636
 
 
1637
 
krb5_error_code KRB5_CALLCONV
1638
 
krb5_get_credentials(krb5_context, krb5_flags, krb5_ccache, krb5_creds *,
1639
 
                     krb5_creds **);
1640
 
 
1641
 
krb5_error_code KRB5_CALLCONV
1642
 
krb5_get_credentials_validate(krb5_context, krb5_flags, krb5_ccache,
1643
 
                              krb5_creds *, krb5_creds **);
1644
 
 
1645
 
krb5_error_code KRB5_CALLCONV
1646
 
krb5_get_credentials_renew(krb5_context, krb5_flags, krb5_ccache, krb5_creds *,
1647
 
                           krb5_creds **);
1648
 
 
1649
 
krb5_error_code KRB5_CALLCONV
1650
 
krb5_mk_req(krb5_context, krb5_auth_context *, krb5_flags, char *, char *,
1651
 
            krb5_data *, krb5_ccache, krb5_data *);
1652
 
 
1653
 
krb5_error_code KRB5_CALLCONV
1654
 
krb5_mk_req_extended(krb5_context, krb5_auth_context *, krb5_flags,
1655
 
                     krb5_data *, krb5_creds *, krb5_data * );
1656
 
 
1657
 
krb5_error_code KRB5_CALLCONV
1658
 
krb5_mk_rep(krb5_context, krb5_auth_context, krb5_data *);
1659
 
 
1660
 
krb5_error_code KRB5_CALLCONV
1661
 
krb5_mk_rep_dce(krb5_context, krb5_auth_context, krb5_data *);
1662
 
 
1663
 
krb5_error_code KRB5_CALLCONV
1664
 
krb5_rd_rep(krb5_context, krb5_auth_context, const krb5_data *,
1665
 
            krb5_ap_rep_enc_part **);
1666
 
 
1667
 
krb5_error_code KRB5_CALLCONV
1668
 
krb5_rd_rep_dce(krb5_context, krb5_auth_context, const krb5_data *,
1669
 
                krb5_ui_4 *);
1670
 
 
1671
 
krb5_error_code KRB5_CALLCONV
1672
 
krb5_mk_error(krb5_context, const krb5_error *, krb5_data *);
1673
 
 
1674
 
krb5_error_code KRB5_CALLCONV
1675
 
krb5_rd_error(krb5_context, const krb5_data *, krb5_error **);
1676
 
 
1677
 
krb5_error_code KRB5_CALLCONV
1678
 
krb5_rd_safe(krb5_context, krb5_auth_context, const krb5_data *, krb5_data *,
1679
 
             krb5_replay_data *);
1680
 
 
1681
 
krb5_error_code KRB5_CALLCONV
1682
 
krb5_rd_priv(krb5_context, krb5_auth_context, const krb5_data *, krb5_data *,
1683
 
             krb5_replay_data *);
1684
 
 
1685
 
krb5_error_code KRB5_CALLCONV
1686
 
krb5_parse_name(krb5_context, const char *, krb5_principal *);
1687
 
 
1688
 
#define KRB5_PRINCIPAL_PARSE_NO_REALM           0x1
1689
 
#define KRB5_PRINCIPAL_PARSE_REQUIRE_REALM      0x2
1690
 
#define KRB5_PRINCIPAL_PARSE_ENTERPRISE         0x4
1691
 
krb5_error_code KRB5_CALLCONV
1692
 
krb5_parse_name_flags(krb5_context, const char *, int, krb5_principal *);
1693
 
 
1694
 
krb5_error_code KRB5_CALLCONV
1695
 
krb5_unparse_name(krb5_context, krb5_const_principal, char **);
1696
 
 
1697
 
krb5_error_code KRB5_CALLCONV
1698
 
krb5_unparse_name_ext(krb5_context, krb5_const_principal, char **,
1699
 
                      unsigned int *);
1700
 
 
1701
 
#define KRB5_PRINCIPAL_UNPARSE_SHORT            0x1
1702
 
#define KRB5_PRINCIPAL_UNPARSE_NO_REALM         0x2
1703
 
#define KRB5_PRINCIPAL_UNPARSE_DISPLAY          0x4
1704
 
krb5_error_code KRB5_CALLCONV
1705
 
krb5_unparse_name_flags(krb5_context, krb5_const_principal, int, char **);
1706
 
 
1707
 
krb5_error_code KRB5_CALLCONV
1708
 
krb5_unparse_name_flags_ext(krb5_context, krb5_const_principal, int,
1709
 
                            char **, unsigned int *);
1710
 
 
1711
 
krb5_error_code KRB5_CALLCONV
1712
 
krb5_set_principal_realm(krb5_context, krb5_principal, const char *);
1713
 
 
 
3055
/**
 
3056
 * Free an array of credential structures.
 
3057
 *
 
3058
 * @param [in] context          Library context
 
3059
 * @param [in] tgts             Null-terminated array of credentials to free
 
3060
 *
 
3061
 * @note The last entry in the array @a tgts must be a NULL pointer.
 
3062
 */
 
3063
void KRB5_CALLCONV
 
3064
krb5_free_tgt_creds(krb5_context context, krb5_creds **tgts);
 
3065
 
 
3066
/** @defgroup KRB5_GC  KRB5_GC
 
3067
 * @{
 
3068
 */
 
3069
#define KRB5_GC_USER_USER    1  /**< Want user-user ticket */
 
3070
#define KRB5_GC_CACHED       2  /**< Want cached ticket only */
 
3071
#define KRB5_GC_CANONICALIZE 4  /**< Set canonicalize KDC option */
 
3072
#define KRB5_GC_NO_STORE     8  /**< Do not store in credential cache */
 
3073
#define KRB5_GC_FORWARDABLE             16  /**< Acquire forwardable tickets */
 
3074
#define KRB5_GC_NO_TRANSIT_CHECK        32  /**< Disable transited check */
 
3075
#define KRB5_GC_CONSTRAINED_DELEGATION  64  /**< Constrained delegation */
 
3076
/** @} */ /* end of KRB5_GC group */
 
3077
 
 
3078
/**
 
3079
 * Get an additional ticket.
 
3080
 *
 
3081
 * @param [in]     context      Library context
 
3082
 * @param [in]     options      Options
 
3083
 * @param [in,out] ccache       Credential cache handle
 
3084
 * @param [in]     in_creds     Input credentials
 
3085
 * @param [out]    out_creds    Output updated credentials
 
3086
 *
 
3087
 * Use @a ccache or a TGS exchange to get a service ticket matching @a
 
3088
 * in_creds.
 
3089
 *
 
3090
 * Valid values for @a options are:
 
3091
 * @li #KRB5_GC_CACHED     Search only credential cache for the ticket
 
3092
 * @li #KRB5_GC_USER_USER  Return a user to user authentication ticket
 
3093
 *
 
3094
 * @a in_creds must be non-null.  @a in_creds->client and @a in_creds->server
 
3095
 * must be filled in to specify the client and the server respectively.  If any
 
3096
 * authorization data needs to be requested for the service ticket (such as
 
3097
 * restrictions on how the ticket can be used), specify it in @a
 
3098
 * in_creds->authdata; otherwise set @a in_creds->authdata to NULL.  The
 
3099
 * session key type is specified in @a in_creds->keyblock.enctype, if it is
 
3100
 * nonzero.
 
3101
 *
 
3102
 * The expiration date is specified in @a in_creds->times.endtime.
 
3103
 * The KDC may return tickets with an earlier expiration date.
 
3104
 * If @a in_creds->times.endtime is set to 0, the latest possible
 
3105
 * expiration date will be requested.
 
3106
 *
 
3107
 * Any returned ticket and intermediate ticket-granting tickets are stored
 
3108
 * in @a ccache.
 
3109
 *
 
3110
 * Use krb5_free_creds() to free @a out_creds when it is no longer needed.
 
3111
 *
 
3112
 * @retval
 
3113
 *  0  Success
 
3114
 * @return
 
3115
 * Kerberos error codes
 
3116
 */
 
3117
krb5_error_code KRB5_CALLCONV
 
3118
krb5_get_credentials(krb5_context context, krb5_flags options,
 
3119
                     krb5_ccache ccache, krb5_creds *in_creds,
 
3120
                     krb5_creds **out_creds);
 
3121
 
 
3122
/** @deprecated Replaced by krb5_get_validated_creds. */
 
3123
krb5_error_code KRB5_CALLCONV
 
3124
krb5_get_credentials_validate(krb5_context context, krb5_flags options,
 
3125
                              krb5_ccache ccache, krb5_creds *in_creds,
 
3126
                              krb5_creds **out_creds);
 
3127
 
 
3128
/** @deprecated Replaced by krb5_get_renewed_creds. */
 
3129
krb5_error_code KRB5_CALLCONV
 
3130
krb5_get_credentials_renew(krb5_context context, krb5_flags options,
 
3131
                           krb5_ccache ccache, krb5_creds *in_creds,
 
3132
                           krb5_creds **out_creds);
 
3133
 
 
3134
/**
 
3135
 * Create a @c KRB_AP_REQ message.
 
3136
 *
 
3137
 * @param [in]     context        Library context
 
3138
 * @param [in,out] auth_context   Pre-existing or newly created auth context
 
3139
 * @param [in]     ap_req_options @ref AP_OPTS options
 
3140
 * @param [in]     service        Service name, or NULL to use @c "host"
 
3141
 * @param [in]     hostname       Host name, or NULL to use local hostname
 
3142
 * @param [in]     in_data        Application data to be checksummed in the
 
3143
 *                                authenticator, or NULL
 
3144
 * @param [in]     ccache         Credential cache used to obtain credentials
 
3145
 *                                for the desired service.
 
3146
 * @param [out]    outbuf         @c AP-REQ message
 
3147
 *
 
3148
 * This function is similar to krb5_mk_req_extended() except that it uses a
 
3149
 * given @a hostname, @a service, and @a ccache to construct a service
 
3150
 * principal name and obtain credentials.
 
3151
 *
 
3152
 * Use krb5_free_data_contents() to free @a outbuf when it is no longer needed.
 
3153
 *
 
3154
 * @retval 0 Success; otherwise - Kerberos error codes
 
3155
 */
 
3156
krb5_error_code KRB5_CALLCONV
 
3157
krb5_mk_req(krb5_context context, krb5_auth_context *auth_context,
 
3158
            krb5_flags ap_req_options, char *service, char *hostname,
 
3159
            krb5_data *in_data, krb5_ccache ccache, krb5_data *outbuf);
 
3160
 
 
3161
/**
 
3162
 * Create a @c KRB_AP_REQ message using supplied credentials.
 
3163
 *
 
3164
 * @param [in]     context        Library context
 
3165
 * @param [in,out] auth_context   Pre-existing or newly created auth context
 
3166
 * @param [in]     ap_req_options @ref AP_OPTS options
 
3167
 * @param [in]     in_data        Application data to be checksummed in the
 
3168
 *                                authenticator, or NULL
 
3169
 * @param [in]     in_creds       Credentials for the service with valid ticket
 
3170
 *                                and key
 
3171
 * @param [out]    outbuf         @c AP-REQ message
 
3172
 *
 
3173
 * Valid @a ap_req_options are:
 
3174
 * @li #AP_OPTS_USE_SESSION_KEY - Use the session key when creating the
 
3175
 *                                request used for user to user
 
3176
 *                                authentication.
 
3177
 * @li #AP_OPTS_MUTUAL_REQUIRED - Request a mutual authentication packet from
 
3178
 *                                the reciever.
 
3179
 * @li #AP_OPTS_USE_SUBKEY      - Generate a subsession key from the current
 
3180
 *                                session key obtained from the credentials.
 
3181
 *
 
3182
 * This function creates a KRB_AP_REQ message using supplied credentials @a
 
3183
 * in_creds.  @a auth_context may point to an existing auth context or to NULL,
 
3184
 * in which case a new one will be created.  If @a in_data is non-null, a
 
3185
 * checksum of it will be included in the authenticator contained in the
 
3186
 * KRB_AP_REQ message.  Use krb5_free_data_contents() to free @a outbuf when it
 
3187
 * is no longer needed.
 
3188
 *
 
3189
 * On successful return, the authenticator is stored in @a auth_context with
 
3190
 * the @a client and @a checksum fields nulled out.  (This is to prevent
 
3191
 * pointer-sharing problems; the caller should not need these fields anyway,
 
3192
 * since the caller supplied them.)
 
3193
 *
 
3194
 * @sa krb5_mk_req()
 
3195
 *
 
3196
 * @retval 0 Success; otherwise - Kerberos error codes
 
3197
 */
 
3198
krb5_error_code KRB5_CALLCONV
 
3199
krb5_mk_req_extended(krb5_context context, krb5_auth_context *auth_context,
 
3200
                     krb5_flags ap_req_options, krb5_data *in_data,
 
3201
                     krb5_creds *in_creds, krb5_data *outbuf);
 
3202
 
 
3203
/**
 
3204
 * Format and encrypt a @c KRB_AP_REP message.
 
3205
 *
 
3206
 * @param [in]     context      Library context
 
3207
 * @param [in,out] auth_context Authentication context
 
3208
 * @param [out]    outbuf       @c AP-REP message
 
3209
 *
 
3210
 * This function fills in @a outbuf with an AP-REP message using information
 
3211
 * from @a auth_context.
 
3212
 *
 
3213
 * If the flags in @a auth_context indicate that a sequence number should be
 
3214
 * used (either #KRB5_AUTH_CONTEXT_DO_SEQUENCE or
 
3215
 * #KRB5_AUTH_CONTEXT_RET_SEQUENCE) and the local sequence number in @a
 
3216
 * auth_context is 0, a new number will be generated with
 
3217
 * krb5_generate_seq_number().
 
3218
 *
 
3219
 * Use krb5_free_data_contents() to free @a outbuf when it is no longer needed.
 
3220
 *
 
3221
 * @retval 0 Success; otherwise - Kerberos error codes
 
3222
 */
 
3223
krb5_error_code KRB5_CALLCONV
 
3224
krb5_mk_rep(krb5_context context, krb5_auth_context auth_context, krb5_data *outbuf);
 
3225
 
 
3226
/**
 
3227
 * Format and encrypt a @c KRB_AP_REP message for DCE RPC.
 
3228
 *
 
3229
 * @param [in]     context           Library context
 
3230
 * @param [in,out] auth_context      Authentication context
 
3231
 * @param [out]    outbuf            @c AP-REP message
 
3232
 *
 
3233
 * Use krb5_free_data_contents() to free @a outbuf when it is no longer needed.
 
3234
 *
 
3235
 * @retval 0 Success; otherwise - Kerberos error codes
 
3236
 */
 
3237
krb5_error_code KRB5_CALLCONV
 
3238
krb5_mk_rep_dce(krb5_context context, krb5_auth_context auth_context, krb5_data *outbuf);
 
3239
 
 
3240
/**
 
3241
 * Parse and decrypt a @c KRB_AP_REP message.
 
3242
 *
 
3243
 * @param [in]     context      Library context
 
3244
 * @param [in,out] auth_context Authentication context
 
3245
 * @param [in]     inbuf        AP-REP message
 
3246
 * @param [out]    repl         Decrypted reply message
 
3247
 *
 
3248
 * This function parses, decrypts and verifies a message from @a inbuf and
 
3249
 * fills in @a repl with a pointer to allocated memory containing the fields
 
3250
 * from the encrypted response.
 
3251
 *
 
3252
 * Use krb5_free_ap_rep_enc_part() to free @a repl when it is no longer needed.
 
3253
 *
 
3254
 * @retval 0 Success; otherwise - Kerberos error codes
 
3255
 */
 
3256
krb5_error_code KRB5_CALLCONV
 
3257
krb5_rd_rep(krb5_context context, krb5_auth_context auth_context,
 
3258
            const krb5_data *inbuf, krb5_ap_rep_enc_part **repl);
 
3259
 
 
3260
/**
 
3261
 * Parse and decrypt a @c KRB_AP_REP message for DCE RPC.
 
3262
 *
 
3263
 * @param [in]     context      Library context
 
3264
 * @param [in,out] auth_context Authentication context
 
3265
 * @param [in]     inbuf        AP-REP message
 
3266
 * @param [out]    nonce        Sequence number from the decrypted reply
 
3267
 *
 
3268
 * This function parses, decrypts and verifies a message from @a inbuf and
 
3269
 * fills in @a nonce with a decrypted reply sequence number.
 
3270
 *
 
3271
 * @retval 0 Success; otherwise - Kerberos error codes
 
3272
 */
 
3273
krb5_error_code KRB5_CALLCONV
 
3274
krb5_rd_rep_dce(krb5_context context, krb5_auth_context auth_context,
 
3275
                const krb5_data *inbuf, krb5_ui_4 *nonce);
 
3276
 
 
3277
/**
 
3278
 * Format and encode a @c KRB_ERROR message.
 
3279
 *
 
3280
 * @param [in]  context         Library context
 
3281
 * @param [in]  dec_err         Error structure to be encoded
 
3282
 * @param [out] enc_err         Encoded error structure
 
3283
 *
 
3284
 * This function creates a @c KRB_ERROR message in @a enc_err.  Use
 
3285
 * krb5_free_data_contents() to free @a enc_err when it is no longer needed.
 
3286
 *
 
3287
 * @retval 0 Success; otherwise - Kerberos error codes
 
3288
 */
 
3289
krb5_error_code KRB5_CALLCONV
 
3290
krb5_mk_error(krb5_context context, const krb5_error *dec_err,
 
3291
              krb5_data *enc_err);
 
3292
 
 
3293
/**
 
3294
 * Decode a @c KRB-ERROR message.
 
3295
 *
 
3296
 * @param [in]  context         Library context
 
3297
 * @param [in]  enc_errbuf      Encoded error message
 
3298
 * @param [out] dec_error       Decoded error message
 
3299
 *
 
3300
 * This function processes @c KRB-ERROR message @a enc_errbuf and returns
 
3301
 * an allocated structure @a dec_error containing the error message.
 
3302
 * Use krb5_free_error() to free @a dec_error when it is no longer needed.
 
3303
 *
 
3304
 * @retval 0 Success; otherwise - Kerberos error codes
 
3305
 */
 
3306
krb5_error_code KRB5_CALLCONV
 
3307
krb5_rd_error(krb5_context context, const krb5_data *enc_errbuf,
 
3308
              krb5_error **dec_error);
 
3309
 
 
3310
/**
 
3311
 * Process @c KRB-SAFE message.
 
3312
 *
 
3313
 * @param [in]     context      Library context
 
3314
 * @param [in,out] auth_context Authentication structure
 
3315
 * @param [in]     inbuf        @c KRB-SAFE message to be parsed
 
3316
 * @param [out]    outbuf       Data parsed from @c KRB-SAFE message
 
3317
 * @param [out]    outdata      Replay data. Specify NULL if not needed
 
3318
 *
 
3319
 * This function parses a @c KRB-SAFE message, verifies its integrity, and
 
3320
 * stores its data into @a outbuf.
 
3321
 *
 
3322
 * @note The @a outdata argument is required if #KRB5_AUTH_CONTEXT_RET_TIME or
 
3323
 *       #KRB5_AUTH_CONTEXT_RET_SEQUENCE flag is set in the @a auth_context.
 
3324
 *
 
3325
 * @note @a auth_context must have a remote address set.  This address will be
 
3326
 *       used to verify the sender address in the KRB-SAFE message.  If @a
 
3327
 *       auth_context has a local address set, it will be used to verify the
 
3328
 *       receiver address in the KRB-SAFE message if the message contains one.
 
3329
 *       Both addresses must use type @c ADDRTYPE_ADDRPORT.
 
3330
 *
 
3331
 * If the #KRB5_AUTH_CONTEXT_DO_SEQUENCE flag is set in @a auth_context, the
 
3332
 * sequence number of the KRB-SAFE message is checked against the remote
 
3333
 * sequence number field of @a auth_context.  Otherwise, the sequence number is
 
3334
 * not used.
 
3335
 *
 
3336
 * If the #KRB5_AUTH_CONTEXT_DO_TIME flag is set in @a auth_context,
 
3337
 * then two additional checks are performed:
 
3338
 * @li The timestamp in the message must be within the permitted clock skew
 
3339
 *     (which is usually five minutes).
 
3340
 * @li The message must not be a replayed message field in @a auth_context.
 
3341
 *
 
3342
 * Use krb5_free_data_contents() to free @a outbuf when it is no longer needed.
 
3343
 *
 
3344
 * @retval 0 Success; otherwise - Kerberos error codes
 
3345
 */
 
3346
krb5_error_code KRB5_CALLCONV
 
3347
krb5_rd_safe(krb5_context context, krb5_auth_context auth_context,
 
3348
             const krb5_data *inbuf, krb5_data *outbuf,
 
3349
             krb5_replay_data *outdata);
 
3350
 
 
3351
/**
 
3352
 * Process a @c KRB-PRIV message.
 
3353
 *
 
3354
 * @param [in]     context      Library context
 
3355
 * @param [in,out] auth_context Authentication structure
 
3356
 * @param [in]     inbuf        @c KRB-PRIV message to be parsed
 
3357
 * @param [out]    outbuf       Data parsed from @c KRB-PRIV message
 
3358
 * @param [out]    outdata      Replay data. Specify NULL if not needed
 
3359
 *
 
3360
 * This function parses a @c KRB-PRIV message, verifies its integrity, and
 
3361
 * stores its unencrypted data into @a outbuf.
 
3362
 *
 
3363
 * @note If the #KRB5_AUTH_CONTEXT_RET_TIME or @c
 
3364
 *       #KRB5_AUTH_CONTEXT_RET_SEQUENCE flag is set in @a auth_context, @a
 
3365
 *       outdata is required.
 
3366
 *
 
3367
 * @note @a auth_context must have a remote address set.  This address will be
 
3368
 *       used to verify the sender address in the KRB-PRIV message.  If @a
 
3369
 *       auth_context has a local address set, it will be used to verify the
 
3370
 *       receiver address in the KRB-PRIV message if the message contains one.
 
3371
 *       Both addresses must use type @c ADDRTYPE_ADDRPORT.
 
3372
 *
 
3373
 * If the #KRB5_AUTH_CONTEXT_DO_SEQUENCE flag is set in @a auth_context, the
 
3374
 * sequence number of the KRB-SAFE message is checked against the remote
 
3375
 * sequence number field of @a auth_context.  Otherwise, the sequence number is
 
3376
 * not used.
 
3377
 *
 
3378
 * If the #KRB5_AUTH_CONTEXT_DO_TIME flag is set in @a auth_context,
 
3379
 * then two additional checks are performed:
 
3380
 * @li The timestamp in the message must be within the permitted clock skew
 
3381
 *     (which is usually five minutes).
 
3382
 * @li The message must not be a replayed message field in @a auth_context.
 
3383
 *
 
3384
 * @retval 0 Success; otherwise - Kerberos error codes
 
3385
 */
 
3386
krb5_error_code KRB5_CALLCONV
 
3387
krb5_rd_priv(krb5_context context, krb5_auth_context auth_context,
 
3388
             const krb5_data *inbuf, krb5_data *outbuf,
 
3389
             krb5_replay_data *outdata);
 
3390
 
 
3391
/**
 
3392
 * Convert a string principal name to a krb5_principal structure.
 
3393
 *
 
3394
 * @param [in]  context         Library context
 
3395
 * @param [in]  name            String representation of a principal name
 
3396
 * @param [out] nprincipal      Principal
 
3397
 *
 
3398
 * Convert a string representation of a principal name to a krb5_principal
 
3399
 * structure.
 
3400
 *
 
3401
 * A string representation of a Kerberos name consists of one or more principal
 
3402
 * name components, separated by slashes, optionally followed by the \@
 
3403
 * character and a realm name.  If the realm name is not specified, the local
 
3404
 * realm is used.
 
3405
 *
 
3406
 * To use the slash and \@ symbols as part of a component (quoted) instead of
 
3407
 * using them as a component separator or as a realm prefix), put a backslash
 
3408
 * (\) character in front of the symbol.  Similarly, newline, tab, backspace,
 
3409
 * and NULL characters can be included in a component by using @c n, @c t, @c b
 
3410
 * or @c 0, respectively.
 
3411
 *
 
3412
 * @note The realm in a Kerberos @a name cannot contain slash, colon,
 
3413
 * or NULL characters.
 
3414
 *
 
3415
 * Use krb5_free_principal() to free @a nprincipal when it is no longer needed.
 
3416
 *
 
3417
 * @retval
 
3418
 * 0 Success
 
3419
 * @return
 
3420
 * Kerberos error codes
 
3421
 */
 
3422
krb5_error_code KRB5_CALLCONV
 
3423
krb5_parse_name(krb5_context context, const char *name, krb5_principal *nprincipal);
 
3424
 
 
3425
#define KRB5_PRINCIPAL_PARSE_NO_REALM      0x1 /**< Error if realm is present */
 
3426
#define KRB5_PRINCIPAL_PARSE_REQUIRE_REALM 0x2 /**< Error if realm is not present */
 
3427
#define KRB5_PRINCIPAL_PARSE_ENTERPRISE    0x4 /**< Create single-component
 
3428
                                                  enterprise principle */
 
3429
 
 
3430
/**
 
3431
 * Convert a string principal name to a krb5_principal with flags
 
3432
 *
 
3433
 * @param [in]  context         Library context
 
3434
 * @param [in]  name            String representation of a principal name
 
3435
 * @param [in]  flags           Flag
 
3436
 * @param [out] nprincipal      Principal
 
3437
 *
 
3438
 * Similar to krb5_parse_name(), this function converts a single-string
 
3439
 * representation of a principal name to a krb5_principal structure.
 
3440
 *
 
3441
 * The following flags are valid:
 
3442
 * @li #KRB5_PRINCIPAL_PARSE_NO_REALM - no realm must be present in @a name
 
3443
 * @li #KRB5_PRINCIPAL_PARSE_REQUIRE_REALM - realm must be present in @a name
 
3444
 * @li #KRB5_PRINCIPAL_PARSE_ENTERPRISE - create single-component enterprise
 
3445
 *                                        principal
 
3446
 *
 
3447
 * Use krb5_free_principal() to free @a nprincipal when it is no longer needed.
 
3448
 *
 
3449
 * @retval
 
3450
 * 0 Success
 
3451
 * @return
 
3452
 * Kerberos error codes
 
3453
 */
 
3454
krb5_error_code KRB5_CALLCONV
 
3455
krb5_parse_name_flags(krb5_context context, const char *name,
 
3456
                      int flags, krb5_principal *nprincipal);
 
3457
 
 
3458
/**
 
3459
 * Convert a krb5_principal structure to a string representation.
 
3460
 *
 
3461
 * @param [in]  context         Library context
 
3462
 * @param [in]  principal       Principal
 
3463
 * @param [out] name            String representation of principal name
 
3464
 *
 
3465
 * The resulting string representation uses the format and quoting conventions
 
3466
 * described for krb5_parse_name().
 
3467
 *
 
3468
 * Use krb5_free_unparsed_name() to free @a name when it is no longer needed.
 
3469
 *
 
3470
 * @retval
 
3471
 * 0 Success
 
3472
 * @return
 
3473
 * Kerberos error codes
 
3474
 */
 
3475
krb5_error_code KRB5_CALLCONV
 
3476
krb5_unparse_name(krb5_context context, krb5_const_principal principal,
 
3477
                  register char **name);
 
3478
 
 
3479
/**
 
3480
 * Convert krb5_principal structure to string and length.
 
3481
 *
 
3482
 * @param [in]  context         Library context
 
3483
 * @param [in]  principal       Principal
 
3484
 * @param [out] name            String representation of principal name
 
3485
 * @param [out] size            Size of unparsed name
 
3486
 *
 
3487
 * This function is similar to krb5_unparse_name(), but also returns the length
 
3488
 * of the string representation.
 
3489
 *
 
3490
 * @retval
 
3491
 * 0 Success
 
3492
 * @return
 
3493
 * Kerberos error codes. On failure @a name is set to NULL
 
3494
 */
 
3495
krb5_error_code KRB5_CALLCONV
 
3496
krb5_unparse_name_ext(krb5_context context, krb5_const_principal principal,
 
3497
                      char **name, unsigned int *size);
 
3498
 
 
3499
#define KRB5_PRINCIPAL_UNPARSE_SHORT  0x1 /**< Omit realm if it is the local realm */
 
3500
#define KRB5_PRINCIPAL_UNPARSE_NO_REALM 0x2 /**< Omit realm always */
 
3501
#define KRB5_PRINCIPAL_UNPARSE_DISPLAY  0x4 /**< Don't escape special characters */
 
3502
 
 
3503
/**
 
3504
 * Convert krb5_principal structure to a string with flags.
 
3505
 *
 
3506
 * @param [in]  context         Library context
 
3507
 * @param [in]  principal       Principal
 
3508
 * @param [in]  flags           Flags
 
3509
 * @param [out] name            String representation of principal name
 
3510
 *
 
3511
 * Similar to krb5_unparse_name(), this function converts a krb5_principal
 
3512
 * structure to a string representation.
 
3513
 *
 
3514
 * The following flags are valid:
 
3515
 * @li #KRB5_PRINCIPAL_UNPARSE_SHORT - omit realm if it is the local realm
 
3516
 * @li #KRB5_PRINCIPAL_UNPARSE_NO_REALM - omit realm
 
3517
 * @li #KRB5_PRINCIPAL_UNPARSE_DISPLAY - do not quote special characters
 
3518
 *
 
3519
 * Use krb5_free_unparsed_name() to free @a name when it is no longer needed.
 
3520
 *
 
3521
 * @retval
 
3522
 * 0 Success
 
3523
 * @return
 
3524
 * Kerberos error codes. On failure @a name is set to NULL
 
3525
 */
 
3526
krb5_error_code KRB5_CALLCONV
 
3527
krb5_unparse_name_flags(krb5_context context, krb5_const_principal principal,
 
3528
                        int flags, char **name);
 
3529
 
 
3530
/**
 
3531
 * Convert krb5_principal structure to string format with flags.
 
3532
 *
 
3533
 * @param [in]  context         Library context
 
3534
 * @param [in]  principal       Principal
 
3535
 * @param [in]  flags           Flags
 
3536
 * @param [out] name            Single string format of principal name
 
3537
 * @param [out] size            Size of unparsed name buffer
 
3538
 *
 
3539
 * @sa krb5_unparse_name() krb5_unparse_name_flags() krb5_unparse_name_ext()
 
3540
 *
 
3541
 * @retval
 
3542
 * 0 Success
 
3543
 * @return
 
3544
 * Kerberos error codes. On failure @a name is set to NULL
 
3545
 */
 
3546
krb5_error_code KRB5_CALLCONV
 
3547
krb5_unparse_name_flags_ext(krb5_context context, krb5_const_principal principal,
 
3548
                            int flags, char **name, unsigned int *size);
 
3549
 
 
3550
/**
 
3551
 * Set the realm field of a principal
 
3552
 *
 
3553
 * @param [in,out] context      Library context
 
3554
 * @param [in]     principal    Principal name
 
3555
 * @param [in]     realm        Realm name
 
3556
 *
 
3557
 * Set the realm name part of @a principal to @a realm, overwriting the
 
3558
 * previous realm.
 
3559
 *
 
3560
 * @retval
 
3561
 * 0   Success
 
3562
 * @return
 
3563
 * Kerberos error codes
 
3564
 */
 
3565
krb5_error_code KRB5_CALLCONV
 
3566
krb5_set_principal_realm(krb5_context context, krb5_principal principal,
 
3567
                         const char *realm);
 
3568
 
 
3569
/**
 
3570
 * Search a list of addresses for a specified address.
 
3571
 *
 
3572
 * @param [in] context          Library context
 
3573
 * @param [in] addr             Address to search for
 
3574
 * @param [in] addrlist         Address list to be searched (or NULL)
 
3575
 *
 
3576
 * @note If @a addrlist contains only a NetBIOS addresses, it will be treated
 
3577
 *       as a null list.
 
3578
 *
 
3579
 * @return
 
3580
 * TRUE if @a addr is listed in @a addrlist, or @c addrlist is NULL; FALSE
 
3581
 * otherwise
 
3582
 */
1714
3583
krb5_boolean KRB5_CALLCONV_WRONG
1715
 
krb5_address_search(krb5_context, const krb5_address *, krb5_address *const *);
 
3584
krb5_address_search(krb5_context context, const krb5_address *addr,
 
3585
                    krb5_address *const *addrlist);
1716
3586
 
 
3587
/**
 
3588
 * Compare two Kerberos addresses.
 
3589
 *
 
3590
 * @param [in] context          Library context
 
3591
 * @param [in] addr1            First address to be compared
 
3592
 * @param [in] addr2            Second address to be compared
 
3593
 *
 
3594
 * @return
 
3595
 * TRUE if the addresses are the same, FALSE otherwise
 
3596
 */
1717
3597
krb5_boolean KRB5_CALLCONV
1718
 
krb5_address_compare(krb5_context, const krb5_address *, const krb5_address *);
 
3598
krb5_address_compare(krb5_context context, const krb5_address *addr1,
 
3599
                     const krb5_address *addr2);
1719
3600
 
 
3601
/**
 
3602
 * Return an ordering of the specified addresses.
 
3603
 *
 
3604
 * @param [in] context          Library context
 
3605
 * @param [in] addr1            First address
 
3606
 * @param [in] addr2            Second address
 
3607
 *
 
3608
 * @retval
 
3609
 *  0 The two addresses are the same
 
3610
 * @retval
 
3611
 *  \< 0 First address is less than second
 
3612
 * @retval
 
3613
 *  \> 0 First address is greater than second
 
3614
 */
1720
3615
int KRB5_CALLCONV
1721
 
krb5_address_order(krb5_context, const krb5_address *, const krb5_address *);
1722
 
 
1723
 
krb5_boolean KRB5_CALLCONV
1724
 
krb5_realm_compare(krb5_context, krb5_const_principal, krb5_const_principal);
1725
 
 
1726
 
krb5_boolean KRB5_CALLCONV
1727
 
krb5_principal_compare(krb5_context, krb5_const_principal,
1728
 
                       krb5_const_principal);
1729
 
 
1730
 
krb5_boolean KRB5_CALLCONV
1731
 
krb5_principal_compare_any_realm(krb5_context, krb5_const_principal,
1732
 
                                 krb5_const_principal);
1733
 
 
1734
 
#define KRB5_PRINCIPAL_COMPARE_IGNORE_REALM  1
1735
 
#define KRB5_PRINCIPAL_COMPARE_ENTERPRISE    2 /* UPNs as real principals */
1736
 
#define KRB5_PRINCIPAL_COMPARE_CASEFOLD      4 /* case-insensitive */
1737
 
#define KRB5_PRINCIPAL_COMPARE_UTF8          8 /* treat principals as UTF-8 */
1738
 
 
1739
 
krb5_boolean KRB5_CALLCONV
1740
 
krb5_principal_compare_flags(krb5_context, krb5_const_principal,
1741
 
                             krb5_const_principal, int);
1742
 
 
1743
 
krb5_error_code KRB5_CALLCONV
1744
 
krb5_init_keyblock(krb5_context, krb5_enctype enctype, size_t length,
1745
 
                   krb5_keyblock **out);
1746
 
 
1747
 
/* Initialize a new keyblock and allocate storage
1748
 
 * for the contents of the key, which will be freed along
1749
 
 * with the keyblock when krb5_free_keyblock is called.
1750
 
 * It is legal to pass in a length of 0, in which
1751
 
 * case contents are left unallocated.
1752
 
 */
1753
 
krb5_error_code KRB5_CALLCONV
1754
 
krb5_copy_keyblock(krb5_context, const krb5_keyblock *, krb5_keyblock **);
1755
 
 
1756
 
krb5_error_code KRB5_CALLCONV
1757
 
krb5_copy_keyblock_contents(krb5_context, const krb5_keyblock *,
1758
 
                            krb5_keyblock *);
1759
 
 
1760
 
krb5_error_code KRB5_CALLCONV
1761
 
krb5_copy_creds(krb5_context, const krb5_creds *, krb5_creds **);
1762
 
 
1763
 
krb5_error_code KRB5_CALLCONV
1764
 
krb5_copy_data(krb5_context, const krb5_data *, krb5_data **);
1765
 
 
1766
 
krb5_error_code KRB5_CALLCONV
1767
 
krb5_copy_principal(krb5_context, krb5_const_principal, krb5_principal *);
1768
 
 
1769
 
krb5_error_code KRB5_CALLCONV
1770
 
krb5_copy_addresses(krb5_context, krb5_address * const *, krb5_address ***);
1771
 
 
1772
 
krb5_error_code KRB5_CALLCONV
1773
 
krb5_copy_ticket(krb5_context, const krb5_ticket *, krb5_ticket **);
1774
 
 
1775
 
krb5_error_code KRB5_CALLCONV
1776
 
krb5_copy_authdata(krb5_context, krb5_authdata * const *, krb5_authdata ***);
1777
 
 
1778
 
/* Merge two authdata arrays, such as the array from a ticket
1779
 
 * and authenticator. */
1780
 
krb5_error_code KRB5_CALLCONV
1781
 
krb5_merge_authdata(krb5_context, krb5_authdata * const *,
1782
 
                    krb5_authdata *const *, krb5_authdata ***);
1783
 
 
1784
 
krb5_error_code KRB5_CALLCONV
1785
 
krb5_copy_authenticator(krb5_context, const krb5_authenticator *,
1786
 
                        krb5_authenticator **);
1787
 
 
1788
 
krb5_error_code KRB5_CALLCONV
1789
 
krb5_copy_checksum(krb5_context, const krb5_checksum *, krb5_checksum **);
1790
 
 
1791
 
krb5_error_code KRB5_CALLCONV
1792
 
krb5_get_server_rcache(krb5_context, const krb5_data *, krb5_rcache *);
1793
 
 
1794
 
krb5_error_code KRB5_CALLCONV_C
1795
 
krb5_build_principal_ext(krb5_context, krb5_principal *, unsigned int,
1796
 
                         const char *, ...);
1797
 
 
1798
 
krb5_error_code KRB5_CALLCONV_C
1799
 
krb5_build_principal(krb5_context, krb5_principal *, unsigned int,
1800
 
                     const char *, ...)
 
3616
krb5_address_order(krb5_context context, const krb5_address *addr1,
 
3617
                   const krb5_address *addr2);
 
3618
 
 
3619
/**
 
3620
 * Compare the realms of two principals.
 
3621
 *
 
3622
 * @param [in] context          Library context
 
3623
 * @param [in] princ1           First principal
 
3624
 * @param [in] princ2           Second principal
 
3625
 *
 
3626
 * @retval
 
3627
 * TRUE if the realm names are the same; FALSE otherwise
 
3628
 */
 
3629
krb5_boolean KRB5_CALLCONV
 
3630
krb5_realm_compare(krb5_context context, krb5_const_principal princ1,
 
3631
                   krb5_const_principal princ2);
 
3632
 
 
3633
/**
 
3634
 * Compare two principals.
 
3635
 *
 
3636
 * @param [in] context          Library context
 
3637
 * @param [in] princ1           First principal
 
3638
 * @param [in] princ2           Second principal
 
3639
 *
 
3640
 * @retval
 
3641
 * TRUE if the principals are the same; FALSE otherwise
 
3642
 */
 
3643
krb5_boolean KRB5_CALLCONV
 
3644
krb5_principal_compare(krb5_context context,
 
3645
                       krb5_const_principal princ1,
 
3646
                       krb5_const_principal princ2);
 
3647
 
 
3648
/**
 
3649
 * Compare two principals ignoring realm components.
 
3650
 *
 
3651
 * @param [in] context          Library context
 
3652
 * @param [in] princ1           First principal
 
3653
 * @param [in] princ2           Second principal
 
3654
 *
 
3655
 * Similar to krb5_principal_compare(), but do not compare the realm
 
3656
 * components of the principals.
 
3657
 *
 
3658
 * @retval
 
3659
 * TRUE if the principals are the same; FALSE otherwise
 
3660
 */
 
3661
krb5_boolean KRB5_CALLCONV
 
3662
krb5_principal_compare_any_realm(krb5_context context,
 
3663
                                 krb5_const_principal princ1,
 
3664
                                 krb5_const_principal princ2);
 
3665
 
 
3666
#define KRB5_PRINCIPAL_COMPARE_IGNORE_REALM  1 /**< ignore realm component */
 
3667
#define KRB5_PRINCIPAL_COMPARE_ENTERPRISE    2 /**< UPNs as real principals */
 
3668
#define KRB5_PRINCIPAL_COMPARE_CASEFOLD      4 /**< case-insensitive */
 
3669
#define KRB5_PRINCIPAL_COMPARE_UTF8          8 /**< treat principals as UTF-8 */
 
3670
 
 
3671
/**
 
3672
 * Compare two principals with additional flags.
 
3673
 *
 
3674
 * @param [in] context           Library context
 
3675
 * @param [in] princ1            First principal
 
3676
 * @param [in] princ2            Second principal
 
3677
 * @param [in] flags             Flags
 
3678
 *
 
3679
 * Valid flags are:
 
3680
 * @li #KRB5_PRINCIPAL_COMPARE_IGNORE_REALM - ignore realm component
 
3681
 * @li #KRB5_PRINCIPAL_COMPARE_ENTERPRISE - UPNs as real principals
 
3682
 * @li #KRB5_PRINCIPAL_COMPARE_CASEFOLD case-insensitive
 
3683
 * @li #KRB5_PRINCIPAL_COMPARE_UTF8 - treat principals as UTF-8
 
3684
 *
 
3685
 * @sa krb5_principal_compare()
 
3686
 *
 
3687
 * @retval
 
3688
 * TRUE if the principal names are the same; FALSE otherwise
 
3689
 */
 
3690
krb5_boolean KRB5_CALLCONV
 
3691
krb5_principal_compare_flags(krb5_context context,
 
3692
                             krb5_const_principal princ1,
 
3693
                             krb5_const_principal princ2,
 
3694
                             int flags);
 
3695
 
 
3696
/**
 
3697
 * Initialize an empty @c krb5_keyblock.
 
3698
 *
 
3699
 * @param [in]  context         Library context
 
3700
 * @param [in]  enctype         Encryption type
 
3701
 * @param [in]  length          Length of keyblock (or 0)
 
3702
 * @param [out] out             New keyblock structure
 
3703
 *
 
3704
 * Initialize a new keyblock and allocate storage for the contents of the key.
 
3705
 * It is legal to pass in a length of 0, in which case contents are left
 
3706
 * unallocated.  Use krb5_free_keyblock() to free @a out when it is no longer
 
3707
 * needed.
 
3708
 *
 
3709
 * @note If @a length is set to 0, contents are left unallocated.
 
3710
 *
 
3711
 * @retval 0 Success; otherwise - Kerberos error codes
 
3712
 */
 
3713
krb5_error_code KRB5_CALLCONV
 
3714
krb5_init_keyblock(krb5_context context, krb5_enctype enctype,
 
3715
                   size_t length, krb5_keyblock **out);
 
3716
 
 
3717
/**
 
3718
 * Copy a keyblock.
 
3719
 *
 
3720
 * @param [in]  context         Library context
 
3721
 * @param [in]  from            Keyblock to be copied
 
3722
 * @param [out] to              Copy of keyblock @a from
 
3723
 *
 
3724
 * This function creates a new keyblock with the same contents as @a from.  Use
 
3725
 * krb5_free_keyblock() to free @a to when it is no longer needed.
 
3726
 *
 
3727
 * @retval 0 Success; otherwise - Kerberos error codes
 
3728
 */
 
3729
krb5_error_code KRB5_CALLCONV
 
3730
krb5_copy_keyblock(krb5_context context, const krb5_keyblock *from,
 
3731
                   krb5_keyblock **to);
 
3732
 
 
3733
/**
 
3734
 * Copy the contents of a keyblock.
 
3735
 *
 
3736
 * @param [in]  context         Library context
 
3737
 * @param [in]  from            Key to be copied
 
3738
 * @param [out] to              Output key
 
3739
 *
 
3740
 * This function copies the contents of @a from to @a to.  Use
 
3741
 * krb5_free_keyblock_contents() to free @a to when it is no longer needed.
 
3742
 *
 
3743
 * @retval 0 Success; otherwise - Kerberos error codes
 
3744
 */
 
3745
krb5_error_code KRB5_CALLCONV
 
3746
krb5_copy_keyblock_contents(krb5_context context, const krb5_keyblock *from,
 
3747
                            krb5_keyblock *to);
 
3748
 
 
3749
/**
 
3750
 * Copy a krb5_creds structure.
 
3751
 *
 
3752
 * @param [in]  context         Library context
 
3753
 * @param [in]  incred          Credentials structure to be copied
 
3754
 * @param [out] outcred         Copy of @a incred
 
3755
 *
 
3756
 * This function creates a new credential with the contents of @a incred.  Use
 
3757
 * krb5_free_creds() to free @a outcred when it is no longer needed.
 
3758
 *
 
3759
 * @retval 0 Success; otherwise - Kerberos error codes
 
3760
 */
 
3761
krb5_error_code KRB5_CALLCONV
 
3762
krb5_copy_creds(krb5_context context, const krb5_creds *incred, krb5_creds **outcred);
 
3763
 
 
3764
/**
 
3765
 * Copy a krb5_data object.
 
3766
 *
 
3767
 * @param [in]  context           Library context
 
3768
 * @param [in]  indata            Data object to be copied
 
3769
 * @param [out] outdata           Copy of @a indata
 
3770
 *
 
3771
 * This function creates a new krb5_data object with the contents of @a indata.
 
3772
 * Use krb5_free_data() to free @a outdata when it is no longer needed.
 
3773
 *
 
3774
 * @retval 0 Success; otherwise - Kerberos error codes
 
3775
 */
 
3776
krb5_error_code KRB5_CALLCONV
 
3777
krb5_copy_data(krb5_context context, const krb5_data *indata, krb5_data **outdata);
 
3778
 
 
3779
/**
 
3780
 * Copy a principal.
 
3781
 *
 
3782
 * @param [in]  context         Library context
 
3783
 * @param [in]  inprinc         Principal to be copied
 
3784
 * @param [out] outprinc        Copy of @a inprinc
 
3785
 *
 
3786
 * This function creates a new principal structure with the contents of @a
 
3787
 * inprinc.  Use krb5_free_principal() to free @a outprinc when it is no longer
 
3788
 * needed.
 
3789
 *
 
3790
 * @retval 0 Success; otherwise - Kerberos error codes
 
3791
 */
 
3792
krb5_error_code KRB5_CALLCONV
 
3793
krb5_copy_principal(krb5_context context, krb5_const_principal inprinc,
 
3794
                    krb5_principal *outprinc);
 
3795
 
 
3796
/**
 
3797
 * Copy an array of addresses.
 
3798
 *
 
3799
 * @param [in]  context         Library context
 
3800
 * @param [in]  inaddr          Array of addresses to be copied
 
3801
 * @param [out] outaddr         Copy of array of addresses
 
3802
 *
 
3803
 * This function creates a new address array containing a copy of @a inaddr.
 
3804
 * Use krb5_free_addresses() to free @a outaddr when it is no longer needed.
 
3805
 *
 
3806
 * @retval 0 Success; otherwise - Kerberos error codes
 
3807
 */
 
3808
krb5_error_code KRB5_CALLCONV
 
3809
krb5_copy_addresses(krb5_context context, krb5_address *const *inaddr,
 
3810
                    krb5_address ***outaddr);
 
3811
 
 
3812
/**
 
3813
 * Copy a krb5_ticket structure.
 
3814
 *
 
3815
 * @param [in]  context         Library context
 
3816
 * @param [in]  from            Ticket to be copied
 
3817
 * @param [out] pto             Copy of ticket
 
3818
 *
 
3819
 * This function creates a new krb5_ticket structure containing the contents of
 
3820
 * @a from.  Use krb5_free_ticket() to free @a pto when it is no longer needed.
 
3821
 *
 
3822
 * @retval 0 Success; otherwise - Kerberos error codes
 
3823
 */
 
3824
krb5_error_code KRB5_CALLCONV
 
3825
krb5_copy_ticket(krb5_context context, const krb5_ticket *from, krb5_ticket **pto);
 
3826
 
 
3827
/**
 
3828
 * Copy an authorization data list.
 
3829
 *
 
3830
 * @param [in]  context         Library context
 
3831
 * @param [in]  in_authdat      List of @a krb5_authdata structures
 
3832
 * @param [out] out             New array of @a krb5_authdata structures
 
3833
 *
 
3834
 * This function creates a new authorization data list containing a copy of @a
 
3835
 * in_authdat, which must be null-terminated.  Use krb5_free_authdata() to free
 
3836
 * @a out when it is no longer needed.
 
3837
 *
 
3838
 * @note The last array entry in @a in_authdat must be a NULL pointer.
 
3839
 *
 
3840
 * @retval 0 Success; otherwise - Kerberos error codes
 
3841
 */
 
3842
krb5_error_code KRB5_CALLCONV
 
3843
krb5_copy_authdata(krb5_context context,
 
3844
                   krb5_authdata *const *in_authdat, krb5_authdata ***out);
 
3845
 
 
3846
/**
 
3847
 * Find authorization data elements.
 
3848
 *
 
3849
 * @param [in]  context         Library context
 
3850
 * @param [in]  ticket_authdata Authorization data list from ticket
 
3851
 * @param [in]  ap_req_authdata Authorization data list from AP request
 
3852
 * @param [in]  ad_type         Authorization data type to find
 
3853
 * @param [out] results         List of matching entries
 
3854
 *
 
3855
 * This function searches @a ticket_authdata and @a ap_req_authdata for
 
3856
 * elements of type @a ad_type.  Either input list may be NULL, in which case
 
3857
 * it will not be searched; otherwise, the input lists must be terminated by
 
3858
 * NULL entries.  This function will search inside AD-IF-RELEVANT containers if
 
3859
 * found in either list.  Use krb5_free_authdata() to free @a results when it
 
3860
 * is no longer needed.
 
3861
 */
 
3862
krb5_error_code KRB5_CALLCONV
 
3863
krb5_find_authdata(krb5_context context, krb5_authdata *const *ticket_authdata,
 
3864
                   krb5_authdata *const *ap_req_authdata,
 
3865
                   krb5_authdatatype ad_type, krb5_authdata ***results);
 
3866
 
 
3867
/**
 
3868
 * Merge two authorization data lists into a new list.
 
3869
 *
 
3870
 * @param [in]  context         Library context
 
3871
 * @param [in]  inauthdat1      First list of @a krb5_authdata structures
 
3872
 * @param [in]  inauthdat2      Second list of @a krb5_authdata structures
 
3873
 * @param [out] outauthdat      Merged list of @a krb5_authdata structures
 
3874
 *
 
3875
 * Merge two authdata arrays, such as the array from a ticket
 
3876
 * and authenticator.
 
3877
 * Use krb5_free_authdata() to free @a outauthdat when it is no longer needed.
 
3878
 *
 
3879
 * @note The last array entry in @a inauthdat1 and @a inauthdat2
 
3880
 * must be a NULL pointer.
 
3881
 *
 
3882
 * @retval 0 Success; otherwise - Kerberos error codes
 
3883
 */
 
3884
krb5_error_code KRB5_CALLCONV
 
3885
krb5_merge_authdata(krb5_context context,
 
3886
                    krb5_authdata *const *inauthdat1,
 
3887
                    krb5_authdata * const *inauthdat2,
 
3888
                    krb5_authdata ***outauthdat);
 
3889
 
 
3890
/**
 
3891
 * Copy a krb5_authenticator structure.
 
3892
 *
 
3893
 * @param [in]  context         Library context
 
3894
 * @param [in]  authfrom        krb5_authenticator structure to be copied
 
3895
 * @param [out] authto          Copy of krb5_authenticator structure
 
3896
 *
 
3897
 * This function creates a new krb5_authenticator structure with the content of
 
3898
 * @a authfrom.  Use krb5_free_authenticator() to free @a authto when it is no
 
3899
 * longer needed.
 
3900
 *
 
3901
 * @retval 0 Success; otherwise - Kerberos error codes
 
3902
 */
 
3903
krb5_error_code KRB5_CALLCONV
 
3904
krb5_copy_authenticator(krb5_context context, const krb5_authenticator *authfrom,
 
3905
                        krb5_authenticator **authto);
 
3906
 
 
3907
/**
 
3908
 * Copy a krb5_checksum structure.
 
3909
 *
 
3910
 * @param [in]  context         Library context
 
3911
 * @param [in]  ckfrom          Checksum to be copied
 
3912
 * @param [out] ckto            Copy of krb5_checksum structure
 
3913
 *
 
3914
 * This function creates a new krb5_checksum structure with the contents of @a
 
3915
 * ckfrom.  Use krb5_free_checksum() to free @a ckto when it is no longer
 
3916
 * needed.
 
3917
 *
 
3918
 * @retval 0 Success; otherwise - Kerberos error codes
 
3919
 */
 
3920
krb5_error_code KRB5_CALLCONV
 
3921
krb5_copy_checksum(krb5_context context, const krb5_checksum *ckfrom,
 
3922
                   krb5_checksum **ckto);
 
3923
 
 
3924
/**
 
3925
 * Generate a replay cache object for server use and open it.
 
3926
 *
 
3927
 * @param [in]  context         Library context
 
3928
 * @param [in]  piece           Unique identifier for replay cache
 
3929
 * @param [out] rcptr           Handle to an open rcache
 
3930
 *
 
3931
 * This function generates a replay cache name based on @a piece and opens a
 
3932
 * handle to it.  Typically @a piece is the first component of the service
 
3933
 * principal name.  Use krb5_rc_close() to close @a rcptr when it is no longer
 
3934
 * needed.
 
3935
 *
 
3936
 * @retval 0 Success; otherwise - Kerberos error codes
 
3937
 */
 
3938
krb5_error_code KRB5_CALLCONV
 
3939
krb5_get_server_rcache(krb5_context context, const krb5_data *piece,
 
3940
                       krb5_rcache *rcptr);
 
3941
 
 
3942
/**
 
3943
 * Build a principal name using length-counted strings.
 
3944
 *
 
3945
 * @param [in]  context  Library context
 
3946
 * @param [out] princ    Principal name
 
3947
 * @param [in]  rlen     Realm name length
 
3948
 * @param [in]  realm    Realm name
 
3949
 * @param [in]  ...      List of unsigned int/char * components, followed by 0
 
3950
 *
 
3951
 * This function creates a principal from a length-counted string and a
 
3952
 * variable-length list of length-counted components.  The list of components
 
3953
 * ends with the first 0 length argument (so it is not possible to specify an
 
3954
 * empty component with this function).  Call krb5_free_principal() to free
 
3955
 * allocated memory for principal when it is no longer needed.
 
3956
 *
 
3957
 * @code
 
3958
 * Example of how to build principal WELLKNOWN/ANONYMOUS@R
 
3959
 *     krb5_build_principal_ext(context, &principal, strlen("R"), "R",
 
3960
 *         (unsigned int)strlen(KRB5_WELLKNOWN_NAMESTR),
 
3961
 *         KRB5_WELLKNOWN_NAMESTR,
 
3962
 *         (unsigned int)strlen(KRB5_ANONYMOUS_PRINCSTR),
 
3963
 *         KRB5_ANONYMOUS_PRINCSTR, 0);
 
3964
 * @endcode
 
3965
 *
 
3966
 * @retval
 
3967
 * 0  Success
 
3968
 * @return
 
3969
 * Kerberos error codes
 
3970
 */
 
3971
krb5_error_code KRB5_CALLCONV_C
 
3972
krb5_build_principal_ext(krb5_context context,  krb5_principal * princ,
 
3973
                         unsigned int rlen, const char * realm, ...);
 
3974
 
 
3975
/**
 
3976
 * Build a principal name using null-terminated strings.
 
3977
 *
 
3978
 * @param [in]  context         Library context
 
3979
 * @param [out] princ           Principal name
 
3980
 * @param [in]  rlen            Realm name length
 
3981
 * @param [in]  realm           Realm name
 
3982
 * @param [in]  ...             List of char * components, ending with NULL
 
3983
 *
 
3984
 * Call krb5_free_principal() to free @a princ when it is no longer needed.
 
3985
 *
 
3986
 * @note krb5_build_principal() and krb5_build_principal_alloc_va() perform the
 
3987
 * same task.  krb5_build_principal() takes variadic arguments.
 
3988
 * krb5_build_principal_alloc_va() takes a pre-computed @a varargs pointer.
 
3989
 *
 
3990
 * @code
 
3991
 * Example of how to build principal H/S@R
 
3992
 *     krb5_build_principal(context, &principal,
 
3993
 *                          strlen("R"), "R", "H", "S", (char*)NULL);
 
3994
 * @endcode
 
3995
 *
 
3996
 * @retval
 
3997
 * 0  Success
 
3998
 * @return
 
3999
 * Kerberos error codes
 
4000
 */
 
4001
krb5_error_code KRB5_CALLCONV_C
 
4002
krb5_build_principal(krb5_context context,
 
4003
                     krb5_principal * princ,
 
4004
                     unsigned int rlen,
 
4005
                     const char * realm, ...)
1801
4006
#if __GNUC__ >= 4
1802
4007
    __attribute__ ((sentinel))
1803
4008
#endif
1804
4009
    ;
1805
4010
#if KRB5_DEPRECATED
 
4011
/** @deprecated Replaced by krb5_build_principal_alloc_va(). */
1806
4012
KRB5_ATTR_DEPRECATED krb5_error_code KRB5_CALLCONV
1807
 
krb5_build_principal_va(krb5_context, krb5_principal, unsigned int,
1808
 
                        const char *, va_list);
 
4013
krb5_build_principal_va(krb5_context context,
 
4014
                        krb5_principal princ,
 
4015
                        unsigned int rlen,
 
4016
                        const char *realm,
 
4017
                        va_list ap);
1809
4018
#endif
1810
4019
 
1811
 
/* Version of krb5_build_principal_va which allocates krb5_principal_data */
1812
 
krb5_error_code KRB5_CALLCONV
1813
 
krb5_build_principal_alloc_va(krb5_context, krb5_principal *, unsigned int,
1814
 
                              const char *, va_list);
1815
 
 
1816
 
krb5_error_code KRB5_CALLCONV
1817
 
krb5_425_conv_principal(krb5_context, const char *name, const char *instance,
1818
 
                        const char *realm, krb5_principal *princ);
1819
 
 
 
4020
/**
 
4021
 * Build a principal name, using a precomputed variable argument list
 
4022
 *
 
4023
 * @param [in]  context         Library context
 
4024
 * @param [out] princ           Principal structure
 
4025
 * @param [in]  rlen            Realm name length
 
4026
 * @param [in]  realm           Realm name
 
4027
 * @param [in]  ap              List of char * components, ending with NULL
 
4028
 *
 
4029
 * Similar to krb5_build_principal(), this function builds a principal name,
 
4030
 * but its name components are specified as a va_list.
 
4031
 *
 
4032
 * Use krb5_free_principal() to deallocate @a princ when it is no longer
 
4033
 * needed.
 
4034
 *
 
4035
 * @code
 
4036
 * Function usage example:
 
4037
 *   va_list ap;
 
4038
 *   va_start(ap, realm);
 
4039
 *   krb5_build_principal_alloc_va(context, princ, rlen, realm, ap);
 
4040
 *   va_end(ap);
 
4041
 * @endcode
 
4042
 *
 
4043
 * @retval
 
4044
 * 0  Success
 
4045
 * @return
 
4046
 * Kerberos error codes
 
4047
 */
 
4048
krb5_error_code KRB5_CALLCONV
 
4049
krb5_build_principal_alloc_va(krb5_context context,
 
4050
                              krb5_principal *princ,
 
4051
                              unsigned int rlen,
 
4052
                              const char *realm,
 
4053
                              va_list ap);
 
4054
 
 
4055
/**
 
4056
 * Convert a Kerberos V4 principal to a Kerberos V5 principal.
 
4057
 *
 
4058
 * @param [in]  context         Library context
 
4059
 * @param [in]  name            V4 name
 
4060
 * @param [in]  instance        V4 instance
 
4061
 * @param [in]  realm           Realm
 
4062
 * @param [out] princ           V5 principal
 
4063
 *
 
4064
 * This function builds a @a princ from V4 specification based on given input
 
4065
 * @a name.instance\@realm.
 
4066
 *
 
4067
 * Use krb5_free_principal() to free @a princ when it is no longer needed.
 
4068
 *
 
4069
 * @retval 0 Success; otherwise - Kerberos error codes
 
4070
 */
 
4071
krb5_error_code KRB5_CALLCONV
 
4072
krb5_425_conv_principal(krb5_context context, const char *name,
 
4073
                        const char *instance, const char *realm,
 
4074
                        krb5_principal *princ);
 
4075
 
 
4076
/**
 
4077
 * Convert a Kerberos V5 principal to a Kerberos V4 principal.
 
4078
 *
 
4079
 * @param [in]  context         Library context
 
4080
 * @param [in]  princ           V5 Principal
 
4081
 * @param [out] name            V4 principal's name to be filled in
 
4082
 * @param [out] inst            V4 principal's instance name to be filled in
 
4083
 * @param [out] realm           Principal's realm name to be filled in
 
4084
 *
 
4085
 * This function separates a V5 principal @a princ into @a name, @a instance,
 
4086
 * and @a realm.
 
4087
 *
 
4088
 * @retval
 
4089
 *  0  Success
 
4090
 * @retval
 
4091
 *  KRB5_INVALID_PRINCIPAL   Invalid principal name
 
4092
 * @retval
 
4093
 *  KRB5_CONFIG_CANTOPEN     Can't open or find Kerberos configuration file
 
4094
 * @return
 
4095
 * Kerberos error codes
 
4096
 */
1820
4097
krb5_error_code KRB5_CALLCONV
1821
4098
krb5_524_conv_principal(krb5_context context, krb5_const_principal princ,
1822
4099
                        char *name, char *inst, char *realm);
1823
 
 
 
4100
/**
 
4101
 *@deprecated
 
4102
 */
1824
4103
struct credentials;
 
4104
 
 
4105
/**
 
4106
 * Convert a Kerberos V5 credentials to a Kerberos V4 credentials
 
4107
 *
 
4108
 * @note Not implemented
 
4109
 *
 
4110
 * @retval KRB524_KRB4_DISABLED (always)
 
4111
 */
1825
4112
int KRB5_CALLCONV
1826
4113
krb5_524_convert_creds(krb5_context context, krb5_creds *v5creds,
1827
4114
                       struct credentials *v4creds);
 
4115
 
1828
4116
#if KRB5_DEPRECATED
1829
4117
#define krb524_convert_creds_kdc krb5_524_convert_creds
1830
4118
#define krb524_init_ets(x) (0)
1831
4119
#endif
1832
4120
 
1833
4121
/* libkt.spec */
1834
 
krb5_error_code KRB5_CALLCONV
1835
 
krb5_kt_resolve(krb5_context, const char *, krb5_keytab *);
1836
 
 
1837
 
krb5_error_code KRB5_CALLCONV
1838
 
krb5_kt_default_name(krb5_context, char *, int);
1839
 
 
1840
 
krb5_error_code KRB5_CALLCONV
1841
 
krb5_kt_default(krb5_context, krb5_keytab * );
1842
 
 
1843
 
krb5_error_code KRB5_CALLCONV
1844
 
krb5_free_keytab_entry_contents(krb5_context, krb5_keytab_entry *);
1845
 
 
1846
 
/* use krb5_free_keytab_entry_contents instead; this does the same thing but is
1847
 
 * misnamed and retained for backward compatability.*/
1848
 
krb5_error_code KRB5_CALLCONV krb5_kt_free_entry(krb5_context,
1849
 
                                                 krb5_keytab_entry * );
 
4122
 
 
4123
/**
 
4124
 * Get a handle for a key table.
 
4125
 *
 
4126
 * @param [in]  context         Library context
 
4127
 * @param [in]  name            Name of the key table
 
4128
 * @param [out] ktid            Key table handle
 
4129
 *
 
4130
 * Resolve the key table name @a name and fill in a handle identifying the key
 
4131
 * table.  The key table is not opened.
 
4132
 *
 
4133
 * @note @a name must be of the form @c type:residual, where @a type must be a
 
4134
 * type known to the library and @a residual portion should be specific to the
 
4135
 * particular keytab type.
 
4136
 *
 
4137
 * @sa krb5_kt_close()
 
4138
 *
 
4139
 * @code
 
4140
 *  Example: krb5_kt_resolve(context, "FILE:/tmp/filename",&ktid);
 
4141
 * @endcode
 
4142
 *
 
4143
 * @retval
 
4144
 * 0  Success
 
4145
 * @return
 
4146
 * Kerberos error codes
 
4147
 */
 
4148
krb5_error_code KRB5_CALLCONV
 
4149
krb5_kt_resolve(krb5_context context, const char *name, krb5_keytab *ktid);
 
4150
 
 
4151
/**
 
4152
 * Get default key table name.
 
4153
 *
 
4154
 * @param [in]     context      Library context
 
4155
 * @param [in,out] name         Key table name to be resolved
 
4156
 * @param [in]     name_size    Size of @a name to return
 
4157
 *
 
4158
 * Fill @a name with the first @a name_size bytes of the name of the default
 
4159
 * key table for the current user.
 
4160
 *
 
4161
 * @sa MAX_KEYTAB_NAME_LEN
 
4162
 *
 
4163
 * @retval
 
4164
 * 0 Success
 
4165
 * @retval
 
4166
 * KRB5_CONFIG_NOTENUFSPACE Buffer is too short
 
4167
 * @return
 
4168
 * Kerberos error codes
 
4169
 */
 
4170
krb5_error_code KRB5_CALLCONV
 
4171
krb5_kt_default_name(krb5_context context, char *name, int name_size);
 
4172
 
 
4173
/**
 
4174
 * Resolve default key table.
 
4175
 *
 
4176
 * @param [in]  context         Library context
 
4177
 * @param [in,out] id           Key table handle
 
4178
 *
 
4179
 * Fill @a keytab with the default key table's @a handle.
 
4180
 *
 
4181
 * @retval
 
4182
 * 0  Success
 
4183
 * @return
 
4184
 * Kerberos error codes
 
4185
 */
 
4186
krb5_error_code KRB5_CALLCONV
 
4187
krb5_kt_default(krb5_context context, krb5_keytab *id);
 
4188
 
 
4189
/**
 
4190
 * Free the contents of a key table entry.
 
4191
 *
 
4192
 * @param [in] context          Library context
 
4193
 * @param [in] entry            Key table entry whose contents are to be freed
 
4194
 *
 
4195
 * @note The pointer is not freed.
 
4196
 *
 
4197
 * @retval 0  Success; otherwise - Kerberos error codes
 
4198
 */
 
4199
krb5_error_code KRB5_CALLCONV
 
4200
krb5_free_keytab_entry_contents(krb5_context context, krb5_keytab_entry *entry);
 
4201
 
 
4202
/** @deprecated Use krb5_free_keytab_entry_contents instead. */
 
4203
krb5_error_code KRB5_CALLCONV
 
4204
krb5_kt_free_entry(krb5_context context, krb5_keytab_entry *entry);
 
4205
 
1850
4206
 
1851
4207
/* remove and add are functions, so that they can return NOWRITE
1852
4208
   if not a writable keytab */
1853
 
krb5_error_code KRB5_CALLCONV
1854
 
krb5_kt_remove_entry(krb5_context, krb5_keytab, krb5_keytab_entry *);
1855
 
 
1856
 
krb5_error_code KRB5_CALLCONV
1857
 
krb5_kt_add_entry(krb5_context, krb5_keytab, krb5_keytab_entry *);
1858
 
 
 
4209
 
 
4210
/**
 
4211
 * Remove an entry from a key table.
 
4212
 *
 
4213
 * @param [in] context          Library context
 
4214
 * @param [in] id               Key table handle
 
4215
 * @param [in] entry            Entry to remove from key table
 
4216
 *
 
4217
 * @retval
 
4218
 * 0 Success
 
4219
 * @retval
 
4220
 *  KRB5_KT_NOWRITE     Key table is not writable
 
4221
 * @return
 
4222
 * Kerberos error codes
 
4223
 */
 
4224
krb5_error_code KRB5_CALLCONV
 
4225
krb5_kt_remove_entry(krb5_context context, krb5_keytab id, krb5_keytab_entry *entry);
 
4226
 
 
4227
/**
 
4228
 * Add a new entry to a key table.
 
4229
 *
 
4230
 * @param [in] context          Library context
 
4231
 * @param [in] id               Key table handle
 
4232
 * @param [in] entry            Entry to be added
 
4233
 *
 
4234
 * @retval
 
4235
 * 0  Success
 
4236
 * @retval
 
4237
 *  ENOMEM    Insufficient memory
 
4238
 * @retval
 
4239
 *  KRB5_KT_NOWRITE  Key table is not writeable
 
4240
 * @return
 
4241
 * Kerberos error codes
 
4242
 */
 
4243
krb5_error_code KRB5_CALLCONV
 
4244
krb5_kt_add_entry(krb5_context context, krb5_keytab id, krb5_keytab_entry *entry);
 
4245
 
 
4246
/**
 
4247
 * Convert a principal name into the default salt for that principal.
 
4248
 *
 
4249
 * @param [in]  context         Library context
 
4250
 * @param [in]  pr              Principal name
 
4251
 * @param [out] ret             Default salt for @a pr to be filled in
 
4252
 *
 
4253
 * @retval 0 Success; otherwise - Kerberos error codes
 
4254
 */
1859
4255
krb5_error_code KRB5_CALLCONV_WRONG
1860
 
krb5_principal2salt(krb5_context, krb5_const_principal, krb5_data *);
 
4256
krb5_principal2salt(krb5_context context,
 
4257
                    register krb5_const_principal pr, krb5_data *ret);
1861
4258
/* librc.spec--see rcache.h */
1862
4259
 
1863
4260
/* libcc.spec */
 
4261
 
 
4262
/**
 
4263
 * Resolve a credential cache name.
 
4264
 *
 
4265
 * @param [in]  context         Library context
 
4266
 * @param [in]  name            Credential cache name to be resolved
 
4267
 * @param [out] cache           Credential cache handle
 
4268
 *
 
4269
 * Fills in @a cache with a @a cache handle that corresponds to the name in @a
 
4270
 * name.  @a name should be of the form @c type:residual, and @a type must be a
 
4271
 * type known to the library.  If the @a name does not contain a colon,
 
4272
 * interpret it as a file name.
 
4273
 *
 
4274
 * @code
 
4275
 * Example: krb5_cc_resolve(context, "MEMORY:C_", &cache);
 
4276
 * @endcode
 
4277
 *
 
4278
 * @retval
 
4279
 * 0  Success
 
4280
 * @return
 
4281
 * Kerberos error codes
 
4282
 */
1864
4283
krb5_error_code KRB5_CALLCONV
1865
 
krb5_cc_resolve(krb5_context, const char *, krb5_ccache *);
 
4284
krb5_cc_resolve(krb5_context context, const char *name, krb5_ccache *cache);
1866
4285
 
1867
4286
/**
 
4287
 * Duplicate ccache handle.
 
4288
 *
 
4289
 * @param [in]  context         Library context
 
4290
 * @param [in]  in              Credential cache handle to be duplicated
 
4291
 * @param [out] out             Credential cache handle
 
4292
 *
1868
4293
 * Create a new handle referring to the same cache as @a in.
1869
4294
 * The new handle and @a in can be closed independently.
1870
4295
 */
1871
4296
krb5_error_code KRB5_CALLCONV
1872
4297
krb5_cc_dup(krb5_context context, krb5_ccache in, krb5_ccache *out);
1873
4298
 
 
4299
/**
 
4300
 * Return the name of the default credential cache.
 
4301
 *
 
4302
 * @param [in] context          Library context
 
4303
 *
 
4304
 * Try the environment variable KRB5CCNAME first then, if it is not set,
 
4305
 * fall back on the default ccache name for the OS.
 
4306
 *
 
4307
 * @return
 
4308
 * Name of default credential cache for the current user.
 
4309
 */
1874
4310
const char *KRB5_CALLCONV
1875
 
krb5_cc_default_name(krb5_context);
1876
 
 
1877
 
krb5_error_code KRB5_CALLCONV
1878
 
krb5_cc_set_default_name(krb5_context, const char *);
1879
 
 
1880
 
krb5_error_code KRB5_CALLCONV
1881
 
krb5_cc_default(krb5_context, krb5_ccache *);
1882
 
 
 
4311
krb5_cc_default_name(krb5_context context);
 
4312
 
 
4313
/**
 
4314
 * Set the default credential cache name.
 
4315
 *
 
4316
 * @param [in,out]  context     Library context
 
4317
 * @param [in]      name        Default credential cache name
 
4318
 *
 
4319
 * This function frees the old default credential cache name and then sets it
 
4320
 * to @a name.
 
4321
 *
 
4322
 * @retval
 
4323
 *  0  Success
 
4324
 * @retval
 
4325
 *  KV5M_CONTEXT          Bad magic number for @c _krb5_context structure
 
4326
 * @return
 
4327
 * Kerberos error codes
 
4328
 */
 
4329
krb5_error_code KRB5_CALLCONV
 
4330
krb5_cc_set_default_name(krb5_context context, const char *name);
 
4331
 
 
4332
/**
 
4333
 * Resolve the default crendentials cache name.
 
4334
 *
 
4335
 * @param [in,out] context      Library context
 
4336
 * @param [out]    ccache       Pointer to credential cache name
 
4337
 *
 
4338
 * @retval
 
4339
 * 0  Success
 
4340
 * @retval
 
4341
 * KV5M_CONTEXT            Bad magic number for @c _krb5_context structure
 
4342
 * @retval
 
4343
 * KRB5_FCC_INTERNAL       The name of the default credential cache cannot be
 
4344
 *                         obtained
 
4345
 * @return
 
4346
 * Kerberos error codes
 
4347
 */
 
4348
krb5_error_code KRB5_CALLCONV
 
4349
krb5_cc_default(krb5_context context, krb5_ccache *ccache);
 
4350
 
 
4351
/**
 
4352
 * Copy a credential cache.
 
4353
 *
 
4354
 * @param [in]  context         Library context
 
4355
 * @param [in]  incc            Credential cache to be copied
 
4356
 * @param [out] outcc           Copy of credential cache to be filled in
 
4357
 *
 
4358
 * @retval 0  Success; otherwise - Kerberos error codes
 
4359
 */
1883
4360
krb5_error_code KRB5_CALLCONV
1884
4361
krb5_cc_copy_creds(krb5_context context, krb5_ccache incc, krb5_ccache outcc);
1885
4362
 
1886
 
krb5_error_code KRB5_CALLCONV
1887
 
krb5_cc_get_config(krb5_context, krb5_ccache,
1888
 
                   krb5_const_principal,
1889
 
                   const char *, krb5_data *);
1890
 
 
1891
 
krb5_error_code KRB5_CALLCONV
1892
 
krb5_cc_set_config(krb5_context, krb5_ccache,
1893
 
                   krb5_const_principal,
1894
 
                   const char *, krb5_data *);
1895
 
 
1896
 
krb5_boolean KRB5_CALLCONV
1897
 
krb5_is_config_principal(krb5_context,
1898
 
                         krb5_const_principal);
 
4363
/**
 
4364
 * Get a configuration value from a credential cache.
 
4365
 *
 
4366
 * @param [in]     context      Library context
 
4367
 * @param [in]     id           Credential cache handle
 
4368
 * @param [in]     principal    Configuration for this principal;
 
4369
 *                              if NULL, global for the whole cache
 
4370
 * @param [in]     key          Name of config variable
 
4371
 * @param [out]    data         Data to be fetched
 
4372
 *
 
4373
 * Use krb5_free_data_contents() to free @a data when it is no longer needed.
 
4374
 *
 
4375
 * @retval
 
4376
 * 0  Success
 
4377
 * @return
 
4378
 * Kerberos error codes
 
4379
 */
 
4380
krb5_error_code KRB5_CALLCONV
 
4381
krb5_cc_get_config(krb5_context context, krb5_ccache id,
 
4382
                   krb5_const_principal principal,
 
4383
                   const char *key, krb5_data *data);
 
4384
 
 
4385
/**
 
4386
 * Store a configuration value in a credential cache.
 
4387
 *
 
4388
 * @param [in]     context      Library context
 
4389
 * @param [in]     id           Credential cache handle
 
4390
 * @param [in]     principal    Configuration for a specific principal;
 
4391
 *                              if NULL, global for the whole cache
 
4392
 * @param [in]     key          Name of config variable
 
4393
 * @param [in]     data         Data to store, or NULL to remove
 
4394
 *
 
4395
 * @note Existing configuration under the same key is over-written.
 
4396
 *
 
4397
 * @warning Before version 1.10 @a data was assumed to be always non-null.
 
4398
 *
 
4399
 * @retval
 
4400
 * 0  Success
 
4401
 * @return
 
4402
 * Kerberos error codes
 
4403
 */
 
4404
krb5_error_code KRB5_CALLCONV
 
4405
krb5_cc_set_config(krb5_context context, krb5_ccache id,
 
4406
                   krb5_const_principal principal,
 
4407
                   const char *key, krb5_data *data);
 
4408
 
 
4409
/**
 
4410
 * Test whether a principal is a configuration principal.
 
4411
 *
 
4412
 * @param [in] context          Library context
 
4413
 * @param [in] principal        Principal to check
 
4414
 *
 
4415
 * @return
 
4416
 * @c TRUE if the principal is a configuration principal (generated part of
 
4417
 * krb5_cc_set_config()); @c FALSE otherwise.
 
4418
 */
 
4419
krb5_boolean KRB5_CALLCONV
 
4420
krb5_is_config_principal(krb5_context context, krb5_const_principal principal);
 
4421
 
 
4422
/**
 
4423
 * Make a credential cache the primary cache for its collection.
 
4424
 *
 
4425
 * @param [in] context          Library context
 
4426
 * @param [in] cache            Credential cache handle
 
4427
 *
 
4428
 * If the type of @a cache supports it, set @a cache to be the primary
 
4429
 * credential cache for the collection it belongs to.
 
4430
 *
 
4431
 * @retval
 
4432
 * 0  Success, or the type of @a cache doesn't support switching
 
4433
 * @return
 
4434
 * Kerberos error codes
 
4435
 */
 
4436
krb5_error_code KRB5_CALLCONV
 
4437
krb5_cc_switch(krb5_context context, krb5_ccache cache);
 
4438
 
 
4439
/**
 
4440
 * Determine whether a credential cache type supports switching.
 
4441
 *
 
4442
 * @param [in] context          Library context
 
4443
 * @param [in] type             Credential cache type
 
4444
 *
 
4445
 * @retval TRUE if @a type supports switching
 
4446
 * @retval FALSE if it does not or is not a valid credential cache type.
 
4447
 */
 
4448
krb5_boolean KRB5_CALLCONV
 
4449
krb5_cc_support_switch(krb5_context context, const char *type);
 
4450
 
 
4451
/**
 
4452
 * Find a credential cache with a specified client principal.
 
4453
 *
 
4454
 * @param [in]  context         Library context
 
4455
 * @param [in]  client          Client principal
 
4456
 * @param [out] cache_out       Credential cache handle
 
4457
 *
 
4458
 * Find a cache within the collection whose default principal is @a client.
 
4459
 * Use @a krb5_cc_close to close @a ccache when it is no longer needed.
 
4460
 *
 
4461
 * @retval 0 Success
 
4462
 * @retval KRB5_CC_NOTFOUND
 
4463
 *
 
4464
 * @sa krb5_cccol_cursor_new
 
4465
 */
 
4466
krb5_error_code KRB5_CALLCONV
 
4467
krb5_cc_cache_match(krb5_context context, krb5_principal client,
 
4468
                    krb5_ccache *cache_out);
 
4469
 
 
4470
/**
 
4471
 * Select a credential cache to use with a server principal.
 
4472
 *
 
4473
 * @param [in]  context         Library context
 
4474
 * @param [in]  server          Server principal
 
4475
 * @param [out] cache_out       Credential cache handle
 
4476
 * @param [out] princ_out       Client principal
 
4477
 *
 
4478
 * Select a cache within the collection containing credentials most appropriate
 
4479
 * for use with @a server, according to configured rules and heuristics.
 
4480
 *
 
4481
 * Use krb5_cc_close() to release @a cache_out when it is no longer needed.
 
4482
 * Use krb5_free_principal() to release @a princ_out when it is no longer
 
4483
 * needed.  Note that @a princ_out is set in some error conditions.
 
4484
 *
 
4485
 * @return
 
4486
 * If an appropriate cache is found, 0 is returned, @a cache_out is set to the
 
4487
 * selected cache, and @a princ_out is set to the default principal of that
 
4488
 * cache.
 
4489
 *
 
4490
 * If the appropriate client principal can be authoritatively determined but
 
4491
 * the cache collection contains no credentials for that principal, then
 
4492
 * KRB5_CC_NOTFOUND is returned, @a cache_out is set to NULL, and @a princ_out
 
4493
 * is set to the appropriate client principal.
 
4494
 *
 
4495
 * If no configured mechanism can determine the appropriate cache or principal,
 
4496
 * KRB5_CC_NOTFOUND is returned and @a cache_out and @a princ_out are set to
 
4497
 * NULL.
 
4498
 *
 
4499
 * Any other error code indicates a fatal error in the processing of a cache
 
4500
 * selection mechanism.
 
4501
 */
 
4502
krb5_error_code KRB5_CALLCONV
 
4503
krb5_cc_select(krb5_context context, krb5_principal server,
 
4504
               krb5_ccache *cache_out, krb5_principal *princ_out);
1899
4505
 
1900
4506
/* krb5_free.c */
1901
 
void KRB5_CALLCONV krb5_free_principal(krb5_context, krb5_principal );
1902
 
void KRB5_CALLCONV krb5_free_authenticator(krb5_context,
1903
 
                                           krb5_authenticator * );
1904
 
void KRB5_CALLCONV krb5_free_addresses(krb5_context, krb5_address ** );
1905
 
void KRB5_CALLCONV krb5_free_authdata(krb5_context, krb5_authdata ** );
1906
 
void KRB5_CALLCONV krb5_free_ticket(krb5_context, krb5_ticket * );
1907
 
void KRB5_CALLCONV krb5_free_error(krb5_context, krb5_error * );
1908
 
void KRB5_CALLCONV krb5_free_creds(krb5_context, krb5_creds *);
1909
 
void KRB5_CALLCONV krb5_free_cred_contents(krb5_context, krb5_creds *);
1910
 
void KRB5_CALLCONV krb5_free_checksum(krb5_context, krb5_checksum *);
1911
 
void KRB5_CALLCONV krb5_free_checksum_contents(krb5_context, krb5_checksum *);
1912
 
void KRB5_CALLCONV krb5_free_keyblock(krb5_context, krb5_keyblock *);
1913
 
void KRB5_CALLCONV krb5_free_keyblock_contents(krb5_context, krb5_keyblock *);
1914
 
void KRB5_CALLCONV krb5_free_ap_rep_enc_part(krb5_context,
1915
 
                                             krb5_ap_rep_enc_part *);
1916
 
void KRB5_CALLCONV krb5_free_data(krb5_context, krb5_data *);
1917
 
void KRB5_CALLCONV krb5_free_data_contents(krb5_context, krb5_data *);
1918
 
void KRB5_CALLCONV krb5_free_unparsed_name(krb5_context, char *);
1919
 
void KRB5_CALLCONV krb5_free_cksumtypes(krb5_context, krb5_cksumtype *);
1920
 
 
1921
 
/* From krb5/os but needed but by the outside world */
1922
 
krb5_error_code KRB5_CALLCONV
1923
 
krb5_us_timeofday(krb5_context, krb5_timestamp *, krb5_int32 *);
1924
 
 
1925
 
krb5_error_code KRB5_CALLCONV
1926
 
krb5_timeofday(krb5_context, krb5_timestamp *);
1927
 
 
1928
 
/* get all the addresses of this host */
1929
 
krb5_error_code KRB5_CALLCONV
1930
 
krb5_os_localaddr(krb5_context, krb5_address ***);
1931
 
 
1932
 
krb5_error_code KRB5_CALLCONV
1933
 
krb5_get_default_realm(krb5_context, char **);
1934
 
 
1935
 
krb5_error_code KRB5_CALLCONV
1936
 
krb5_set_default_realm(krb5_context, const char * );
1937
 
 
1938
 
void KRB5_CALLCONV
1939
 
krb5_free_default_realm(krb5_context, char * );
1940
 
 
1941
 
krb5_error_code KRB5_CALLCONV
1942
 
krb5_sname_to_principal(krb5_context, const char *, const char *,  krb5_int32,
1943
 
                        krb5_principal *);
1944
 
 
 
4507
/**
 
4508
 * Free the storage assigned to a principal.
 
4509
 *
 
4510
 * @param [in] context          Library context
 
4511
 * @param [in] val              Principal to be freed
 
4512
 */
 
4513
void KRB5_CALLCONV
 
4514
krb5_free_principal(krb5_context context, krb5_principal val);
 
4515
 
 
4516
/**
 
4517
 * Free a krb5_authenticator structure.
 
4518
 *
 
4519
 * @param [in] context          Library context
 
4520
 * @param [in] val              Authenticator structure to be freed
 
4521
 *
 
4522
 * This function frees the contents of @a val and the structure itself.
 
4523
 */
 
4524
void KRB5_CALLCONV
 
4525
krb5_free_authenticator(krb5_context context, krb5_authenticator *val);
 
4526
 
 
4527
/**
 
4528
 * Free the data stored in array of addresses.
 
4529
 *
 
4530
 * @param [in] context          Library context
 
4531
 * @param [in] val              Array of addresses to be freed
 
4532
 *
 
4533
 * This function frees the contents of @a val and the array itself.
 
4534
 *
 
4535
 * @note The last entry in the array must be a NULL pointer.
 
4536
 */
 
4537
void KRB5_CALLCONV
 
4538
krb5_free_addresses(krb5_context context, krb5_address **val);
 
4539
 
 
4540
/**
 
4541
 * Free the storage assigned to array of authentication data.
 
4542
 *
 
4543
 * @param [in] context          Library context
 
4544
 * @param [in] val              Array of authentication data to be freed
 
4545
 *
 
4546
 * This function frees the contents of @a val and the array itself.
 
4547
 *
 
4548
 * @note The last entry in the array must be a NULL pointer.
 
4549
 */
 
4550
void KRB5_CALLCONV
 
4551
krb5_free_authdata(krb5_context context, krb5_authdata **val);
 
4552
 
 
4553
/**
 
4554
 * Free a ticket.
 
4555
 *
 
4556
 * @param [in] context          Library context
 
4557
 * @param [in] val              Ticket to be freed
 
4558
 *
 
4559
 * This function frees the contents of @a val and the structure itself.
 
4560
 */
 
4561
void KRB5_CALLCONV
 
4562
krb5_free_ticket(krb5_context context, krb5_ticket *val);
 
4563
 
 
4564
/**
 
4565
 * Free an error allocated by krb5_read_error() or krb5_sendauth().
 
4566
 *
 
4567
 * @param [in] context          Library context
 
4568
 * @param [in] val              Error data structure to be freed
 
4569
 *
 
4570
 * This function frees the contents of @a val and the structure itself.
 
4571
 */
 
4572
void KRB5_CALLCONV
 
4573
krb5_free_error(krb5_context context, register krb5_error *val);
 
4574
 
 
4575
/**
 
4576
 * Free a krb5_creds structure.
 
4577
 *
 
4578
 * @param [in] context          Library context
 
4579
 * @param [in] val              Credential structure to be freed.
 
4580
 *
 
4581
 * This function frees the contents of @a val and the structure itself.
 
4582
 */
 
4583
void KRB5_CALLCONV
 
4584
krb5_free_creds(krb5_context context, krb5_creds *val);
 
4585
 
 
4586
/**
 
4587
 * Free the contents of a krb5_creds structure.
 
4588
 *
 
4589
 * @param [in] context          Library context
 
4590
 * @param [in] val              Credential structure to free contents of
 
4591
 *
 
4592
 * This function frees the contents of @a val, but not the structure itself.
 
4593
 */
 
4594
void KRB5_CALLCONV
 
4595
krb5_free_cred_contents(krb5_context context, krb5_creds *val);
 
4596
 
 
4597
/**
 
4598
 * Free a krb5_checksum structure.
 
4599
 *
 
4600
 * @param [in] context          Library context
 
4601
 * @param [in] val              Checksum structure to be freed
 
4602
 *
 
4603
 * This function frees the contents of @a val and the structure itself.
 
4604
 */
 
4605
void KRB5_CALLCONV
 
4606
krb5_free_checksum(krb5_context context, register krb5_checksum *val);
 
4607
 
 
4608
/**
 
4609
 * Free the contents of a krb5_checksum structure.
 
4610
 *
 
4611
 * @param [in] context          Library context
 
4612
 * @param [in] val              Checksum structure to free contents of
 
4613
 *
 
4614
 * This function frees the contents of @a val, but not the structure itself.
 
4615
 */
 
4616
void KRB5_CALLCONV
 
4617
krb5_free_checksum_contents(krb5_context context, register krb5_checksum *val);
 
4618
 
 
4619
/**
 
4620
 * Free a krb5_keyblock structure.
 
4621
 *
 
4622
 * @param [in] context          Library context
 
4623
 * @param [in] val              Keyblock to be freed
 
4624
 *
 
4625
 * This function frees the contents of @a val and the structure itself.
 
4626
 */
 
4627
void KRB5_CALLCONV
 
4628
krb5_free_keyblock(krb5_context context, register krb5_keyblock *val);
 
4629
 
 
4630
/**
 
4631
 * Free the contents of a krb5_keyblock structure.
 
4632
 *
 
4633
 * @param [in] context          Library context
 
4634
 * @param [in] key              Keyblock to be freed
 
4635
 *
 
4636
 * This function frees the contents of @a key, but not the structure itself.
 
4637
 */
 
4638
void KRB5_CALLCONV
 
4639
krb5_free_keyblock_contents(krb5_context context, register krb5_keyblock *key);
 
4640
 
 
4641
/**
 
4642
 * Free a krb5_ap_rep_enc_part structure.
 
4643
 *
 
4644
 * @param [in] context          Library context
 
4645
 * @param [in] val              AP-REP enc part to be freed
 
4646
 *
 
4647
 * This function frees the contents of @a val and the structure itself.
 
4648
 */
 
4649
void KRB5_CALLCONV
 
4650
krb5_free_ap_rep_enc_part(krb5_context context, krb5_ap_rep_enc_part *val);
 
4651
 
 
4652
/**
 
4653
 * Free a krb5_data structure.
 
4654
 *
 
4655
 * @param [in] context          Library context
 
4656
 * @param [in] val              Data structure to be freed
 
4657
 *
 
4658
 * This function frees the contents of @a val and the structure itself.
 
4659
 */
 
4660
void KRB5_CALLCONV
 
4661
krb5_free_data(krb5_context context, krb5_data *val);
 
4662
 
 
4663
/**
 
4664
 * Free storage associated with a @c krb5_octet_data structure and its pointer.
 
4665
 *
 
4666
 * @param [in] context          Context structure
 
4667
 * @param [in] val              Data structure to be freed
 
4668
 *
 
4669
 * @return
 
4670
 * None
 
4671
 */
 
4672
void KRB5_CALLCONV
 
4673
krb5_free_octet_data(krb5_context context, krb5_octet_data *val);
 
4674
 
 
4675
/**
 
4676
 * Free the contents of a krb5_data structure and zero the data field.
 
4677
 *
 
4678
 * @param [in] context          Library context
 
4679
 * @param [in] val              Data structure to free contents of
 
4680
 *
 
4681
 * This function frees the contents of @a val, but not the structure itself.
 
4682
 */
 
4683
void KRB5_CALLCONV
 
4684
krb5_free_data_contents(krb5_context context, krb5_data *val);
 
4685
 
 
4686
/**
 
4687
 * Free a string representation of a principal.
 
4688
 *
 
4689
 * @param [in] context          Library context
 
4690
 * @param [in] val              Name string to be freed
 
4691
 */
 
4692
void KRB5_CALLCONV
 
4693
krb5_free_unparsed_name(krb5_context context, char *val);
 
4694
 
 
4695
/**
 
4696
 * Free a string allocated by a krb5 function.
 
4697
 *
 
4698
 * @param [in] context          Library context
 
4699
 * @param [in] val              String to be freed
 
4700
 */
 
4701
void KRB5_CALLCONV
 
4702
krb5_free_string(krb5_context context, char *val);
 
4703
 
 
4704
/**
 
4705
 * Free an array of checksum types.
 
4706
 *
 
4707
 * @param [in] context          Library context
 
4708
 * @param [in] val              Array of checksum types to be freed
 
4709
 */
 
4710
void KRB5_CALLCONV
 
4711
krb5_free_cksumtypes(krb5_context context, krb5_cksumtype *val);
 
4712
 
 
4713
/* From krb5/os, but needed by the outside world */
 
4714
/**
 
4715
 * Retrieve the system time of day, in sec and ms, since the epoch.
 
4716
 *
 
4717
 * @param [in]  context         Library context
 
4718
 * @param [out] seconds         System timeofday, seconds portion
 
4719
 * @param [out] microseconds    System timeofday, microseconds portion
 
4720
 *
 
4721
 * This function retrieves the system time of day with the context
 
4722
 * specific time offset adjustment.
 
4723
 *
 
4724
 * @sa krb5_crypto_us_timeofday()
 
4725
 *
 
4726
 * @retval
 
4727
 * 0  Success
 
4728
 * @return
 
4729
 * Kerberos error codes
 
4730
 */
 
4731
krb5_error_code KRB5_CALLCONV
 
4732
krb5_us_timeofday(krb5_context context,
 
4733
                  krb5_timestamp *seconds, krb5_int32 *microseconds);
 
4734
 
 
4735
/**
 
4736
 * Retrieve the current time with context specific time offset adjustment.
 
4737
 *
 
4738
 * @param [in]     context      Library context
 
4739
 * @param [in,out] timeret      Timestamp to fill in
 
4740
 *
 
4741
 * This function retrieves the system time of day with the context specific
 
4742
 * time offset adjustment.
 
4743
 *
 
4744
 * @retval
 
4745
 * 0  Success
 
4746
 * @return
 
4747
 * Kerberos error codes
 
4748
 */
 
4749
krb5_error_code KRB5_CALLCONV
 
4750
krb5_timeofday(krb5_context context, register krb5_timestamp *timeret);
 
4751
 
 
4752
/**
 
4753
 * Check if a timestamp is within the allowed clock skew of the current time.
 
4754
 *
 
4755
 * @param [in]     context      Library context
 
4756
 * @param [in]     date         Timestamp to check
 
4757
 *
 
4758
 * This function checks if @a date is close enough to the current time
 
4759
 * according to the configured allowable clock skew.
 
4760
 *
 
4761
 * @retval 0 Success
 
4762
 * @retval KRB5KRB_AP_ERR_SKEW @a date is not within allowable clock skew
 
4763
 */
 
4764
krb5_error_code KRB5_CALLCONV
 
4765
krb5_check_clockskew(krb5_context context, krb5_timestamp date);
 
4766
 
 
4767
/**
 
4768
 * Return all interface addresses for this host.
 
4769
 *
 
4770
 * @param [in]  context         Library context
 
4771
 * @param [out] addr            Array of krb5_address pointers, ending with
 
4772
 *                              NULL
 
4773
 *
 
4774
 * Use krb5_free_addresses() to free @a addr when it is no longer needed.
 
4775
 *
 
4776
 * @retval 0 Success; otherwise - Kerberos error codes
 
4777
 */
 
4778
krb5_error_code KRB5_CALLCONV
 
4779
krb5_os_localaddr(krb5_context context, krb5_address ***addr);
 
4780
 
 
4781
/**
 
4782
 * Retrieve the default realm.
 
4783
 *
 
4784
 * @param [in]  context         Library context
 
4785
 * @param [out] lrealm          Default realm name
 
4786
 *
 
4787
 * Retrieves the default realm to be used if no user-specified realm is
 
4788
 * available.
 
4789
 *
 
4790
 * Use krb5_free_default_realm() to free @a lrealm when it is no longer needed.
 
4791
 *
 
4792
 * @retval
 
4793
 * 0  Success
 
4794
 * @return
 
4795
 * Kerberos error codes
 
4796
 */
 
4797
krb5_error_code KRB5_CALLCONV
 
4798
krb5_get_default_realm(krb5_context context, char **lrealm);
 
4799
 
 
4800
/**
 
4801
 * Override the default realm for the specified context.
 
4802
 *
 
4803
 * @param [in]     context      Library context
 
4804
 * @param [in]     lrealm       Realm name for the default realm
 
4805
 *
 
4806
 * If @a lrealm is NULL, clear the default realm setting.
 
4807
 *
 
4808
 * @retval
 
4809
 * 0  Success
 
4810
 * @return
 
4811
 * Kerberos error codes
 
4812
 */
 
4813
krb5_error_code KRB5_CALLCONV
 
4814
krb5_set_default_realm(krb5_context context, const char *lrealm);
 
4815
 
 
4816
/**
 
4817
 * Free a default realm string returned by krb5_get_default_realm().
 
4818
 *
 
4819
 * @param [in] context          Library context
 
4820
 * @param [in] lrealm           Realm to be freed
 
4821
 */
 
4822
void KRB5_CALLCONV
 
4823
krb5_free_default_realm(krb5_context context, char *lrealm);
 
4824
 
 
4825
/**
 
4826
 * Generate a full principal name from a service name.
 
4827
 *
 
4828
 * @param [in]  context         Library context
 
4829
 * @param [in]  hostname        Host name, or NULL to use local host
 
4830
 * @param [in]  sname           Service name, or NULL to use @c "host"
 
4831
 * @param [in]  type            Principal type
 
4832
 * @param [out] ret_princ       Generated principal
 
4833
 *
 
4834
 * This function converts a @a hostname and @a sname into @a krb5_principal
 
4835
 * structure @a ret_princ.  The returned principal will be of the form @a
 
4836
 * sname\/hostname\@REALM where REALM is determined by krb5_get_host_realm().
 
4837
 * In some cases this may be the referral (empty) realm.
 
4838
 *
 
4839
 * The @a type can be one of the following:
 
4840
 *
 
4841
 * @li #KRB5_NT_SRV_HOST canonicalizes the host name before looking up the
 
4842
 * realm and generating the principal.
 
4843
 *
 
4844
 * @li #KRB5_NT_UNKNOWN accepts the hostname as given, and does not
 
4845
 * canonicalize it.
 
4846
 *
 
4847
 * Use krb5_free_principal to free @a ret_princ when it is no longer needed.
 
4848
 *
 
4849
 * @retval
 
4850
 * 0  Success
 
4851
 * @return
 
4852
 * Kerberos error codes
 
4853
 */
 
4854
krb5_error_code KRB5_CALLCONV
 
4855
krb5_sname_to_principal(krb5_context context, const char *hostname, const char *sname,
 
4856
                        krb5_int32 type, krb5_principal *ret_princ);
 
4857
 
 
4858
/**
 
4859
 * Test whether a principal matches a matching principal.
 
4860
 *
 
4861
 * @param [in]  context         Library context
 
4862
 * @param [in]  matching        Matching principal
 
4863
 * @param [in]  princ           Principal to test
 
4864
 *
 
4865
 * @note A matching principal is a host-based principal with an empty realm
 
4866
 * and/or second data component (hostname).  Profile configuration may cause
 
4867
 * the hostname to be ignored even if it is present.  A principal matches a
 
4868
 * matching principal if the former has the same non-empty (and non-ignored)
 
4869
 * components of the latter.
 
4870
 *
 
4871
 * If @a matching is NULL, return TRUE.  If @a matching is not a matching
 
4872
 * principal, return the value of krb5_principal_compare(context, matching,
 
4873
 * princ).
 
4874
 *
 
4875
 * @return
 
4876
 * TRUE if @a princ matches @a matching, FALSE otherwise.
 
4877
 */
 
4878
krb5_boolean KRB5_CALLCONV
 
4879
krb5_sname_match(krb5_context context, krb5_const_principal matching,
 
4880
                 krb5_const_principal princ);
 
4881
 
 
4882
/**
 
4883
 * Change a password for an existing Kerberos account.
 
4884
 *
 
4885
 * @param [in]  context             Library context
 
4886
 * @param [in]  creds               Credentials for kadmin/changepw service
 
4887
 * @param [in]  newpw               New password
 
4888
 * @param [out] result_code         Numeric error code from server
 
4889
 * @param [out] result_code_string  String equivalent to @a result_code
 
4890
 * @param [out] result_string       Change password response from the KDC
 
4891
 *
 
4892
 * Change the password for the existing principal identified by @a creds.
 
4893
 *
 
4894
 * The possible values of the output @a result_code are:
 
4895
 *
 
4896
 * @li #KRB5_KPASSWD_SUCCESS   (0) - success
 
4897
 * @li #KRB5_KPASSWD_MALFORMED (1) - Malformed request error
 
4898
 * @li #KRB5_KPASSWD_HARDERROR (2) - Server error
 
4899
 * @li #KRB5_KPASSWD_AUTHERROR (3) - Authentication error
 
4900
 * @li #KRB5_KPASSWD_SOFTERROR (4) - Password change rejected
 
4901
 *
 
4902
 * @retval 0 Success; otherwise - Kerberos error codes
 
4903
 */
1945
4904
krb5_error_code KRB5_CALLCONV
1946
4905
krb5_change_password(krb5_context context, krb5_creds *creds, char *newpw,
1947
4906
                     int *result_code, krb5_data *result_code_string,
1948
4907
                     krb5_data *result_string);
1949
4908
 
 
4909
/**
 
4910
 * Set a password for a principal using specified credentials.
 
4911
 *
 
4912
 * @param [in]  context              Library context
 
4913
 * @param [in]  creds                Credentials for kadmin/changepw service
 
4914
 * @param [in]  newpw                New password
 
4915
 * @param [in]  change_password_for  Change the password for this principal
 
4916
 * @param [out] result_code          Numeric error code from server
 
4917
 * @param [out] result_code_string   String equivalent to @a result_code
 
4918
 * @param [out] result_string        Data returned from the remote system
 
4919
 *
 
4920
 * This function uses the credentials @a creds to set the password @a newpw for
 
4921
 * the principal @a change_password_for.  It implements the set password
 
4922
 * operation of RFC 3244, for interoperability with Microsoft Windows
 
4923
 * implementations.
 
4924
 *
 
4925
 * @note If @a change_password_for is NULL, the change is performed on the
 
4926
 * current principal. If @a change_password_for is non-null, the change is
 
4927
 * performed on the principal name passed in @a change_password_for.
 
4928
 *
 
4929
 * The error code and strings are returned in @a result_code,
 
4930
 * @a result_code_string and @a result_string.
 
4931
 *
 
4932
 * @sa krb5_set_password_using_ccache()
 
4933
 *
 
4934
 * @retval
 
4935
 * 0  Success and result_code is set to #KRB5_KPASSWD_SUCCESS.
 
4936
 * @return
 
4937
 * Kerberos error codes.
 
4938
 */
1950
4939
krb5_error_code KRB5_CALLCONV
1951
4940
krb5_set_password(krb5_context context, krb5_creds *creds, char *newpw,
1952
4941
                  krb5_principal change_password_for, int *result_code,
1953
4942
                  krb5_data *result_code_string, krb5_data *result_string);
1954
4943
 
 
4944
/**
 
4945
 * Set a password for a principal using cached credentials.
 
4946
 *
 
4947
 * @param [in]  context              Library context
 
4948
 * @param [in]  ccache               Credential cache
 
4949
 * @param [in]  newpw                New password
 
4950
 * @param [in]  change_password_for  Change the password for this principal
 
4951
 * @param [out] result_code          Numeric error code from server
 
4952
 * @param [out] result_code_string   String equivalent to @a result_code
 
4953
 * @param [out] result_string        Data returned from the remote system
 
4954
 *
 
4955
 * This function uses the cached credentials from @a ccache to set the password
 
4956
 * @a newpw for the principal @a change_password_for.  It implements RFC 3244
 
4957
 * set password operation (interoperable with MS Windows implementations) using
 
4958
 * the credential cache.
 
4959
 *
 
4960
 * The error code and strings are returned in @a result_code,
 
4961
 * @a result_code_string and @a result_string.
 
4962
 *
 
4963
 * @note If @a change_password_for is set to NULL, the change is performed on
 
4964
 * the default principal in @a ccache. If @a change_password_for is non null,
 
4965
 * the change is performed on the specified principal.
 
4966
 *
 
4967
 * @sa krb5_set_password()
 
4968
 *
 
4969
 * @retval
 
4970
 * 0  Success
 
4971
 * @return
 
4972
 * Kerberos error codes
 
4973
 */
1955
4974
krb5_error_code KRB5_CALLCONV
1956
4975
krb5_set_password_using_ccache(krb5_context context, krb5_ccache ccache,
1957
4976
                               char *newpw, krb5_principal change_password_for,
1958
4977
                               int *result_code, krb5_data *result_code_string,
1959
4978
                               krb5_data *result_string);
1960
4979
 
 
4980
/**
 
4981
 * Retrieve configuration profile from the context.
 
4982
 *
 
4983
 * @param [in]  context         Library context
 
4984
 * @param [out] profile         Pointer to data read from a configuration file
 
4985
 *
 
4986
 * This function creates a new @a profile object that reflects profile
 
4987
 * in the supplied @a context.
 
4988
 *
 
4989
 * The @a profile object may be freed with profile_release() function.
 
4990
 * See profile.h and profile API for more details.
 
4991
 *
 
4992
 * @retval
 
4993
 * 0 Success
 
4994
 * @return
 
4995
 * Kerberos error codes
 
4996
 */
1961
4997
krb5_error_code KRB5_CALLCONV
1962
 
krb5_get_profile(krb5_context, struct _profile_t * /* profile_t */ *);
 
4998
krb5_get_profile(krb5_context context, struct _profile_t ** profile);
1963
4999
 
1964
5000
#if KRB5_DEPRECATED
1965
 
KRB5_ATTR_DEPRECATED krb5_error_code KRB5_CALLCONV
1966
 
krb5_get_in_tkt_with_password(krb5_context, krb5_flags, krb5_address *const *,
1967
 
                              krb5_enctype *, krb5_preauthtype *, const char *,
1968
 
                              krb5_ccache, krb5_creds *, krb5_kdc_rep **);
1969
 
 
1970
 
KRB5_ATTR_DEPRECATED krb5_error_code KRB5_CALLCONV
1971
 
krb5_get_in_tkt_with_skey(krb5_context, krb5_flags, krb5_address *const *,
1972
 
                          krb5_enctype *, krb5_preauthtype *,
1973
 
                          const krb5_keyblock *, krb5_ccache, krb5_creds *,
1974
 
                          krb5_kdc_rep **);
1975
 
 
1976
 
KRB5_ATTR_DEPRECATED krb5_error_code KRB5_CALLCONV
1977
 
krb5_get_in_tkt_with_keytab(krb5_context, krb5_flags, krb5_address *const *,
1978
 
                            krb5_enctype *, krb5_preauthtype *, krb5_keytab,
1979
 
                            krb5_ccache, krb5_creds *, krb5_kdc_rep ** );
 
5001
/** @deprecated Replaced by krb5_get_init_creds_password().*/
 
5002
KRB5_ATTR_DEPRECATED krb5_error_code KRB5_CALLCONV
 
5003
krb5_get_in_tkt_with_password(krb5_context context, krb5_flags options,
 
5004
                              krb5_address *const *addrs, krb5_enctype *ktypes,
 
5005
                              krb5_preauthtype *pre_auth_types,
 
5006
                              const char *password, krb5_ccache ccache,
 
5007
                              krb5_creds *creds, krb5_kdc_rep **ret_as_reply);
 
5008
 
 
5009
/** @deprecated Replaced by krb5_get_init_creds(). */
 
5010
KRB5_ATTR_DEPRECATED krb5_error_code KRB5_CALLCONV
 
5011
krb5_get_in_tkt_with_skey(krb5_context context, krb5_flags options,
 
5012
                          krb5_address *const *addrs, krb5_enctype *ktypes,
 
5013
                          krb5_preauthtype *pre_auth_types,
 
5014
                          const krb5_keyblock *key, krb5_ccache ccache,
 
5015
                          krb5_creds *creds, krb5_kdc_rep **ret_as_reply);
 
5016
 
 
5017
/** @deprecated Replaced by krb5_get_init_creds_keytab(). */
 
5018
KRB5_ATTR_DEPRECATED krb5_error_code KRB5_CALLCONV
 
5019
krb5_get_in_tkt_with_keytab(krb5_context context, krb5_flags options,
 
5020
                            krb5_address *const *addrs, krb5_enctype *ktypes,
 
5021
                            krb5_preauthtype *pre_auth_types,
 
5022
                            krb5_keytab arg_keytab, krb5_ccache ccache,
 
5023
                            krb5_creds *creds, krb5_kdc_rep **ret_as_reply);
 
5024
 
1980
5025
#endif /* KRB5_DEPRECATED */
1981
5026
 
1982
 
krb5_error_code KRB5_CALLCONV
1983
 
krb5_rd_req(krb5_context, krb5_auth_context *, const krb5_data *,
1984
 
            krb5_const_principal, krb5_keytab, krb5_flags *, krb5_ticket **);
1985
 
 
1986
 
krb5_error_code KRB5_CALLCONV
1987
 
krb5_kt_read_service_key(krb5_context, krb5_pointer, krb5_principal, krb5_kvno,
1988
 
                         krb5_enctype, krb5_keyblock **);
1989
 
 
1990
 
krb5_error_code KRB5_CALLCONV
1991
 
krb5_mk_safe(krb5_context, krb5_auth_context, const krb5_data *, krb5_data *,
1992
 
             krb5_replay_data *);
1993
 
 
1994
 
krb5_error_code KRB5_CALLCONV
1995
 
krb5_mk_priv(krb5_context, krb5_auth_context, const krb5_data *, krb5_data *,
1996
 
             krb5_replay_data *);
1997
 
 
1998
 
krb5_error_code KRB5_CALLCONV
1999
 
krb5_sendauth(krb5_context, krb5_auth_context *, krb5_pointer, char *,
2000
 
              krb5_principal, krb5_principal, krb5_flags, krb5_data *,
2001
 
              krb5_creds *, krb5_ccache, krb5_error **,
2002
 
              krb5_ap_rep_enc_part **, krb5_creds **);
2003
 
 
2004
 
krb5_error_code KRB5_CALLCONV
2005
 
krb5_recvauth(krb5_context, krb5_auth_context *, krb5_pointer, char *,
2006
 
              krb5_principal, krb5_int32, krb5_keytab, krb5_ticket **);
2007
 
 
2008
 
krb5_error_code KRB5_CALLCONV
2009
 
krb5_recvauth_version(krb5_context, krb5_auth_context *, krb5_pointer,
2010
 
                      krb5_principal, krb5_int32, krb5_keytab, krb5_ticket **,
2011
 
                      krb5_data *);
2012
 
 
2013
 
krb5_error_code KRB5_CALLCONV
2014
 
krb5_mk_ncred(krb5_context, krb5_auth_context, krb5_creds **, krb5_data **,
2015
 
              krb5_replay_data *);
2016
 
 
2017
 
krb5_error_code KRB5_CALLCONV
2018
 
krb5_mk_1cred(krb5_context, krb5_auth_context, krb5_creds *, krb5_data **,
2019
 
              krb5_replay_data *);
2020
 
 
2021
 
krb5_error_code KRB5_CALLCONV
2022
 
krb5_rd_cred(krb5_context, krb5_auth_context, krb5_data *, krb5_creds ***,
2023
 
             krb5_replay_data *);
2024
 
 
2025
 
krb5_error_code KRB5_CALLCONV
2026
 
krb5_fwd_tgt_creds(krb5_context, krb5_auth_context, char *, krb5_principal,
2027
 
                   krb5_principal, krb5_ccache, int forwardable, krb5_data *);
2028
 
 
2029
 
krb5_error_code KRB5_CALLCONV
2030
 
krb5_auth_con_init(krb5_context, krb5_auth_context *);
2031
 
 
2032
 
krb5_error_code KRB5_CALLCONV
2033
 
krb5_auth_con_free(krb5_context, krb5_auth_context);
2034
 
 
2035
 
krb5_error_code KRB5_CALLCONV
2036
 
krb5_auth_con_setflags(krb5_context, krb5_auth_context, krb5_int32);
2037
 
 
2038
 
krb5_error_code KRB5_CALLCONV
2039
 
krb5_auth_con_getflags(krb5_context, krb5_auth_context, krb5_int32 *);
2040
 
 
2041
 
krb5_error_code KRB5_CALLCONV
2042
 
krb5_auth_con_set_checksum_func(krb5_context, krb5_auth_context,
2043
 
                                krb5_mk_req_checksum_func, void *);
2044
 
 
2045
 
krb5_error_code KRB5_CALLCONV
2046
 
krb5_auth_con_get_checksum_func(krb5_context, krb5_auth_context,
2047
 
                                krb5_mk_req_checksum_func *, void **);
2048
 
 
2049
 
krb5_error_code KRB5_CALLCONV_WRONG
2050
 
krb5_auth_con_setaddrs(krb5_context, krb5_auth_context, krb5_address *,
2051
 
                       krb5_address *);
2052
 
 
2053
 
krb5_error_code KRB5_CALLCONV
2054
 
krb5_auth_con_getaddrs(krb5_context, krb5_auth_context, krb5_address **,
2055
 
                       krb5_address **);
2056
 
 
2057
 
krb5_error_code KRB5_CALLCONV
2058
 
krb5_auth_con_setports(krb5_context, krb5_auth_context, krb5_address *,
2059
 
                       krb5_address *);
2060
 
 
2061
 
krb5_error_code KRB5_CALLCONV
2062
 
krb5_auth_con_setuseruserkey(krb5_context, krb5_auth_context, krb5_keyblock *);
2063
 
 
2064
 
krb5_error_code KRB5_CALLCONV
2065
 
krb5_auth_con_getkey(krb5_context, krb5_auth_context, krb5_keyblock **);
2066
 
 
2067
 
krb5_error_code KRB5_CALLCONV
2068
 
krb5_auth_con_getkey_k(krb5_context, krb5_auth_context, krb5_key *);
2069
 
 
2070
 
krb5_error_code KRB5_CALLCONV
2071
 
krb5_auth_con_getsendsubkey(krb5_context, krb5_auth_context, krb5_keyblock **);
2072
 
 
2073
 
krb5_error_code KRB5_CALLCONV
2074
 
krb5_auth_con_getsendsubkey_k(krb5_context, krb5_auth_context, krb5_key *);
2075
 
 
2076
 
krb5_error_code KRB5_CALLCONV
2077
 
krb5_auth_con_getrecvsubkey(krb5_context, krb5_auth_context, krb5_keyblock **);
2078
 
 
2079
 
krb5_error_code KRB5_CALLCONV
2080
 
krb5_auth_con_getrecvsubkey_k(krb5_context, krb5_auth_context, krb5_key *);
2081
 
 
2082
 
krb5_error_code KRB5_CALLCONV
2083
 
krb5_auth_con_setsendsubkey(krb5_context, krb5_auth_context, krb5_keyblock *);
2084
 
 
2085
 
krb5_error_code KRB5_CALLCONV
2086
 
krb5_auth_con_setsendsubkey_k(krb5_context, krb5_auth_context, krb5_key);
2087
 
 
2088
 
krb5_error_code KRB5_CALLCONV
2089
 
krb5_auth_con_setrecvsubkey(krb5_context, krb5_auth_context, krb5_keyblock *);
2090
 
 
2091
 
krb5_error_code KRB5_CALLCONV
2092
 
krb5_auth_con_setrecvsubkey_k(krb5_context, krb5_auth_context, krb5_key);
2093
 
 
2094
 
#if KRB5_DEPRECATED
2095
 
KRB5_ATTR_DEPRECATED krb5_error_code KRB5_CALLCONV
2096
 
krb5_auth_con_getlocalsubkey(krb5_context, krb5_auth_context,
2097
 
                             krb5_keyblock **);
2098
 
 
2099
 
KRB5_ATTR_DEPRECATED krb5_error_code KRB5_CALLCONV
2100
 
krb5_auth_con_getremotesubkey(krb5_context, krb5_auth_context,
2101
 
                              krb5_keyblock **);
2102
 
#endif
2103
 
 
2104
 
krb5_error_code KRB5_CALLCONV
2105
 
krb5_auth_con_getlocalseqnumber(krb5_context, krb5_auth_context, krb5_int32 *);
2106
 
 
2107
 
krb5_error_code KRB5_CALLCONV
2108
 
krb5_auth_con_getremoteseqnumber(krb5_context, krb5_auth_context,
2109
 
                                 krb5_int32 *);
2110
 
 
2111
 
#if KRB5_DEPRECATED
2112
 
KRB5_ATTR_DEPRECATED krb5_error_code KRB5_CALLCONV
2113
 
krb5_auth_con_initivector(krb5_context, krb5_auth_context);
2114
 
#endif
2115
 
 
2116
 
krb5_error_code KRB5_CALLCONV
2117
 
krb5_auth_con_setrcache(krb5_context, krb5_auth_context, krb5_rcache);
2118
 
 
2119
 
krb5_error_code KRB5_CALLCONV_WRONG
2120
 
krb5_auth_con_getrcache(krb5_context, krb5_auth_context, krb5_rcache *);
2121
 
 
2122
 
krb5_error_code KRB5_CALLCONV
2123
 
krb5_auth_con_getauthenticator(krb5_context, krb5_auth_context,
2124
 
                               krb5_authenticator **);
2125
 
 
2126
 
krb5_error_code KRB5_CALLCONV
2127
 
krb5_auth_con_set_req_cksumtype(krb5_context, krb5_auth_context,
2128
 
                                krb5_cksumtype);
 
5027
/**
 
5028
 * Parse and decrypt a @c KRB_AP_REQ message.
 
5029
 *
 
5030
 * @param [in]     context        Library context
 
5031
 * @param [in,out] auth_context   Pre-existing or newly created auth context
 
5032
 * @param [in]     inbuf          AP-REQ message to be parsed
 
5033
 * @param [in]     server         Matching principal for server, or NULL to
 
5034
 *                                allow any principal in keytab
 
5035
 * @param [in]     keytab         Key table, or NULL to use the default
 
5036
 * @param [out]    ap_req_options If non-null, the AP-REQ flags on output
 
5037
 * @param [out]    ticket         If non-null, ticket from the AP-REQ message
 
5038
 *
 
5039
 * This function parses, decrypts and verifies a AP-REQ message from @a inbuf
 
5040
 * and stores the authenticator in @a auth_context.
 
5041
 *
 
5042
 * If a keyblock is present in the @a auth_context, it is used to decrypt the
 
5043
 * ticket in AP-REQ message. (This is useful for user-to-user authentication.)
 
5044
 * Otherwise, the decryption key is obtained from the @a keytab.  If @a keytab
 
5045
 * is iterable, all of its key entries it will be tried against the ticket;
 
5046
 * otherwise, the server principal in the ticket will be looked up in the
 
5047
 * keytab and that key will be tried.
 
5048
 *
 
5049
 * The client specified in the decrypted authenticator must match the client
 
5050
 * specified in the decrypted ticket.  If @a server is non-null, the key in
 
5051
 * which the ticket is encrypted must correspond to a principal in @a keytab
 
5052
 * matching @a server according to the rules of krb5_sname_match().
 
5053
 *
 
5054
 * If the @a remote_addr field of @a auth_context is set, the request must come
 
5055
 * from that address.
 
5056
 *
 
5057
 * If a replay cache handle is provided in the @a auth_context, the
 
5058
 * authenticator and ticket are verified against it.  If no conflict is found,
 
5059
 * the new authenticator is then stored in the replay cash of @a auth_context.
 
5060
 *
 
5061
 * Various other checks are performed on the decoded data, including
 
5062
 * cross-realm policy, clockskew, and ticket validation times.
 
5063
 *
 
5064
 * On success the authenticator, subkey, and remote sequence number of the
 
5065
 * request are stored in @a auth_context. If the #AP_OPTS_MUTUAL_REQUIRED
 
5066
 * bit is set, the local sequence number is XORed with the remote sequence
 
5067
 * number in the request.
 
5068
 *
 
5069
 * Use krb5_free_ticket() to free @a ticket when it is no longer needed.
 
5070
 *
 
5071
 * @retval 0 Success; otherwise - Kerberos error codes
 
5072
 */
 
5073
krb5_error_code KRB5_CALLCONV
 
5074
krb5_rd_req(krb5_context context, krb5_auth_context *auth_context,
 
5075
            const krb5_data *inbuf, krb5_const_principal server,
 
5076
            krb5_keytab keytab, krb5_flags *ap_req_options,
 
5077
            krb5_ticket **ticket);
 
5078
 
 
5079
/**
 
5080
 * Retrieve a service key from a key table.
 
5081
 *
 
5082
 * @param [in]  context     Library context
 
5083
 * @param [in]  keyprocarg  Name of a key table (NULL to use default name)
 
5084
 * @param [in]  principal   Service principal
 
5085
 * @param [in]  vno         Key version number (0 for highest available)
 
5086
 * @param [in]  enctype     Encryption type (0 for any type)
 
5087
 * @param [out] key         Service key from key table
 
5088
 *
 
5089
 * Open and search the specified key table for the entry identified by @a
 
5090
 * principal, @a enctype, and @a vno. If no key is found, return an error code.
 
5091
 *
 
5092
 * The default key table is used, unless @a keyprocarg is non-null.
 
5093
 * @a keyprocarg designates a specific key table.
 
5094
 *
 
5095
 * Use krb5_free_keyblock() to free @a key when it is no longer needed.
 
5096
 *
 
5097
 * @retval
 
5098
 * 0 Success
 
5099
 * @return Kerberos error code if not found or @a keyprocarg is invalid.
 
5100
 */
 
5101
krb5_error_code KRB5_CALLCONV
 
5102
krb5_kt_read_service_key(krb5_context context, krb5_pointer keyprocarg,
 
5103
                         krb5_principal principal, krb5_kvno vno,
 
5104
                         krb5_enctype enctype, krb5_keyblock **key);
 
5105
 
 
5106
/**
 
5107
 * Format a @c KRB-SAFE message.
 
5108
 *
 
5109
 * @param [in]     context      Library context
 
5110
 * @param [in,out] auth_context Authentication context
 
5111
 * @param [in]     userdata     User data in the message
 
5112
 * @param [out]    outbuf       Formatted @c KRB-SAFE buffer
 
5113
 * @param [out]    outdata      Replay data. Specify NULL if not needed
 
5114
 *
 
5115
 * This function creates an integrity protected @c KRB-SAFE message
 
5116
 * using data supplied by the application.
 
5117
 *
 
5118
 * Fields in @a auth_context specify the checksum type, the keyblock that
 
5119
 * can be used to seed the checksum, full addresses (host and port) for
 
5120
 * the sender and receiver, and @ref KRB5_AUTH_CONTEXT flags.
 
5121
 *
 
5122
 * The local address in @a auth_context must be set, and is used to form the
 
5123
 * sender address used in the KRB-SAFE message.  The remote address is
 
5124
 * optional; if specified, it will be used to form the receiver address used in
 
5125
 * the message.
 
5126
 *
 
5127
 * If #KRB5_AUTH_CONTEXT_DO_TIME flag is set in the @a auth_context, an entry
 
5128
 * describing the message is entered in the replay cache @a
 
5129
 * auth_context->rcache which enables the caller to detect if this message is
 
5130
 * reflected by an attacker.  If #KRB5_AUTH_CONTEXT_DO_TIME is not set, the
 
5131
 * replay cache is not used.
 
5132
 *
 
5133
 * If either #KRB5_AUTH_CONTEXT_DO_SEQUENCE or
 
5134
 * #KRB5_AUTH_CONTEXT_RET_SEQUENCE is set, the @a auth_context local sequence
 
5135
 * number will be placed in @a outdata as its sequence number.
 
5136
 *
 
5137
 * @note The @a outdata argument is required if #KRB5_AUTH_CONTEXT_RET_TIME or
 
5138
 *       #KRB5_AUTH_CONTEXT_RET_SEQUENCE flag is set in the @a auth_context.
 
5139
 *
 
5140
 * Use krb5_free_data_contents() to free @a outbuf when it is no longer needed.
 
5141
 *
 
5142
 * @retval 0 Success; otherwise - Kerberos error codes
 
5143
 */
 
5144
krb5_error_code KRB5_CALLCONV
 
5145
krb5_mk_safe(krb5_context context, krb5_auth_context auth_context,
 
5146
             const krb5_data *userdata, krb5_data *outbuf,
 
5147
             krb5_replay_data *outdata);
 
5148
 
 
5149
/**
 
5150
 * Format a @c KRB-PRIV message.
 
5151
 *
 
5152
 * @param [in]     context      Library context
 
5153
 * @param [in,out] auth_context Authentication context
 
5154
 * @param [in]     userdata     User data for @c KRB-PRIV message
 
5155
 * @param [out]    outbuf       Formatted @c KRB-PRIV message
 
5156
 * @param [out]    outdata      Replay cache handle (NULL if not needed)
 
5157
 *
 
5158
 * This function is similar to krb5_mk_safe(), but the message is encrypted and
 
5159
 * integrity-protected, not just integrity-protected.
 
5160
 *
 
5161
 * The local address in @a auth_context must be set, and is used to form the
 
5162
 * sender address used in the KRB-SAFE message.  The remote address is
 
5163
 * optional; if specified, it will be used to form the receiver address used in
 
5164
 * the message.
 
5165
 *
 
5166
 * @note If the #KRB5_AUTH_CONTEXT_RET_TIME or
 
5167
 * #KRB5_AUTH_CONTEXT_RET_SEQUENCE flag is set in @a auth_context, the @a
 
5168
 * outdata is required.
 
5169
 *
 
5170
 * @note The flags from @a auth_context specify whether sequence numbers or
 
5171
 * timestamps will be used to identify the message.  Valid values are:
 
5172
 *
 
5173
 * @li #KRB5_AUTH_CONTEXT_DO_TIME      - Use timestamps in @a outdata
 
5174
 * @li #KRB5_AUTH_CONTEXT_RET_TIME     - Copy timestamp to @a outdata.
 
5175
 * @li #KRB5_AUTH_CONTEXT_DO_SEQUENCE  - Use local sequence numbers from
 
5176
 *                                       @a auth_context in replay cache.
 
5177
 * @li #KRB5_AUTH_CONTEXT_RET_SEQUENCE - Use local sequence numbers from
 
5178
 *                                       @a auth_context as a sequence number
 
5179
 *                                       in the encrypted message @a outbuf.
 
5180
 *
 
5181
 * @retval 0 Success; otherwise - Kerberos error codes
 
5182
 */
 
5183
krb5_error_code KRB5_CALLCONV
 
5184
krb5_mk_priv(krb5_context context, krb5_auth_context auth_context,
 
5185
             const krb5_data *userdata, krb5_data *outbuf,
 
5186
             krb5_replay_data *outdata);
 
5187
 
 
5188
/**
 
5189
 * Client function for @c sendauth protocol.
 
5190
 *
 
5191
 * @param [in]     context        Library context
 
5192
 * @param [in,out] auth_context   Authentication context
 
5193
 * @param [in]     fd             File descriptor that describes network socket
 
5194
 * @param [in]     appl_version   Application protocol version to be matched
 
5195
 *                                with the receiver's application version
 
5196
 * @param [in]     client         Client principal
 
5197
 * @param [in]     server         Server principal
 
5198
 * @param [in]     ap_req_options @ref AP_OPTS options
 
5199
 * @param [in]     in_data        Data to be sent to the server
 
5200
 * @param [in]     in_creds       Input credentials, or NULL to use @a ccache
 
5201
 * @param [in]     ccache         Credential cache
 
5202
 * @param [out]    error          If non-null, contains KRB_ERROR message
 
5203
 *                                returned from server
 
5204
 * @param [out]    rep_result     If non-null and @a ap_req_options is
 
5205
 *                                #AP_OPTS_MUTUAL_REQUIRED, contains the result
 
5206
 *                                of mutual authentication exchange
 
5207
 * @param [out]    out_creds      If non-null, the retrieved credentials
 
5208
 *
 
5209
 * This function performs the client side of a sendauth/recvauth exchange by
 
5210
 * sending and receiving messages over @a fd.
 
5211
 *
 
5212
 * Credentials may be specified in three ways:
 
5213
 *
 
5214
 * @li If @a in_creds is NULL, credentials are obtained with
 
5215
 * krb5_get_credentials() using the principals @a client and @a server.  @a
 
5216
 * server must be non-null; @a client may NULL to use the default principal of
 
5217
 * @a ccache.
 
5218
 *
 
5219
 * @li If @a in_creds is non-null, but does not contain a ticket, credentials
 
5220
 * for the exchange are obtained with krb5_get_credentials() using @a in_creds.
 
5221
 * In this case, the values of @a client and @a server are unused.
 
5222
 *
 
5223
 * @li If @a in_creds is a complete credentials structure, it used directly.
 
5224
 * In this case, the values of @a client, @a server, and @a ccache are unused.
 
5225
 *
 
5226
 * If the server is using a different application protocol than that specified
 
5227
 * in @a appl_version, an error will be returned.
 
5228
 *
 
5229
 * Use krb5_free_creds() to free @a out_creds, krb5_free_ap_rep_enc_part() to
 
5230
 * free @a rep_result, and krb5_free_error() to free @a error when they are no
 
5231
 * longer needed.
 
5232
 *
 
5233
 * @sa krb5_recvauth()
 
5234
 *
 
5235
 * @retval 0 Success; otherwise - Kerberos error codes
 
5236
 */
 
5237
krb5_error_code KRB5_CALLCONV
 
5238
krb5_sendauth(krb5_context context, krb5_auth_context *auth_context,
 
5239
              krb5_pointer fd, char *appl_version, krb5_principal client,
 
5240
              krb5_principal server, krb5_flags ap_req_options,
 
5241
              krb5_data *in_data, krb5_creds *in_creds, krb5_ccache ccache,
 
5242
              krb5_error **error, krb5_ap_rep_enc_part **rep_result,
 
5243
              krb5_creds **out_creds);
 
5244
 
 
5245
/**
 
5246
 * Server function for @a sendauth protocol.
 
5247
 *
 
5248
 * @param [in]     context      Library context
 
5249
 * @param [in,out] auth_context Authentication context
 
5250
 * @param [in]     fd           File descriptor
 
5251
 * @param [in]     appl_version Application protocol version to be matched
 
5252
 *                              against the client's application version
 
5253
 * @param [in]     server       Server principal (NULL for any in @a keytab)
 
5254
 * @param [in]     flags        Additional specifications
 
5255
 * @param [in]     keytab       Key table containing service keys
 
5256
 * @param [out]    ticket       Ticket (NULL if not needed)
 
5257
 *
 
5258
 * This function performs the srever side of a sendauth/recvauth exchange by
 
5259
 * sending and receiving messages over @a fd.
 
5260
 *
 
5261
 * Use krb5_free_ticket() to free @a ticket when it is no longer needed.
 
5262
 *
 
5263
 * @sa krb5_sendauth()
 
5264
 *
 
5265
 * @retval 0 Success; otherwise - Kerberos error codes
 
5266
 */
 
5267
krb5_error_code KRB5_CALLCONV
 
5268
krb5_recvauth(krb5_context context, krb5_auth_context *auth_context,
 
5269
              krb5_pointer fd, char *appl_version, krb5_principal server,
 
5270
              krb5_int32 flags, krb5_keytab keytab, krb5_ticket **ticket);
 
5271
 
 
5272
/**
 
5273
 * Server function for @a sendauth protocol with version parameter.
 
5274
 *
 
5275
 * @param [in]     context      Library context
 
5276
 * @param [in,out] auth_context Authentication context
 
5277
 * @param [in]     fd           File descriptor
 
5278
 * @param [in]     server       Server principal (NULL for any in @a keytab)
 
5279
 * @param [in]     flags        Additional specifications
 
5280
 * @param [in]     keytab       Decryption key
 
5281
 * @param [out]    ticket       Ticket (NULL if not needed)
 
5282
 * @param [out]    version      sendauth protocol version (NULL if not needed)
 
5283
 *
 
5284
 * This function is similar to krb5_recvauth() with the additional output
 
5285
 * information place into @a version.
 
5286
 *
 
5287
 * @retval 0 Success; otherwise - Kerberos error codes
 
5288
 */
 
5289
krb5_error_code KRB5_CALLCONV
 
5290
krb5_recvauth_version(krb5_context context,
 
5291
                      krb5_auth_context *auth_context,
 
5292
                      krb5_pointer fd,
 
5293
                      krb5_principal server,
 
5294
                      krb5_int32 flags,
 
5295
                      krb5_keytab keytab,
 
5296
                      krb5_ticket **ticket,
 
5297
                      krb5_data *version);
 
5298
 
 
5299
/**
 
5300
 * Format a @c KRB-CRED message for an array of credentials.
 
5301
 *
 
5302
 * @param [in]     context      Library context
 
5303
 * @param [in,out] auth_context Authentication context
 
5304
 * @param [in]     ppcreds      Null-terminated array of credentials
 
5305
 * @param [out]    ppdata       Encoded credentials
 
5306
 * @param [out]    outdata      Replay cache information (NULL if not needed)
 
5307
 *
 
5308
 * This function takes an array of credentials @a ppcreds and formats
 
5309
 * a @c KRB-CRED message @a ppdata to pass to krb5_rd_cred().
 
5310
 *
 
5311
 * @note If the #KRB5_AUTH_CONTEXT_RET_TIME or #KRB5_AUTH_CONTEXT_RET_SEQUENCE
 
5312
 *       flag is set in @a auth_context, @a outdata is required.
 
5313
 *
 
5314
 * The message will be encrypted using the send subkey of @a auth_context if it
 
5315
 * is present, or the session key otherwise.
 
5316
 *
 
5317
 * @retval
 
5318
 *  0 Success
 
5319
 * @retval
 
5320
 *  ENOMEM Insufficient memory
 
5321
 * @retval
 
5322
 *   KRB5_RC_REQUIRED Message replay detection requires @a rcache parameter
 
5323
 * @return
 
5324
 * Kerberos error codes
 
5325
 */
 
5326
krb5_error_code KRB5_CALLCONV
 
5327
krb5_mk_ncred(krb5_context context, krb5_auth_context auth_context,
 
5328
              krb5_creds **ppcreds, krb5_data **ppdata,
 
5329
              krb5_replay_data *outdata);
 
5330
 
 
5331
/**
 
5332
 * Format a @c KRB-CRED message for a single set of credentials.
 
5333
 *
 
5334
 * @param [in]     context      Library context
 
5335
 * @param [in,out] auth_context Authentication context
 
5336
 * @param [in]     pcreds       Pointer to credentials
 
5337
 * @param [out]    ppdata       Encoded credentials
 
5338
 * @param [out]    outdata      Replay cache data (NULL if not needed)
 
5339
 *
 
5340
 * This is a convenience function that calls krb5_mk_ncred() with a single set
 
5341
 * of credentials.
 
5342
 *
 
5343
 * @retval
 
5344
 * 0 Success
 
5345
 * @retval
 
5346
 *  ENOMEM Insufficient memory
 
5347
 * @retval
 
5348
 *  KRB5_RC_REQUIRED   Message replay detection requires @a rcache parameter
 
5349
 * @return
 
5350
 * Kerberos error codes
 
5351
 */
 
5352
krb5_error_code KRB5_CALLCONV
 
5353
krb5_mk_1cred(krb5_context context, krb5_auth_context auth_context,
 
5354
              krb5_creds *pcreds, krb5_data **ppdata,
 
5355
              krb5_replay_data *outdata);
 
5356
 
 
5357
/**
 
5358
 * Read and validate a @c KRB-CRED message.
 
5359
 *
 
5360
 * @param [in]     context      Library context
 
5361
 * @param [in,out] auth_context Authentication context
 
5362
 * @param [in]     pcreddata    @c KRB-CRED message
 
5363
 * @param [out]    pppcreds     Null-terminated array of forwarded credentials
 
5364
 * @param [out]    outdata      Replay data (NULL if not needed)
 
5365
 *
 
5366
 * @note The @a outdata argument is required if #KRB5_AUTH_CONTEXT_RET_TIME or
 
5367
 *       #KRB5_AUTH_CONTEXT_RET_SEQUENCE flag is set in the @a auth_context.`
 
5368
 *
 
5369
 * @a pcreddata will be decrypted using the receiving subkey if it is present
 
5370
 * in @a auth_context, or the session key if the receiving subkey is not
 
5371
 * present or fails to decrypt the message.
 
5372
 *
 
5373
 * Use krb5_free_tgt_creds() to free @a pppcreds when it is no longer needed.
 
5374
 *
 
5375
 * @retval 0 Success; otherwise - Kerberos error codes
 
5376
 */
 
5377
krb5_error_code KRB5_CALLCONV
 
5378
krb5_rd_cred(krb5_context context, krb5_auth_context auth_context,
 
5379
             krb5_data *pcreddata, krb5_creds ***pppcreds,
 
5380
             krb5_replay_data *outdata);
 
5381
 
 
5382
/**
 
5383
 * Get a forwarded TGT and format a @c KRB-CRED message.
 
5384
 *
 
5385
 * @param [in] context          Library context
 
5386
 * @param [in] auth_context     Authentication context
 
5387
 * @param [in] rhost            Remote host
 
5388
 * @param [in] client           Client principal of TGT
 
5389
 * @param [in] server           Principal of server to receive TGT
 
5390
 * @param [in] cc               Credential cache handle (NULL to use default)
 
5391
 * @param [in] forwardable      Whether TGT should be forwardable
 
5392
 * @param [out] outbuf          KRB-CRED message
 
5393
 *
 
5394
 * Get a TGT for use at the remote host @a rhost and format it into a KRB-CRED
 
5395
 * message.  If @a rhost is NULL and @a server is of type #KRB5_NT_SRV_HST,
 
5396
 * the second component of @a server will be used.
 
5397
 *
 
5398
 * @retval
 
5399
 *  0 Success
 
5400
 * @retval
 
5401
 *   ENOMEM Insufficient memory
 
5402
 * @retval
 
5403
 *   KRB5_PRINC_NOMATCH Requested principal and ticket do not match
 
5404
 * @retval
 
5405
 *   KRB5_NO_TKT_SUPPLIED Request did not supply a ticket
 
5406
 * @retval
 
5407
 *   KRB5_CC_BADNAME Credential cache name or principal name malformed
 
5408
 * @return
 
5409
 * Kerberos error codes
 
5410
 */
 
5411
krb5_error_code KRB5_CALLCONV
 
5412
krb5_fwd_tgt_creds(krb5_context context, krb5_auth_context auth_context,
 
5413
                   char *rhost, krb5_principal client, krb5_principal server,
 
5414
                   krb5_ccache cc, int forwardable, krb5_data *outbuf);
 
5415
 
 
5416
/**
 
5417
 * Create and initialize an authentication context.
 
5418
 *
 
5419
 * @param [in]  context         Library context
 
5420
 * @param [out] auth_context    Authentication context
 
5421
 *
 
5422
 * This function creates an authentication context to hold configuration and
 
5423
 * state relevant to krb5 functions for authenticating principals and
 
5424
 * protecting messages once authentication has occurred.
 
5425
 *
 
5426
 * By default, flags for the context are set to enable the use of the replay
 
5427
 * cache (#KRB5_AUTH_CONTEXT_DO_TIME), but not sequence numbers.  Use
 
5428
 * krb5_auth_con_setflags() to change the flags.
 
5429
 *
 
5430
 * The allocated @a auth_context must be freed with krb5_auth_con_free() when
 
5431
 * it is no longer needed.
 
5432
 *
 
5433
 * @retval 0 Success; otherwise - Kerberos error codes
 
5434
 */
 
5435
krb5_error_code KRB5_CALLCONV
 
5436
krb5_auth_con_init(krb5_context context, krb5_auth_context *auth_context);
 
5437
 
 
5438
/**
 
5439
 * Free a krb5_auth_context structure.
 
5440
 *
 
5441
 * @param [in] context          Library context
 
5442
 * @param [in] auth_context     Authentication context to be freed
 
5443
 *
 
5444
 * This function frees an auth context allocated by krb5_auth_con_init().
 
5445
 *
 
5446
 * @retval 0  (always)
 
5447
 */
 
5448
krb5_error_code KRB5_CALLCONV
 
5449
krb5_auth_con_free(krb5_context context, krb5_auth_context auth_context);
 
5450
 
 
5451
/**
 
5452
 * Set a flags field in a krb5_auth_context structure.
 
5453
 *
 
5454
 * @param [in]     context      Library context
 
5455
 * @param [in,out] auth_context Authentication context
 
5456
 * @param [in]     flags        Flags bit mask
 
5457
 *
 
5458
 * Valid values for @a flags are:
 
5459
 * @li #KRB5_AUTH_CONTEXT_DO_TIME Use timestamps
 
5460
 * @li #KRB5_AUTH_CONTEXT_RET_TIME Save timestamps
 
5461
 * @li #KRB5_AUTH_CONTEXT_DO_SEQUENCE Use sequence numbers
 
5462
 * @li #KRB5_AUTH_CONTEXT_RET_SEQUENCE Save sequence numbers
 
5463
 *
 
5464
 * @retval 0 (always)
 
5465
 */
 
5466
krb5_error_code KRB5_CALLCONV
 
5467
krb5_auth_con_setflags(krb5_context context, krb5_auth_context auth_context, krb5_int32 flags);
 
5468
 
 
5469
/**
 
5470
 * Retrieve flags from a krb5_auth_context structure.
 
5471
 *
 
5472
 * @param [in]  context         Library context
 
5473
 * @param [in]  auth_context    Authentication context
 
5474
 * @param [out] flags           Flags bit mask
 
5475
 *
 
5476
 * Valid values for @a flags are:
 
5477
 * @li #KRB5_AUTH_CONTEXT_DO_TIME Use timestamps
 
5478
 * @li #KRB5_AUTH_CONTEXT_RET_TIME Save timestamps
 
5479
 * @li #KRB5_AUTH_CONTEXT_DO_SEQUENCE Use sequence numbers
 
5480
 * @li #KRB5_AUTH_CONTEXT_RET_SEQUENCE Save sequence numbers
 
5481
 *
 
5482
 * @retval 0 (always)
 
5483
 */
 
5484
krb5_error_code KRB5_CALLCONV
 
5485
krb5_auth_con_getflags(krb5_context context, krb5_auth_context auth_context,
 
5486
                       krb5_int32 *flags);
 
5487
 
 
5488
/**
 
5489
 * Set a checksum callback in an auth context.
 
5490
 *
 
5491
 * @param [in] context          Library context
 
5492
 * @param [in] auth_context     Authentication context
 
5493
 * @param [in] func             Checksum callback
 
5494
 * @param [in] data             Callback argument
 
5495
 *
 
5496
 * Set a callback to obtain checksum data in krb5_mk_req().  The callback will
 
5497
 * be invoked after the subkey and local sequence number are stored in @a
 
5498
 * auth_context.
 
5499
 *
 
5500
 * @retval 0 (always)
 
5501
 */
 
5502
krb5_error_code KRB5_CALLCONV
 
5503
krb5_auth_con_set_checksum_func( krb5_context context,
 
5504
                                 krb5_auth_context  auth_context,
 
5505
                                 krb5_mk_req_checksum_func func,
 
5506
                                 void *data);
 
5507
 
 
5508
/**
 
5509
 * Get the checksum callback from an auth context.
 
5510
 *
 
5511
 * @param [in]  context         Library context
 
5512
 * @param [in]  auth_context    Authentication context
 
5513
 * @param [out] func            Checksum callback
 
5514
 * @param [out] data            Callback argument
 
5515
 *
 
5516
 * @retval 0 (always)
 
5517
 */
 
5518
krb5_error_code KRB5_CALLCONV
 
5519
krb5_auth_con_get_checksum_func( krb5_context context,
 
5520
                                 krb5_auth_context auth_context,
 
5521
                                 krb5_mk_req_checksum_func *func,
 
5522
                                 void **data);
 
5523
 
 
5524
/**
 
5525
 * Set the local and remote addresses in an auth context.
 
5526
 *
 
5527
 * @param [in] context          Library context
 
5528
 * @param [in] auth_context     Authentication context
 
5529
 * @param [in] local_addr       Local address
 
5530
 * @param [in] remote_addr      Remote address
 
5531
 *
 
5532
 * This function releases the storage assigned to the contents of the local and
 
5533
 * remote addresses of @a auth_context and then sets them to @a local_addr and
 
5534
 * @a remote_addr respectively.
 
5535
 *
 
5536
 * @sa krb5_auth_con_genaddrs()
 
5537
 *
 
5538
 * @retval 0 Success; otherwise - Kerberos error codes
 
5539
 */
 
5540
krb5_error_code KRB5_CALLCONV_WRONG
 
5541
krb5_auth_con_setaddrs(krb5_context context, krb5_auth_context auth_context,
 
5542
                       krb5_address *local_addr, krb5_address *remote_addr);
 
5543
 
 
5544
/**
 
5545
 * Retrieve address fields from an auth context.
 
5546
 *
 
5547
 * @param [in]  context         Library context
 
5548
 * @param [in]  auth_context    Authentication context
 
5549
 * @param [out] local_addr      Local address (NULL if not needed)
 
5550
 * @param [out] remote_addr     Remote address (NULL if not needed)
 
5551
 *
 
5552
 * @retval 0 Success; otherwise - Kerberos error codes
 
5553
 */
 
5554
krb5_error_code KRB5_CALLCONV
 
5555
krb5_auth_con_getaddrs(krb5_context context, krb5_auth_context auth_context,
 
5556
                       krb5_address **local_addr, krb5_address **remote_addr);
 
5557
 
 
5558
/**
 
5559
 * Set local and remote port fields in an auth context.
 
5560
 *
 
5561
 * @param [in] context          Library context
 
5562
 * @param [in] auth_context     Authentication context
 
5563
 * @param [in] local_port       Local port
 
5564
 * @param [in] remote_port      Remote port
 
5565
 *
 
5566
 * This function releases the storage assigned to the contents of the local and
 
5567
 * remote ports of @a auth_context and then sets them to @a local_port and @a
 
5568
 * remote_port respectively.
 
5569
 *
 
5570
 * @sa krb5_auth_con_genaddrs()
 
5571
 *
 
5572
 * @retval 0 Success; otherwise - Kerberos error codes
 
5573
 */
 
5574
krb5_error_code KRB5_CALLCONV
 
5575
krb5_auth_con_setports(krb5_context context, krb5_auth_context auth_context,
 
5576
                       krb5_address *local_port, krb5_address *remote_port);
 
5577
 
 
5578
/**
 
5579
 * Set the session key in an auth context.
 
5580
 *
 
5581
 * @param [in] context          Library context
 
5582
 * @param [in] auth_context     Authentication context
 
5583
 * @param [in] keyblock         User key
 
5584
 *
 
5585
 * @retval 0 Success; otherwise - Kerberos error codes
 
5586
 */
 
5587
krb5_error_code KRB5_CALLCONV
 
5588
krb5_auth_con_setuseruserkey(krb5_context context, krb5_auth_context auth_context,
 
5589
                             krb5_keyblock *keyblock);
 
5590
 
 
5591
/**
 
5592
 * Retrieve the session key from an auth context as a keyblock.
 
5593
 *
 
5594
 * @param [in]  context         Library context
 
5595
 * @param [in]  auth_context    Authentication context
 
5596
 * @param [out] keyblock        Session key
 
5597
 *
 
5598
 * This function creates a keyblock containing the session key from @a
 
5599
 * auth_context.  Use krb5_free_keyblock() to free @a keyblock when it is no
 
5600
 * longer needed
 
5601
 *
 
5602
 * @retval 0 Success. Otherwise - Kerberos error codes
 
5603
 */
 
5604
krb5_error_code KRB5_CALLCONV
 
5605
krb5_auth_con_getkey(krb5_context context, krb5_auth_context auth_context,
 
5606
                     krb5_keyblock **keyblock);
 
5607
 
 
5608
/**
 
5609
 * Retrieve the session key from an auth context.
 
5610
 *
 
5611
 * @param [in]  context         Library context
 
5612
 * @param [in]  auth_context    Authentication context
 
5613
 * @param [out] key             Session key
 
5614
 *
 
5615
 * This function sets @a key to the session key from @a auth_context.  Use
 
5616
 * krb5_k_free_key() to release @a key when it is no longer needed.
 
5617
 *
 
5618
 * @retval 0 (always)
 
5619
 */
 
5620
krb5_error_code KRB5_CALLCONV
 
5621
krb5_auth_con_getkey_k(krb5_context context, krb5_auth_context auth_context,
 
5622
                       krb5_key *key);
 
5623
 
 
5624
/**
 
5625
 * Retrieve the send subkey from an auth context as a keyblock.
 
5626
 *
 
5627
 * @param [in]  ctx             Library context
 
5628
 * @param [in]  ac              Authentication context
 
5629
 * @param [out] keyblock        Send subkey
 
5630
 *
 
5631
 * This function creates a keyblock containing the send subkey from @a
 
5632
 * auth_context.  Use krb5_free_keyblock() to free @a keyblock when it is no
 
5633
 * longer needed.
 
5634
 *
 
5635
 * @retval 0 Success; otherwise - Kerberos error codes
 
5636
 */
 
5637
krb5_error_code KRB5_CALLCONV
 
5638
krb5_auth_con_getsendsubkey(krb5_context ctx, krb5_auth_context ac, krb5_keyblock **keyblock);
 
5639
 
 
5640
/**
 
5641
 * Retrieve the send subkey from an auth context.
 
5642
 *
 
5643
 * @param [in]  ctx             Library context
 
5644
 * @param [in]  ac              Authentication context
 
5645
 * @param [out] key             Send subkey
 
5646
 *
 
5647
 * This function sets @a key to the send subkey from @a auth_context.  Use
 
5648
 * krb5_k_free_key() to release @a key when it is no longer needed.
 
5649
 *
 
5650
 * @retval 0 Success; otherwise - Kerberos error codes
 
5651
 */
 
5652
krb5_error_code KRB5_CALLCONV
 
5653
krb5_auth_con_getsendsubkey_k(krb5_context ctx, krb5_auth_context ac,
 
5654
                              krb5_key *key);
 
5655
 
 
5656
/**
 
5657
 * Retrieve the receiving subkey from an auth context as a keyblock.
 
5658
 *
 
5659
 * @param [in]  ctx             Library context
 
5660
 * @param [in]  ac              Authentication context
 
5661
 * @param [out] keyblock        Receiving subkey
 
5662
 *
 
5663
 * This function creates a keyblock containing the receiving subkey from @a
 
5664
 * auth_context.  Use krb5_free_keyblock() to free @a keyblock when it is no
 
5665
 * longer needed.
 
5666
 *
 
5667
 * @retval 0 Success; otherwise - Kerberos error codes
 
5668
 */
 
5669
krb5_error_code KRB5_CALLCONV
 
5670
krb5_auth_con_getrecvsubkey(krb5_context ctx, krb5_auth_context ac, krb5_keyblock **keyblock);
 
5671
 
 
5672
/**
 
5673
 * Retrieve the receiving subkey from an auth context as a keyblock.
 
5674
 *
 
5675
 * @param [in]  ctx             Library context
 
5676
 * @param [in]  ac              Authentication context
 
5677
 * @param [out] key             Receiving subkey
 
5678
 *
 
5679
 * This function sets @a key to the receiving subkey from @a auth_context.  Use
 
5680
 * krb5_k_free_key() to release @a key when it is no longer needed.
 
5681
 *
 
5682
 * @retval 0 Success; otherwise - Kerberos error codes
 
5683
 */
 
5684
krb5_error_code KRB5_CALLCONV
 
5685
krb5_auth_con_getrecvsubkey_k(krb5_context ctx, krb5_auth_context ac, krb5_key *key);
 
5686
 
 
5687
/**
 
5688
 * Set the send subkey in an auth context with a keyblock.
 
5689
 *
 
5690
 * @param [in] ctx              Library context
 
5691
 * @param [in] ac               Authentication context
 
5692
 * @param [in] keyblock         Send subkey
 
5693
 *
 
5694
 * This function sets the send subkey in @a ac to a copy of @a keyblock.
 
5695
 *
 
5696
 * @retval 0 Success. Otherwise - Kerberos error codes
 
5697
 */
 
5698
krb5_error_code KRB5_CALLCONV
 
5699
krb5_auth_con_setsendsubkey(krb5_context ctx, krb5_auth_context ac,
 
5700
                            krb5_keyblock *keyblock);
 
5701
 
 
5702
/**
 
5703
 * Set the send subkey in an auth context.
 
5704
 *
 
5705
 * @param [in]  ctx             Library context
 
5706
 * @param [in]  ac              Authentication context
 
5707
 * @param [out] key             Send subkey
 
5708
 *
 
5709
 * This function sets the send subkey in @a ac to @a key, incrementing its
 
5710
 * reference count.
 
5711
 *
 
5712
 * @retval 0 Success; otherwise - Kerberos error codes
 
5713
 */
 
5714
krb5_error_code KRB5_CALLCONV
 
5715
krb5_auth_con_setsendsubkey_k(krb5_context ctx, krb5_auth_context ac, krb5_key key);
 
5716
 
 
5717
/**
 
5718
 * Set the receiving subkey in an auth context with a keyblock.
 
5719
 *
 
5720
 * @param [in] ctx              Library context
 
5721
 * @param [in] ac               Authentication context
 
5722
 * @param [in] keyblock         Receiving subkey
 
5723
 *
 
5724
 * This function sets the receiving subkey in @a ac to a copy of @a keyblock.
 
5725
 *
 
5726
 * @retval 0 Success; otherwise - Kerberos error codes
 
5727
 */
 
5728
krb5_error_code KRB5_CALLCONV
 
5729
krb5_auth_con_setrecvsubkey(krb5_context ctx, krb5_auth_context ac,
 
5730
                            krb5_keyblock *keyblock);
 
5731
 
 
5732
/**
 
5733
 * Set the receiving subkey in an auth context.
 
5734
 *
 
5735
 * @param [in] ctx              Library context
 
5736
 * @param [in] ac               Authentication context
 
5737
 * @param [in] key              Receiving subkey
 
5738
 *
 
5739
 * This function sets the receiving subkey in @a ac to @a key, incrementing its
 
5740
 * reference count.
 
5741
 *
 
5742
 * @retval 0 Success; otherwise - Kerberos error codes
 
5743
 */
 
5744
krb5_error_code KRB5_CALLCONV
 
5745
krb5_auth_con_setrecvsubkey_k(krb5_context ctx, krb5_auth_context ac,
 
5746
                              krb5_key key);
 
5747
 
 
5748
#if KRB5_DEPRECATED
 
5749
/** @deprecated Replaced by krb5_auth_con_getsendsubkey(). */
 
5750
KRB5_ATTR_DEPRECATED krb5_error_code KRB5_CALLCONV
 
5751
krb5_auth_con_getlocalsubkey(krb5_context context, krb5_auth_context auth_context,
 
5752
                             krb5_keyblock **keyblock);
 
5753
 
 
5754
/** @deprecated Replaced by krb5_auth_con_getrecvsubkey(). */
 
5755
KRB5_ATTR_DEPRECATED krb5_error_code KRB5_CALLCONV
 
5756
krb5_auth_con_getremotesubkey(krb5_context context, krb5_auth_context auth_context,
 
5757
                              krb5_keyblock **keyblock);
 
5758
#endif
 
5759
 
 
5760
/**
 
5761
 * Retrieve the local sequence number from an auth context.
 
5762
 *
 
5763
 * @param [in]  context         Library context
 
5764
 * @param [in]  auth_context    Authentication context
 
5765
 * @param [out] seqnumber       Local sequence number
 
5766
 *
 
5767
 * Retrieve the local sequence number from @a auth_context and return it in @a
 
5768
 * seqnumber.  The #KRB5_AUTH_CONTEXT_DO_SEQUENCE flag must be set in @a
 
5769
 * auth_context for this function to be useful.
 
5770
 *
 
5771
 * @retval 0 Success; otherwise - Kerberos error codes
 
5772
 */
 
5773
krb5_error_code KRB5_CALLCONV
 
5774
krb5_auth_con_getlocalseqnumber(krb5_context context, krb5_auth_context auth_context,
 
5775
                                krb5_int32 *seqnumber);
 
5776
 
 
5777
/**
 
5778
 * Retrieve the remote sequence number from an auth context.
 
5779
 *
 
5780
 * @param [in]  context         Library context
 
5781
 * @param [in]  auth_context    Authentication context
 
5782
 * @param [out] seqnumber       Remote sequence number
 
5783
 *
 
5784
 * Retrieve the remote sequence number from @a auth_context and return it in @a
 
5785
 * seqnumber.  The #KRB5_AUTH_CONTEXT_DO_SEQUENCE flag must be set in @a
 
5786
 * auth_context for this function to be useful.
 
5787
 *
 
5788
 * @retval 0 Success; otherwise - Kerberos error codes
 
5789
 */
 
5790
krb5_error_code KRB5_CALLCONV
 
5791
krb5_auth_con_getremoteseqnumber(krb5_context context, krb5_auth_context auth_context,
 
5792
                                 krb5_int32 *seqnumber);
 
5793
 
 
5794
#if KRB5_DEPRECATED
 
5795
/** @deprecated Not replaced.
 
5796
 *
 
5797
 * RFC 4120 doesn't have anything like the initvector concept;
 
5798
 * only really old protocols may need this API.
 
5799
 */
 
5800
KRB5_ATTR_DEPRECATED krb5_error_code KRB5_CALLCONV
 
5801
krb5_auth_con_initivector(krb5_context context, krb5_auth_context auth_context);
 
5802
#endif
 
5803
 
 
5804
/**
 
5805
 * Set the replay cache in an auth context.
 
5806
 *
 
5807
 * @param [in] context          Library context
 
5808
 * @param [in] auth_context     Authentication context
 
5809
 * @param [in] rcache           Replay cache haddle
 
5810
 *
 
5811
 * This function sets the replay cache in @a auth_context to @a rcache.  @a
 
5812
 * rcache will be closed when @a auth_context is freed, so the caller should
 
5813
 * relinguish that responsibility.
 
5814
 *
 
5815
 * @retval 0 Success; otherwise - Kerberos error codes
 
5816
 */
 
5817
krb5_error_code KRB5_CALLCONV
 
5818
krb5_auth_con_setrcache(krb5_context context, krb5_auth_context auth_context,
 
5819
                        krb5_rcache rcache);
 
5820
 
 
5821
/**
 
5822
 * Retrieve the replay cache from an auth context.
 
5823
 *
 
5824
 * @param [in]  context         Library context
 
5825
 * @param [in]  auth_context    Authentication context
 
5826
 * @param [out] rcache          Replay cache handle
 
5827
 *
 
5828
 * This function fetches the replay cache from @a auth_context.  The caller
 
5829
 * should not close @a rcache.
 
5830
 *
 
5831
 * @retval 0 (always)
 
5832
 */
 
5833
krb5_error_code KRB5_CALLCONV_WRONG
 
5834
krb5_auth_con_getrcache(krb5_context context, krb5_auth_context auth_context,
 
5835
                        krb5_rcache *rcache);
 
5836
 
 
5837
/**
 
5838
 * Retrieve the authenticator from an auth context.
 
5839
 *
 
5840
 * @param [in]  context         Library context
 
5841
 * @param [in]  auth_context    Authentication context
 
5842
 * @param [out] authenticator   Authenticator
 
5843
 *
 
5844
 * Use krb5_free_authenticator() to free @a authenticator when it is no longer
 
5845
 * needed.
 
5846
 *
 
5847
 * @retval 0 Success. Otherwise - Kerberos error codes
 
5848
 */
 
5849
krb5_error_code KRB5_CALLCONV
 
5850
krb5_auth_con_getauthenticator(krb5_context context, krb5_auth_context auth_context,
 
5851
                               krb5_authenticator **authenticator);
 
5852
 
 
5853
/**
 
5854
 * Set checksum type in an an auth context.
 
5855
 *
 
5856
 * @param [in] context          Library context
 
5857
 * @param [in] auth_context     Authentication context
 
5858
 * @param [in] cksumtype        Checksum type
 
5859
 *
 
5860
 * This function sets the checksum type in @a auth_context to be used by
 
5861
 * krb5_mk_req() for the authenticator checksum.
 
5862
 *
 
5863
 * @retval 0 Success. Otherwise - Kerberos error codes
 
5864
 */
 
5865
krb5_error_code KRB5_CALLCONV
 
5866
krb5_auth_con_set_req_cksumtype(krb5_context context, krb5_auth_context auth_context,
 
5867
                                krb5_cksumtype cksumtype);
2129
5868
 
2130
5869
#define KRB5_REALM_BRANCH_CHAR '.'
2131
5870
 
2137
5876
 * begin stuff from libos.h
2138
5877
 */
2139
5878
 
2140
 
krb5_error_code KRB5_CALLCONV
2141
 
krb5_read_password(krb5_context, const char *, const char *, char *,
2142
 
                   unsigned int * );
2143
 
 
2144
 
krb5_error_code KRB5_CALLCONV
2145
 
krb5_aname_to_localname(krb5_context, krb5_const_principal, int, char *);
2146
 
 
2147
 
krb5_error_code KRB5_CALLCONV
2148
 
krb5_get_host_realm(krb5_context, const char *, char ***);
2149
 
 
2150
 
krb5_error_code KRB5_CALLCONV
2151
 
krb5_get_fallback_host_realm(krb5_context, krb5_data *, char ***);
2152
 
 
2153
 
krb5_error_code KRB5_CALLCONV
2154
 
krb5_free_host_realm(krb5_context, char * const * );
2155
 
 
 
5879
/**
 
5880
 * @brief Read a password from keyboard input.
 
5881
 *
 
5882
 * @param [in]     context      Library context
 
5883
 * @param [in]     prompt       First user prompt when reading password
 
5884
 * @param [in]     prompt2      Second user prompt (NULL to prompt only once)
 
5885
 * @param [out]    return_pwd   Returned password
 
5886
 * @param [in,out] size_return  On input, maximum size of password; on output,
 
5887
 *                              size of password read
 
5888
 *
 
5889
 * This function reads a password from keyboard input and stores it in @a
 
5890
 * return_pwd.  @a size_return should be set by the caller to the amount of
 
5891
 * storage space available in @a return_pwd; on successful return, it will be
 
5892
 * set to the length of the password read.
 
5893
 *
 
5894
 * @a prompt is printed to the terminal, followed by ": ", and then a password
 
5895
 * is read from the keyboard.
 
5896
 *
 
5897
 * If @a prompt2 is NULL, the password is read only once.  Otherwise, @a
 
5898
 * prompt2 is printed to the terminal and a second password is read.  If the
 
5899
 * two passwords entered are not identical, KRB5_LIBOS_BADPWDMATCH is returned.
 
5900
 *
 
5901
 * Echoing is turned off when the password is read.
 
5902
 *
 
5903
 * @retval
 
5904
 *  0   Success
 
5905
 * @return
 
5906
 * Error in reading or verifying the password
 
5907
 * @return
 
5908
 * Kerberos error codes
 
5909
 */
 
5910
krb5_error_code KRB5_CALLCONV
 
5911
krb5_read_password(krb5_context context,
 
5912
                   const char *prompt, const char *prompt2,
 
5913
                   char *return_pwd, unsigned int *size_return);
 
5914
 
 
5915
/**
 
5916
 * Convert a principal name to a local name.
 
5917
 *
 
5918
 * @param [in]  context         Library context
 
5919
 * @param [in]  aname           Principal name
 
5920
 * @param [in]  lnsize_in       Space available in @a lname
 
5921
 * @param [out] lname           Local name buffer to be filled in
 
5922
 *
 
5923
 * If @a aname does not correspond to any local account, KRB5_LNAME_NOTRANS is
 
5924
 * returned.  If @a lnsize_in is too small for the local name,
 
5925
 * KRB5_CONFIG_NOTENUFSPACE is returned.
 
5926
 *
 
5927
 * Local names, rather than principal names, can be used by programs that
 
5928
 * translate to an environment-specific name (for example, a user account
 
5929
 * name).
 
5930
 *
 
5931
 * @retval
 
5932
 * 0  Success
 
5933
 * @retval
 
5934
 *  System errors
 
5935
 * @return
 
5936
 * Kerberos error codes
 
5937
 */
 
5938
krb5_error_code KRB5_CALLCONV
 
5939
krb5_aname_to_localname(krb5_context context, krb5_const_principal aname,
 
5940
                        int lnsize_in, char *lname);
 
5941
 
 
5942
/**
 
5943
 * Get the Kerberos realm names for a host.
 
5944
 *
 
5945
 * @param [in]  context         Library context
 
5946
 * @param [in]  host            Host name (or NULL)
 
5947
 * @param [out] realmsp         Null-terminated list of realm names
 
5948
 *
 
5949
 * Fill in @a realmsp with a pointer to a null-terminated list of realm names.
 
5950
 * If there are no known realms for the host, a list containing the referral
 
5951
 * (empty) realm is returned.
 
5952
 *
 
5953
 * If @a host is NULL, the local host's realms are determined.
 
5954
 *
 
5955
 * Use krb5_free_host_realm() to release @a realmsp when it is no longer
 
5956
 * needed.
 
5957
 *
 
5958
 * @retval
 
5959
 *  0   Success
 
5960
 * @retval
 
5961
 *  ENOMEM  Insufficient memory
 
5962
 * @return
 
5963
 * Kerberos error codes
 
5964
 */
 
5965
krb5_error_code KRB5_CALLCONV
 
5966
krb5_get_host_realm(krb5_context context, const char *host, char ***realmsp);
 
5967
 
 
5968
/**
 
5969
 *
 
5970
 * @param [in] context           Library context
 
5971
 * @param [in] hdata             Host name (or NULL)
 
5972
 * @param [out] realmsp          Null-terminated list of realm names
 
5973
 *
 
5974
 * Fill in @a realmsp with a pointer to a null-terminated list of realm names
 
5975
 * obtained through heuristics or insecure resolution methods which have lower
 
5976
 * priority than KDC referrals.
 
5977
 *
 
5978
 * If @a host is NULL, the local host's realms are determined.
 
5979
 *
 
5980
 * Use krb5_free_host_realm() to release @a realmsp when it is no longer
 
5981
 * needed.
 
5982
 */
 
5983
krb5_error_code KRB5_CALLCONV
 
5984
krb5_get_fallback_host_realm(krb5_context context,
 
5985
                             krb5_data *hdata, char ***realmsp);
 
5986
 
 
5987
/**
 
5988
 * Free the memory allocated by krb5_get_host_realm().
 
5989
 *
 
5990
 * @param [in] context          Library context
 
5991
 * @param [in] realmlist        List of realm names to be released
 
5992
 *
 
5993
 * @retval
 
5994
 * 0  Success
 
5995
 * @return
 
5996
 * Kerberos error codes
 
5997
 */
 
5998
krb5_error_code KRB5_CALLCONV
 
5999
krb5_free_host_realm(krb5_context context, char *const *realmlist);
 
6000
 
 
6001
/**
 
6002
 * Determine if a principal is authorized to log in as a local user.
 
6003
 *
 
6004
 * @param [in] context          Library context
 
6005
 * @param [in] principal        Principal name
 
6006
 * @param [in] luser            Local username
 
6007
 *
 
6008
 * Determine whether @a principal is authorized to log in as a local user @a
 
6009
 * luser.
 
6010
 *
 
6011
 * @retval
 
6012
 * TRUE Principal is authorized to log in as user; FALSE otherwise.
 
6013
 */
2156
6014
krb5_boolean KRB5_CALLCONV
2157
 
krb5_kuserok(krb5_context, krb5_principal, const char *);
2158
 
 
2159
 
krb5_error_code KRB5_CALLCONV
2160
 
krb5_auth_con_genaddrs(krb5_context, krb5_auth_context, int, int);
2161
 
 
2162
 
krb5_error_code KRB5_CALLCONV
2163
 
krb5_set_real_time(krb5_context, krb5_timestamp, krb5_int32);
2164
 
 
2165
 
krb5_error_code KRB5_CALLCONV
2166
 
krb5_get_time_offsets(krb5_context, krb5_timestamp *, krb5_int32 *);
 
6015
krb5_kuserok(krb5_context context, krb5_principal principal, const char *luser);
 
6016
 
 
6017
/**
 
6018
 * Generate auth context addresses from a connected socket.
 
6019
 *
 
6020
 * @param [in] context          Library context
 
6021
 * @param [in] auth_context     Authentication context
 
6022
 * @param [in] infd             Connected socket descriptor
 
6023
 * @param [in] flags            Flags
 
6024
 *
 
6025
 * This function sets the local and/or remote addresses in @a auth_context
 
6026
 * based on the local and remote endpoints of the socket @a infd.  The
 
6027
 * following flags determine the operations performed:
 
6028
 *
 
6029
 * @li #KRB5_AUTH_CONTEXT_GENERATE_LOCAL_ADDR   Generate local address.
 
6030
 * @li #KRB5_AUTH_CONTEXT_GENERATE_REMOTE_ADDR  Generate remote address.
 
6031
 * @li #KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR  Generate local address and port.
 
6032
 * @li #KRB5_AUTH_CONTEXT_GENERATE_REMOTE_FULL_ADDR Generate remote address and port.
 
6033
 *
 
6034
 * @retval 0 Success; otherwise - Kerberos error codes
 
6035
 */
 
6036
krb5_error_code KRB5_CALLCONV
 
6037
krb5_auth_con_genaddrs(krb5_context context, krb5_auth_context auth_context,
 
6038
                       int infd, int flags);
 
6039
 
 
6040
/**
 
6041
 * Set time offset field in a krb5_context structure.
 
6042
 *
 
6043
 * @param [in] context          Library context
 
6044
 * @param [in] seconds          Real time, seconds portion
 
6045
 * @param [in] microseconds     Real time, microseconds portion
 
6046
 *
 
6047
 * This function sets the time offset in @a context to the difference between
 
6048
 * the system time and the real time as determined by @a seconds and @a
 
6049
 * microseconds.
 
6050
 *
 
6051
 * @retval 0 Success; otherwise - Kerberos error codes
 
6052
 */
 
6053
krb5_error_code KRB5_CALLCONV
 
6054
krb5_set_real_time(krb5_context context, krb5_timestamp seconds,
 
6055
                   krb5_int32 microseconds);
 
6056
 
 
6057
/**
 
6058
 * Return the time offsets from the os context.
 
6059
 *
 
6060
 * @param [in]  context         Library context
 
6061
 * @param [out] seconds         Time offset, seconds portion
 
6062
 * @param [out] microseconds    Time offset, microseconds portion
 
6063
 *
 
6064
 * This function returns the time offsets in @a context.
 
6065
 *
 
6066
 * @retval 0  Success; otherwise - Kerberos error codes
 
6067
 */
 
6068
krb5_error_code KRB5_CALLCONV
 
6069
krb5_get_time_offsets(krb5_context context, krb5_timestamp *seconds, krb5_int32 *microseconds);
2167
6070
 
2168
6071
/* str_conv.c */
2169
 
krb5_error_code KRB5_CALLCONV krb5_string_to_enctype(char *, krb5_enctype *);
2170
 
krb5_error_code KRB5_CALLCONV krb5_string_to_salttype(char *, krb5_int32 *);
2171
 
krb5_error_code KRB5_CALLCONV krb5_string_to_cksumtype(char *,
2172
 
                                                       krb5_cksumtype *);
2173
 
krb5_error_code KRB5_CALLCONV krb5_string_to_timestamp(char *,
2174
 
                                                       krb5_timestamp *);
2175
 
krb5_error_code KRB5_CALLCONV krb5_string_to_deltat(char *, krb5_deltat *);
2176
 
krb5_error_code KRB5_CALLCONV krb5_enctype_to_string(krb5_enctype, char *,
2177
 
                                                     size_t);
2178
 
krb5_error_code KRB5_CALLCONV krb5_enctype_to_name(krb5_enctype, krb5_boolean,
2179
 
                                                   char *, size_t);
2180
 
krb5_error_code KRB5_CALLCONV krb5_salttype_to_string(krb5_int32, char *,
2181
 
                                                      size_t);
2182
 
krb5_error_code KRB5_CALLCONV krb5_cksumtype_to_string(krb5_cksumtype, char *,
2183
 
                                                       size_t);
2184
 
krb5_error_code KRB5_CALLCONV krb5_timestamp_to_string(krb5_timestamp, char *,
2185
 
                                                       size_t);
2186
 
krb5_error_code KRB5_CALLCONV krb5_timestamp_to_sfstring(krb5_timestamp,
2187
 
                                                         char *, size_t,
2188
 
                                                         char *);
2189
 
krb5_error_code KRB5_CALLCONV krb5_deltat_to_string(krb5_deltat, char *,
2190
 
                                                    size_t);
2191
 
 
2192
 
 
 
6072
/**
 
6073
 * Convert a string to an encryption type.
 
6074
 *
 
6075
 * @param [in]  string          String to convert to an encryption type
 
6076
 * @param [out] enctypep        Encryption type
 
6077
 *
 
6078
 * @retval 0  Success; otherwise - EINVAL
 
6079
 */
 
6080
krb5_error_code KRB5_CALLCONV
 
6081
krb5_string_to_enctype(char *string, krb5_enctype *enctypep);
 
6082
 
 
6083
/**
 
6084
 * Convert a string to a salt type.
 
6085
 *
 
6086
 * @param [in]  string          String to convert to an encryption type
 
6087
 * @param [out] salttypep       Salt type to be filled in
 
6088
 *
 
6089
 * @retval 0  Success; otherwise - EINVAL
 
6090
 */
 
6091
krb5_error_code KRB5_CALLCONV
 
6092
krb5_string_to_salttype(char *string, krb5_int32 *salttypep);
 
6093
 
 
6094
/**
 
6095
 * Convert a string to a checksum type.
 
6096
 *
 
6097
 * @param [in]  string          String to be converted
 
6098
 * @param [out] cksumtypep      Checksum type to be filled in
 
6099
 *
 
6100
 * @retval 0  Success; otherwise - EINVAL
 
6101
 */
 
6102
krb5_error_code KRB5_CALLCONV
 
6103
krb5_string_to_cksumtype(char *string, krb5_cksumtype *cksumtypep);
 
6104
 
 
6105
/**
 
6106
 * Convert a string to a timestamp.
 
6107
 *
 
6108
 * @param [in]  string          String to be converted
 
6109
 * @param [out] timestampp      Pointer to timestamp
 
6110
 *
 
6111
 * @retval 0  Success; otherwise - EINVAL
 
6112
 */
 
6113
krb5_error_code KRB5_CALLCONV
 
6114
krb5_string_to_timestamp(char *string, krb5_timestamp *timestampp);
 
6115
 
 
6116
/**
 
6117
 * Convert a string to a delta time value.
 
6118
 *
 
6119
 * @param [in]  string          String to be converted
 
6120
 * @param [out] deltatp         Delta time to be filled in
 
6121
 *
 
6122
 * @retval 0  Success; otherwise - KRB5_DELTAT_BADFORMAT
 
6123
 */
 
6124
krb5_error_code KRB5_CALLCONV
 
6125
krb5_string_to_deltat(char *string, krb5_deltat *deltatp);
 
6126
 
 
6127
/**
 
6128
 * Convert an encryption type to a string.
 
6129
 *
 
6130
 * @param [in]  enctype         Encryption type
 
6131
 * @param [out] buffer          Buffer to hold encryption type string
 
6132
 * @param [in]  buflen          Storage available in @a buffer
 
6133
 *
 
6134
 * @retval 0  Success; otherwise - Kerberos error codes
 
6135
 */
 
6136
krb5_error_code KRB5_CALLCONV
 
6137
krb5_enctype_to_string(krb5_enctype enctype, char *buffer, size_t buflen);
 
6138
 
 
6139
/**
 
6140
 * Convert an encryption type to a name or alias.
 
6141
 *
 
6142
 * @param [in]  enctype         Encryption type
 
6143
 * @param [in]  shortest        Flag
 
6144
 * @param [out] buffer          Buffer to hold encryption type string
 
6145
 * @param [in]  buflen          Storage available in @a buffer
 
6146
 *
 
6147
 * If @a shortest is FALSE, this function returns the enctype's canonical name
 
6148
 * (like "aes128-cts-hmac-sha1-96").  If @a shortest is TRUE, it return the
 
6149
 * enctype's shortest alias (like "aes128-cts").
 
6150
 *
 
6151
 * @retval 0  Success; otherwise - Kerberos error codes
 
6152
 */
 
6153
krb5_error_code KRB5_CALLCONV
 
6154
krb5_enctype_to_name(krb5_enctype enctype, krb5_boolean shortest,
 
6155
                     char *buffer, size_t buflen);
 
6156
 
 
6157
/**
 
6158
 * Convert a salt type to a string.
 
6159
 *
 
6160
 * @param [in]  salttype        Salttype to convert
 
6161
 * @param [out] buffer          Buffer to receive the converted string
 
6162
 * @param [in]  buflen          Storage available in @a buffer
 
6163
 *
 
6164
 * @retval 0  Success; otherwise - Kerberos error codes
 
6165
 */
 
6166
krb5_error_code KRB5_CALLCONV
 
6167
krb5_salttype_to_string(krb5_int32 salttype, char *buffer, size_t buflen);
 
6168
 
 
6169
/**
 
6170
 * Convert a checksum type to a string.
 
6171
 *
 
6172
 * @param [in]  cksumtype       Checksum type
 
6173
 * @param [out] buffer          Buffer to hold converted checksum type
 
6174
 * @param [in]  buflen          Storage available in @a buffer
 
6175
 *
 
6176
 * @retval 0  Success; otherwise - Kerberos error codes
 
6177
 */
 
6178
krb5_error_code KRB5_CALLCONV
 
6179
krb5_cksumtype_to_string(krb5_cksumtype cksumtype, char *buffer, size_t buflen);
 
6180
 
 
6181
/**
 
6182
 * Convert a timestamp to a string.
 
6183
 *
 
6184
 * @param [in]  timestamp       Timestamp to convert
 
6185
 * @param [out] buffer          Buffer to hold converted timestamp
 
6186
 * @param [in]  buflen          Storage available in @a buffer
 
6187
 *
 
6188
 * The string is returned in the locale's appropriate date and time
 
6189
 * representation.
 
6190
 *
 
6191
 * @retval 0  Success; otherwise - Kerberos error codes
 
6192
 */
 
6193
krb5_error_code KRB5_CALLCONV
 
6194
krb5_timestamp_to_string(krb5_timestamp timestamp, char *buffer, size_t buflen);
 
6195
 
 
6196
/**
 
6197
 * Convert a timestamp to a string, with optional output padding
 
6198
 *
 
6199
 * @param [in]  timestamp       Timestamp to convert
 
6200
 * @param [out] buffer          Buffer to hold the converted timestamp
 
6201
 * @param [in]  buflen          Length of buffer
 
6202
 * @param [in]  pad             Optional value to pad @a buffer if converted
 
6203
 *                              timestamp does not fill it
 
6204
 *
 
6205
 * If @a pad is not NULL, @a buffer is padded out to @a buflen - 1 characters
 
6206
 * with the value of *@a pad.
 
6207
 *
 
6208
 * @retval 0  Success; otherwise - Kerberos error codes
 
6209
 */
 
6210
krb5_error_code KRB5_CALLCONV
 
6211
krb5_timestamp_to_sfstring(krb5_timestamp timestamp, char *buffer,
 
6212
                           size_t buflen, char *pad);
 
6213
 
 
6214
/**
 
6215
 * Convert a relative time value to a string.
 
6216
 *
 
6217
 * @param [in]  deltat          Relative time value to convert
 
6218
 * @param [out] buffer          Buffer to hold time string
 
6219
 * @param [in]  buflen          Storage available in @a buffer
 
6220
 *
 
6221
 * @retval 0  Success; otherwise - Kerberos error codes
 
6222
 */
 
6223
krb5_error_code KRB5_CALLCONV
 
6224
krb5_deltat_to_string(krb5_deltat deltat, char *buffer, size_t buflen);
2193
6225
 
2194
6226
/* The name of the Kerberos ticket granting service... and its size */
2195
6227
#define KRB5_TGS_NAME           "krbtgt"
2200
6232
#define KRB5_RECVAUTH_BADAUTHVERS       0x0002
2201
6233
/* initial ticket api functions */
2202
6234
 
 
6235
/** Text for prompt used in prompter callback function.  */
2203
6236
typedef struct _krb5_prompt {
2204
 
    char *prompt;
2205
 
    int hidden;
2206
 
    krb5_data *reply;
 
6237
    char *prompt;      /**< The prompt to show to the user */
 
6238
    int hidden;        /**< Boolean; informative prompt or hidden (e.g. PIN) */
 
6239
    krb5_data *reply;  /**< Must be allocated before call to  prompt routine */
2207
6240
} krb5_prompt;
2208
6241
 
 
6242
/** Pointer to a prompter callback function. */
2209
6243
typedef krb5_error_code
2210
6244
(KRB5_CALLCONV *krb5_prompter_fct)(krb5_context context, void *data,
2211
6245
                                   const char *name, const char *banner,
2212
6246
                                   int num_prompts, krb5_prompt prompts[]);
2213
6247
 
 
6248
/**
 
6249
 * Prompt user for password.
 
6250
 *
 
6251
 * @param [in]     context      Library context
 
6252
 * @param          data         Unused (callback argument)
 
6253
 * @param [in]     name         Name to output during prompt
 
6254
 * @param [in]     banner       Banner to output during prompt
 
6255
 * @param [in]     num_prompts  Number of prompts in @a prompts
 
6256
 * @param [in,out] prompts      Array of output prompts and replies
 
6257
 *
 
6258
 * This function is intended to be used as a prompter callback for
 
6259
 * krb5_get_init_creds_password() or krb5_init_creds_init().
 
6260
 *
 
6261
 * Writes @a name and @a banner to stdout, each followed by a newline, then
 
6262
 * writes each prompt field in the @a prompts array, followed by ": ", and sets
 
6263
 * the reply field of the entry to a line of input read from stdin.  If the
 
6264
 * hidden flag is set for a prompt, then terminal echoing is turned off when
 
6265
 * input is read.
 
6266
 *
 
6267
 * @retval
 
6268
 *  0   Success
 
6269
 * @return
 
6270
 * Kerberos error codes
 
6271
 *
 
6272
 */
2214
6273
krb5_error_code KRB5_CALLCONV
2215
6274
krb5_prompter_posix(krb5_context context, void *data, const char *name,
2216
6275
                    const char *banner, int num_prompts,
2217
6276
                    krb5_prompt prompts[]);
2218
6277
 
 
6278
/** Store options for @c _krb5_get_init_creds */
2219
6279
typedef struct _krb5_get_init_creds_opt {
2220
6280
    krb5_flags flags;
2221
6281
    krb5_deltat tkt_life;
2240
6300
#define KRB5_GET_INIT_CREDS_OPT_SALT            0x0080
2241
6301
#define KRB5_GET_INIT_CREDS_OPT_CHG_PWD_PRMPT   0x0100
2242
6302
#define KRB5_GET_INIT_CREDS_OPT_CANONICALIZE    0x0200
2243
 
#define KRB5_GET_INIT_CREDS_OPT_ANONYMOUS 0x0400
2244
 
 
2245
 
 
 
6303
#define KRB5_GET_INIT_CREDS_OPT_ANONYMOUS       0x0400
 
6304
 
 
6305
 
 
6306
/**
 
6307
 * Allocate a new initial credential options structure.
 
6308
 *
 
6309
 * @param [in]  context         Library context
 
6310
 * @param [out] opt             New options structure
 
6311
 *
 
6312
 * This function is the preferred way to create an options structure for
 
6313
 * getting initial credentials, and is required to make use of certain options.
 
6314
 * Use krb5_get_init_creds_opt_free() to free @a opt when it is no longer
 
6315
 * needed.
 
6316
 *
 
6317
 * @retval 0 - Success; Kerberos errors otherwise.
 
6318
 */
2246
6319
krb5_error_code KRB5_CALLCONV
2247
6320
krb5_get_init_creds_opt_alloc(krb5_context context,
2248
6321
                              krb5_get_init_creds_opt **opt);
2249
6322
 
 
6323
/**
 
6324
 * Free initial credential options.
 
6325
 *
 
6326
 * @param [in] context          Library context
 
6327
 * @param [in] opt              Options structure to free
 
6328
 *
 
6329
 * @sa krb5_get_init_creds_opt_alloc()
 
6330
 */
2250
6331
void KRB5_CALLCONV
2251
6332
krb5_get_init_creds_opt_free(krb5_context context,
2252
6333
                             krb5_get_init_creds_opt *opt);
2253
6334
 
 
6335
/** @deprecated Use krb5_get_init_creds_opt_alloc() instead. */
2254
6336
void KRB5_CALLCONV
2255
6337
krb5_get_init_creds_opt_init(krb5_get_init_creds_opt *opt);
2256
6338
 
 
6339
/**
 
6340
 * Set the ticket lifetime in initial credential options.
 
6341
 *
 
6342
 * @param [in] opt              Options structure
 
6343
 * @param [in] tkt_life         Ticket lifetime
 
6344
 */
2257
6345
void KRB5_CALLCONV
2258
6346
krb5_get_init_creds_opt_set_tkt_life(krb5_get_init_creds_opt *opt,
2259
6347
                                     krb5_deltat tkt_life);
2260
6348
 
 
6349
/**
 
6350
 * Set the ticket renewal lifetime in initial credential options.
 
6351
 *
 
6352
 * @param [in] opt              Pointer to @a options field
 
6353
 * @param [in] renew_life       Ticket renewal lifetime
 
6354
 */
2261
6355
void KRB5_CALLCONV
2262
6356
krb5_get_init_creds_opt_set_renew_life(krb5_get_init_creds_opt *opt,
2263
6357
                                       krb5_deltat renew_life);
2264
6358
 
 
6359
/**
 
6360
 * Set or unset the forwardable flag in initial credential options.
 
6361
 *
 
6362
 * @param [in] opt              Options structure
 
6363
 * @param [in] forwardable      Whether credentials should be forwardable
 
6364
 */
2265
6365
void KRB5_CALLCONV
2266
6366
krb5_get_init_creds_opt_set_forwardable(krb5_get_init_creds_opt *opt,
2267
6367
                                        int forwardable);
2268
6368
 
 
6369
/**
 
6370
 * Set or unset the proxiable flag in initial credential options.
 
6371
 *
 
6372
 * @param [in] opt              Options structure
 
6373
 * @param [in] proxiable        Whether credentials should be proxiable
 
6374
 */
2269
6375
void KRB5_CALLCONV
2270
6376
krb5_get_init_creds_opt_set_proxiable(krb5_get_init_creds_opt *opt,
2271
6377
                                      int proxiable);
2272
6378
 
 
6379
/**
 
6380
 * Set or unset the canonicalize flag in initial credential options.
 
6381
 *
 
6382
 * @param [in] opt              Options structure
 
6383
 * @param [in] canonicalize     Whether to canonicalize client principal
 
6384
 */
2273
6385
void KRB5_CALLCONV
2274
6386
krb5_get_init_creds_opt_set_canonicalize(krb5_get_init_creds_opt *opt,
2275
6387
                                         int canonicalize);
2276
6388
 
2277
6389
/**
2278
 
 * Request anonymous credentials from the KDC.  If the  client name looks like
2279
 
 * "@REALM" (an empty principal name), then fully anonymous credentials are
2280
 
 * requested.  If the client name looks like "name@REALM," then credentials
2281
 
 * tied to a specific realm are requested.
2282
 
 *
2283
 
 * Credentials tied to a specific realm are not supported in this version.
2284
 
 *
2285
 
 * Note that anonymous credentials are only a request; clients must verify that
2286
 
 * credentials are anonymous if that is a requirement.
 
6390
 * Set or unset the anonymous flag in initial credential options.
 
6391
 *
 
6392
 * @param [in] opt              Options structure
 
6393
 * @param [in] anonymous        Whether to make an anonymous request
 
6394
 *
 
6395
 * This function may be used to request anonymous credentials from the KDC by
 
6396
 * setting @a anonymous to non-zero.  Note that anonymous credentials are only
 
6397
 * a request; clients must verify that credentials are anonymous if that is a
 
6398
 * requirement.
2287
6399
 */
2288
6400
void KRB5_CALLCONV
2289
6401
krb5_get_init_creds_opt_set_anonymous(krb5_get_init_creds_opt *opt,
2290
6402
                                      int anonymous);
2291
6403
 
 
6404
/**
 
6405
 * Set allowable encryption types in initial credential options.
 
6406
 *
 
6407
 * @param [in] opt               Options structure
 
6408
 * @param [in] etype_list        Array of encryption types
 
6409
 * @param [in] etype_list_length Length of @a etype_list
 
6410
 */
2292
6411
void KRB5_CALLCONV
2293
6412
krb5_get_init_creds_opt_set_etype_list(krb5_get_init_creds_opt *opt,
2294
6413
                                       krb5_enctype *etype_list,
2295
6414
                                       int etype_list_length);
2296
6415
 
 
6416
/**
 
6417
 * Set address restrictions in initial credential options.
 
6418
 *
 
6419
 * @param [in] opt              Options structure
 
6420
 * @param [in] addresses        Null-terminated array of addresses
 
6421
 */
2297
6422
void KRB5_CALLCONV
2298
6423
krb5_get_init_creds_opt_set_address_list(krb5_get_init_creds_opt *opt,
2299
6424
                                         krb5_address **addresses);
2300
6425
 
 
6426
/**
 
6427
 * Set preauthentication types in initial credential options.
 
6428
 *
 
6429
 * @param [in] opt                 Options structure
 
6430
 * @param [in] preauth_list        Array of preauthentication types
 
6431
 * @param [in] preauth_list_length Length of @a preauth_list
 
6432
 *
 
6433
 * This function can be used to perform optimistic preauthentication when
 
6434
 * getting initial credentials, in combination with
 
6435
 * krb5_get_init_creds_opt_set_salt() and krb5_get_init_creds_opt_set_pa().
 
6436
 */
2301
6437
void KRB5_CALLCONV
2302
6438
krb5_get_init_creds_opt_set_preauth_list(krb5_get_init_creds_opt *opt,
2303
6439
                                         krb5_preauthtype *preauth_list,
2304
6440
                                         int preauth_list_length);
2305
6441
 
 
6442
/**
 
6443
 * Set salt for optimistic preauthentication in initial credential options.
 
6444
 *
 
6445
 * @param [in] opt              Options structure
 
6446
 * @param [in] salt             Salt data
 
6447
 *
 
6448
 * When getting initial credentials with a password, a salt string it used to
 
6449
 * convert the password to a key.  Normally this salt is obtained from the
 
6450
 * first KDC reply, but when performing optimistic preauthentication, the
 
6451
 * client may need to supply the salt string with this function.
 
6452
 */
2306
6453
void KRB5_CALLCONV
2307
6454
krb5_get_init_creds_opt_set_salt(krb5_get_init_creds_opt *opt,
2308
6455
                                 krb5_data *salt);
2309
6456
 
 
6457
/**
 
6458
 * Set or unset change-password-prompt flag in initial credential options.
 
6459
 *
 
6460
 * @param [in] opt              Options structure
 
6461
 * @param [in] prompt           Whether to prompt to change password
 
6462
 *
 
6463
 * This flag is on by default.  It controls whether
 
6464
 * krb5_get_init_creds_password() will react to an expired-password error by
 
6465
 * prompting for a new password and attempting to change the old one.
 
6466
 */
2310
6467
void KRB5_CALLCONV
2311
 
krb5_get_init_creds_opt_set_change_password_prompt(krb5_get_init_creds_opt
2312
 
                                                   *opt, int prompt);
 
6468
krb5_get_init_creds_opt_set_change_password_prompt(krb5_get_init_creds_opt *opt,
 
6469
                                                   int prompt);
2313
6470
 
2314
 
/* Generic preauth option attribute/value pairs */
 
6471
/** Generic preauth option attribute/value pairs */
2315
6472
typedef struct _krb5_gic_opt_pa_data {
2316
6473
    char *attr;
2317
6474
    char *value;
2318
6475
} krb5_gic_opt_pa_data;
2319
6476
 
2320
 
/*
2321
 
 * This function allows the caller to supply options to preauth
2322
 
 * plugins.  Preauth plugin modules are given a chance to look
2323
 
 * at each option at the time this function is called in ordre
2324
 
 * to check the validity of the option.
2325
 
 * The 'opt' pointer supplied to this function must have been
2326
 
 * obtained using krb5_get_init_creds_opt_alloc()
 
6477
/**
 
6478
 * Supply options for preauthentication in initial credential options.
 
6479
 *
 
6480
 * @param [in] context          Library context
 
6481
 * @param [in] opt              Options structure
 
6482
 * @param [in] attr             Preauthentication option name
 
6483
 * @param [in] value            Preauthentication option value
 
6484
 *
 
6485
 * This function allows the caller to supply options for preauthentication.
 
6486
 * The values of @a attr and @a value are supplied to each preauthentication
 
6487
 * module available within @a context.
2327
6488
 */
2328
6489
krb5_error_code KRB5_CALLCONV
2329
6490
krb5_get_init_creds_opt_set_pa(krb5_context context,
2331
6492
                               const char *value);
2332
6493
 
2333
6494
/**
2334
 
 * This API sets a ccache name that will contain some TGT on calls to
2335
 
 * t_init_creds functions.  If set, this ccache will be used for FAST
2336
 
 * (draft-ietf-krb-wg-preauth-framework) to protect the AS-REQ from observation
2337
 
 * and active attack.  If the fast_ccache_name is set, then FAST may be
2338
 
 * required by the client library.  In this and future versions, FAST will be
2339
 
 * used if available; krb5_get_init_creds_opt_set_fast_flags() may be used to
2340
 
 * require that the request fail is FAST is unavailable.  In MIT Kerberos 1.7
2341
 
 * setting the fast ccache at all required that FAST be present or the request
2342
 
 * would fail.
 
6495
 * Set location of FAST armor ccache in initial credential options.
 
6496
 *
 
6497
 * @param [in] context          Library context
 
6498
 * @param [in] opt              Options
 
6499
 * @param [in] fast_ccache_name Credential cache name
 
6500
 *
 
6501
 * Sets the location of a credential cache containing an armor ticket to
 
6502
 * protect an initial credential exchange using the FAST protocol extension.
 
6503
 *
 
6504
 * In version 1.7, setting an armor ccache requires that FAST be used for the
 
6505
 * exchange.  In version 1.8 or later, setting the armor ccache causes FAST to
 
6506
 * be used if the KDC supports it; krb5_get_init_creds_opt_set_fast_flags()
 
6507
 * must be used to require that FAST be used.
2343
6508
 */
2344
6509
krb5_error_code KRB5_CALLCONV
2345
6510
krb5_get_init_creds_opt_set_fast_ccache_name(krb5_context context,
2346
6511
                                             krb5_get_init_creds_opt *opt,
2347
6512
                                             const char *fast_ccache_name);
2348
6513
 
2349
 
/** Set the FAST ccache name as in
2350
 
 * krb5_get_init_creds_opt_set_fast_ccache_name() but using a krb5_ccache
2351
 
 * rather than a name.
 
6514
/**
 
6515
 * Set FAST armor cache in initial credential options.
 
6516
 *
 
6517
 * @param [in] context           Library context
 
6518
 * @param [in] opt               Options
 
6519
 * @param [in] ccache            Credential cache handle
 
6520
 *
 
6521
 * This function is similar to krb5_get_init_creds_opt_set_fast_ccache_name(),
 
6522
 * but uses a credential cache handle instead of a name.
2352
6523
 */
2353
6524
krb5_error_code KRB5_CALLCONV
2354
6525
krb5_get_init_creds_opt_set_fast_ccache(krb5_context context,
2355
6526
                                        krb5_get_init_creds_opt *opt,
2356
 
                                        krb5_ccache fast_ccache_name);
 
6527
                                        krb5_ccache ccache);
2357
6528
 
2358
6529
/**
2359
 
 * Set a ccache where resulting credentials will be stored.  If set, then the
2360
 
 * krb5_get_init_creds family of APIs will write out credentials to the given
2361
 
 * ccache.  Setting an output ccache is desirable both because it simplifies
2362
 
 * calling code and because it permits the krb5_get_init_creds APIs to write
2363
 
 * out configuration information about the realm to the ccache.
 
6530
 * Set an output credential cache in initial credential options.
 
6531
 *
 
6532
 * @param [in] context          Library context
 
6533
 * @param [in] opt              Options
 
6534
 * @param [in] ccache           Credential cache handle
 
6535
 *
 
6536
 * If an output credential cache is set, then the krb5_get_init_creds family of
 
6537
 * APIs will write credentials to it.  Setting an output ccache is desirable
 
6538
 * both because it simplifies calling code and because it permits the
 
6539
 * krb5_get_init_creds APIs to write out configuration information about the
 
6540
 * realm to the ccache.
2364
6541
 */
2365
6542
krb5_error_code KRB5_CALLCONV
2366
6543
krb5_get_init_creds_opt_set_out_ccache(krb5_context context,
2367
6544
                                       krb5_get_init_creds_opt *opt,
2368
6545
                                       krb5_ccache ccache);
2369
6546
 
 
6547
/**
 
6548
 * Set FAST flags in initial credential options.
 
6549
 *
 
6550
 * @param [in] context          Library context
 
6551
 * @param [in] opt              Options
 
6552
 * @param [in] flags            FAST flags
 
6553
 *
 
6554
 * The following flag values are valid:
 
6555
 * @li #KRB5_FAST_REQUIRED - Require FAST to be used
 
6556
 *
 
6557
 * @retval
 
6558
 * 0 - Success; Kerberos errors otherwise.
 
6559
 */
2370
6560
krb5_error_code KRB5_CALLCONV
2371
6561
krb5_get_init_creds_opt_set_fast_flags(krb5_context context,
2372
6562
                                       krb5_get_init_creds_opt *opt,
2373
6563
                                       krb5_flags flags);
2374
6564
 
 
6565
/**
 
6566
 * Retrieve FAST flags from initial credential options.
 
6567
 *
 
6568
 * @param [in]  context         Library context
 
6569
 * @param [in]  opt             Options
 
6570
 * @param [out] out_flags       FAST flags
 
6571
 *
 
6572
 * @retval
 
6573
 * 0 - Success; Kerberos errors otherwise.
 
6574
 */
2375
6575
krb5_error_code KRB5_CALLCONV
2376
6576
krb5_get_init_creds_opt_get_fast_flags(krb5_context context,
2377
6577
                                       krb5_get_init_creds_opt *opt,
2378
6578
                                       krb5_flags *out_flags);
2379
6579
 
2380
6580
/* Fast flags*/
2381
 
#define KRB5_FAST_REQUIRED 1l<<0 /*!< Require KDC to support FAST*/
 
6581
#define KRB5_FAST_REQUIRED 1l<<0 /**< Require KDC to support FAST*/
2382
6582
 
2383
6583
typedef void
2384
6584
(KRB5_CALLCONV *krb5_expire_callback_func)(krb5_context context, void *data,
2387
6587
                                           krb5_boolean is_last_req);
2388
6588
 
2389
6589
/**
 
6590
 * Set an expiration callback in initial credential options.
 
6591
 *
 
6592
 * @param [in] context          Library context
 
6593
 * @param [in] opt              Options structure
 
6594
 * @param [in] cb               Callback function
 
6595
 * @param [in] data             Callback argument
 
6596
 *
2390
6597
 * Set a callback to receive password and account expiration times.
2391
6598
 *
2392
6599
 * This option only applies to krb5_get_init_creds_password().  @a cb will be
2412
6619
 * caller's responsibility to avoid displaying a password expiry warning in
2413
6620
 * this case.
2414
6621
 *
2415
 
 * Setting an expire callback with this API will cause
 
6622
 * @warning Setting an expire callback with this API will cause
2416
6623
 * krb5_get_init_creds_password() not to send password expiry warnings to the
2417
6624
 * prompter, as it ordinarily may.
2418
6625
 */
2422
6629
                                            krb5_expire_callback_func cb,
2423
6630
                                            void *data);
2424
6631
 
 
6632
/**
 
6633
 * Get initial credentials using a password.
 
6634
 *
 
6635
 * @param [in]  context         Library context
 
6636
 * @param [out] creds           New credentials
 
6637
 * @param [in]  client          Client principal
 
6638
 * @param [in]  password        Password (or NULL)
 
6639
 * @param [in]  prompter        Prompter function
 
6640
 * @param [in]  data            Prompter callback data
 
6641
 * @param [in]  start_time      Time when ticket becomes valid (0 for now)
 
6642
 * @param [in]  in_tkt_service  Service name of initial credentials (or NULL)
 
6643
 * @param [in]  k5_gic_options  Initial credential options
 
6644
 *
 
6645
 * This function requests KDC for an initial credentials for @a client using @a
 
6646
 * password.  If @a password is NULL, a password will be prompted for using @a
 
6647
 * prompter if necessary.  If @a in_tkt_service is specified, it is parsed as a
 
6648
 * principal name (with the realm ignored) and used as the service principal
 
6649
 * for the request; otherwise the ticket-granting service is used.
 
6650
 *
 
6651
 * @sa krb5_verify_init_creds()
 
6652
 *
 
6653
 * @retval
 
6654
 *  0    Success
 
6655
 * @retval
 
6656
 *  EINVAL Invalid argument
 
6657
 * @retval
 
6658
 *  KRB5_KDC_UNREACH Cannot contact any KDC for requested realm
 
6659
 * @retval
 
6660
 *  KRB5_PREAUTH_FAILED Generic Pre-athentication failure
 
6661
 * @retval
 
6662
 *  KRB5_LIBOS_PWDINTR Password read interrupted
 
6663
 * @retval
 
6664
 *  KRB5_REALM_CANT_RESOLVE Cannot resolve network address for KDC in requested realm
 
6665
 * @retval
 
6666
 *  KRB5KDC_ERR_KEY_EXP Password has expired
 
6667
 * @retval
 
6668
 *  KRB5_LIBOS_BADPWDMATCH Password mismatch
 
6669
 * @retval
 
6670
 *  KRB5_CHPW_PWDNULL New password cannot be zero length
 
6671
 * @retval
 
6672
 *  KRB5_CHPW_FAIL Password change failed
 
6673
 * @return
 
6674
 * Kerberos error codes
 
6675
 */
2425
6676
krb5_error_code KRB5_CALLCONV
2426
6677
krb5_get_init_creds_password(krb5_context context, krb5_creds *creds,
2427
6678
                             krb5_principal client, char *password,
2434
6685
 
2435
6686
#define KRB5_INIT_CREDS_STEP_FLAG_CONTINUE 0x1  /* More responses needed */
2436
6687
 
 
6688
/**
 
6689
 * Free an initial credentials context.
 
6690
 *
 
6691
 * @param [in] context          Library context
 
6692
 * @param [in] ctx              Initial credentials context
 
6693
 */
2437
6694
void KRB5_CALLCONV
2438
6695
krb5_init_creds_free(krb5_context context, krb5_init_creds_context ctx);
2439
6696
 
 
6697
/**
 
6698
 * Acquire credentials using an initial credentials context.
 
6699
 *
 
6700
 * @param [in] context          Library context
 
6701
 * @param [in] ctx              Initial credentials context
 
6702
 *
 
6703
 * This function synchronously obtains credentials using a context created by
 
6704
 * krb5_init_creds_init().  On successful return, the credentials can be
 
6705
 * retrieved with krb5_init_creds_get_creds().
 
6706
 *
 
6707
 * @retval 0 Success; otherwise - Kerberos error codes
 
6708
 */
2440
6709
krb5_error_code KRB5_CALLCONV
2441
6710
krb5_init_creds_get(krb5_context context, krb5_init_creds_context ctx);
2442
6711
 
 
6712
/**
 
6713
 * Retrieve acquired credentials from an initial credentials context.
 
6714
 *
 
6715
 * @param [in]  context         Library context
 
6716
 * @param [in]  ctx             Initial credentials context
 
6717
 * @param [out] creds           Acquired credentials
 
6718
 *
 
6719
 * This function copies the acquired initial credentials from @a ctx into @a
 
6720
 * creds, after the successful completion of krb5_init_creds_get() or
 
6721
 * krb5_init_creds_step().  Use krb5_free_cred_contents() to free @a creds when
 
6722
 * it is no longer needed.
 
6723
 *
 
6724
 * @retval 0 Success; otherwise - Kerberos error codes
 
6725
 */
2443
6726
krb5_error_code KRB5_CALLCONV
2444
6727
krb5_init_creds_get_creds(krb5_context context, krb5_init_creds_context ctx,
2445
6728
                          krb5_creds *creds);
2446
6729
 
 
6730
/**
 
6731
 * Get the last error from KDC from an initial credentials context.
 
6732
 *
 
6733
 * @param [in]  context         Library context
 
6734
 * @param [in]  ctx             Initial credentials context
 
6735
 * @param [out] error           Error from KDC, or NULL if none was received
 
6736
 *
 
6737
 * @retval 0 Success; otherwise - Kerberos error codes
 
6738
 */
2447
6739
krb5_error_code KRB5_CALLCONV
2448
6740
krb5_init_creds_get_error(krb5_context context, krb5_init_creds_context ctx,
2449
6741
                          krb5_error **error);
2450
6742
 
 
6743
/**
 
6744
 * Create a context for acquiring initial credentials.
 
6745
 *
 
6746
 * @param [in]  context         Library context
 
6747
 * @param [in]  client          Client principal to get initial creds for
 
6748
 * @param [in]  prompter        Prompter callback
 
6749
 * @param [in]  data            Prompter callback argument
 
6750
 * @param [in]  start_time      Time when credentials become valid (0 for now)
 
6751
 * @param [in]  options         Options structure (NULL for default)
 
6752
 * @param [out] ctx             New initial credentials context
 
6753
 *
 
6754
 * This function creates a new context for acquiring initial credentials.  Use
 
6755
 * krb5_init_creds_free() to free @a ctx when it is no longer needed.
 
6756
 *
 
6757
 * @retval 0 Success; otherwise - Kerberos error codes
 
6758
 */
2451
6759
krb5_error_code KRB5_CALLCONV
2452
6760
krb5_init_creds_init(krb5_context context, krb5_principal client,
2453
6761
                     krb5_prompter_fct prompter, void *data,
2454
6762
                     krb5_deltat start_time, krb5_get_init_creds_opt *options,
2455
6763
                     krb5_init_creds_context *ctx);
2456
6764
 
2457
 
krb5_error_code KRB5_CALLCONV
2458
 
krb5_init_creds_set_keyblock(krb5_context context, krb5_init_creds_context ctx,
2459
 
                             krb5_keyblock *keyblock);
2460
 
 
 
6765
/**
 
6766
 * Specify a keytab to use for acquiring initial credentials.
 
6767
 *
 
6768
 * @param [in] context          Library context
 
6769
 * @param [in] ctx              Initial credentials context
 
6770
 * @param [in] keytab           Key table handle
 
6771
 *
 
6772
 * This function supplies a keytab containing the client key for an initial
 
6773
 * credentials request.
 
6774
 *
 
6775
 * @retval 0 Success; otherwise - Kerberos error codes
 
6776
 */
2461
6777
krb5_error_code KRB5_CALLCONV
2462
6778
krb5_init_creds_set_keytab(krb5_context context, krb5_init_creds_context ctx,
2463
6779
                           krb5_keytab keytab);
2464
6780
 
 
6781
/**
 
6782
 * Get the next KDC request for acquiring initial credentials.
 
6783
 *
 
6784
 * @param [in]  context         Library context
 
6785
 * @param [in]  ctx             Initial credentials context
 
6786
 * @param [in]  in              KDC response (empty on the first call)
 
6787
 * @param [out] out             Next KDC request
 
6788
 * @param [out] realm           Realm for next KDC request
 
6789
 * @param [out] flags           Output flags
 
6790
 *
 
6791
 * This function constructs the next KDC request in an initial credential
 
6792
 * exchange, allowing the caller to control the transport of KDC requests and
 
6793
 * replies.  On the first call, @a in should be set to an empty buffer; on
 
6794
 * subsequent calls, it should be set to the KDC's reply to the previous
 
6795
 * request.
 
6796
 *
 
6797
 * If more requests are needed, @a flags will be set to
 
6798
 * #KRB5_INIT_CREDS_STEP_FLAG_CONTINUE and the next request will be placed in
 
6799
 * @a out.  If no more requests are needed, @a flags will not contain
 
6800
 * #KRB5_INIT_CREDS_STEP_FLAG_CONTINUE and @a out will be empty.
 
6801
 *
 
6802
 * If this function returns @c KRB5KRB_ERR_RESPONSE_TOO_BIG, the caller should
 
6803
 * transmit the next request using TCP rather than UDP.  If this function
 
6804
 * returns any other error, the initial credential exchange has failed.
 
6805
 *
 
6806
 * @retval 0 Success; otherwise - Kerberos error codes
 
6807
 */
2465
6808
krb5_error_code KRB5_CALLCONV
2466
6809
krb5_init_creds_step(krb5_context context, krb5_init_creds_context ctx,
2467
6810
                     krb5_data *in, krb5_data *out, krb5_data *realm,
2468
6811
                     unsigned int *flags);
2469
6812
 
 
6813
/**
 
6814
 * Set a password for acquiring initial credentials.
 
6815
 *
 
6816
 * @param [in] context          Library context
 
6817
 * @param [in] ctx              Initial credentials context
 
6818
 * @param [in] password         Password
 
6819
 *
 
6820
 * This function supplies a password to be used to construct the client key for
 
6821
 * an initial credentials request.
 
6822
 *
 
6823
 * @retval 0 Success; otherwise - Kerberos error codes
 
6824
 */
2470
6825
krb5_error_code KRB5_CALLCONV
2471
6826
krb5_init_creds_set_password(krb5_context context, krb5_init_creds_context ctx,
2472
6827
                             const char *password);
2473
6828
 
 
6829
/**
 
6830
 * Specify a service principal for acquiring initial credentials.
 
6831
 *
 
6832
 * @param [in] context          Library context
 
6833
 * @param [in] ctx              Initial credentials context
 
6834
 * @param [in] service          Service principal string
 
6835
 *
 
6836
 * This function supplies a service principal string to acquire initial
 
6837
 * credentials for instead of the default krbtgt service.  @a service is parsed
 
6838
 * as a principal name; any realm part is ignored.
 
6839
 *
 
6840
 * @retval 0 Success; otherwise - Kerberos error codes
 
6841
 */
2474
6842
krb5_error_code KRB5_CALLCONV
2475
6843
krb5_init_creds_set_service(krb5_context context, krb5_init_creds_context ctx,
2476
6844
                            const char *service);
2477
6845
 
 
6846
/**
 
6847
 * Retrieve ticket times from an initial credentials context.
 
6848
 *
 
6849
 * @param [in]  context         Library context
 
6850
 * @param [in]  ctx             Initial credentials context
 
6851
 * @param [out] times           Ticket times for acquired credentials
 
6852
 *
 
6853
 * The initial credentials context must have completed obtaining credentials
 
6854
 * via either krb5_init_creds_get() or krb5_init_creds_step().
 
6855
 *
 
6856
 * @retval 0 Success; otherwise - Kerberos error codes
 
6857
 */
2478
6858
krb5_error_code KRB5_CALLCONV
2479
6859
krb5_init_creds_get_times(krb5_context context, krb5_init_creds_context ctx,
2480
6860
                          krb5_ticket_times *times);
2485
6865
/**
2486
6866
 * Create a context to get credentials from a KDC's Ticket Granting Service.
2487
6867
 *
 
6868
 * @param[in]  context          Library context
 
6869
 * @param[in]  ccache           Credential cache handle
 
6870
 * @param[in]  creds            Input credentials
 
6871
 * @param[in]  options          @ref KRB5_GC options for this request.
 
6872
 * @param[out] ctx              New TGS request context
 
6873
 *
 
6874
 * This function prepares to obtain credentials matching @a creds, either by
 
6875
 * retrieving them from @a ccache or by making requests to ticket-granting
 
6876
 * services beginning with a ticket-granting ticket for the client principal's
 
6877
 * realm.
 
6878
 *
2488
6879
 * The resulting TGS acquisition context can be used asynchronously with
2489
6880
 * krb5_tkt_creds_step() or synchronously with krb5_tkt_creds_get().  See also
2490
 
 * krb5_get_credentials() for synchrous use.
2491
 
 *
2492
 
 * @param[in]  context  A krb5 library context (see krb5_init_context())
2493
 
 * @param[in]  ccache   A credentials cache containing the desired credentials
2494
 
 *                      or a Ticket Granting Ticket (TGT) for the client realm.
2495
 
 *                      TGT and service credentials may be stored into this
2496
 
 *                      cache as they are acquired.
2497
 
 * @param[in]  options  KRB5_GC_* options for this request.
2498
 
 * @param[out] ctx      The TGS acquisition context.
 
6881
 * krb5_get_credentials() for synchronous use.
 
6882
 *
 
6883
 * Use krb5_tkt_creds_free() to free @a ctx when it is no longer needed.
 
6884
 *
 
6885
 * @retval 0  Success; otherwise - Kerberos error codes
2499
6886
 */
2500
6887
krb5_error_code KRB5_CALLCONV
2501
6888
krb5_tkt_creds_init(krb5_context context, krb5_ccache ccache,
2503
6890
                    krb5_tkt_creds_context *ctx);
2504
6891
 
2505
6892
/**
2506
 
 * Synchronously obtain credentials within an acquisition context.
2507
 
 *
2508
 
 * This function repeatedly generates requests, sends them to the appropriate
2509
 
 * realms' KDCs, and processes the replies until credentials are available for
2510
 
 * retrieval with krb5_tkt_creds_get_creds().
2511
 
 *
2512
 
 * @param[in]  context  A krb5 library context (see krb5_init_context())
2513
 
 * @param[in]  ctx      A TGS acquisition context (see krb5_tkt_creds_init())
 
6893
 * Synchronously obtain credentials using a TGS request context.
 
6894
 *
 
6895
 * @param[in] context           Library context
 
6896
 * @param[in] ctx               TGS request context
 
6897
 *
 
6898
 * This function synchronously obtains credentials using a context created by
 
6899
 * krb5_tkt_creds_init().  On successful return, the credentials can be
 
6900
 * retrieved with krb5_tkt_creds_get_creds().
 
6901
 *
 
6902
 * @retval 0  Success; otherwise - Kerberos error codes
2514
6903
 */
2515
6904
krb5_error_code KRB5_CALLCONV
2516
6905
krb5_tkt_creds_get(krb5_context context, krb5_tkt_creds_context ctx);
2517
6906
 
2518
6907
/**
2519
 
 * Retrieve credentials from an acquisition context, filling in @a creds.
2520
 
 *
2521
 
 * The acquisition context must have completed obtaining credentials via either
2522
 
 * krb5_tkt_creds_get() or krb5_tkt_creds_step().
2523
 
 *
2524
 
 * @param[in]  context  A krb5 library context (see krb5_init_context())
2525
 
 * @param[in]  ctx      A TGS acquisition context (see krb5_tkt_creds_init())
2526
 
 * @param[out] creds    The acquired credentials
 
6908
 * Retrieve acquired credentials from a TGS request context.
 
6909
 *
 
6910
 * @param[in]  context          Library context
 
6911
 * @param[in]  ctx              TGS request context
 
6912
 * @param[out] creds            Acquired credentials
 
6913
 *
 
6914
 * This function copies the acquired initial credentials from @a ctx into @a
 
6915
 * creds, after the successful completion of krb5_tkt_creds_get() or
 
6916
 * krb5_tkt_creds_step().  Use krb5_free_cred_contents() to free @a creds when
 
6917
 * it is no longer needed.
 
6918
 *
 
6919
 * @retval 0  Success; otherwise - Kerberos error codes
2527
6920
 */
2528
6921
krb5_error_code KRB5_CALLCONV
2529
6922
krb5_tkt_creds_get_creds(krb5_context context, krb5_tkt_creds_context ctx,
2530
6923
                         krb5_creds *creds);
2531
6924
 
2532
6925
/**
2533
 
 * Release the resources used by an acquisition context.
 
6926
 * Free a TGS request context.
2534
6927
 *
2535
 
 * @param[in]  context  A krb5 library context (see krb5_init_context())
2536
 
 * @param[in]  ctx      A TGS acquisition context (see krb5_tkt_creds_init())
 
6928
 * @param[in]  context  Library context
 
6929
 * @param[in]  ctx      TGS request context
2537
6930
 */
2538
6931
void KRB5_CALLCONV
2539
6932
krb5_tkt_creds_free(krb5_context context, krb5_tkt_creds_context ctx);
2541
6934
#define KRB5_TKT_CREDS_STEP_FLAG_CONTINUE 0x1  /* More responses needed. */
2542
6935
 
2543
6936
/**
2544
 
 * Process a response and generate the next request to acquire credentials.
2545
 
 *
2546
 
 * On the first call, @a in should be empty or NULL.  If more responses are
2547
 
 * needed, the @a flags output parameter will contain @a
2548
 
 * KRB5_TKT_CREDS_STEP_FLAG_CONTINUE.  In that case, the caller must transport
2549
 
 * @a out to a KDC for @a realm and receive a response, which should be
2550
 
 * provided as @a in to the next call.
2551
 
 *
2552
 
 * @param[in]  context  A krb5 library context (see krb5_init_context())
2553
 
 * @param[in]  ctx      A TGS acquisition context (see krb5_tkt_creds_init())
2554
 
 * @param[in]  in       The last response (empty or NULL for first call)
2555
 
 * @param[out] out      The next request to be sent
2556
 
 * @param[out] realm    The realm to which the next request should be sent
2557
 
 * @param[out] flags    Indicates whether more responses are needed
 
6937
 * Get the next KDC request in a TGS exchange.
 
6938
 *
 
6939
 * @param[in]  context          Library context
 
6940
 * @param[in]  ctx              TGS request context
 
6941
 * @param[in]  in               KDC response (empty on the first call)
 
6942
 * @param[out] out              Next KDC request
 
6943
 * @param[out] realm            Realm for next KDC request
 
6944
 * @param[out] flags            Output flags
 
6945
 *
 
6946
 * This function constructs the next KDC request for a TGS exchange, allowing
 
6947
 * the caller to control the transport of KDC requests and replies.  On the
 
6948
 * first call, @a in should be set to an empty buffer; on subsequent calls, it
 
6949
 * should be set to the KDC's reply to the previous request.
 
6950
 *
 
6951
 * If more requests are needed, @a flags will be set to
 
6952
 * #KRB5_TKT_CREDS_STEP_FLAG_CONTINUE and the next request will be placed in @a
 
6953
 * out.  If no more requests are needed, @a flags will not contain
 
6954
 * #KRB5_TKT_CREDS_STEP_FLAG_CONTINUE and @a out will be empty.
 
6955
 *
 
6956
 * If this function returns @c KRB5KRB_ERR_RESPONSE_TOO_BIG, the caller should
 
6957
 * transmit the next request using TCP rather than UDP.  If this function
 
6958
 * returns any other error, the TGS exchange has failed.
 
6959
 *
 
6960
 * @retval 0  Success; otherwise - Kerberos error codes
2558
6961
 */
2559
6962
krb5_error_code KRB5_CALLCONV
2560
6963
krb5_tkt_creds_step(krb5_context context, krb5_tkt_creds_context ctx,
2562
6965
                    unsigned int *flags);
2563
6966
 
2564
6967
/**
2565
 
 * Retrieve ticket times for obtained credentials, filling in @a times.
2566
 
 *
2567
 
 * The acquisition context must have completed obtaining credentials via either
 
6968
 * Retrieve ticket times from a TGS request context.
 
6969
 *
 
6970
 * @param[in]  context          Library context
 
6971
 * @param[in]  ctx              TGS request context
 
6972
 * @param[out] times            Ticket times for acquired credentials
 
6973
 *
 
6974
 * The TGS request context must have completed obtaining credentials via either
2568
6975
 * krb5_tkt_creds_get() or krb5_tkt_creds_step().
2569
6976
 *
2570
 
 * @param[in]  context  A krb5 library context (see krb5_init_context())
2571
 
 * @param[in]  ctx      A TGS acquisition context (see krb5_tkt_creds_init())
2572
 
 * @param[out] times    Ticket times for the acquired credentials
 
6977
 * @retval 0  Success; otherwise - Kerberos error codes
2573
6978
 */
2574
6979
krb5_error_code KRB5_CALLCONV
2575
6980
krb5_tkt_creds_get_times(krb5_context context, krb5_tkt_creds_context ctx,
2576
6981
                         krb5_ticket_times *times);
2577
6982
 
 
6983
/**
 
6984
 * Get initial credentials using a key table.
 
6985
 *
 
6986
 * @param [in]  context         Library context
 
6987
 * @param [out] creds           New credentials
 
6988
 * @param [in]  client          Client principal
 
6989
 * @param [in]  arg_keytab      Key table handle
 
6990
 * @param [in]  start_time      Time when ticket becomes valid (0 for now)
 
6991
 * @param [in]  in_tkt_service  Service name of initial credentials (or NLUL)
 
6992
 * @param [in]  k5_gic_options  Initial credential options
 
6993
 *
 
6994
 * This function requests KDC for an initial credentials for @a client using a
 
6995
 * client key stored in @a arg_keytab.  If @a in_tkt_service is specified, it
 
6996
 * is parsed as a principal name (with the realm ignored) and used as the
 
6997
 * service principal for the request; otherwise the ticket-granting service is
 
6998
 * used.
 
6999
 *
 
7000
 * @sa krb5_verify_init_creds()
 
7001
 *
 
7002
 * @retval
 
7003
 * 0 Success
 
7004
 * @return
 
7005
 * Kerberos error codes
 
7006
 */
2578
7007
krb5_error_code KRB5_CALLCONV
2579
7008
krb5_get_init_creds_keytab(krb5_context context, krb5_creds *creds,
2580
7009
                           krb5_principal client, krb5_keytab arg_keytab,
2583
7012
 
2584
7013
typedef struct _krb5_verify_init_creds_opt {
2585
7014
    krb5_flags flags;
2586
 
    int ap_req_nofail;
 
7015
    int ap_req_nofail; /**< boolean */
2587
7016
} krb5_verify_init_creds_opt;
2588
7017
 
2589
7018
#define KRB5_VERIFY_INIT_CREDS_OPT_AP_REQ_NOFAIL        0x0001
2590
7019
 
 
7020
/**
 
7021
 * Initialize a credential verification options structure.
 
7022
 *
 
7023
 * @param [in] k5_vic_options   Verification options structure
 
7024
 */
2591
7025
void KRB5_CALLCONV
2592
7026
krb5_verify_init_creds_opt_init(krb5_verify_init_creds_opt *k5_vic_options);
2593
7027
 
 
7028
/**
 
7029
 * Set whether credential verification is required.
 
7030
 *
 
7031
 * @param [in] k5_vic_options   Verification options structure
 
7032
 * @param [in] ap_req_nofail    Whether to require successful verification
 
7033
 *
 
7034
 * This function determines how krb5_verify_init_creds() behaves if no keytab
 
7035
 * information is available.  If @a ap_req_nofail is @c FALSE, verification
 
7036
 * will be skipped in this case and krb5_verify_init_creds() will return
 
7037
 * successfully.  If @a ap_req_nofail is @c TRUE, krb5_verify_init_creds() will
 
7038
 * not return successfully unless verification can be performed.
 
7039
 *
 
7040
 * If this function is not used, the behavior of krb5_verify_init_creds() is
 
7041
 * determined through configuration.
 
7042
 */
2594
7043
void KRB5_CALLCONV
2595
 
krb5_verify_init_creds_opt_set_ap_req_nofail(krb5_verify_init_creds_opt *
2596
 
                                             k5_vic_options,
 
7044
krb5_verify_init_creds_opt_set_ap_req_nofail(krb5_verify_init_creds_opt * k5_vic_options,
2597
7045
                                             int ap_req_nofail);
2598
7046
 
 
7047
/**
 
7048
 * Verify initial credentials against a keytab.
 
7049
 *
 
7050
 * @param [in]     context      Library context
 
7051
 * @param [in]     creds        Initial credentials to be verified
 
7052
 * @param [in]     server_arg   Server principal (or NULL)
 
7053
 * @param [in]     keytab_arg   Key table (NULL to use default keytab)
 
7054
 * @param [in,out] ccache_arg   Credential cache for fetched creds (or NULL)
 
7055
 * @param [in]     options      Verification options (NULL for default options)
 
7056
 *
 
7057
 * This function attempts to verify that @a creds were obtained from a KDC with
 
7058
 * knowledge of a key in @a keytab_arg.  If @a server_arg is provided, the
 
7059
 * highest-kvno key entry for that principal name is used to verify the
 
7060
 * credentials; otherwise, the highest-kvno key entry for the first principal
 
7061
 * listed in @a keytab_arg is used.
 
7062
 *
 
7063
 * If the specified keytab does not exist, or is empty, or cannot be read, or
 
7064
 * does not contain an entry for @a server_arg, then credential verification
 
7065
 * may be skipped unless configuration demands that it succeed.  The caller can
 
7066
 * control this behavior by providing a verification options structure; see
 
7067
 * krb5_verify_init_creds_opt_init() and
 
7068
 * krb5_verify_init_creds_opt_set_ap_req_nofail().
 
7069
 *
 
7070
 * If @a ccache_arg is NULL, any additional credentials fetched during the
 
7071
 * verification process will be destroyed.  If @a ccache_arg points to NULL, a
 
7072
 * memory ccache will be created for the additional credentials and returned in
 
7073
 * @a ccache_arg.  If @a ccache_arg points to a valid credential cache handle,
 
7074
 * the additional credentials will be stored in that cache.
 
7075
 *
 
7076
 * @retval 0  Success; otherwise - Kerberos error codes
 
7077
 */
2599
7078
krb5_error_code KRB5_CALLCONV
2600
7079
krb5_verify_init_creds(krb5_context context, krb5_creds *creds,
2601
 
                       krb5_principal ap_req_server, krb5_keytab ap_req_keytab,
2602
 
                       krb5_ccache *ccache,
2603
 
                       krb5_verify_init_creds_opt *k5_vic_options);
 
7080
                       krb5_principal server_arg, krb5_keytab keytab_arg,
 
7081
                       krb5_ccache *ccache_arg, krb5_verify_init_creds_opt *options);
2604
7082
 
 
7083
/**
 
7084
 * Get validated credentials from the KDC.
 
7085
 *
 
7086
 * @param [in]  context         Library context
 
7087
 * @param [out] creds           Validated credentials
 
7088
 * @param [in]  client          Client principal name
 
7089
 * @param [in]  ccache          Credential cache
 
7090
 * @param [in]  in_tkt_service  Server principal string (or NULL)
 
7091
 *
 
7092
 * This function gets a validated credential using a postdated credential from
 
7093
 * @a ccache.  If @a in_tkt_service is specified, it is parsed (with the realm
 
7094
 * part ignored) and used as the server principal of the credential;
 
7095
 * otherwise, the ticket-granting service is used.
 
7096
 *
 
7097
 * If successful, the validated credential is placed in @a creds.
 
7098
 *
 
7099
 * @sa krb5_get_renewed_creds()
 
7100
 *
 
7101
 * @retval
 
7102
 * 0 Success
 
7103
 * @retval
 
7104
 * KRB5_NO_2ND_TKT Request missing second ticket
 
7105
 * @retval
 
7106
 * KRB5_NO_TKT_SUPPLIED Request did not supply a ticket
 
7107
 * @retval
 
7108
 * KRB5_PRINC_NOMATCH Requested principal and ticket do not match
 
7109
 * @retval
 
7110
 * KRB5_KDCREP_MODIFIED KDC reply did not match expectations
 
7111
 * @retval
 
7112
 * KRB5_KDCREP_SKEW Clock skew too great in KDC reply
 
7113
 * @return
 
7114
 * Kerberos error codes
 
7115
 */
2605
7116
krb5_error_code KRB5_CALLCONV
2606
7117
krb5_get_validated_creds(krb5_context context, krb5_creds *creds,
2607
7118
                         krb5_principal client, krb5_ccache ccache,
2608
7119
                         char *in_tkt_service);
2609
7120
 
 
7121
/**
 
7122
 * Get renewed credential from KDC using an existing credential.
 
7123
 *
 
7124
 * @param [in]  context         Library context
 
7125
 * @param [out] creds           Renewed credentials
 
7126
 * @param [in]  client          Client principal name
 
7127
 * @param [in]  ccache          Credential cache
 
7128
 * @param [in]  in_tkt_service  Server principal string (or NULL)
 
7129
 *
 
7130
 * This function gets a renewed credential using an existing one from @a
 
7131
 * ccache.  If @a in_tkt_service is specified, it is parsed (with the realm
 
7132
 * part ignored) and used as the server principal of the credential; otherwise,
 
7133
 * the ticket-granting service is used.
 
7134
 *
 
7135
 * If successful, the renewed credential is placed in @a creds.
 
7136
 *
 
7137
 * @retval
 
7138
 * 0 Success
 
7139
 * @return
 
7140
 * Kerberos error codes
 
7141
 */
2610
7142
krb5_error_code KRB5_CALLCONV
2611
7143
krb5_get_renewed_creds(krb5_context context, krb5_creds *creds,
2612
7144
                       krb5_principal client, krb5_ccache ccache,
2613
7145
                       char *in_tkt_service);
2614
7146
 
 
7147
/**
 
7148
 * Decode an ASN.1-formatted ticket.
 
7149
 *
 
7150
 * @param [in]  code            ASN.1-formatted ticket
 
7151
 * @param [out] rep             Decoded ticket information
 
7152
 *
 
7153
 * @retval 0  Success; otherwise - Kerberos error codes
 
7154
 */
2615
7155
krb5_error_code KRB5_CALLCONV
2616
7156
krb5_decode_ticket(const krb5_data *code, krb5_ticket **rep);
2617
7157
 
 
7158
/**
 
7159
 * Retrieve a string value from the appdefaults section of krb5.conf.
 
7160
 *
 
7161
 * @param [in]  context         Library context
 
7162
 * @param [in]  appname         Application name
 
7163
 * @param [in]  realm           Realm name
 
7164
 * @param [in]  option          Option to be checked
 
7165
 * @param [in]  default_value   Default value to return if no match is found
 
7166
 * @param [out] ret_value       String value of @a option
 
7167
 *
 
7168
 * This function gets the application defaults for @a option based on the given
 
7169
 * @a appname and/or @a realm.
 
7170
 *
 
7171
 * @sa krb5_appdefault_boolean()
 
7172
 */
2618
7173
void KRB5_CALLCONV
2619
7174
krb5_appdefault_string(krb5_context context, const char *appname,
2620
7175
                       const krb5_data *realm, const char *option,
2621
7176
                       const char *default_value, char ** ret_value);
2622
7177
 
 
7178
/**
 
7179
 * Retrieve a boolean value from the appdefaults section of krb5.conf.
 
7180
 *
 
7181
 * @param [in]  context         Library context
 
7182
 * @param [in]  appname         Application name
 
7183
 * @param [in]  realm           Realm name
 
7184
 * @param [in]  option          Option to be checked
 
7185
 * @param [in]  default_value   Default value to return if no match is found
 
7186
 * @param [out] ret_value       Boolean value of @a option
 
7187
 *
 
7188
 * This function gets the application defaults for @a option based on the given
 
7189
 * @a appname and/or @a realm.
 
7190
 *
 
7191
 * @sa krb5_appdefault_string()
 
7192
 */
2623
7193
void KRB5_CALLCONV
2624
7194
krb5_appdefault_boolean(krb5_context context, const char *appname,
2625
7195
                        const krb5_data *realm, const char *option,
2628
7198
/*
2629
7199
 * Prompter enhancements
2630
7200
 */
2631
 
 
2632
7201
#define KRB5_PROMPT_TYPE_PASSWORD            0x1
2633
7202
#define KRB5_PROMPT_TYPE_NEW_PASSWORD        0x2
2634
7203
#define KRB5_PROMPT_TYPE_NEW_PASSWORD_AGAIN  0x3
2636
7205
 
2637
7206
typedef krb5_int32 krb5_prompt_type;
2638
7207
 
2639
 
krb5_prompt_type* KRB5_CALLCONV krb5_get_prompt_types(krb5_context context);
 
7208
/**
 
7209
 * Get prompt types array from a context.
 
7210
 *
 
7211
 * @param [in] context          Library context
 
7212
 *
 
7213
 * @return
 
7214
 * Pointer to an array of prompt types corresponding to the prompter's @a
 
7215
 * prompts arguments.  Each type has one of the following values:
 
7216
 *  @li #KRB5_PROMPT_TYPE_PASSWORD
 
7217
 *  @li #KRB5_PROMPT_TYPE_NEW_PASSWORD
 
7218
 *  @li #KRB5_PROMPT_TYPE_NEW_PASSWORD_AGAIN
 
7219
 *  @li #KRB5_PROMPT_TYPE_PREAUTH
 
7220
 */
 
7221
krb5_prompt_type* KRB5_CALLCONV
 
7222
krb5_get_prompt_types(krb5_context context);
2640
7223
 
2641
7224
/* Error reporting */
 
7225
/**
 
7226
 * Set an extended error message for an error code.
 
7227
 *
 
7228
 * @param [in] ctx              Library context
 
7229
 * @param [in] code             Error code
 
7230
 * @param [in] fmt              Error string for the error code
 
7231
 * @param [in] ...              printf(3) style parameters
 
7232
 */
2642
7233
void KRB5_CALLCONV_C
2643
 
krb5_set_error_message(krb5_context, krb5_error_code, const char *, ...)
 
7234
krb5_set_error_message(krb5_context ctx, krb5_error_code code, const char *fmt, ...)
2644
7235
#if !defined(__cplusplus) && (__GNUC__ > 2)
2645
7236
    __attribute__((__format__(__printf__, 3, 4)))
2646
7237
#endif
2647
7238
    ;
 
7239
 
 
7240
/**
 
7241
 * Set an extended error message for an error code using a va_list.
 
7242
 *
 
7243
 * @param [in] ctx              Library context
 
7244
 * @param [in] code             Error code
 
7245
 * @param [in] fmt              Error string for the error code
 
7246
 * @param [in] args             List of vprintf(3) style arguments
 
7247
 */
2648
7248
void KRB5_CALLCONV
2649
 
krb5_vset_error_message(krb5_context, krb5_error_code, const char *, va_list)
 
7249
krb5_vset_error_message(krb5_context  ctx, krb5_error_code code,
 
7250
                        const char *fmt, va_list args)
2650
7251
#if !defined(__cplusplus) && (__GNUC__ > 2)
2651
7252
    __attribute__((__format__(__printf__, 3, 0)))
2652
7253
#endif
2653
7254
    ;
 
7255
 
 
7256
/**
 
7257
 * Copy the most recent extended error message from one context to another.
 
7258
 *
 
7259
 * @param [in] dest_ctx         Library context to copy message to
 
7260
 * @param [in] src_ctx          Library context with current message
 
7261
 */
2654
7262
void KRB5_CALLCONV
2655
 
krb5_copy_error_message(krb5_context, krb5_context);
 
7263
krb5_copy_error_message(krb5_context dest_ctx, krb5_context src_ctx);
2656
7264
 
2657
 
/*
2658
 
 * The behavior of krb5_get_error_message is only defined the first
2659
 
 * time it is called after a failed call to a krb5 function using the
2660
 
 * same context, and only when the error code passed in is the same as
2661
 
 * that returned by the krb5 function.  Future versions may return the
2662
 
 * same string for the second and following calls.  This function never
2663
 
 * returns NULL, so its result may be used unconditionally as a C
2664
 
 * string.
 
7265
/**
 
7266
 * Get the (possibly extended) error message for a code.
 
7267
 *
 
7268
 * @param [in] ctx              Library context
 
7269
 * @param [in] code             Error code
 
7270
 *
 
7271
 * The behavior of krb5_get_error_message() is only defined the first time it
 
7272
 * is called after a failed call to a krb5 function using the same context, and
 
7273
 * only when the error code passed in is the same as that returned by the krb5
 
7274
 * function.
 
7275
 *
 
7276
 * This function never returns NULL, so its result may be used unconditionally
 
7277
 * as a C string.
2665
7278
 *
2666
7279
 * The string returned by this function must be freed using
2667
 
 * krb5_free_error_message.
 
7280
 * krb5_free_error_message()
 
7281
 *
 
7282
 * @note Future versions may return the same string for the second
 
7283
 * and following calls.
2668
7284
 */
2669
7285
const char * KRB5_CALLCONV
2670
 
krb5_get_error_message(krb5_context, krb5_error_code);
2671
 
void KRB5_CALLCONV
2672
 
krb5_free_error_message(krb5_context, const char *);
2673
 
void KRB5_CALLCONV
2674
 
krb5_clear_error_message(krb5_context);
2675
 
 
 
7286
krb5_get_error_message(krb5_context ctx, krb5_error_code code);
 
7287
 
 
7288
/**
 
7289
 * Free an error message generated by krb5_get_error_message().
 
7290
 *
 
7291
 * @param [in] ctx              Library context
 
7292
 * @param [in] msg              Pointer to error message
 
7293
 */
 
7294
void KRB5_CALLCONV
 
7295
krb5_free_error_message(krb5_context ctx, const char *msg);
 
7296
 
 
7297
/**
 
7298
 * Clear the extended error message in a context.
 
7299
 *
 
7300
 * @param [in] ctx              Library context
 
7301
 *
 
7302
 * This function unsets the extended error message in a context, to ensure that
 
7303
 * it is not mistakenly applied to another occurrence of the same error code.
 
7304
 */
 
7305
void KRB5_CALLCONV
 
7306
krb5_clear_error_message(krb5_context ctx);
 
7307
 
 
7308
/**
 
7309
 * Unwrap authorization data.
 
7310
 *
 
7311
 * @param [in]  context         Library context
 
7312
 * @param [in]  type            @ref KRB5_AUTHDATA type of @a container
 
7313
 * @param [in]  container       Authorization data to be decoded
 
7314
 * @param [out] authdata        List of decoded authorization data
 
7315
 *
 
7316
 * @sa krb5_encode_authdata_container()
 
7317
 *
 
7318
 * @retval 0 Success; otherwise - Kerberos error codes
 
7319
 */
2676
7320
krb5_error_code KRB5_CALLCONV
2677
7321
krb5_decode_authdata_container(krb5_context context,
2678
7322
                               krb5_authdatatype type,
2679
7323
                               const krb5_authdata *container,
2680
7324
                               krb5_authdata ***authdata);
2681
 
 
 
7325
/**
 
7326
 * Wrap authorization data in a container.
 
7327
 *
 
7328
 * @param [in]  context         Library context
 
7329
 * @param [in]  type            @ref KRB5_AUTHDATA type of @a container
 
7330
 * @param [in]  authdata        List of authorization data to be encoded
 
7331
 * @param [out] container       List of encoded authorization data
 
7332
 *
 
7333
 * The result is returned in @a container as a single-element list.
 
7334
 *
 
7335
 * @sa krb5_decode_authdata_container()
 
7336
 *
 
7337
 * @retval 0 Success; otherwise - Kerberos error codes
 
7338
 */
2682
7339
krb5_error_code KRB5_CALLCONV
2683
7340
krb5_encode_authdata_container(krb5_context context,
2684
7341
                               krb5_authdatatype type,
2688
7345
/*
2689
7346
 * AD-KDCIssued
2690
7347
 */
 
7348
/**
 
7349
 * Encode and sign AD-KDCIssued authorization data.
 
7350
 *
 
7351
 * @param [in]  context         Library context
 
7352
 * @param [in]  key             Session key
 
7353
 * @param [in]  issuer          The name of the issuing principal
 
7354
 * @param [in]  authdata        List of authorization data to be signed
 
7355
 * @param [out] ad_kdcissued    List containing AD-KDCIssued authdata
 
7356
 *
 
7357
 * This function wraps a list of authorization data entries @a authdata in an
 
7358
 * AD-KDCIssued container (see RFC 4120 section 5.2.6.2) signed with @a key.
 
7359
 * The result is returned in @a ad_kdcissued as a single-element list.
 
7360
 */
2691
7361
krb5_error_code KRB5_CALLCONV
2692
7362
krb5_make_authdata_kdc_issued(krb5_context context,
2693
7363
                              const krb5_keyblock *key,
2695
7365
                              krb5_authdata *const *authdata,
2696
7366
                              krb5_authdata ***ad_kdcissued);
2697
7367
 
 
7368
/**
 
7369
 * Unwrap and verify AD-KDCIssued authorization data.
 
7370
 *
 
7371
 * @param [in] context          Library context
 
7372
 * @param [in] key              Session key
 
7373
 * @param [in] ad_kdcissued     AD-KDCIssued authorization data to be unwrapped
 
7374
 * @param [out] issuer          Name of issuing principal (or NULL)
 
7375
 * @param [out] authdata        Unwrapped list of authorization data
 
7376
 *
 
7377
 * This function unwraps an AD-KDCIssued authdatum (see RFC 4120 section
 
7378
 * 5.2.6.2) and verifies its signature against @a key.  The issuer field of the
 
7379
 * authdatum element is returned in @a issuer, and the unwrapped list of
 
7380
 * authdata is returned in @a authdata.
 
7381
 */
2698
7382
krb5_error_code KRB5_CALLCONV
2699
7383
krb5_verify_authdata_kdc_issued(krb5_context context,
2700
7384
                                const krb5_keyblock *key,
2705
7389
/*
2706
7390
 * Windows PAC
2707
7391
 */
 
7392
 
 
7393
/* Microsoft defined types of data */
 
7394
#define KRB5_PAC_LOGON_INFO        1  /**< Logon information */
 
7395
#define KRB5_PAC_CREDENTIALS_INFO  2  /**< Credentials information */
 
7396
#define KRB5_PAC_SERVER_CHECKSUM   6  /**< Server checksum */
 
7397
#define KRB5_PAC_PRIVSVR_CHECKSUM  7  /**< KDC checksum */
 
7398
#define KRB5_PAC_CLIENT_INFO       10 /**< Client name and ticket info */
 
7399
#define KRB5_PAC_DELEGATION_INFO   11 /**< Constrained delegation info */
 
7400
#define KRB5_PAC_UPN_DNS_INFO      12 /**< User principal name and DNS info */
 
7401
 
2708
7402
struct krb5_pac_data;
 
7403
/** PAC data structure to convey authorization information */
2709
7404
typedef struct krb5_pac_data *krb5_pac;
2710
7405
 
 
7406
/**
 
7407
 * Add a buffer to a PAC handle.
 
7408
 *
 
7409
 * @param [in] context          Library context
 
7410
 * @param [in] pac              PAC handle
 
7411
 * @param [in] type             Buffer type
 
7412
 * @param [in] data             contents
 
7413
 *
 
7414
 * This function adds a buffer of type @a type and contents @a data to @a pac
 
7415
 * if there isn't already a buffer of this type present.
 
7416
 *
 
7417
 * The valid values of @a type is one of the following:
 
7418
 * @li #PAC_LOGON_INFO         -  Logon information
 
7419
 * @li #PAC_CREDENTIALS_INFO   -  Credentials information
 
7420
 * @li #PAC_SERVER_CHECKSUM    -  Server checksum
 
7421
 * @li #PAC_PRIVSVR_CHECKSUM   -  KDC checksum
 
7422
 * @li #PAC_CLIENT_INFO        -  Client name and ticket information
 
7423
 * @li #PAC_DELEGATION_INFO    -  Constrained delegation information
 
7424
 * @li #PAC_UPN_DNS_INFO       -  User principal name and DNS information
 
7425
 *
 
7426
 * @retval 0 Success; otherwise - Kerberos error codes
 
7427
 */
2711
7428
krb5_error_code KRB5_CALLCONV
2712
7429
krb5_pac_add_buffer(krb5_context context, krb5_pac pac, krb5_ui_4 type,
2713
7430
                    const krb5_data *data);
2714
7431
 
 
7432
/**
 
7433
 * Free a PAC handle.
 
7434
 *
 
7435
 * @param [in] context         Library context
 
7436
 * @param [in] pac             PAC to be freed
 
7437
 *
 
7438
 * This function frees the contents of @a pac and the structure itself.
 
7439
 */
2715
7440
void KRB5_CALLCONV
2716
7441
krb5_pac_free(krb5_context context, krb5_pac pac);
2717
7442
 
 
7443
/**
 
7444
 * Retrieve a buffer value from a PAC.
 
7445
 *
 
7446
 * @param [in]  context         Library context
 
7447
 * @param [in]  pac             PAC handle
 
7448
 * @param [in]  type            Type of buffer to retrieve
 
7449
 * @param [out] data            Buffer value
 
7450
 *
 
7451
 * Use krb5_free_data_contents() to free @a data when it is no longer needed.
 
7452
 *
 
7453
 * @retval 0 Success; otherwise - Kerberos error codes
 
7454
 */
2718
7455
krb5_error_code KRB5_CALLCONV
2719
7456
krb5_pac_get_buffer(krb5_context context, krb5_pac pac, krb5_ui_4 type,
2720
7457
                    krb5_data *data);
2721
7458
 
 
7459
/**
 
7460
 * Return an array of buffer types in a PAC handle.
 
7461
 *
 
7462
 * @param [in]  context         Library context
 
7463
 * @param [in]  pac             PAC handle
 
7464
 * @param [out] len             Number of entries in @a types
 
7465
 * @param [out] types           Array of buffer types
 
7466
 *
 
7467
 * @retval 0 Success; otherwise - Kerberos error codes
 
7468
 */
2722
7469
krb5_error_code KRB5_CALLCONV
2723
7470
krb5_pac_get_types(krb5_context context, krb5_pac pac, size_t *len,
2724
7471
                   krb5_ui_4 **types);
2725
7472
 
 
7473
/**
 
7474
 * Create an empty Privilege Attribute Certificate (PAC) handle.
 
7475
 *
 
7476
 * @param [in]  context         Library context
 
7477
 * @param [out] pac             New PAC handle
 
7478
 *
 
7479
 * Use krb5_pac_free() to free @a pac when it is no longer needed.
 
7480
 *
 
7481
 * @retval 0 Success; otherwise - Kerberos error codes
 
7482
 */
2726
7483
krb5_error_code KRB5_CALLCONV
2727
7484
krb5_pac_init(krb5_context context, krb5_pac *pac);
2728
7485
 
 
7486
/**
 
7487
 * Unparse an encoded PAC into a new handle.
 
7488
 *
 
7489
 * @param [in]  context         Library context
 
7490
 * @param [in]  ptr             PAC buffer
 
7491
 * @param [in]  len             Length of @a ptr
 
7492
 * @param [out] pac             PAC handle
 
7493
 *
 
7494
 * Use krb5_pac_free() to free @a pac when it is no longer needed.
 
7495
 *
 
7496
 * @retval 0 Success; otherwise - Kerberos error codes
 
7497
 */
2729
7498
krb5_error_code KRB5_CALLCONV
2730
7499
krb5_pac_parse(krb5_context context, const void *ptr, size_t len,
2731
7500
               krb5_pac *pac);
2732
7501
 
 
7502
/**
 
7503
 * Verify a PAC.
 
7504
 *
 
7505
 * @param [in] context          Library context
 
7506
 * @param [in] pac              PAC handle
 
7507
 * @param [in] authtime         Expected timestamp
 
7508
 * @param [in] principal        Expected principal name (or NULL)
 
7509
 * @param [in] server           Key to validate server checksum
 
7510
 * @param [in] privsvr          Key to validate KDC checksum (or NULL)
 
7511
 *
 
7512
 * This function validates @a pac against the supplied @a server, @a privsvr,
 
7513
 * @a principal and @a authtime.  If @a principal is NULL, the principal and
 
7514
 * authtime are not verified.  If @a privsvr is NULL, the KDC checksum is not
 
7515
 * verified.
 
7516
 *
 
7517
 * If successful, @a pac is marked as verified.
 
7518
 *
 
7519
 * @note A checksum mismatch can occur if the PAC was copied from a cross-realm
 
7520
 * TGT by an ignorant KDC; also Apple Mac OS X Server Open Directory (as of
 
7521
 * 10.6) generates PACs with no server checksum at all.  One should consider
 
7522
 * not failing the whole authentication because of this reason, but, instead,
 
7523
 * treating the ticket as if it did not contain a PAC or marking the PAC
 
7524
 * information as non-verified.
 
7525
 *
 
7526
 * @retval 0 Success; otherwise - Kerberos error codes
 
7527
 */
2733
7528
krb5_error_code KRB5_CALLCONV
2734
7529
krb5_pac_verify(krb5_context context, const krb5_pac pac,
2735
7530
                krb5_timestamp authtime, krb5_const_principal principal,
2736
7531
                const krb5_keyblock *server, const krb5_keyblock *privsvr);
2737
7532
 
2738
 
/* Allows the appplication to override the profile's allow_weak_crypto setting.
2739
 
 * Primarily for use by aklog. */
 
7533
/**
 
7534
 * Sign a PAC.
 
7535
 *
 
7536
 * @param [in]  context         Library context
 
7537
 * @param [in]  pac             PAC handle
 
7538
 * @param [in]  authtime        Expected timestamp
 
7539
 * @param [in]  principal       Expected principal name (or NULL)
 
7540
 * @param [in]  server_key      Key for server checksum
 
7541
 * @param [in]  privsvr_key     Key for KDC checksum
 
7542
 * @param [out] data            Signed PAC encoding
 
7543
 *
 
7544
 * This function signs @a pac using the keys @a server_key and @a privsvr_key
 
7545
 * and returns the signed encoding in @a data.  @a pac is modified to include
 
7546
 * the server and KDC checksum buffers.  Use krb5_free_data_contents() to free
 
7547
 * @a data when it is no longer needed.
 
7548
 */
 
7549
krb5_error_code KRB5_CALLCONV
 
7550
krb5_pac_sign(krb5_context context, krb5_pac pac, krb5_timestamp authtime,
 
7551
              krb5_const_principal principal, const krb5_keyblock *server_key,
 
7552
              const krb5_keyblock *privsvr_key, krb5_data *data);
 
7553
 
 
7554
/**
 
7555
 * Allow the appplication to override the profile's allow_weak_crypto setting.
 
7556
 *
 
7557
 * @param [in] context          Library context
 
7558
 * @param [in] enable           Boolean flag
 
7559
 *
 
7560
 * This function allows an application to override the allow_weak_crypto
 
7561
 * setting.  It is primarily for use by aklog.
 
7562
 *
 
7563
 * @retval 0  (always)
 
7564
 */
2740
7565
krb5_error_code KRB5_CALLCONV
2741
7566
krb5_allow_weak_crypto(krb5_context context, krb5_boolean enable);
2742
7567
 
2751
7576
                                     void *cb_data);
2752
7577
 
2753
7578
/**
 
7579
 * Specify a callback function for trace events.
 
7580
 *
 
7581
 * @param [in] context          Library context
 
7582
 * @param [in] fn               Callback function
 
7583
 * @param [in] cb_data          Callback data
 
7584
 *
2754
7585
 * Specify a callback for trace events occurring in krb5 operations performed
2755
7586
 * within @a context.  @a fn will be invoked with @a context as the first
2756
7587
 * argument, @a cb_data as the last argument, and a pointer to a struct
2757
7588
 * krb5_trace_info as the second argument.  If the trace callback is reset via
2758
7589
 * this function or @a context is destroyed, @a fn will be invoked with a NULL
2759
 
 * second argument to allow cleanup of @a cb_data.  Supply a NULL value for @a
 
7590
 * second argument so it can clean up @a cb_data.  Supply a NULL value for @a
2760
7591
 * fn to disable trace callbacks within @a context.
2761
7592
 *
2762
 
 * Returns KRB5_TRACE_NOSUPP if tracing is not supported in the library (unless
2763
 
 * @a fn is NULL).
 
7593
 * @return Returns KRB5_TRACE_NOSUPP if tracing is not supported in the library
 
7594
 * (unless @a fn is NULL).
2764
7595
 */
2765
7596
krb5_error_code KRB5_CALLCONV
2766
7597
krb5_set_trace_callback(krb5_context context, krb5_trace_callback fn,
2767
7598
                        void *cb_data);
2768
7599
 
2769
7600
/**
 
7601
 * Specify a file name for directing trace events.
 
7602
 *
 
7603
 * @param [in] context          Library context
 
7604
 * @param [in] filename         File name
 
7605
 *
2770
7606
 * Open @a filename for appending (creating it, if necessary) and set up a
2771
 
 * callback to write trace events to it.  Returns KRB5_TRACE_NOSUPP if tracing
2772
 
 * is not supported in the library.
 
7607
 * callback to write trace events to it.
 
7608
 *
 
7609
 * @retval KRB5_TRACE_NOSUPP Tracing is not supported in the library.
2773
7610
 */
2774
7611
krb5_error_code KRB5_CALLCONV
2775
7612
krb5_set_trace_filename(krb5_context context, const char *filename);