Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
116 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source4/heimdal/lib/gssapi/gssapi/gssapi.h

    r414 r745  
    4646#ifndef BUILD_GSSAPI_LIB
    4747#if defined(_WIN32)
    48 #define GSSAPI_LIB_FUNCTION _stdcall __declspec(dllimport)
     48#define GSSAPI_LIB_FUNCTION __declspec(dllimport)
     49#define GSSAPI_LIB_CALL     __stdcall
    4950#define GSSAPI_LIB_VARIABLE __declspec(dllimport)
    5051#else
    5152#define GSSAPI_LIB_FUNCTION
     53#define GSSAPI_LIB_CALL
    5254#define GSSAPI_LIB_VARIABLE
    5355#endif
     
    7274#endif
    7375
     76#ifdef _WIN32
     77#define GSSAPI_CALLCONV __stdcall
     78#else
     79#define GSSAPI_CALLCONV
     80#endif
     81
    7482/*
    7583 * Now define the three implementation-dependent types.
     
    8391struct gss_name_t_desc_struct;
    8492typedef struct gss_name_t_desc_struct *gss_name_t;
     93typedef const struct gss_name_t_desc_struct *gss_const_name_t;
    8594
    8695struct gss_ctx_id_t_desc_struct;
    8796typedef struct gss_ctx_id_t_desc_struct *gss_ctx_id_t;
     97typedef const struct gss_ctx_id_t_desc_struct gss_const_ctx_id_t;
    8898
    8999typedef struct gss_OID_desc_struct {
     
    91101      void      *elements;
    92102} gss_OID_desc, *gss_OID;
     103typedef const gss_OID_desc * gss_const_OID;
    93104
    94105typedef struct gss_OID_set_desc_struct  {
     
    96107      gss_OID    elements;
    97108} gss_OID_set_desc, *gss_OID_set;
     109typedef const gss_OID_set_desc * gss_const_OID_set;
    98110
    99111typedef int gss_cred_usage_t;
     
    101113struct gss_cred_id_t_desc_struct;
    102114typedef struct gss_cred_id_t_desc_struct *gss_cred_id_t;
     115typedef const struct gss_cred_id_t_desc_struct *gss_const_cred_id_t;
    103116
    104117typedef struct gss_buffer_desc_struct {
     
    106119      void *value;
    107120} gss_buffer_desc, *gss_buffer_t;
     121typedef const gss_buffer_desc * gss_const_buffer_t;
    108122
    109123typedef struct gss_channel_bindings_struct {
     
    114128      gss_buffer_desc application_data;
    115129} *gss_channel_bindings_t;
     130typedef const struct gss_channel_bindings_struct *gss_const_channel_bindings_t;
    116131
    117132/* GGF extension data types */
     
    130145 */
    131146typedef OM_uint32 gss_qop_t;
     147
     148
    132149
    133150/*
     
    245262#define GSS_IOV_BUFFER_TYPE_SIGN_ONLY 11
    246263
    247 #define GSS_IOV_BUFFER_TYPE_FLAG_MASK 0xffff0000
    248 #define GSS_IOV_BUFFER_TYPE_FLAG_ALLOCATE 0x00010000
    249 #define GSS_IOV_BUFFER_TYPE_FLAG_ALLOCATED 0x00020000
     264#define GSS_IOV_BUFFER_TYPE_FLAG_MASK           0xffff0000
     265#define GSS_IOV_BUFFER_FLAG_ALLOCATE            0x00010000
     266#define GSS_IOV_BUFFER_FLAG_ALLOCATED           0x00020000
     267
     268#define GSS_IOV_BUFFER_TYPE_FLAG_ALLOCATE       0x00010000 /* old name */
     269#define GSS_IOV_BUFFER_TYPE_FLAG_ALLOCATED      0x00020000 /* old name */
    250270
    251271#define GSS_IOV_BUFFER_TYPE(_t) ((_t) & ~GSS_IOV_BUFFER_TYPE_FLAG_MASK)
     
    253273
    254274GSSAPI_CPP_START
     275
     276#include <gssapi/gssapi_oid.h>
    255277
    256278/*
     
    265287 * to that gss_OID_desc.
    266288 */
    267 extern GSSAPI_LIB_VARIABLE gss_OID GSS_C_NT_USER_NAME;
     289extern GSSAPI_LIB_VARIABLE gss_OID_desc __gss_c_nt_user_name_oid_desc;
     290#define GSS_C_NT_USER_NAME (&__gss_c_nt_user_name_oid_desc)
    268291
    269292/*
     
    278301 * initialized to point to that gss_OID_desc.
    279302 */
    280 extern GSSAPI_LIB_VARIABLE gss_OID GSS_C_NT_MACHINE_UID_NAME;
     303extern GSSAPI_LIB_VARIABLE gss_OID_desc __gss_c_nt_machine_uid_name_oid_desc;
     304#define GSS_C_NT_MACHINE_UID_NAME (&__gss_c_nt_machine_uid_name_oid_desc)
    281305
    282306/*
     
    291315 * initialized to point to that gss_OID_desc.
    292316 */
    293 extern GSSAPI_LIB_VARIABLE gss_OID GSS_C_NT_STRING_UID_NAME;
     317extern GSSAPI_LIB_VARIABLE gss_OID_desc __gss_c_nt_string_uid_name_oid_desc;
     318#define GSS_C_NT_STRING_UID_NAME (&__gss_c_nt_string_uid_name_oid_desc)
    294319
    295320/*
     
    310335 * implementations
    311336 */
    312 extern GSSAPI_LIB_VARIABLE gss_OID GSS_C_NT_HOSTBASED_SERVICE_X;
     337extern GSSAPI_LIB_VARIABLE gss_OID_desc __gss_c_nt_hostbased_service_x_oid_desc;
     338#define GSS_C_NT_HOSTBASED_SERVICE_X (&__gss_c_nt_hostbased_service_x_oid_desc)
    313339
    314340/*
     
    323349 * to point to that gss_OID_desc.
    324350 */
    325 extern GSSAPI_LIB_VARIABLE gss_OID GSS_C_NT_HOSTBASED_SERVICE;
     351extern GSSAPI_LIB_VARIABLE gss_OID_desc __gss_c_nt_hostbased_service_oid_desc;
     352#define GSS_C_NT_HOSTBASED_SERVICE (&__gss_c_nt_hostbased_service_oid_desc)
    326353
    327354/*
     
    335362 * to that gss_OID_desc.
    336363 */
    337 extern GSSAPI_LIB_VARIABLE gss_OID GSS_C_NT_ANONYMOUS;
     364extern GSSAPI_LIB_VARIABLE gss_OID_desc __gss_c_nt_anonymous_oid_desc;
     365#define GSS_C_NT_ANONYMOUS (&__gss_c_nt_anonymous_oid_desc)
    338366
    339367/*
     
    347375 * to that gss_OID_desc.
    348376 */
    349 extern GSSAPI_LIB_VARIABLE gss_OID GSS_C_NT_EXPORT_NAME;
    350 
    351 /*
    352  * Digest mechanism
    353  */
    354 
    355 extern GSSAPI_LIB_VARIABLE gss_OID GSS_SASL_DIGEST_MD5_MECHANISM;
     377extern GSSAPI_LIB_VARIABLE gss_OID_desc __gss_c_nt_export_name_oid_desc;
     378#define GSS_C_NT_EXPORT_NAME (&__gss_c_nt_export_name_oid_desc)
    356379
    357380/* Major status codes */
     
    422445#define GSS_S_DUPLICATE_ELEMENT (17ul << GSS_C_ROUTINE_ERROR_OFFSET)
    423446#define GSS_S_NAME_NOT_MN (18ul << GSS_C_ROUTINE_ERROR_OFFSET)
     447#define GSS_S_BAD_MECH_ATTR (19ul << GSS_C_ROUTINE_ERROR_OFFSET)
    424448
    425449/*
     
    436460 */
    437461
    438 OM_uint32 GSSAPI_LIB_FUNCTION gss_acquire_cred
     462GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_acquire_cred
    439463           (OM_uint32 * /*minor_status*/,
    440464            const gss_name_t /*desired_name*/,
     
    447471           );
    448472
    449 OM_uint32 GSSAPI_LIB_FUNCTION gss_release_cred
     473GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_release_cred
    450474           (OM_uint32 * /*minor_status*/,
    451475            gss_cred_id_t * /*cred_handle*/
    452476           );
    453477
    454 OM_uint32 GSSAPI_LIB_FUNCTION gss_init_sec_context
     478GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_init_sec_context
    455479           (OM_uint32 * /*minor_status*/,
    456480            const gss_cred_id_t /*initiator_cred_handle*/,
     
    468492           );
    469493
    470 OM_uint32 GSSAPI_LIB_FUNCTION gss_accept_sec_context
     494GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_accept_sec_context
    471495           (OM_uint32 * /*minor_status*/,
    472496            gss_ctx_id_t * /*context_handle*/,
     
    482506           );
    483507
    484 OM_uint32 GSSAPI_LIB_FUNCTION gss_process_context_token
     508GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_process_context_token
    485509           (OM_uint32 * /*minor_status*/,
    486510            const gss_ctx_id_t /*context_handle*/,
     
    488512           );
    489513
    490 OM_uint32 GSSAPI_LIB_FUNCTION gss_delete_sec_context
     514GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_delete_sec_context
    491515           (OM_uint32 * /*minor_status*/,
    492516            gss_ctx_id_t * /*context_handle*/,
     
    494518           );
    495519
    496 OM_uint32 GSSAPI_LIB_FUNCTION gss_context_time
     520GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_context_time
    497521           (OM_uint32 * /*minor_status*/,
    498522            const gss_ctx_id_t /*context_handle*/,
     
    500524           );
    501525
    502 OM_uint32 GSSAPI_LIB_FUNCTION gss_get_mic
     526GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_get_mic
    503527           (OM_uint32 * /*minor_status*/,
    504528            const gss_ctx_id_t /*context_handle*/,
     
    508532           );
    509533
    510 OM_uint32 GSSAPI_LIB_FUNCTION gss_verify_mic
     534GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_verify_mic
    511535           (OM_uint32 * /*minor_status*/,
    512536            const gss_ctx_id_t /*context_handle*/,
     
    516540           );
    517541
    518 OM_uint32 GSSAPI_LIB_FUNCTION gss_wrap
     542GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_wrap
    519543           (OM_uint32 * /*minor_status*/,
    520544            const gss_ctx_id_t /*context_handle*/,
     
    526550           );
    527551
    528 OM_uint32 GSSAPI_LIB_FUNCTION gss_unwrap
     552GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_unwrap
    529553           (OM_uint32 * /*minor_status*/,
    530554            const gss_ctx_id_t /*context_handle*/,
     
    535559           );
    536560
    537 OM_uint32 GSSAPI_LIB_FUNCTION gss_display_status
     561GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_display_status
    538562           (OM_uint32 * /*minor_status*/,
    539563            OM_uint32 /*status_value*/,
     
    544568           );
    545569
    546 OM_uint32 GSSAPI_LIB_FUNCTION gss_indicate_mechs
     570GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_indicate_mechs
    547571           (OM_uint32 * /*minor_status*/,
    548572            gss_OID_set * /*mech_set*/
    549573           );
    550574
    551 OM_uint32 GSSAPI_LIB_FUNCTION gss_compare_name
     575GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_compare_name
    552576           (OM_uint32 * /*minor_status*/,
    553577            const gss_name_t /*name1*/,
     
    556580           );
    557581
    558 OM_uint32 GSSAPI_LIB_FUNCTION gss_display_name
     582GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_display_name
    559583           (OM_uint32 * /*minor_status*/,
    560584            const gss_name_t /*input_name*/,
     
    563587           );
    564588
    565 OM_uint32 GSSAPI_LIB_FUNCTION gss_import_name
     589GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_import_name
    566590           (OM_uint32 * /*minor_status*/,
    567591            const gss_buffer_t /*input_name_buffer*/,
     
    570594           );
    571595
    572 OM_uint32 GSSAPI_LIB_FUNCTION gss_export_name
     596GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_export_name
    573597           (OM_uint32  * /*minor_status*/,
    574598            const gss_name_t /*input_name*/,
     
    576600           );
    577601
    578 OM_uint32 GSSAPI_LIB_FUNCTION gss_release_name
     602GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_release_name
    579603           (OM_uint32 * /*minor_status*/,
    580604            gss_name_t * /*input_name*/
    581605           );
    582606
    583 OM_uint32 GSSAPI_LIB_FUNCTION gss_release_buffer
     607GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_release_buffer
    584608           (OM_uint32 * /*minor_status*/,
    585609            gss_buffer_t /*buffer*/
    586610           );
    587611
    588 OM_uint32 GSSAPI_LIB_FUNCTION gss_release_oid_set
     612GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_release_oid_set
    589613           (OM_uint32 * /*minor_status*/,
    590614            gss_OID_set * /*set*/
    591615           );
    592616
    593 OM_uint32 GSSAPI_LIB_FUNCTION gss_inquire_cred
     617GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_inquire_cred
    594618           (OM_uint32 * /*minor_status*/,
    595619            const gss_cred_id_t /*cred_handle*/,
     
    600624           );
    601625
    602 OM_uint32 GSSAPI_LIB_FUNCTION gss_inquire_context (
     626GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_inquire_context (
    603627            OM_uint32 * /*minor_status*/,
    604628            const gss_ctx_id_t /*context_handle*/,
     
    612636           );
    613637
    614 OM_uint32 GSSAPI_LIB_FUNCTION gss_wrap_size_limit (
     638GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_wrap_size_limit (
    615639            OM_uint32 * /*minor_status*/,
    616640            const gss_ctx_id_t /*context_handle*/,
     
    621645           );
    622646
    623 OM_uint32 GSSAPI_LIB_FUNCTION gss_add_cred (
     647GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_add_cred (
    624648            OM_uint32 * /*minor_status*/,
    625649            const gss_cred_id_t /*input_cred_handle*/,
     
    635659           );
    636660
    637 OM_uint32 GSSAPI_LIB_FUNCTION gss_inquire_cred_by_mech (
     661GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_inquire_cred_by_mech (
    638662            OM_uint32 * /*minor_status*/,
    639663            const gss_cred_id_t /*cred_handle*/,
     
    645669           );
    646670
    647 OM_uint32 GSSAPI_LIB_FUNCTION gss_export_sec_context (
     671GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_export_sec_context (
    648672            OM_uint32 * /*minor_status*/,
    649673            gss_ctx_id_t * /*context_handle*/,
     
    651675           );
    652676
    653 OM_uint32 GSSAPI_LIB_FUNCTION gss_import_sec_context (
     677GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_import_sec_context (
    654678            OM_uint32 * /*minor_status*/,
    655679            const gss_buffer_t /*interprocess_token*/,
     
    657681           );
    658682
    659 OM_uint32 GSSAPI_LIB_FUNCTION gss_create_empty_oid_set (
     683GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_create_empty_oid_set (
    660684            OM_uint32 * /*minor_status*/,
    661685            gss_OID_set * /*oid_set*/
    662686           );
    663687
    664 OM_uint32 GSSAPI_LIB_FUNCTION gss_add_oid_set_member (
     688GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_add_oid_set_member (
    665689            OM_uint32 * /*minor_status*/,
    666690            const gss_OID /*member_oid*/,
     
    668692           );
    669693
    670 OM_uint32 GSSAPI_LIB_FUNCTION gss_test_oid_set_member (
     694GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_test_oid_set_member (
    671695            OM_uint32 * /*minor_status*/,
    672696            const gss_OID /*member*/,
     
    675699           );
    676700
    677 OM_uint32 GSSAPI_LIB_FUNCTION gss_inquire_names_for_mech (
     701GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_inquire_names_for_mech (
    678702            OM_uint32 * /*minor_status*/,
    679703            const gss_OID /*mechanism*/,
     
    681705           );
    682706
    683 OM_uint32 GSSAPI_LIB_FUNCTION gss_inquire_mechs_for_name (
     707GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_inquire_mechs_for_name (
    684708            OM_uint32 * /*minor_status*/,
    685709            const gss_name_t /*input_name*/,
     
    687711           );
    688712
    689 OM_uint32 GSSAPI_LIB_FUNCTION gss_canonicalize_name (
     713GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_canonicalize_name (
    690714            OM_uint32 * /*minor_status*/,
    691715            const gss_name_t /*input_name*/,
     
    694718           );
    695719
    696 OM_uint32 GSSAPI_LIB_FUNCTION gss_duplicate_name (
     720GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_duplicate_name (
    697721            OM_uint32 * /*minor_status*/,
    698722            const gss_name_t /*src_name*/,
     
    700724           );
    701725
    702 OM_uint32 GSSAPI_LIB_FUNCTION gss_duplicate_oid (
     726GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_duplicate_oid (
    703727            OM_uint32 * /* minor_status */,
    704728            gss_OID /* src_oid */,
     
    706730           );
    707731
    708 OM_uint32 GSSAPI_LIB_FUNCTION
     732GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    709733gss_release_oid
    710734        (OM_uint32 * /*minor_status*/,
     
    712736        );
    713737
    714 OM_uint32 GSSAPI_LIB_FUNCTION
     738GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    715739gss_oid_to_str(
    716740            OM_uint32 * /*minor_status*/,
     
    719743           );
    720744
    721 OM_uint32 GSSAPI_LIB_FUNCTION
     745GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    722746gss_inquire_sec_context_by_oid(
    723747            OM_uint32 * minor_status,
     
    727751           );
    728752
    729 OM_uint32 GSSAPI_LIB_FUNCTION
     753GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    730754gss_set_sec_context_option (OM_uint32 *minor_status,
    731755                            gss_ctx_id_t *context_handle,
     
    733757                            const gss_buffer_t value);
    734758
    735 OM_uint32 GSSAPI_LIB_FUNCTION
     759GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    736760gss_set_cred_option (OM_uint32 *minor_status,
    737761                     gss_cred_id_t *cred_handle,
     
    739763                     const gss_buffer_t value);
    740764
    741 int GSSAPI_LIB_FUNCTION
    742 gss_oid_equal(const gss_OID a, const gss_OID b);
    743 
    744 OM_uint32 GSSAPI_LIB_FUNCTION
     765GSSAPI_LIB_FUNCTION int GSSAPI_LIB_CALL
     766gss_oid_equal(gss_const_OID a, gss_const_OID b);
     767
     768GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    745769gss_create_empty_buffer_set
    746770           (OM_uint32 * minor_status,
    747771            gss_buffer_set_t *buffer_set);
    748772
    749 OM_uint32 GSSAPI_LIB_FUNCTION
     773GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    750774gss_add_buffer_set_member
    751775           (OM_uint32 * minor_status,
     
    753777            gss_buffer_set_t *buffer_set);
    754778
    755 OM_uint32 GSSAPI_LIB_FUNCTION
     779GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    756780gss_release_buffer_set
    757781           (OM_uint32 * minor_status,
    758782            gss_buffer_set_t *buffer_set);
    759783
    760 OM_uint32 GSSAPI_LIB_FUNCTION
     784GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    761785gss_inquire_cred_by_oid(OM_uint32 *minor_status,
    762786                        const gss_cred_id_t cred_handle,
     
    771795#define GSS_C_PRF_KEY_PARTIAL 1
    772796
    773 OM_uint32 GSSAPI_LIB_FUNCTION
     797GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    774798gss_pseudo_random
    775799        (OM_uint32 *minor_status,
     
    781805        );
    782806
    783 OM_uint32
     807GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    784808gss_store_cred(OM_uint32         * /* minor_status */,
    785809               gss_cred_id_t     /* input_cred_handle */,
     
    806830} gss_context_stream_sizes;
    807831
    808 extern gss_OID GSSAPI_LIB_VARIABLE GSS_C_ATTR_STREAM_SIZES;
    809 
    810 
    811 OM_uint32 GSSAPI_LIB_FUNCTION
     832extern gss_OID_desc GSSAPI_LIB_VARIABLE __gss_c_attr_stream_sizes_oid_desc;
     833#define GSS_C_ATTR_STREAM_SIZES (&__gss_c_attr_stream_sizes_oid_desc)
     834
     835
     836GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    812837gss_context_query_attributes(OM_uint32 * /* minor_status */,
    813                              gss_OID /* attribute */,
     838                             const gss_ctx_id_t /* context_handle */,
     839                             const gss_OID /* attribute */,
    814840                             void * /*data*/,
    815841                             size_t /* len */);
     
    825851 */
    826852
    827 OM_uint32 GSSAPI_LIB_FUNCTION GSSAPI_DEPRECATED gss_sign
     853GSSAPI_DEPRECATED GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_sign
    828854           (OM_uint32 * /*minor_status*/,
    829855            gss_ctx_id_t /*context_handle*/,
     
    833859           );
    834860
    835 OM_uint32 GSSAPI_LIB_FUNCTION GSSAPI_DEPRECATED gss_verify
     861GSSAPI_DEPRECATED GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_verify
    836862           (OM_uint32 * /*minor_status*/,
    837863            gss_ctx_id_t /*context_handle*/,
     
    841867           );
    842868
    843 OM_uint32 GSSAPI_LIB_FUNCTION GSSAPI_DEPRECATED gss_seal
     869GSSAPI_DEPRECATED GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_seal
    844870           (OM_uint32 * /*minor_status*/,
    845871            gss_ctx_id_t /*context_handle*/,
     
    851877           );
    852878
    853 OM_uint32 GSSAPI_LIB_FUNCTION GSSAPI_DEPRECATED gss_unseal
     879GSSAPI_DEPRECATED GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_unseal
    854880           (OM_uint32 * /*minor_status*/,
    855881            gss_ctx_id_t /*context_handle*/,
     
    860886           );
    861887
    862 /*
     888/**
    863889 *
    864890 */
    865891
    866 OM_uint32 GSSAPI_LIB_FUNCTION
    867 gss_encapsulate_token(gss_buffer_t /* input_token */,
    868                       gss_OID /* oid */,
     892GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
     893gss_encapsulate_token(const gss_buffer_t /* input_token */,
     894                      const gss_OID /* oid */,
    869895                      gss_buffer_t /* output_token */);
    870896
    871 OM_uint32 GSSAPI_LIB_FUNCTION
    872 gss_decapsulate_token(gss_buffer_t /* input_token */,
    873                       gss_OID /* oid */,
     897GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
     898gss_decapsulate_token(const gss_buffer_t /* input_token */,
     899                      const gss_OID /* oid */,
    874900                      gss_buffer_t /* output_token */);
    875901
     
    884910 */
    885911
    886 OM_uint32 GSSAPI_LIB_FUNCTION
     912GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    887913gss_wrap_iov(OM_uint32 *, gss_ctx_id_t, int, gss_qop_t, int *,
    888914             gss_iov_buffer_desc *, int);
    889915
    890916
    891 OM_uint32 GSSAPI_LIB_FUNCTION
     917GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    892918gss_unwrap_iov(OM_uint32 *, gss_ctx_id_t, int *, gss_qop_t *,
    893919               gss_iov_buffer_desc *, int);
    894920
    895 OM_uint32 GSSAPI_LIB_FUNCTION
     921GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    896922gss_wrap_iov_length(OM_uint32 *, gss_ctx_id_t, int, gss_qop_t, int *,
    897923                    gss_iov_buffer_desc *, int);
    898924
    899 OM_uint32 GSSAPI_LIB_FUNCTION
     925GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    900926gss_release_iov_buffer(OM_uint32 *, gss_iov_buffer_desc *, int);
    901927
    902928
    903 OM_uint32 GSSAPI_LIB_FUNCTION
     929GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    904930gss_export_cred(OM_uint32 * /* minor_status */,
    905931                gss_cred_id_t /* cred_handle */,
    906932                gss_buffer_t /* cred_token */);
    907933
    908 OM_uint32 GSSAPI_LIB_FUNCTION
     934GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    909935gss_import_cred(OM_uint32 * /* minor_status */,
    910936                gss_buffer_t /* cred_token */,
    911937                gss_cred_id_t * /* cred_handle */);
    912938
     939/*
     940 * mech option
     941 */
     942
     943GSSAPI_LIB_FUNCTION int GSSAPI_LIB_CALL
     944gss_mo_set(gss_const_OID mech, gss_const_OID option,
     945           int enable, gss_buffer_t value);
     946
     947GSSAPI_LIB_FUNCTION int GSSAPI_LIB_CALL
     948gss_mo_get(gss_const_OID mech, gss_const_OID option, gss_buffer_t value);
     949
     950GSSAPI_LIB_FUNCTION void GSSAPI_LIB_CALL
     951gss_mo_list(gss_const_OID mech, gss_OID_set *options);
     952
     953GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
     954gss_mo_name(gss_const_OID mech, gss_const_OID options, gss_buffer_t name);
     955
     956/*
     957 * SASL glue functions and mech inquire
     958 */
     959
     960GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
     961gss_inquire_saslname_for_mech(OM_uint32 *minor_status,
     962                              const gss_OID desired_mech,
     963                              gss_buffer_t sasl_mech_name,
     964                              gss_buffer_t mech_name,
     965                              gss_buffer_t mech_description);
     966
     967GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
     968gss_inquire_mech_for_saslname(OM_uint32 *minor_status,
     969                              const gss_buffer_t sasl_mech_name,
     970                              gss_OID *mech_type);
     971
     972GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
     973gss_indicate_mechs_by_attrs(OM_uint32 * minor_status,
     974                            gss_const_OID_set desired_mech_attrs,
     975                            gss_const_OID_set except_mech_attrs,
     976                            gss_const_OID_set critical_mech_attrs,
     977                            gss_OID_set *mechs);
     978
     979GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
     980gss_inquire_attrs_for_mech(OM_uint32 * minor_status,
     981                           gss_const_OID mech,
     982                           gss_OID_set *mech_attr,
     983                           gss_OID_set *known_mech_attrs);
     984
     985GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
     986gss_display_mech_attr(OM_uint32 * minor_status,
     987                      gss_const_OID mech_attr,
     988                      gss_buffer_t name,
     989                      gss_buffer_t short_desc,
     990                      gss_buffer_t long_desc);
     991
     992/*
     993 * Naming extensions
     994 */
     995
     996GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_display_name_ext (
     997    OM_uint32 *,        /* minor_status */
     998    gss_name_t,         /* name */
     999    gss_OID,            /* display_as_name_type */
     1000    gss_buffer_t        /* display_name */
     1001    );
     1002
     1003GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_inquire_name (
     1004    OM_uint32 *,        /* minor_status */
     1005    gss_name_t,         /* name */
     1006    int *,              /* name_is_MN */
     1007    gss_OID *,          /* MN_mech */
     1008    gss_buffer_set_t *  /* attrs */
     1009    );
     1010
     1011GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_get_name_attribute (
     1012    OM_uint32 *,        /* minor_status */
     1013    gss_name_t,         /* name */
     1014    gss_buffer_t,       /* attr */
     1015    int *,              /* authenticated */
     1016    int *,              /* complete */
     1017    gss_buffer_t,       /* value */
     1018    gss_buffer_t,       /* display_value */
     1019    int *               /* more */
     1020    );
     1021
     1022GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_set_name_attribute (
     1023    OM_uint32 *,        /* minor_status */
     1024    gss_name_t,         /* name */
     1025    int,                /* complete */
     1026    gss_buffer_t,       /* attr */
     1027    gss_buffer_t        /* value */
     1028    );
     1029
     1030GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_delete_name_attribute (
     1031    OM_uint32 *,        /* minor_status */
     1032    gss_name_t,         /* name */
     1033    gss_buffer_t        /* attr */
     1034    );
     1035
     1036GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_export_name_composite (
     1037    OM_uint32 *,        /* minor_status */
     1038    gss_name_t,         /* name */
     1039    gss_buffer_t        /* exp_composite_name */
     1040    );
     1041
     1042/*
     1043 *
     1044 */
     1045
     1046GSSAPI_LIB_FUNCTION const char * GSSAPI_LIB_CALL
     1047gss_oid_to_name(gss_const_OID oid);
     1048
     1049GSSAPI_LIB_FUNCTION gss_OID GSSAPI_LIB_CALL
     1050gss_name_to_oid(const char *name);
    9131051
    9141052GSSAPI_CPP_END
  • trunk/server/source4/heimdal/lib/gssapi/gssapi/gssapi_krb5.h

    r414 r745  
    5454 */
    5555
    56 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_NT_PRINCIPAL_NAME;
    57 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_NT_USER_NAME;
    58 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_NT_MACHINE_UID_NAME;
    59 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_NT_STRING_UID_NAME;
    60 
    61 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_MECHANISM;
     56extern gss_OID_desc GSSAPI_LIB_VARIABLE __gss_krb5_nt_principal_name_oid_desc;
     57#define GSS_KRB5_NT_PRINCIPAL_NAME (&__gss_krb5_nt_principal_name_oid_desc)
     58
     59#define GSS_KRB5_NT_USER_NAME (&__gss_c_nt_user_name_oid_desc)
     60#define GSS_KRB5_NT_MACHINE_UID_NAME (&__gss_c_nt_machine_uid_name_oid_desc)
     61#define GSS_KRB5_NT_STRING_UID_NAME (&__gss_c_nt_string_uid_name_oid_desc)
     62
     63extern gss_OID_desc GSSAPI_LIB_VARIABLE __gss_krb5_mechanism_oid_desc;
     64#define GSS_KRB5_MECHANISM (&__gss_krb5_mechanism_oid_desc)
    6265
    6366/* for compatibility with MIT api */
     
    6568#define gss_mech_krb5 GSS_KRB5_MECHANISM
    6669#define gss_krb5_nt_general_name GSS_KRB5_NT_PRINCIPAL_NAME
    67 
    68 /* Extensions set contexts options */
    69 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_COPY_CCACHE_X;
    70 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_COMPAT_DES3_MIC_X;
    71 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_REGISTER_ACCEPTOR_IDENTITY_X;
    72 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_SET_DNS_CANONICALIZE_X;
    73 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_SEND_TO_KDC_X;
    74 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_SET_DEFAULT_REALM_X;
    75 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_CCACHE_NAME_X;
    76 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_SET_TIME_OFFSET_X;
    77 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_GET_TIME_OFFSET_X;
    78 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_PLUGIN_REGISTER_X;
    79 /* Extensions inquire context */
    80 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_GET_TKT_FLAGS_X;
    81 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_EXTRACT_AUTHZ_DATA_FROM_SEC_CONTEXT_X;
    82 extern GSSAPI_LIB_VARIABLE gss_OID GSS_C_PEER_HAS_UPDATED_SPNEGO;
    83 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_EXPORT_LUCID_CONTEXT_X;
    84 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_EXPORT_LUCID_CONTEXT_V1_X;
    85 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_GET_SUBKEY_X;
    86 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_GET_INITIATOR_SUBKEY_X;
    87 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_GET_ACCEPTOR_SUBKEY_X;
    88 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_GET_AUTHTIME_X;
    89 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_GET_SERVICE_KEYBLOCK_X;
    90 /* Extensions creds */
    91 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_IMPORT_CRED_X;
    92 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_SET_ALLOWABLE_ENCTYPES_X;
    93 extern GSSAPI_LIB_VARIABLE gss_OID GSS_KRB5_CRED_NO_CI_FLAGS_X;
    9470
    9571/*
     
    10177struct Principal;
    10278
    103 OM_uint32 GSSAPI_LIB_FUNCTION
     79GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    10480gss_krb5_ccache_name(OM_uint32 * /*minor_status*/,
    10581                     const char * /*name */,
    10682                     const char ** /*out_name */);
    10783
    108 OM_uint32 GSSAPI_LIB_FUNCTION gsskrb5_register_acceptor_identity
    109         (const char */*identity*/);
    110 
    111 OM_uint32 GSSAPI_LIB_FUNCTION krb5_gss_register_acceptor_identity
    112         (const char */*identity*/);
    113 
    114 OM_uint32 GSSAPI_LIB_FUNCTION gss_krb5_copy_ccache
    115         (OM_uint32 */*minor*/,
     84GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gsskrb5_register_acceptor_identity
     85        (const char * /*identity*/);
     86
     87GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL krb5_gss_register_acceptor_identity
     88        (const char * /*identity*/);
     89
     90GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_krb5_copy_ccache
     91        (OM_uint32 * /*minor*/,
    11692         gss_cred_id_t /*cred*/,
    117          struct krb5_ccache_data */*out*/);
    118 
    119 OM_uint32 GSSAPI_LIB_FUNCTION
    120 gss_krb5_import_cred(OM_uint32 */*minor*/,
     93         struct krb5_ccache_data * /*out*/);
     94
     95GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
     96gss_krb5_import_cred(OM_uint32 * /*minor*/,
    12197                     struct krb5_ccache_data * /*in*/,
    12298                     struct Principal * /*keytab_principal*/,
    12399                     struct krb5_keytab_data * /*keytab*/,
    124                      gss_cred_id_t */*out*/);
    125 
    126 OM_uint32 GSSAPI_LIB_FUNCTION gss_krb5_get_tkt_flags
    127         (OM_uint32 */*minor*/,
     100                     gss_cred_id_t * /*out*/);
     101
     102GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL gss_krb5_get_tkt_flags
     103        (OM_uint32 * /*minor*/,
    128104         gss_ctx_id_t /*context_handle*/,
    129          OM_uint32 */*tkt_flags*/);
    130 
    131 OM_uint32 GSSAPI_LIB_FUNCTION
     105         OM_uint32 * /*tkt_flags*/);
     106
     107GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    132108gsskrb5_extract_authz_data_from_sec_context
    133109        (OM_uint32 * /*minor_status*/,
     
    136112         gss_buffer_t /*ad_data*/);
    137113
    138 OM_uint32 GSSAPI_LIB_FUNCTION
     114GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    139115gsskrb5_set_dns_canonicalize(int);
    140116
     
    144120};
    145121
    146 OM_uint32 GSSAPI_LIB_FUNCTION
     122GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    147123gsskrb5_set_send_to_kdc(struct gsskrb5_send_to_kdc *)
    148124    GSSKRB5_FUNCTION_DEPRECATED;
    149125
    150 OM_uint32 GSSAPI_LIB_FUNCTION
     126GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    151127gsskrb5_set_default_realm(const char *);
    152128
    153 OM_uint32 GSSAPI_LIB_FUNCTION
     129GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    154130gsskrb5_extract_authtime_from_sec_context(OM_uint32 *, gss_ctx_id_t, time_t *);
    155131
    156132struct EncryptionKey;
    157133
    158 OM_uint32 GSSAPI_LIB_FUNCTION
     134GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    159135gsskrb5_extract_service_keyblock(OM_uint32 *minor_status,
    160136                                 gss_ctx_id_t context_handle,
    161137                                 struct EncryptionKey **out);
    162 OM_uint32 GSSAPI_LIB_FUNCTION
     138GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    163139gsskrb5_get_initiator_subkey(OM_uint32 *minor_status,
    164140                                 gss_ctx_id_t context_handle,
    165141                                 struct EncryptionKey **out);
    166 OM_uint32 GSSAPI_LIB_FUNCTION
     142GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    167143gsskrb5_get_subkey(OM_uint32 *minor_status,
    168144                   gss_ctx_id_t context_handle,
    169145                   struct EncryptionKey **out);
    170146
    171 OM_uint32 GSSAPI_LIB_FUNCTION
     147GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    172148gsskrb5_set_time_offset(int);
    173149
    174 OM_uint32 GSSAPI_LIB_FUNCTION
     150GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    175151gsskrb5_get_time_offset(int *);
    176152
     
    181157};
    182158
    183 OM_uint32 GSSAPI_LIB_FUNCTION
     159GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    184160gsskrb5_plugin_register(struct gsskrb5_krb5_plugin *);
    185161
     
    227203 */
    228204
    229 OM_uint32 GSSAPI_LIB_FUNCTION
     205GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    230206gss_krb5_export_lucid_sec_context(OM_uint32 *minor_status,
    231207                                  gss_ctx_id_t *context_handle,
     
    234210
    235211
    236 OM_uint32 GSSAPI_LIB_FUNCTION
     212GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    237213gss_krb5_free_lucid_sec_context(OM_uint32 *minor_status,
    238214                                void *kctx);
    239215
    240216
    241 OM_uint32 GSSAPI_LIB_FUNCTION
     217GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    242218gss_krb5_set_allowable_enctypes(OM_uint32 *minor_status,
    243219                                gss_cred_id_t cred,
  • trunk/server/source4/heimdal/lib/gssapi/gssapi/gssapi_spnego.h

    r414 r745  
    4747 *  iso.org.dod.internet.security.mechanism.snego (1.3.6.1.5.5.2).
    4848 */
    49 extern GSSAPI_LIB_VARIABLE gss_OID GSS_SPNEGO_MECHANISM;
     49extern GSSAPI_LIB_VARIABLE gss_OID_desc __gss_spnego_mechanism_oid_desc;
     50#define GSS_SPNEGO_MECHANISM (&__gss_spnego_mechanism_oid_desc)
    5051#define gss_mech_spnego GSS_SPNEGO_MECHANISM
    5152
  • trunk/server/source4/heimdal/lib/gssapi/gssapi_mech.h

    r414 r745  
    3232#include <gssapi.h>
    3333
    34 typedef OM_uint32 _gss_acquire_cred_t
     34typedef OM_uint32 GSSAPI_CALLCONV _gss_acquire_cred_t
    3535              (OM_uint32 *,            /* minor_status */
    3636               const gss_name_t,       /* desired_name */
     
    4343              );
    4444
    45 typedef OM_uint32 _gss_release_cred_t
     45typedef OM_uint32 GSSAPI_CALLCONV _gss_release_cred_t
    4646              (OM_uint32 *,            /* minor_status */
    4747               gss_cred_id_t *         /* cred_handle */
    4848              );
    4949
    50 typedef OM_uint32 _gss_init_sec_context_t
     50typedef OM_uint32 GSSAPI_CALLCONV _gss_init_sec_context_t
    5151              (OM_uint32 *,            /* minor_status */
    5252               const gss_cred_id_t,    /* initiator_cred_handle */
     
    6565              );
    6666
    67 typedef OM_uint32 _gss_accept_sec_context_t
     67typedef OM_uint32 GSSAPI_CALLCONV _gss_accept_sec_context_t
    6868              (OM_uint32 *,            /* minor_status */
    6969               gss_ctx_id_t *,         /* context_handle */
     
    8080              );
    8181
    82 typedef OM_uint32 _gss_process_context_token_t
     82typedef OM_uint32 GSSAPI_CALLCONV _gss_process_context_token_t
    8383              (OM_uint32 *,            /* minor_status */
    8484               const gss_ctx_id_t,     /* context_handle */
     
    8686              );
    8787
    88 typedef OM_uint32 _gss_delete_sec_context_t
     88typedef OM_uint32 GSSAPI_CALLCONV _gss_delete_sec_context_t
    8989              (OM_uint32 *,            /* minor_status */
    9090               gss_ctx_id_t *,         /* context_handle */
     
    9292              );
    9393
    94 typedef OM_uint32 _gss_context_time_t
     94typedef OM_uint32 GSSAPI_CALLCONV _gss_context_time_t
    9595              (OM_uint32 *,            /* minor_status */
    9696               const gss_ctx_id_t,     /* context_handle */
     
    9898              );
    9999
    100 typedef OM_uint32 _gss_get_mic_t
     100typedef OM_uint32 GSSAPI_CALLCONV _gss_get_mic_t
    101101              (OM_uint32 *,            /* minor_status */
    102102               const gss_ctx_id_t,     /* context_handle */
     
    106106              );
    107107
    108 typedef OM_uint32 _gss_verify_mic_t
     108typedef OM_uint32 GSSAPI_CALLCONV _gss_verify_mic_t
    109109              (OM_uint32 *,            /* minor_status */
    110110               const gss_ctx_id_t,     /* context_handle */
     
    114114              );
    115115
    116 typedef OM_uint32 _gss_wrap_t
     116typedef OM_uint32 GSSAPI_CALLCONV _gss_wrap_t
    117117              (OM_uint32 *,            /* minor_status */
    118118               const gss_ctx_id_t,     /* context_handle */
     
    124124              );
    125125
    126 typedef OM_uint32 _gss_unwrap_t
     126typedef OM_uint32 GSSAPI_CALLCONV _gss_unwrap_t
    127127              (OM_uint32 *,            /* minor_status */
    128128               const gss_ctx_id_t,     /* context_handle */
     
    133133              );
    134134
    135 typedef OM_uint32 _gss_display_status_t
     135typedef OM_uint32 GSSAPI_CALLCONV _gss_display_status_t
    136136              (OM_uint32 *,            /* minor_status */
    137137               OM_uint32,              /* status_value */
     
    142142              );
    143143
    144 typedef OM_uint32 _gss_indicate_mechs_t
     144typedef OM_uint32 GSSAPI_CALLCONV _gss_indicate_mechs_t
    145145              (OM_uint32 *,            /* minor_status */
    146146               gss_OID_set *           /* mech_set */
    147147              );
    148148
    149 typedef OM_uint32 _gss_compare_name_t
     149typedef OM_uint32 GSSAPI_CALLCONV _gss_compare_name_t
    150150              (OM_uint32 *,            /* minor_status */
    151151               const gss_name_t,       /* name1 */
     
    154154              );
    155155
    156 typedef OM_uint32 _gss_display_name_t
     156typedef OM_uint32 GSSAPI_CALLCONV _gss_display_name_t
    157157              (OM_uint32 *,            /* minor_status */
    158158               const gss_name_t,       /* input_name */
     
    161161              );
    162162
    163 typedef OM_uint32 _gss_import_name_t
     163typedef OM_uint32 GSSAPI_CALLCONV _gss_import_name_t
    164164              (OM_uint32 *,            /* minor_status */
    165165               const gss_buffer_t,     /* input_name_buffer */
     
    168168              );
    169169
    170 typedef OM_uint32 _gss_export_name_t
     170typedef OM_uint32 GSSAPI_CALLCONV _gss_export_name_t
    171171              (OM_uint32 *,            /* minor_status */
    172172               const gss_name_t,       /* input_name */
     
    174174              );
    175175
    176 typedef OM_uint32 _gss_release_name_t
     176typedef OM_uint32 GSSAPI_CALLCONV _gss_release_name_t
    177177              (OM_uint32 *,            /* minor_status */
    178178               gss_name_t *            /* input_name */
    179179              );
    180180
    181 typedef OM_uint32 _gss_inquire_cred_t
     181typedef OM_uint32 GSSAPI_CALLCONV _gss_inquire_cred_t
    182182              (OM_uint32 *,            /* minor_status */
    183183               const gss_cred_id_t,    /* cred_handle */
     
    188188              );
    189189
    190 typedef OM_uint32 _gss_inquire_context_t
     190typedef OM_uint32 GSSAPI_CALLCONV _gss_inquire_context_t
    191191              (OM_uint32 *,            /* minor_status */
    192192               const gss_ctx_id_t,     /* context_handle */
     
    200200              );
    201201
    202 typedef OM_uint32 _gss_wrap_size_limit_t
     202typedef OM_uint32 GSSAPI_CALLCONV _gss_wrap_size_limit_t
    203203              (OM_uint32 *,            /* minor_status */
    204204               const gss_ctx_id_t,     /* context_handle */
     
    209209              );
    210210
    211 typedef OM_uint32 _gss_add_cred_t (
     211typedef OM_uint32 GSSAPI_CALLCONV _gss_add_cred_t (
    212212               OM_uint32 *,            /* minor_status */
    213213               const gss_cred_id_t,    /* input_cred_handle */
     
    223223              );
    224224
    225 typedef OM_uint32 _gss_inquire_cred_by_mech_t (
     225typedef OM_uint32 GSSAPI_CALLCONV _gss_inquire_cred_by_mech_t (
    226226               OM_uint32 *,            /* minor_status */
    227227               const gss_cred_id_t,    /* cred_handle */
     
    233233              );
    234234
    235 typedef OM_uint32 _gss_export_sec_context_t (
     235typedef OM_uint32 GSSAPI_CALLCONV _gss_export_sec_context_t (
    236236               OM_uint32 *,            /* minor_status */
    237237               gss_ctx_id_t *,         /* context_handle */
     
    239239              );
    240240
    241 typedef OM_uint32 _gss_import_sec_context_t (
     241typedef OM_uint32 GSSAPI_CALLCONV _gss_import_sec_context_t (
    242242               OM_uint32 *,            /* minor_status */
    243243               const gss_buffer_t,     /* interprocess_token */
     
    245245              );
    246246
    247 typedef OM_uint32 _gss_inquire_names_for_mech_t (
     247typedef OM_uint32 GSSAPI_CALLCONV _gss_inquire_names_for_mech_t (
    248248               OM_uint32 *,            /* minor_status */
    249249               const gss_OID,          /* mechanism */
     
    251251              );
    252252
    253 typedef OM_uint32 _gss_inquire_mechs_for_name_t (
     253typedef OM_uint32 GSSAPI_CALLCONV _gss_inquire_mechs_for_name_t (
    254254               OM_uint32 *,            /* minor_status */
    255255               const gss_name_t,       /* input_name */
     
    257257              );
    258258
    259 typedef OM_uint32 _gss_canonicalize_name_t (
     259typedef OM_uint32 GSSAPI_CALLCONV _gss_canonicalize_name_t (
    260260               OM_uint32 *,            /* minor_status */
    261261               const gss_name_t,       /* input_name */
     
    264264              );
    265265
    266 typedef OM_uint32 _gss_duplicate_name_t (
     266typedef OM_uint32 GSSAPI_CALLCONV _gss_duplicate_name_t (
    267267               OM_uint32 *,            /* minor_status */
    268268               const gss_name_t,       /* src_name */
     
    270270              );
    271271
    272 typedef OM_uint32 _gss_inquire_sec_context_by_oid (
     272typedef OM_uint32 GSSAPI_CALLCONV _gss_inquire_sec_context_by_oid (
    273273               OM_uint32 *minor_status,
    274274               const gss_ctx_id_t context_handle,
     
    277277              );
    278278
    279 typedef OM_uint32 _gss_inquire_cred_by_oid (
     279typedef OM_uint32 GSSAPI_CALLCONV _gss_inquire_cred_by_oid (
    280280               OM_uint32 *minor_status,
    281281               const gss_cred_id_t cred,
     
    284284              );
    285285
    286 typedef OM_uint32 _gss_set_sec_context_option (
     286typedef OM_uint32 GSSAPI_CALLCONV _gss_set_sec_context_option (
    287287               OM_uint32 *minor_status,
    288288               gss_ctx_id_t *cred_handle,
     
    291291              );
    292292
    293 typedef OM_uint32 _gss_set_cred_option (
     293typedef OM_uint32 GSSAPI_CALLCONV _gss_set_cred_option (
    294294               OM_uint32 *minor_status,
    295295               gss_cred_id_t *cred_handle,
     
    299299
    300300
    301 typedef OM_uint32 _gss_pseudo_random(
     301typedef OM_uint32 GSSAPI_CALLCONV _gss_pseudo_random(
    302302               OM_uint32 *minor_status,
    303303               gss_ctx_id_t context,
     
    308308              );
    309309
    310 typedef OM_uint32
     310typedef OM_uint32 GSSAPI_CALLCONV
    311311_gss_wrap_iov_t(OM_uint32 *minor_status,
    312312                gss_ctx_id_t  context_handle,
     
    317317                int iov_count);
    318318
    319 typedef OM_uint32
     319typedef OM_uint32 GSSAPI_CALLCONV
    320320_gss_unwrap_iov_t(OM_uint32 *minor_status,
    321321                  gss_ctx_id_t context_handle,
     
    325325                  int iov_count);
    326326
    327 typedef OM_uint32
     327typedef OM_uint32 GSSAPI_CALLCONV
    328328_gss_wrap_iov_length_t(OM_uint32 * minor_status,
    329329                       gss_ctx_id_t context_handle,
     
    334334                       int iov_count);
    335335
    336 typedef OM_uint32
     336typedef OM_uint32 GSSAPI_CALLCONV
    337337_gss_store_cred_t(OM_uint32         *minor_status,
    338338                  gss_cred_id_t     input_cred_handle,
     
    344344                  gss_cred_usage_t  *cred_usage_stored);
    345345
    346 typedef OM_uint32
     346typedef OM_uint32 GSSAPI_CALLCONV
    347347_gss_export_cred_t(OM_uint32 *minor_status,
    348348                   gss_cred_id_t cred_handle,
    349349                   gss_buffer_t cred_token);
    350350
    351 typedef OM_uint32
     351typedef OM_uint32 GSSAPI_CALLCONV
    352352_gss_import_cred_t(OM_uint32 * minor_status,
    353353                   gss_buffer_t cred_token,
     
    355355
    356356
    357 #define GMI_VERSION 2
     357typedef OM_uint32 GSSAPI_CALLCONV
     358_gss_acquire_cred_ex_t(void * /* status */,
     359                       const gss_name_t /* desired_name */,
     360                       OM_uint32 /* flags */,
     361                       OM_uint32 /* time_req */,
     362                       gss_cred_usage_t /* cred_usage */,
     363                       void * /* identity */,
     364                       void * /* ctx */,
     365                       void (* /*complete */)(void *, OM_uint32, void *, gss_cred_id_t, OM_uint32));
     366
     367typedef void GSSAPI_CALLCONV
     368_gss_iter_creds_t(OM_uint32 /* flags */,
     369                  void * /* userctx */,
     370                  void (* /*cred_iter */ )(void *, gss_OID, gss_cred_id_t));
     371
     372typedef OM_uint32 GSSAPI_CALLCONV
     373_gss_destroy_cred_t(OM_uint32 * /* minor_status */,
     374                    gss_cred_id_t * /* cred */);
     375
     376typedef OM_uint32 GSSAPI_CALLCONV
     377_gss_cred_hold_t(OM_uint32 * /* minor_status */,
     378                 gss_cred_id_t /* cred */);
     379
     380typedef OM_uint32 GSSAPI_CALLCONV
     381_gss_cred_unhold_t(OM_uint32 * /* minor_status */,
     382                   gss_cred_id_t /* cred */);
     383
     384typedef OM_uint32 GSSAPI_CALLCONV
     385_gss_cred_label_set_t(OM_uint32 * /* minor_status */,
     386                      gss_cred_id_t /* cred */,
     387                      const char * /* label */,
     388                      gss_buffer_t /* value */);
     389
     390typedef OM_uint32 GSSAPI_CALLCONV
     391_gss_cred_label_get_t(OM_uint32 * /* minor_status */,
     392                      gss_cred_id_t /* cred */,
     393                      const char * /* label */,
     394                      gss_buffer_t /* value */);
     395
     396typedef OM_uint32 GSSAPI_CALLCONV _gss_display_name_ext_t (
     397               OM_uint32 *,            /* minor_status */
     398               gss_name_t,             /* name */
     399               gss_OID,                /* display_as_name_type */
     400               gss_buffer_t            /* display_name */
     401              );
     402
     403typedef OM_uint32 GSSAPI_CALLCONV _gss_inquire_name_t (
     404               OM_uint32 *,            /* minor_status */
     405               gss_name_t,             /* name */
     406               int *,                  /* name_is_MN */
     407               gss_OID *,              /* MN_mech */
     408               gss_buffer_set_t *      /* attrs */
     409              );
     410
     411typedef OM_uint32 GSSAPI_CALLCONV _gss_get_name_attribute_t (
     412               OM_uint32 *,           /* minor_status */
     413               gss_name_t,            /* name */
     414               gss_buffer_t,          /* attr */
     415               int *,                 /* authenticated */
     416               int *,                 /* complete */
     417               gss_buffer_t,          /* value */
     418               gss_buffer_t,          /* display_value */
     419               int *                  /* more */
     420            );
     421
     422typedef OM_uint32 GSSAPI_CALLCONV _gss_set_name_attribute_t (
     423               OM_uint32 *,           /* minor_status */
     424               gss_name_t,            /* name */
     425               int,                   /* complete */
     426               gss_buffer_t,          /* attr */
     427               gss_buffer_t           /* value */
     428            );
     429
     430typedef OM_uint32 GSSAPI_CALLCONV _gss_delete_name_attribute_t (
     431               OM_uint32 *,           /* minor_status */
     432               gss_name_t,            /* name */
     433               gss_buffer_t           /* attr */
     434            );
     435
     436typedef OM_uint32 GSSAPI_CALLCONV _gss_export_name_composite_t (
     437               OM_uint32 *,           /* minor_status */
     438               gss_name_t,            /* name */
     439               gss_buffer_t           /* exp_composite_name */
     440            );
     441
     442/*
     443 *
     444 */
     445
     446typedef struct gss_mo_desc_struct gss_mo_desc;
     447
     448typedef OM_uint32 GSSAPI_CALLCONV
     449_gss_mo_init (OM_uint32 *, gss_OID, gss_mo_desc **, size_t *);
     450
     451
     452struct gss_mo_desc_struct {
     453    gss_OID option;
     454    OM_uint32 flags;
     455#define GSS_MO_MA               1
     456#define GSS_MO_MA_CRITICAL      2
     457    const char *name;
     458    void *ctx;
     459    int (*get)(gss_const_OID, gss_mo_desc *, gss_buffer_t);
     460    int (*set)(gss_const_OID, gss_mo_desc *, int, gss_buffer_t);
     461};
     462
     463
     464#define GMI_VERSION 5
     465
     466/* gm_flags */
     467#define GM_USE_MG_CRED          1       /* uses mech glue credentials */
     468
    358469
    359470typedef struct gssapi_mech_interface_desc {
     
    361472        const char                      *gm_name;
    362473        gss_OID_desc                    gm_mech_oid;
     474        unsigned                        gm_flags;
    363475        _gss_acquire_cred_t             *gm_acquire_cred;
    364476        _gss_release_cred_t             *gm_release_cred;
     
    401513        _gss_export_cred_t              *gm_export_cred;
    402514        _gss_import_cred_t              *gm_import_cred;
     515        _gss_acquire_cred_ex_t          *gm_acquire_cred_ex;
     516        _gss_iter_creds_t               *gm_iter_creds;
     517        _gss_destroy_cred_t             *gm_destroy_cred;
     518        _gss_cred_hold_t                *gm_cred_hold;
     519        _gss_cred_unhold_t              *gm_cred_unhold;
     520        _gss_cred_label_get_t           *gm_cred_label_get;
     521        _gss_cred_label_set_t           *gm_cred_label_set;
     522        gss_mo_desc                     *gm_mo;
     523        size_t                           gm_mo_num;
     524        _gss_display_name_ext_t         *gm_display_name_ext;
     525        _gss_inquire_name_t             *gm_inquire_name;
     526        _gss_get_name_attribute_t       *gm_get_name_attribute;
     527        _gss_set_name_attribute_t       *gm_set_name_attribute;
     528        _gss_delete_name_attribute_t    *gm_delete_name_attribute;
     529        _gss_export_name_composite_t    *gm_export_name_composite;
    403530} gssapi_mech_interface_desc, *gssapi_mech_interface;
    404531
    405532gssapi_mech_interface
    406 __gss_get_mechanism(gss_OID /* oid */);
     533__gss_get_mechanism(gss_const_OID /* oid */);
    407534
    408535gssapi_mech_interface __gss_spnego_initialize(void);
     
    412539void            gss_mg_collect_error(gss_OID, OM_uint32, OM_uint32);
    413540
     541int _gss_mo_get_option_1(gss_const_OID, gss_mo_desc *, gss_buffer_t);
     542int _gss_mo_get_option_0(gss_const_OID, gss_mo_desc *, gss_buffer_t);
     543int _gss_mo_get_ctx_as_string(gss_const_OID, gss_mo_desc *, gss_buffer_t);
     544
     545struct _gss_oid_name_table {
     546    gss_OID oid;
     547    const char *name;
     548    const char *short_desc;
     549    const char *long_desc;
     550};
     551
     552extern struct _gss_oid_name_table _gss_ont_mech[];
     553extern struct _gss_oid_name_table _gss_ont_ma[];
     554
    414555#endif /* GSSAPI_MECH_H */
  • trunk/server/source4/heimdal/lib/gssapi/krb5/8003.c

    r414 r745  
    7575{
    7676  u_char num[4];
    77   MD5_CTX md5;
    78 
    79   MD5_Init(&md5);
     77  EVP_MD_CTX *ctx;
     78
     79  ctx = EVP_MD_CTX_create();
     80  EVP_DigestInit_ex(ctx, EVP_md5(), NULL);
     81
    8082  _gsskrb5_encode_om_uint32 (b->initiator_addrtype, num);
    81   MD5_Update (&md5, num, sizeof(num));
     83  EVP_DigestUpdate(ctx, num, sizeof(num));
    8284  _gsskrb5_encode_om_uint32 (b->initiator_address.length, num);
    83   MD5_Update (&md5, num, sizeof(num));
     85  EVP_DigestUpdate(ctx, num, sizeof(num));
    8486  if (b->initiator_address.length)
    85     MD5_Update (&md5,
    86                 b->initiator_address.value,
    87                 b->initiator_address.length);
     87      EVP_DigestUpdate(ctx,
     88                       b->initiator_address.value,
     89                       b->initiator_address.length);
    8890  _gsskrb5_encode_om_uint32 (b->acceptor_addrtype, num);
    89   MD5_Update (&md5, num, sizeof(num));
     91  EVP_DigestUpdate(ctx, num, sizeof(num));
    9092  _gsskrb5_encode_om_uint32 (b->acceptor_address.length, num);
    91   MD5_Update (&md5, num, sizeof(num));
     93  EVP_DigestUpdate(ctx, num, sizeof(num));
    9294  if (b->acceptor_address.length)
    93     MD5_Update (&md5,
    94                 b->acceptor_address.value,
    95                 b->acceptor_address.length);
     95      EVP_DigestUpdate(ctx,
     96                       b->acceptor_address.value,
     97                       b->acceptor_address.length);
    9698  _gsskrb5_encode_om_uint32 (b->application_data.length, num);
    97   MD5_Update (&md5, num, sizeof(num));
     99  EVP_DigestUpdate(ctx, num, sizeof(num));
    98100  if (b->application_data.length)
    99     MD5_Update (&md5,
    100                 b->application_data.value,
    101                 b->application_data.length);
    102   MD5_Final (p, &md5);
     101      EVP_DigestUpdate(ctx,
     102                       b->application_data.value,
     103                       b->application_data.length);
     104  EVP_DigestFinal_ex(ctx, p, NULL);
     105  EVP_MD_CTX_destroy(ctx);
     106
    103107  return 0;
    104108}
     
    179183    static unsigned char zeros[16];
    180184
    181     if (cksum == NULL) {
    182         *minor_status = 0;
    183         return GSS_S_BAD_BINDINGS;
    184     }
    185 
    186185    /* XXX should handle checksums > 24 bytes */
    187186    if(cksum->cksumtype != CKSUMTYPE_GSSAPI || cksum->checksum.length < 24) {
     
    205204            return GSS_S_BAD_BINDINGS;
    206205        }
    207         if(memcmp(hash, p, sizeof(hash)) != 0) {
     206        if(ct_memcmp(hash, p, sizeof(hash)) != 0) {
    208207            *minor_status = 0;
    209208            return GSS_S_BAD_BINDINGS;
  • trunk/server/source4/heimdal/lib/gssapi/krb5/accept_sec_context.c

    r414 r745  
    5656        ret = krb5_kt_default(context, &_gsskrb5_keytab);
    5757    } else {
    58         char *p;
    59 
    60         asprintf(&p, "FILE:%s", identity);
    61         if(p == NULL) {
     58        char *p = NULL;
     59
     60        ret = asprintf(&p, "FILE:%s", identity);
     61        if(ret < 0 || p == NULL) {
    6262            HEIMDAL_MUTEX_unlock(&gssapi_keytab_mutex);
    6363            return GSS_S_FAILURE;
     
    100100    case ETYPE_DES_CBC_MD5:
    101101    case ETYPE_DES3_CBC_MD5:
     102    case ETYPE_OLD_DES3_CBC_SHA1:
    102103    case ETYPE_DES3_CBC_SHA1:
    103104    case ETYPE_ARCFOUR_HMAC_MD5:
     
    208209    int is_cfx = 0;
    209210
    210     krb5_auth_getremoteseqnumber (context,
    211                                   ctx->auth_context,
    212                                   &seq_number);
     211    krb5_auth_con_getremoteseqnumber (context,
     212                                      ctx->auth_context,
     213                                      &seq_number);
    213214
    214215    _gsskrb5i_is_cfx(context, ctx, 1);
     
    264265    krb5_error_code ret;
    265266    krb5_data outbuf;
     267    /* this e_data value encodes KERB_AP_ERR_TYPE_SKEW_RECOVERY which
     268       tells windows to try again with the corrected timestamp. See
     269       [MS-KILE] 2.2.1 KERB-ERROR-DATA */
     270    krb5_data e_data = { 7, rk_UNCONST("\x30\x05\xa1\x03\x02\x01\x02") };
    266271
    267272    /* build server from request if the acceptor had not selected one */
     
    286291    }
    287292
    288     ret = krb5_mk_error(context, kret, NULL, NULL, NULL,
     293    ret = krb5_mk_error(context, kret, NULL, &e_data, NULL,
    289294                        server, NULL, NULL, &outbuf);
    290295    if (ap_req_server)
     
    463468     * We need to get the flags out of the 8003 checksum.
    464469     */
     470
    465471    {
    466472        krb5_authenticator authenticator;
     
    473479            *minor_status = kret;
    474480            return ret;
     481        }
     482
     483        if (authenticator->cksum == NULL) {
     484            krb5_free_authenticator(context, &authenticator);
     485            *minor_status = 0;
     486            return GSS_S_BAD_BINDINGS;
    475487        }
    476488
     
    670682        }
    671683
    672         kret = krb5_auth_getremoteseqnumber(context,
    673                                             ctx->auth_context,
    674                                             &r_seq_number);
     684        kret = krb5_auth_con_getremoteseqnumber(context,
     685                                                ctx->auth_context,
     686                                                &r_seq_number);
    675687        if (kret) {
    676688            *minor_status = kret;
     
    750762        int32_t tmp_r_seq_number, tmp_l_seq_number;
    751763
    752         kret = krb5_auth_getremoteseqnumber(context,
    753                                             ctx->auth_context,
    754                                             &tmp_r_seq_number);
     764        kret = krb5_auth_con_getremoteseqnumber(context,
     765                                                ctx->auth_context,
     766                                                &tmp_r_seq_number);
    755767        if (kret) {
    756768            *minor_status = kret;
     
    794806
    795807
    796 OM_uint32
     808OM_uint32 GSSAPI_CALLCONV
    797809_gsskrb5_accept_sec_context(OM_uint32 * minor_status,
    798810                            gss_ctx_id_t * context_handle,
  • trunk/server/source4/heimdal/lib/gssapi/krb5/acquire_cred.c

    r414 r745  
    4141                          OM_uint32 *lifetime)
    4242{
    43     krb5_creds in_cred, *out_cred;
     43    krb5_creds in_cred, out_cred;
    4444    krb5_const_realm realm;
    4545    krb5_error_code kret;
     
    6262    }
    6363
    64     kret = krb5_get_credentials(context, 0,
    65                                 id, &in_cred, &out_cred);
     64    kret = krb5_cc_retrieve_cred(context, id, 0, &in_cred, &out_cred);
    6665    krb5_free_principal(context, in_cred.server);
    6766    if (kret) {
    68         *minor_status = kret;
    69         return GSS_S_FAILURE;
    70     }
    71 
    72     *lifetime = out_cred->times.endtime;
    73     krb5_free_creds(context, out_cred);
     67        *minor_status = 0;
     68        *lifetime = 0;
     69        return GSS_S_COMPLETE;
     70    }
     71
     72    *lifetime = out_cred.times.endtime;
     73    krb5_free_cred_contents(context, &out_cred);
    7474
    7575    return GSS_S_COMPLETE;
     
    289289}
    290290
    291 OM_uint32 _gsskrb5_acquire_cred
     291OM_uint32 GSSAPI_CALLCONV _gsskrb5_acquire_cred
    292292(OM_uint32 * minor_status,
    293293 const gss_name_t desired_name,
     
    340340    if (desired_name != GSS_C_NO_NAME) {
    341341
    342         ret = _gsskrb5_canon_name(minor_status, context, 0, NULL,
     342        ret = _gsskrb5_canon_name(minor_status, context, 1, NULL,
    343343                                  desired_name, &handle->principal);
    344344        if (ret) {
  • trunk/server/source4/heimdal/lib/gssapi/krb5/add_cred.c

    r414 r745  
    3434#include "gsskrb5_locl.h"
    3535
    36 OM_uint32 _gsskrb5_add_cred (
     36OM_uint32 GSSAPI_CALLCONV _gsskrb5_add_cred (
    3737     OM_uint32           *minor_status,
    3838     const gss_cred_id_t input_cred_handle,
     
    156156        if (cred->ccache) {
    157157            const char *type, *name;
    158             char *type_name;
     158            char *type_name = NULL;
    159159
    160160            ret = GSS_S_FAILURE;
     
    188188                }
    189189               
    190                 asprintf(&type_name, "%s:%s", type, name);
    191                 if (type_name == NULL) {
     190                kret = asprintf(&type_name, "%s:%s", type, name);
     191                if (kret < 0 || type_name == NULL) {
    192192                    *minor_status = ENOMEM;
    193193                    goto failure;
  • trunk/server/source4/heimdal/lib/gssapi/krb5/aeap.c

    r414 r745  
    3636#include <roken.h>
    3737
    38 OM_uint32 GSSAPI_LIB_FUNCTION
     38OM_uint32 GSSAPI_CALLCONV
    3939_gk_wrap_iov(OM_uint32 * minor_status,
    4040             gss_ctx_id_t  context_handle,
     
    5858}
    5959
    60 OM_uint32 GSSAPI_LIB_FUNCTION
     60OM_uint32 GSSAPI_CALLCONV
    6161_gk_unwrap_iov(OM_uint32 *minor_status,
    6262               gss_ctx_id_t context_handle,
     
    7878}
    7979
    80 OM_uint32  GSSAPI_LIB_FUNCTION
     80OM_uint32 GSSAPI_CALLCONV
    8181_gk_wrap_iov_length(OM_uint32 * minor_status,
    8282                    gss_ctx_id_t context_handle,
  • trunk/server/source4/heimdal/lib/gssapi/krb5/arcfour.c

    r414 r745  
    174174    size_t len, total_len;
    175175    u_char k6_data[16], *p0, *p;
    176     RC4_KEY rc4_key;
     176    EVP_CIPHER_CTX rc4_key;
    177177
    178178    _gsskrb5_encap_length (22, &len, &total_len, GSS_KRB5_MECHANISM);
     
    236236    memset (p + 4, (context_handle->more_flags & LOCAL) ? 0 : 0xff, 4);
    237237
    238     RC4_set_key (&rc4_key, sizeof(k6_data), k6_data);
    239     RC4 (&rc4_key, 8, p, p);
    240        
    241     memset(&rc4_key, 0, sizeof(rc4_key));
     238    EVP_CIPHER_CTX_init(&rc4_key);
     239    EVP_CipherInit_ex(&rc4_key, EVP_rc4(), NULL, k6_data, NULL, 1);
     240    EVP_Cipher(&rc4_key, p, p, 8);
     241    EVP_CIPHER_CTX_cleanup(&rc4_key);
     242
    242243    memset(k6_data, 0, sizeof(k6_data));
    243244
     
    301302    }
    302303
    303     cmp = memcmp(cksum_data, p + 8, 8);
     304    cmp = ct_memcmp(cksum_data, p + 8, 8);
    304305    if (cmp) {
    305306        *minor_status = 0;
     
    308309
    309310    {
    310         RC4_KEY rc4_key;
     311        EVP_CIPHER_CTX rc4_key;
    311312       
    312         RC4_set_key (&rc4_key, sizeof(k6_data), (void*)k6_data);
    313         RC4 (&rc4_key, 8, p, SND_SEQ);
    314        
    315         memset(&rc4_key, 0, sizeof(rc4_key));
     313        EVP_CIPHER_CTX_init(&rc4_key);
     314        EVP_CipherInit_ex(&rc4_key, EVP_rc4(), NULL, (void *)k6_data, NULL, 0);
     315        EVP_Cipher(&rc4_key, SND_SEQ, p, 8);
     316        EVP_CIPHER_CTX_cleanup(&rc4_key);
     317
    316318        memset(k6_data, 0, sizeof(k6_data));
    317319    }
     
    460462
    461463    if(conf_req_flag) {
    462         RC4_KEY rc4_key;
    463 
    464         RC4_set_key (&rc4_key, sizeof(k6_data), (void *)k6_data);
    465         /* XXX ? */
    466         RC4 (&rc4_key, 8 + datalen, p0 + 24, p0 + 24); /* Confounder + data */
    467         memset(&rc4_key, 0, sizeof(rc4_key));
     464        EVP_CIPHER_CTX rc4_key;
     465       
     466        EVP_CIPHER_CTX_init(&rc4_key);
     467        EVP_CipherInit_ex(&rc4_key, EVP_rc4(), NULL, k6_data, NULL, 1);
     468        EVP_Cipher(&rc4_key, p0 + 24, p0 + 24, 8 + datalen);
     469        EVP_CIPHER_CTX_cleanup(&rc4_key);
    468470    }
    469471    memset(k6_data, 0, sizeof(k6_data));
     
    479481
    480482    {
    481         RC4_KEY rc4_key;
     483        EVP_CIPHER_CTX rc4_key;
    482484       
    483         RC4_set_key (&rc4_key, sizeof(k6_data), k6_data);
    484         RC4 (&rc4_key, 8, p0 + 8, p0 + 8); /* SND_SEQ */
    485         memset(&rc4_key, 0, sizeof(rc4_key));
     485        EVP_CIPHER_CTX_init(&rc4_key);
     486        EVP_CipherInit_ex(&rc4_key, EVP_rc4(), NULL, k6_data, NULL, 1);
     487        EVP_Cipher(&rc4_key, p0 + 8, p0 + 8 /* SND_SEQ */, 8);
     488        EVP_CIPHER_CTX_cleanup(&rc4_key);
    486489        memset(k6_data, 0, sizeof(k6_data));
    487490    }
     
    578581
    579582    {
    580         RC4_KEY rc4_key;
     583        EVP_CIPHER_CTX rc4_key;
    581584       
    582         RC4_set_key (&rc4_key, sizeof(k6_data), k6_data);
    583         RC4 (&rc4_key, 8, p0 + 8, SND_SEQ); /* SND_SEQ */
    584         memset(&rc4_key, 0, sizeof(rc4_key));
     585        EVP_CIPHER_CTX_init(&rc4_key);
     586        EVP_CipherInit_ex(&rc4_key, EVP_rc4(), NULL, k6_data, NULL, 1);
     587        EVP_Cipher(&rc4_key, SND_SEQ, p0 + 8, 8);
     588        EVP_CIPHER_CTX_cleanup(&rc4_key);
    585589        memset(k6_data, 0, sizeof(k6_data));
    586590    }
     
    625629
    626630    if(conf_flag) {
    627         RC4_KEY rc4_key;
    628 
    629         RC4_set_key (&rc4_key, sizeof(k6_data), k6_data);
    630         RC4 (&rc4_key, 8, p0 + 24, Confounder); /* Confounder */
    631         RC4 (&rc4_key, datalen, p0 + GSS_ARCFOUR_WRAP_TOKEN_SIZE,
    632              output_message_buffer->value);
    633         memset(&rc4_key, 0, sizeof(rc4_key));
     631        EVP_CIPHER_CTX rc4_key;
     632       
     633        EVP_CIPHER_CTX_init(&rc4_key);
     634        EVP_CipherInit_ex(&rc4_key, EVP_rc4(), NULL, k6_data, NULL, 1);
     635        EVP_Cipher(&rc4_key, Confounder, p0 + 24, 8);
     636        EVP_Cipher(&rc4_key, output_message_buffer->value, p0 + GSS_ARCFOUR_WRAP_TOKEN_SIZE, datalen);
     637        EVP_CIPHER_CTX_cleanup(&rc4_key);
    634638    } else {
    635639        memcpy(Confounder, p0 + 24, 8); /* Confounder */
     
    663667    }
    664668
    665     cmp = memcmp(cksum_data, p0 + 16, 8); /* SGN_CKSUM */
     669    cmp = ct_memcmp(cksum_data, p0 + 16, 8); /* SGN_CKSUM */
    666670    if (cmp) {
    667671        _gsskrb5_release_buffer(minor_status, output_message_buffer);
  • trunk/server/source4/heimdal/lib/gssapi/krb5/canonicalize_name.c

    r414 r745  
    3434#include "gsskrb5_locl.h"
    3535
    36 OM_uint32 _gsskrb5_canonicalize_name (
     36OM_uint32 GSSAPI_CALLCONV _gsskrb5_canonicalize_name (
    3737            OM_uint32 * minor_status,
    3838            const gss_name_t input_name,
  • trunk/server/source4/heimdal/lib/gssapi/krb5/cfx.c

    r414 r745  
    214214}
    215215
    216 static OM_uint32
    217 allocate_buffer(OM_uint32 *minor_status, gss_iov_buffer_desc *buffer, size_t size)
     216OM_uint32
     217_gk_allocate_buffer(OM_uint32 *minor_status, gss_iov_buffer_desc *buffer, size_t size)
    218218{
    219     if (buffer->type & GSS_IOV_BUFFER_TYPE_FLAG_ALLOCATED) {
     219    if (buffer->type & GSS_IOV_BUFFER_FLAG_ALLOCATED) {
    220220        if (buffer->buffer.length == size)
    221221            return GSS_S_COMPLETE;
     
    229229        return GSS_S_FAILURE;
    230230    }
    231     buffer->type |= GSS_IOV_BUFFER_TYPE_FLAG_ALLOCATED;
     231    buffer->type |= GSS_IOV_BUFFER_FLAG_ALLOCATED;
    232232
    233233    return GSS_S_COMPLETE;
     
    235235
    236236
     237OM_uint32
     238_gk_verify_buffers(OM_uint32 *minor_status,
     239                   const gsskrb5_ctx ctx,
     240                   const gss_iov_buffer_desc *header,
     241                   const gss_iov_buffer_desc *padding,
     242                   const gss_iov_buffer_desc *trailer)
     243{
     244    if (header == NULL) {
     245        *minor_status = EINVAL;
     246        return GSS_S_FAILURE;
     247    }
     248
     249    if (IS_DCE_STYLE(ctx)) {
     250        /*
     251         * In DCE style mode we reject having a padding or trailer buffer
     252         */
     253        if (padding) {
     254            *minor_status = EINVAL;
     255            return GSS_S_FAILURE;
     256        }
     257        if (trailer) {
     258            *minor_status = EINVAL;
     259            return GSS_S_FAILURE;
     260        }
     261    } else {
     262        /*
     263         * In non-DCE style mode we require having a padding buffer
     264         */
     265        if (padding == NULL) {
     266            *minor_status = EINVAL;
     267            return GSS_S_FAILURE;
     268        }
     269    }
     270
     271    *minor_status = 0;
     272    return GSS_S_COMPLETE;
     273}
    237274
    238275OM_uint32
     
    249286    size_t gsshsize, k5hsize;
    250287    size_t gsstsize, k5tsize;
    251     size_t i, padlength, rrc = 0, ec = 0;
     288    size_t i, rrc = 0, ec = 0;
    252289    gss_cfx_wrap_token token;
    253290    krb5_error_code ret;
     
    255292    unsigned usage;
    256293    krb5_crypto_iov *data = NULL;
    257     int paddingoffset = 0;
    258        
     294
    259295    header = _gk_find_buffer(iov, iov_count, GSS_IOV_BUFFER_TYPE_HEADER);
    260296    if (header == NULL) {
     
    263299    }
    264300
    265     krb5_crypto_length(context, ctx->crypto, KRB5_CRYPTO_TYPE_PADDING, &padlength);
    266 
    267301    padding = _gk_find_buffer(iov, iov_count, GSS_IOV_BUFFER_TYPE_PADDING);
    268     if (padlength != 0 && padding == NULL) {
    269         *minor_status = EINVAL;
    270         return GSS_S_FAILURE;
     302    if (padding != NULL) {
     303        padding->buffer.length = 0;
    271304    }
    272305
    273306    trailer = _gk_find_buffer(iov, iov_count, GSS_IOV_BUFFER_TYPE_TRAILER);
    274307
     308    major_status = _gk_verify_buffers(minor_status, ctx, header, padding, trailer);
     309    if (major_status != GSS_S_COMPLETE) {
     310            return major_status;
     311    }
     312
    275313    if (conf_req_flag) {
    276         ec = padlength;
    277 
    278         krb5_crypto_length(context, ctx->crypto, KRB5_CRYPTO_TYPE_TRAILER, &k5tsize);
    279         krb5_crypto_length(context, ctx->crypto, KRB5_CRYPTO_TYPE_HEADER, &k5hsize);
    280 
    281         gsshsize = k5hsize + sizeof(*token);
    282         gsstsize = k5tsize + sizeof(*token); /* encrypted token stored in trailer */
    283 
    284     } else {
    285 
    286         krb5_crypto_length(context, ctx->crypto, KRB5_CRYPTO_TYPE_CHECKSUM, &k5tsize);
    287 
    288         gsshsize = sizeof(*token);
     314        size_t k5psize = 0;
     315        size_t k5pbase = 0;
     316        size_t k5bsize = 0;
     317        size_t size = 0;
     318
     319        for (i = 0; i < iov_count; i++) {
     320            switch (GSS_IOV_BUFFER_TYPE(iov[i].type)) {
     321            case GSS_IOV_BUFFER_TYPE_DATA:
     322                size += iov[i].buffer.length;
     323                break;
     324            default:
     325                break;
     326            }
     327        }
     328
     329        size += sizeof(gss_cfx_wrap_token_desc);
     330
     331        *minor_status = krb5_crypto_length(context, ctx->crypto,
     332                                           KRB5_CRYPTO_TYPE_HEADER,
     333                                           &k5hsize);
     334        if (*minor_status)
     335            return GSS_S_FAILURE;
     336
     337        *minor_status = krb5_crypto_length(context, ctx->crypto,
     338                                           KRB5_CRYPTO_TYPE_TRAILER,
     339                                           &k5tsize);
     340        if (*minor_status)
     341            return GSS_S_FAILURE;
     342
     343        *minor_status = krb5_crypto_length(context, ctx->crypto,
     344                                           KRB5_CRYPTO_TYPE_PADDING,
     345                                           &k5pbase);
     346        if (*minor_status)
     347            return GSS_S_FAILURE;
     348
     349        if (k5pbase > 1) {
     350            k5psize = k5pbase - (size % k5pbase);
     351        } else {
     352            k5psize = 0;
     353        }
     354
     355        if (k5psize == 0 && IS_DCE_STYLE(ctx)) {
     356            *minor_status = krb5_crypto_getblocksize(context, ctx->crypto,
     357                                                     &k5bsize);
     358            if (*minor_status)
     359                return GSS_S_FAILURE;
     360            ec = k5bsize;
     361        } else {
     362            ec = k5psize;
     363        }
     364
     365        gsshsize = sizeof(gss_cfx_wrap_token_desc) + k5hsize;
     366        gsstsize = sizeof(gss_cfx_wrap_token_desc) + ec + k5tsize;
     367    } else {
     368        if (IS_DCE_STYLE(ctx)) {
     369            *minor_status = EINVAL;
     370            return GSS_S_FAILURE;
     371        }
     372
     373        k5hsize = 0;
     374        *minor_status = krb5_crypto_length(context, ctx->crypto,
     375                                           KRB5_CRYPTO_TYPE_CHECKSUM,
     376                                           &k5tsize);
     377        if (*minor_status)
     378            return GSS_S_FAILURE;
     379
     380        gsshsize = sizeof(gss_cfx_wrap_token_desc);
    289381        gsstsize = k5tsize;
    290382    }
     
    295387
    296388    if (trailer == NULL) {
    297         /* conf_req_flag=0 doesn't support DCE_STYLE */
    298         if (conf_req_flag == 0) {
    299             *minor_status = EINVAL;
    300             major_status = GSS_S_FAILURE;
    301             goto failure;
    302         }           
    303389        rrc = gsstsize;
    304390        if (IS_DCE_STYLE(ctx))
     
    306392        gsshsize += gsstsize;
    307393        gsstsize = 0;
    308     } else if (GSS_IOV_BUFFER_FLAGS(trailer->type) & GSS_IOV_BUFFER_TYPE_FLAG_ALLOCATE) {
    309         major_status = allocate_buffer(minor_status, trailer, gsstsize);
     394    } else if (GSS_IOV_BUFFER_FLAGS(trailer->type) & GSS_IOV_BUFFER_FLAG_ALLOCATE) {
     395        major_status = _gk_allocate_buffer(minor_status, trailer, gsstsize);
    310396        if (major_status)
    311397            goto failure;
     
    321407     */
    322408
    323     if (GSS_IOV_BUFFER_FLAGS(header->type) & GSS_IOV_BUFFER_TYPE_FLAG_ALLOCATE) {
    324         major_status = allocate_buffer(minor_status, header, gsshsize);
     409    if (GSS_IOV_BUFFER_FLAGS(header->type) & GSS_IOV_BUFFER_FLAG_ALLOCATE) {
     410        major_status = _gk_allocate_buffer(minor_status, header, gsshsize);
    325411        if (major_status != GSS_S_COMPLETE)
    326412            goto failure;
     
    353439         */
    354440        token->Flags |= CFXSealed;
    355         token->EC[0] = (padlength >> 8) & 0xFF;
    356         token->EC[1] = (padlength >> 0) & 0xFF;
     441        token->EC[0] = (ec >> 8) & 0xFF;
     442        token->EC[1] = (ec >> 0) & 0xFF;
    357443
    358444    } else {
     
    405491          plain packet:
    406492
    407           {"header" | encrypt(plaintext-data | padding | E"header")}
     493          {"header" | encrypt(plaintext-data | ec-padding | E"header")}
    408494
    409495          Expanded, this is with with RRC = 0:
    410496
    411           {"header" | krb5-header | plaintext-data | padding | E"header" | krb5-trailer }
    412 
    413           In DCE-RPC mode == no trailer: RRC = gss "trailer" == length(padding | E"header" | krb5-trailer)
    414 
    415           {"header" | padding | E"header" | krb5-trailer | krb5-header | plaintext-data  }
     497          {"header" | krb5-header | plaintext-data | ec-padding | E"header" | krb5-trailer }
     498
     499          In DCE-RPC mode == no trailer: RRC = gss "trailer" == length(ec-padding | E"header" | krb5-trailer)
     500
     501          {"header" | ec-padding | E"header" | krb5-trailer | krb5-header | plaintext-data  }
    416502         */
    417503
     
    425511            case GSS_IOV_BUFFER_TYPE_DATA:
    426512                data[i].flags = KRB5_CRYPTO_TYPE_DATA;
    427                 break;
    428             case GSS_IOV_BUFFER_TYPE_PADDING:
    429                 data[i].flags = KRB5_CRYPTO_TYPE_PADDING;
    430                 paddingoffset = i;
    431513                break;
    432514            case GSS_IOV_BUFFER_TYPE_SIGN_ONLY:
     
    447529         */
    448530
    449         /* XXX KRB5_CRYPTO_TYPE_PADDING */
    450 
    451531        /* encrypted CFX header in trailer (or after the header if in
    452532           DCE mode). Copy in header into E"header"
     
    456536            data[i].data.data = trailer->buffer.value;
    457537        else
    458             data[i].data.data = ((uint8_t *)header->buffer.value) + header->buffer.length - k5hsize - k5tsize - sizeof(*token);
    459 
    460         data[i].data.length = sizeof(*token);
    461         memcpy(data[i].data.data, token, sizeof(*token));
     538            data[i].data.data = ((uint8_t *)header->buffer.value) + sizeof(*token);
     539
     540        data[i].data.length = ec + sizeof(*token);
     541        memset(data[i].data.data, 0xFF, ec);
     542        memcpy(((uint8_t *)data[i].data.data) + ec, token, sizeof(*token));
    462543        i++;
    463544
    464545        /* Kerberos trailer comes after the gss trailer */
    465546        data[i].flags = KRB5_CRYPTO_TYPE_TRAILER;
    466         data[i].data.data = ((uint8_t *)data[i-1].data.data) + sizeof(*token);
     547        data[i].data.data = ((uint8_t *)data[i-1].data.data) + ec + sizeof(*token);
    467548        data[i].data.length = k5tsize;
    468549        i++;
     
    480561        }
    481562
    482         if (paddingoffset)
    483             padding->buffer.length = data[paddingoffset].data.length;
    484 
    485563    } else {
    486564        /*
     
    496574            switch (GSS_IOV_BUFFER_TYPE(iov[i].type)) {
    497575            case GSS_IOV_BUFFER_TYPE_DATA:
    498             case GSS_IOV_BUFFER_TYPE_PADDING:
    499576                data[i].flags = KRB5_CRYPTO_TYPE_DATA;
    500577                break;
     
    512589        data[i].flags = KRB5_CRYPTO_TYPE_DATA;
    513590        data[i].data.data = header->buffer.value;
    514         data[i].data.length = header->buffer.length;
     591        data[i].data.length = sizeof(gss_cfx_wrap_token_desc);
    515592        i++;
    516593
    517594        data[i].flags = KRB5_CRYPTO_TYPE_CHECKSUM;
    518         data[i].data.data = trailer->buffer.value;
    519         data[i].data.length = trailer->buffer.length;
     595        if (trailer) {
     596                data[i].data.data = trailer->buffer.value;
     597        } else {
     598                data[i].data.data = (uint8_t *)header->buffer.value +
     599                                     sizeof(gss_cfx_wrap_token_desc);
     600        }
     601        data[i].data.length = k5tsize;
    520602        i++;
    521603
     
    527609        }
    528610
    529         token->EC[0] =  (trailer->buffer.length >> 8) & 0xFF;
    530         token->EC[1] =  (trailer->buffer.length >> 0) & 0xFF;
     611        if (rrc) {
     612            token->RRC[0] = (rrc >> 8) & 0xFF;
     613            token->RRC[1] = (rrc >> 0) & 0xFF;
     614        }
     615
     616        token->EC[0] =  (k5tsize >> 8) & 0xFF;
     617        token->EC[1] =  (k5tsize >> 0) & 0xFF;
    531618    }
    532619
     
    607694            GSS_IOV_BUFFER_TYPE(iov[i].type) == GSS_IOV_BUFFER_TYPE_TRAILER)
    608695        {
    609             memcpy(q, iov[i].buffer.value, MIN(iov[i].buffer.length, skip));
     696            memcpy(q, iov[i].buffer.value, min(iov[i].buffer.length, skip));
    610697            if (iov[i].buffer.length > skip)
    611698                break;
     
    628715{
    629716    OM_uint32 seq_number_lo, seq_number_hi, major_status, junk;
    630     gss_iov_buffer_desc *header, *trailer;
     717    gss_iov_buffer_desc *header, *trailer, *padding;
    631718    gss_cfx_wrap_token token, ttoken;
    632719    u_char token_flags;
     
    648735        return GSS_S_DEFECTIVE_TOKEN;
    649736
     737    padding = _gk_find_buffer(iov, iov_count, GSS_IOV_BUFFER_TYPE_PADDING);
     738    if (padding != NULL && padding->buffer.length != 0) {
     739        *minor_status = EINVAL;
     740        return GSS_S_FAILURE;
     741    }
     742
    650743    trailer = _gk_find_buffer(iov, iov_count, GSS_IOV_BUFFER_TYPE_TRAILER);
     744
     745    major_status = _gk_verify_buffers(minor_status, ctx, header, padding, trailer);
     746    if (major_status != GSS_S_COMPLETE) {
     747            return major_status;
     748    }
    651749
    652750    token = (gss_cfx_wrap_token)header->buffer.value;
     
    731829            size_t gsshsize = k5hsize + sizeof(*token);
    732830
    733             if (IS_DCE_STYLE(ctx))
    734                 gsstsize += ec;
    735             gsshsize += gsstsize;
    736 
    737831            if (rrc != gsstsize) {
    738832                major_status = GSS_S_DEFECTIVE_TOKEN;
    739833                goto failure;
    740834            }
     835
     836            if (IS_DCE_STYLE(ctx))
     837                gsstsize += ec;
     838
     839            gsshsize += gsstsize;
     840
    741841            if (header->buffer.length != gsshsize) {
    742842                major_status = GSS_S_DEFECTIVE_TOKEN;
     
    765865            switch (GSS_IOV_BUFFER_TYPE(iov[j].type)) {
    766866            case GSS_IOV_BUFFER_TYPE_DATA:
    767             case GSS_IOV_BUFFER_TYPE_PADDING:
    768867                data[i].flags = KRB5_CRYPTO_TYPE_DATA;
    769868                break;
     
    783882        */
    784883        data[i].flags = KRB5_CRYPTO_TYPE_DATA;
    785         if (trailer)
     884        if (trailer) {
    786885            data[i].data.data = trailer->buffer.value;
    787         else
    788             data[i].data.data = ((uint8_t *)header->buffer.value) + header->buffer.length - k5hsize - k5tsize - sizeof(*token);
    789         data[i].data.length = sizeof(*token);
    790         ttoken = (gss_cfx_wrap_token)data[i].data.data;
     886        } else {
     887            data[i].data.data = ((uint8_t *)header->buffer.value) +
     888                header->buffer.length - k5hsize - k5tsize - ec- sizeof(*token);
     889        }
     890
     891        data[i].data.length = ec + sizeof(*token);
     892        ttoken = (gss_cfx_wrap_token)(((uint8_t *)data[i].data.data) + ec);
    791893        i++;
    792894
    793895        /* Kerberos trailer comes after the gss trailer */
    794896        data[i].flags = KRB5_CRYPTO_TYPE_TRAILER;
    795         data[i].data.data = ((uint8_t *)data[i-1].data.data) + sizeof(*token);
     897        data[i].data.data = ((uint8_t *)data[i-1].data.data) + ec + sizeof(*token);
    796898        data[i].data.length = k5tsize;
    797899        i++;
     
    808910
    809911        /* Check the integrity of the header */
    810         if (memcmp(ttoken, token, sizeof(*token)) != 0) {
     912        if (ct_memcmp(ttoken, token, sizeof(*token)) != 0) {
    811913            major_status = GSS_S_BAD_MIC;
    812914            goto failure;
    813915        }
    814916    } else {
    815         /* Check RRC */
    816         if (rrc != 0) {
     917        size_t gsstsize = ec;
     918        size_t gsshsize = sizeof(*token);
     919
     920        if (trailer == NULL) {
     921            /* Check RRC */
     922            if (rrc != gsstsize) {
     923               *minor_status = EINVAL;
     924               major_status = GSS_S_FAILURE;
     925               goto failure;
     926            }
     927
     928            gsshsize += gsstsize;
     929            gsstsize = 0;
     930        } else if (trailer->buffer.length != gsstsize) {
     931            major_status = GSS_S_DEFECTIVE_TOKEN;
     932            goto failure;
     933        } else if (rrc != 0) {
     934            /* Check RRC */
    817935            *minor_status = EINVAL;
    818936            major_status = GSS_S_FAILURE;
     
    820938        }
    821939
    822         if (trailer == NULL) {
    823             *minor_status = EINVAL;
    824             major_status = GSS_S_FAILURE;
    825             goto failure;
    826         }
    827 
    828         if (trailer->buffer.length != ec) {
    829             *minor_status = EINVAL;
    830             major_status = GSS_S_FAILURE;
     940        if (header->buffer.length != gsshsize) {
     941            major_status = GSS_S_DEFECTIVE_TOKEN;
    831942            goto failure;
    832943        }
     
    835946            switch (GSS_IOV_BUFFER_TYPE(iov[i].type)) {
    836947            case GSS_IOV_BUFFER_TYPE_DATA:
    837             case GSS_IOV_BUFFER_TYPE_PADDING:
    838948                data[i].flags = KRB5_CRYPTO_TYPE_DATA;
    839949                break;
     
    851961        data[i].flags = KRB5_CRYPTO_TYPE_DATA;
    852962        data[i].data.data = header->buffer.value;
    853         data[i].data.length = header->buffer.length;
     963        data[i].data.length = sizeof(*token);
    854964        i++;
    855965
    856966        data[i].flags = KRB5_CRYPTO_TYPE_CHECKSUM;
    857         data[i].data.data = trailer->buffer.value;
    858         data[i].data.length = trailer->buffer.length;
     967        if (trailer) {
     968                data[i].data.data = trailer->buffer.value;
     969        } else {
     970                data[i].data.data = (uint8_t *)header->buffer.value +
     971                                     sizeof(*token);
     972        }
     973        data[i].data.length = ec;
    859974        i++;
    860975
     
    9011016                            int iov_count)
    9021017{
     1018    OM_uint32 major_status;
    9031019    size_t size;
    9041020    int i;
    905     size_t *padding = NULL;
     1021    gss_iov_buffer_desc *header = NULL;
     1022    gss_iov_buffer_desc *padding = NULL;
     1023    gss_iov_buffer_desc *trailer = NULL;
     1024    size_t gsshsize = 0;
     1025    size_t gsstsize = 0;
     1026    size_t k5hsize = 0;
     1027    size_t k5tsize = 0;
    9061028
    9071029    GSSAPI_KRB5_INIT (&context);
     
    9161038            break;
    9171039        case GSS_IOV_BUFFER_TYPE_HEADER:
    918             *minor_status = krb5_crypto_length(context, ctx->crypto, KRB5_CRYPTO_TYPE_HEADER, &iov[i].buffer.length);
    919             if (*minor_status)
     1040            if (header != NULL) {
     1041                *minor_status = 0;
    9201042                return GSS_S_FAILURE;
     1043            }
     1044            header = &iov[i];
    9211045            break;
    9221046        case GSS_IOV_BUFFER_TYPE_TRAILER:
    923             *minor_status = krb5_crypto_length(context, ctx->crypto, KRB5_CRYPTO_TYPE_TRAILER, &iov[i].buffer.length);
    924             if (*minor_status)
     1047            if (trailer != NULL) {
     1048                *minor_status = 0;
    9251049                return GSS_S_FAILURE;
     1050            }
     1051            trailer = &iov[i];
    9261052            break;
    9271053        case GSS_IOV_BUFFER_TYPE_PADDING:
     
    9301056                return GSS_S_FAILURE;
    9311057            }
    932             padding = &iov[i].buffer.length;
     1058            padding = &iov[i];
    9331059            break;
    9341060        case GSS_IOV_BUFFER_TYPE_SIGN_ONLY:
     
    9391065        }
    9401066    }
     1067
     1068    major_status = _gk_verify_buffers(minor_status, ctx, header, padding, trailer);
     1069    if (major_status != GSS_S_COMPLETE) {
     1070            return major_status;
     1071    }
     1072
     1073    if (conf_req_flag) {
     1074        size_t k5psize = 0;
     1075        size_t k5pbase = 0;
     1076        size_t k5bsize = 0;
     1077        size_t ec = 0;
     1078
     1079        size += sizeof(gss_cfx_wrap_token_desc);
     1080
     1081        *minor_status = krb5_crypto_length(context, ctx->crypto,
     1082                                           KRB5_CRYPTO_TYPE_HEADER,
     1083                                           &k5hsize);
     1084        if (*minor_status)
     1085            return GSS_S_FAILURE;
     1086
     1087        *minor_status = krb5_crypto_length(context, ctx->crypto,
     1088                                           KRB5_CRYPTO_TYPE_TRAILER,
     1089                                           &k5tsize);
     1090        if (*minor_status)
     1091            return GSS_S_FAILURE;
     1092
     1093        *minor_status = krb5_crypto_length(context, ctx->crypto,
     1094                                           KRB5_CRYPTO_TYPE_PADDING,
     1095                                           &k5pbase);
     1096        if (*minor_status)
     1097            return GSS_S_FAILURE;
     1098
     1099        if (k5pbase > 1) {
     1100            k5psize = k5pbase - (size % k5pbase);
     1101        } else {
     1102            k5psize = 0;
     1103        }
     1104
     1105        if (k5psize == 0 && IS_DCE_STYLE(ctx)) {
     1106            *minor_status = krb5_crypto_getblocksize(context, ctx->crypto,
     1107                                                     &k5bsize);
     1108            if (*minor_status)
     1109                return GSS_S_FAILURE;
     1110
     1111            ec = k5bsize;
     1112        } else {
     1113            ec = k5psize;
     1114        }
     1115
     1116        gsshsize = sizeof(gss_cfx_wrap_token_desc) + k5hsize;
     1117        gsstsize = sizeof(gss_cfx_wrap_token_desc) + ec + k5tsize;
     1118    } else {
     1119        *minor_status = krb5_crypto_length(context, ctx->crypto,
     1120                                           KRB5_CRYPTO_TYPE_CHECKSUM,
     1121                                           &k5tsize);
     1122        if (*minor_status)
     1123            return GSS_S_FAILURE;
     1124
     1125        gsshsize = sizeof(gss_cfx_wrap_token_desc);
     1126        gsstsize = k5tsize;
     1127    }
     1128
     1129    if (trailer != NULL) {
     1130        trailer->buffer.length = gsstsize;
     1131    } else {
     1132        gsshsize += gsstsize;
     1133    }
     1134
     1135    header->buffer.length = gsshsize;
     1136
    9411137    if (padding) {
    942         size_t pad;
    943         krb5_crypto_length(context, ctx->crypto, KRB5_CRYPTO_TYPE_PADDING, &pad);
    944         if (pad > 1) {
    945             *padding = pad - (size % pad);
    946             if (*padding == pad)
    947                 *padding = 0;
    948         } else
    949             *padding = 0;
     1138        /* padding is done via EC and is contained in the header or trailer */
     1139        padding->buffer.length = 0;
     1140    }
     1141
     1142    if (conf_state) {
     1143        *conf_state = conf_req_flag;
    9501144    }
    9511145
     
    12951489
    12961490        /* Check the integrity of the header */
    1297         if (memcmp(p, token, sizeof(*token)) != 0) {
     1491        if (ct_memcmp(p, token, sizeof(*token)) != 0) {
    12981492            krb5_data_free(&data);
    12991493            return GSS_S_BAD_MIC;
     
    14971691    }
    14981692
    1499     if (memcmp(token->Filler, "\xff\xff\xff\xff\xff", 5) != 0) {
     1693    if (ct_memcmp(token->Filler, "\xff\xff\xff\xff\xff", 5) != 0) {
    15001694        return GSS_S_DEFECTIVE_TOKEN;
    15011695    }
  • trunk/server/source4/heimdal/lib/gssapi/krb5/compare_name.c

    r414 r745  
    3434#include "gsskrb5_locl.h"
    3535
    36 OM_uint32 _gsskrb5_compare_name
     36OM_uint32 GSSAPI_CALLCONV _gsskrb5_compare_name
    3737           (OM_uint32 * minor_status,
    3838            const gss_name_t name1,
  • trunk/server/source4/heimdal/lib/gssapi/krb5/context_time.c

    r414 r745  
    6363
    6464
    65 OM_uint32 _gsskrb5_context_time
     65OM_uint32 GSSAPI_CALLCONV _gsskrb5_context_time
    6666           (OM_uint32 * minor_status,
    6767            const gss_ctx_id_t context_handle,
  • trunk/server/source4/heimdal/lib/gssapi/krb5/creds.c

    r414 r745  
    3434#include "gsskrb5_locl.h"
    3535
    36 OM_uint32
     36OM_uint32 GSSAPI_CALLCONV
    3737_gsskrb5_export_cred(OM_uint32 *minor_status,
    3838                     gss_cred_id_t cred_handle,
     
    155155}
    156156
    157 OM_uint32
     157OM_uint32 GSSAPI_CALLCONV
    158158_gsskrb5_import_cred(OM_uint32 * minor_status,
    159159                     gss_buffer_t cred_token,
     
    251251
    252252    *cred_handle = (gss_cred_id_t)handle;
     253
    253254    return GSS_S_COMPLETE;
    254255}
  • trunk/server/source4/heimdal/lib/gssapi/krb5/decapsulate.c

    r414 r745  
    8181    if (mech_len != mech->length)
    8282        return GSS_S_BAD_MECH;
    83     if (memcmp(p,
    84                mech->elements,
    85                mech->length) != 0)
     83    if (ct_memcmp(p,
     84                  mech->elements,
     85                  mech->length) != 0)
    8686        return GSS_S_BAD_MECH;
    8787    p += mech_len;
     
    109109        return GSS_S_DEFECTIVE_TOKEN;
    110110
    111     if (memcmp (*str, type, 2) != 0)
     111    if (ct_memcmp (*str, type, 2) != 0)
    112112        return GSS_S_DEFECTIVE_TOKEN;
    113113    *str += 2;
  • trunk/server/source4/heimdal/lib/gssapi/krb5/delete_sec_context.c

    r414 r745  
    3434#include "gsskrb5_locl.h"
    3535
    36 OM_uint32
     36OM_uint32 GSSAPI_CALLCONV
    3737_gsskrb5_delete_sec_context(OM_uint32 * minor_status,
    3838                            gss_ctx_id_t * context_handle,
     
    6060
    6161    krb5_auth_con_free (context, ctx->auth_context);
     62    krb5_auth_con_free (context, ctx->deleg_auth_context);
    6263    if (ctx->kcred)
    6364        krb5_free_creds(context, ctx->kcred);
  • trunk/server/source4/heimdal/lib/gssapi/krb5/display_name.c

    r414 r745  
    3434#include "gsskrb5_locl.h"
    3535
    36 OM_uint32 _gsskrb5_display_name
     36OM_uint32 GSSAPI_CALLCONV _gsskrb5_display_name
    3737           (OM_uint32 * minor_status,
    3838            const gss_name_t input_name,
  • trunk/server/source4/heimdal/lib/gssapi/krb5/display_status.c

    r414 r745  
    126126    va_list args;
    127127    char *str;
     128    int e;
    128129
    129130    if (_gsskrb5_init (&context) != 0)
     
    131132
    132133    va_start(args, fmt);
    133     vasprintf(&str, fmt, args);
     134    e = vasprintf(&str, fmt, args);
    134135    va_end(args);
    135     if (str) {
     136    if (e >= 0 && str) {
    136137        krb5_set_error_message(context, ret, "%s", str);
    137138        free(str);
     
    139140}
    140141
    141 OM_uint32 _gsskrb5_display_status
     142OM_uint32 GSSAPI_CALLCONV _gsskrb5_display_status
    142143(OM_uint32              *minor_status,
    143144 OM_uint32               status_value,
     
    148149{
    149150    krb5_context context;
    150     char *buf;
     151    char *buf = NULL;
     152    int e = 0;
    151153
    152154    GSSAPI_KRB5_INIT (&context);
     
    163165    if (status_type == GSS_C_GSS_CODE) {
    164166        if (GSS_SUPPLEMENTARY_INFO(status_value))
    165             asprintf(&buf, "%s",
    166                     supplementary_error(GSS_SUPPLEMENTARY_INFO(status_value)));
     167            e = asprintf(&buf, "%s",
     168                        supplementary_error(GSS_SUPPLEMENTARY_INFO(status_value)));
    167169        else
    168             asprintf (&buf, "%s %s",
    169                       calling_error(GSS_CALLING_ERROR(status_value)),
    170                       routine_error(GSS_ROUTINE_ERROR(status_value)));
     170            e = asprintf (&buf, "%s %s",
     171                          calling_error(GSS_CALLING_ERROR(status_value)),
     172                          routine_error(GSS_ROUTINE_ERROR(status_value)));
    171173    } else if (status_type == GSS_C_MECH_CODE) {
    172174        const char *buf2 = krb5_get_error_message(context, status_value);
     
    175177            krb5_free_error_message(context, buf2);
    176178        } else {
    177             asprintf(&buf, "unknown mech error-code %u",
    178                     (unsigned)status_value);
     179            e = asprintf(&buf, "unknown mech error-code %u",
     180                        (unsigned)status_value);
    179181        }
    180182    } else {
     
    183185    }
    184186
    185     if (buf == NULL) {
     187    if (e < 0 || buf == NULL) {
    186188        *minor_status = ENOMEM;
    187189        return GSS_S_FAILURE;
  • trunk/server/source4/heimdal/lib/gssapi/krb5/duplicate_name.c

    r414 r745  
    3434#include "gsskrb5_locl.h"
    3535
    36 OM_uint32 _gsskrb5_duplicate_name (
     36OM_uint32 GSSAPI_CALLCONV _gsskrb5_duplicate_name (
    3737            OM_uint32 * minor_status,
    3838            const gss_name_t src_name,
  • trunk/server/source4/heimdal/lib/gssapi/krb5/export_name.c

    r414 r745  
    3434#include "gsskrb5_locl.h"
    3535
    36 OM_uint32 _gsskrb5_export_name
     36OM_uint32 GSSAPI_CALLCONV _gsskrb5_export_name
    3737           (OM_uint32  * minor_status,
    3838            const gss_name_t input_name,
  • trunk/server/source4/heimdal/lib/gssapi/krb5/export_sec_context.c

    r414 r745  
    3434#include "gsskrb5_locl.h"
    3535
    36 OM_uint32
     36OM_uint32 GSSAPI_CALLCONV
    3737_gsskrb5_export_sec_context (
    3838    OM_uint32 * minor_status,
  • trunk/server/source4/heimdal/lib/gssapi/krb5/external.c

    r414 r745  
    4747 */
    4848
    49 static gss_OID_desc gss_c_nt_user_name_oid_desc =
     49gss_OID_desc GSSAPI_LIB_VARIABLE __gss_c_nt_user_name_oid_desc =
    5050    {10, rk_UNCONST("\x2a\x86\x48\x86\xf7\x12" "\x01\x02\x01\x01")};
    51 
    52 gss_OID GSSAPI_LIB_VARIABLE GSS_C_NT_USER_NAME =
    53     &gss_c_nt_user_name_oid_desc;
    5451
    5552/*
     
    6562 */
    6663
    67 static gss_OID_desc gss_c_nt_machine_uid_name_oid_desc =
     64gss_OID_desc GSSAPI_LIB_VARIABLE __gss_c_nt_machine_uid_name_oid_desc =
    6865    {10, rk_UNCONST("\x2a\x86\x48\x86\xf7\x12" "\x01\x02\x01\x02")};
    69 
    70 gss_OID GSSAPI_LIB_VARIABLE GSS_C_NT_MACHINE_UID_NAME =
    71     &gss_c_nt_machine_uid_name_oid_desc;
    7266
    7367/*
     
    8377 */
    8478
    85 static gss_OID_desc gss_c_nt_string_uid_name_oid_desc =
     79gss_OID_desc GSSAPI_LIB_VARIABLE __gss_c_nt_string_uid_name_oid_desc =
    8680    {10, rk_UNCONST("\x2a\x86\x48\x86\xf7\x12" "\x01\x02\x01\x03")};
    87 
    88 gss_OID GSSAPI_LIB_VARIABLE GSS_C_NT_STRING_UID_NAME =
    89     &gss_c_nt_string_uid_name_oid_desc;
    9081
    9182/*
     
    10798 */
    10899
    109 static gss_OID_desc gss_c_nt_hostbased_service_x_oid_desc =
     100gss_OID_desc GSSAPI_LIB_VARIABLE __gss_c_nt_hostbased_service_x_oid_desc =
    110101    {6, rk_UNCONST("\x2b\x06\x01\x05\x06\x02")};
    111 
    112 gss_OID GSSAPI_LIB_VARIABLE GSS_C_NT_HOSTBASED_SERVICE_X =
    113     &gss_c_nt_hostbased_service_x_oid_desc;
    114102
    115103/*
     
    124112 * to point to that gss_OID_desc.
    125113 */
    126 static gss_OID_desc gss_c_nt_hostbased_service_oid_desc =
     114gss_OID_desc GSSAPI_LIB_VARIABLE __gss_c_nt_hostbased_service_oid_desc =
    127115    {10, rk_UNCONST("\x2a\x86\x48\x86\xf7\x12" "\x01\x02\x01\x04")};
    128 
    129 gss_OID GSSAPI_LIB_VARIABLE GSS_C_NT_HOSTBASED_SERVICE =
    130     &gss_c_nt_hostbased_service_oid_desc;
    131116
    132117/*
     
    141126 */
    142127
    143 static gss_OID_desc gss_c_nt_anonymous_oid_desc =
     128gss_OID_desc GSSAPI_LIB_VARIABLE __gss_c_nt_anonymous_oid_desc =
    144129    {6, rk_UNCONST("\x2b\x06\01\x05\x06\x03")};
    145 
    146 gss_OID GSSAPI_LIB_VARIABLE GSS_C_NT_ANONYMOUS =
    147     &gss_c_nt_anonymous_oid_desc;
    148130
    149131/*
     
    158140 */
    159141
    160 static gss_OID_desc gss_c_nt_export_name_oid_desc =
     142gss_OID_desc GSSAPI_LIB_VARIABLE __gss_c_nt_export_name_oid_desc =
    161143    {6, rk_UNCONST("\x2b\x06\x01\x05\x06\x04") };
    162 
    163 gss_OID GSSAPI_LIB_VARIABLE GSS_C_NT_EXPORT_NAME =
    164     &gss_c_nt_export_name_oid_desc;
    165144
    166145/*
     
    171150 */
    172151
    173 static gss_OID_desc gss_krb5_nt_principal_name_oid_desc =
     152gss_OID_desc GSSAPI_LIB_VARIABLE __gss_krb5_nt_principal_name_oid_desc =
    174153    {10, rk_UNCONST("\x2a\x86\x48\x86\xf7\x12\x01\x02\x02\x01") };
    175 
    176 gss_OID GSSAPI_LIB_VARIABLE GSS_KRB5_NT_PRINCIPAL_NAME =
    177     &gss_krb5_nt_principal_name_oid_desc;
    178 
    179 /*
    180  *   This name form shall be represented by the Object Identifier {iso(1)
    181  *   member-body(2) United States(840) mit(113554) infosys(1) gssapi(2)
    182  *   generic(1) user_name(1)}.  The recommended symbolic name for this
    183  *   type is "GSS_KRB5_NT_USER_NAME".
    184  */
    185 
    186 gss_OID GSSAPI_LIB_VARIABLE GSS_KRB5_NT_USER_NAME =
    187     &gss_c_nt_user_name_oid_desc;
    188 
    189 /*
    190  *   This name form shall be represented by the Object Identifier {iso(1)
    191  *   member-body(2) United States(840) mit(113554) infosys(1) gssapi(2)
    192  *   generic(1) machine_uid_name(2)}.  The recommended symbolic name for
    193  *   this type is "GSS_KRB5_NT_MACHINE_UID_NAME".
    194  */
    195 
    196 gss_OID GSSAPI_LIB_VARIABLE GSS_KRB5_NT_MACHINE_UID_NAME =
    197     &gss_c_nt_machine_uid_name_oid_desc;
    198 
    199 /*
    200  *   This name form shall be represented by the Object Identifier {iso(1)
    201  *   member-body(2) United States(840) mit(113554) infosys(1) gssapi(2)
    202  *   generic(1) string_uid_name(3)}.  The recommended symbolic name for
    203  *   this type is "GSS_KRB5_NT_STRING_UID_NAME".
    204  */
    205 
    206 gss_OID GSSAPI_LIB_VARIABLE GSS_KRB5_NT_STRING_UID_NAME =
    207     &gss_c_nt_string_uid_name_oid_desc;
    208 
    209 /*
    210  *   To support ongoing experimentation, testing, and evolution of the
    211  *   specification, the Kerberos V5 GSS-API mechanism as defined in this
    212  *   and any successor memos will be identified with the following Object
    213  *   Identifier, as defined in RFC-1510, until the specification is
    214  *   advanced to the level of Proposed Standard RFC:
    215  *
    216  *   {iso(1), org(3), dod(5), internet(1), security(5), kerberosv5(2)}
    217  *
    218  *   Upon advancement to the level of Proposed Standard RFC, the Kerberos
    219  *   V5 GSS-API mechanism will be identified by an Object Identifier
    220  *   having the value:
    221  *
    222  *   {iso(1) member-body(2) United States(840) mit(113554) infosys(1)
    223  *   gssapi(2) krb5(2)}
    224  */
    225 
    226 #if 0 /* This is the old OID */
    227 
    228 static gss_OID_desc gss_krb5_mechanism_oid_desc =
    229     {5, rk_UNCONST("\x2b\x05\x01\x05\x02")};
    230 
    231 #endif
    232 
    233 static gss_OID_desc gss_krb5_mechanism_oid_desc =
    234     {9, rk_UNCONST("\x2a\x86\x48\x86\xf7\x12\x01\x02\x02") };
    235 
    236 gss_OID GSSAPI_LIB_VARIABLE GSS_KRB5_MECHANISM =
    237     &gss_krb5_mechanism_oid_desc;
    238154
    239155/*
     
    250166 */
    251167
    252 static gss_OID_desc gss_iakerb_proxy_mechanism_oid_desc =
     168gss_OID_desc GSSAPI_LIB_VARIABLE  __gss_iakerb_proxy_mechanism_oid_desc =
    253169    {7, rk_UNCONST("\x2b\x06\x01\x05\x05\x0a\x01")};
    254170
    255 gss_OID GSSAPI_LIB_VARIABLE GSS_IAKERB_PROXY_MECHANISM =
    256     &gss_iakerb_proxy_mechanism_oid_desc;
    257 
    258 static gss_OID_desc gss_iakerb_min_msg_mechanism_oid_desc =
     171gss_OID_desc GSSAPI_LIB_VARIABLE __gss_iakerb_min_msg_mechanism_oid_desc =
    259172    {7, rk_UNCONST("\x2b\x06\x01\x05\x05\x0a\x02") };
    260173
    261 gss_OID GSSAPI_LIB_VARIABLE GSS_IAKERB_MIN_MSG_MECHANISM =
    262     &gss_iakerb_min_msg_mechanism_oid_desc;
    263 
    264 /*
    265  *
    266  */
    267 
    268 static gss_OID_desc gss_c_peer_has_updated_spnego_oid_desc =
    269     {9, (void *)"\x2b\x06\x01\x04\x01\xa9\x4a\x13\x05"};
    270 
    271 gss_OID GSSAPI_LIB_VARIABLE GSS_C_PEER_HAS_UPDATED_SPNEGO =
    272     &gss_c_peer_has_updated_spnego_oid_desc;
    273 
    274 /*
    275  * 1.2.752.43.13 Heimdal GSS-API Extentions
    276  */
    277 
    278 /* 1.2.752.43.13.1 */
    279 static gss_OID_desc gss_krb5_copy_ccache_x_oid_desc =
    280     {6, rk_UNCONST("\x2a\x85\x70\x2b\x0d\x01")};
    281 
    282 gss_OID GSSAPI_LIB_VARIABLE GSS_KRB5_COPY_CCACHE_X =
    283     &gss_krb5_copy_ccache_x_oid_desc;
    284 
    285 /* 1.2.752.43.13.2 */
    286 static gss_OID_desc gss_krb5_get_tkt_flags_x_oid_desc =
    287     {6, rk_UNCONST("\x2a\x85\x70\x2b\x0d\x02")};
    288 
    289 gss_OID GSSAPI_LIB_VARIABLE GSS_KRB5_GET_TKT_FLAGS_X =
    290     &gss_krb5_get_tkt_flags_x_oid_desc;
    291 
    292 /* 1.2.752.43.13.3 */
    293 static gss_OID_desc gss_krb5_extract_authz_data_from_sec_context_x_oid_desc =
    294     {6, rk_UNCONST("\x2a\x85\x70\x2b\x0d\x03")};
    295 
    296 gss_OID GSSAPI_LIB_VARIABLE GSS_KRB5_EXTRACT_AUTHZ_DATA_FROM_SEC_CONTEXT_X =
    297     &gss_krb5_extract_authz_data_from_sec_context_x_oid_desc;
    298 
    299 /* 1.2.752.43.13.4 */
    300 static gss_OID_desc gss_krb5_compat_des3_mic_x_oid_desc =
    301     {6, rk_UNCONST("\x2a\x85\x70\x2b\x0d\x04")};
    302 
    303 gss_OID GSSAPI_LIB_VARIABLE GSS_KRB5_COMPAT_DES3_MIC_X =
    304     &gss_krb5_compat_des3_mic_x_oid_desc;
    305 
    306 /* 1.2.752.43.13.5 */
    307 static gss_OID_desc gss_krb5_register_acceptor_identity_x_desc =
    308     {6, rk_UNCONST("\x2a\x85\x70\x2b\x0d\x05")};
    309 
    310 gss_OID GSSAPI_LIB_VARIABLE GSS_KRB5_REGISTER_ACCEPTOR_IDENTITY_X =
    311     &gss_krb5_register_acceptor_identity_x_desc;
    312 
    313 /* 1.2.752.43.13.6 */
    314 static gss_OID_desc gss_krb5_export_lucid_context_x_desc =
    315     {6, rk_UNCONST("\x2a\x85\x70\x2b\x0d\x06")};
    316 
    317 gss_OID GSSAPI_LIB_VARIABLE GSS_KRB5_EXPORT_LUCID_CONTEXT_X =
    318     &gss_krb5_export_lucid_context_x_desc;
    319 
    320 /* 1.2.752.43.13.6.1 */
    321 static gss_OID_desc gss_krb5_export_lucid_context_v1_x_desc =
    322     {7, rk_UNCONST("\x2a\x85\x70\x2b\x0d\x06\x01")};
    323 
    324 gss_OID GSSAPI_LIB_VARIABLE GSS_KRB5_EXPORT_LUCID_CONTEXT_V1_X =
    325     &gss_krb5_export_lucid_context_v1_x_desc;
    326 
    327 /* 1.2.752.43.13.7 */
    328 static gss_OID_desc gss_krb5_set_dns_canonicalize_x_desc =
    329     {6, rk_UNCONST("\x2a\x85\x70\x2b\x0d\x07")};
    330 
    331 gss_OID GSSAPI_LIB_VARIABLE GSS_KRB5_SET_DNS_CANONICALIZE_X =
    332     &gss_krb5_set_dns_canonicalize_x_desc;
    333 
    334 /* 1.2.752.43.13.8 */
    335 static gss_OID_desc gss_krb5_get_subkey_x_desc =
    336     {6, rk_UNCONST("\x2a\x85\x70\x2b\x0d\x08")};
    337 
    338 gss_OID GSSAPI_LIB_VARIABLE GSS_KRB5_GET_SUBKEY_X =
    339     &gss_krb5_get_subkey_x_desc;
    340 
    341 /* 1.2.752.43.13.9 */
    342 static gss_OID_desc gss_krb5_get_initiator_subkey_x_desc =
    343     {6, rk_UNCONST("\x2a\x85\x70\x2b\x0d\x09")};
    344 
    345 gss_OID GSSAPI_LIB_VARIABLE GSS_KRB5_GET_INITIATOR_SUBKEY_X =
    346     &gss_krb5_get_initiator_subkey_x_desc;
    347 
    348 /* 1.2.752.43.13.10 */
    349 static gss_OID_desc gss_krb5_get_acceptor_subkey_x_desc =
    350     {6, rk_UNCONST("\x2a\x85\x70\x2b\x0d\x0a")};
    351 
    352 gss_OID GSSAPI_LIB_VARIABLE GSS_KRB5_GET_ACCEPTOR_SUBKEY_X =
    353     &gss_krb5_get_acceptor_subkey_x_desc;
    354 
    355 /* 1.2.752.43.13.11 */
    356 static gss_OID_desc gss_krb5_send_to_kdc_x_desc =
    357     {6, rk_UNCONST("\x2a\x85\x70\x2b\x0d\x0b")};
    358 
    359 gss_OID GSSAPI_LIB_VARIABLE GSS_KRB5_SEND_TO_KDC_X =
    360     &gss_krb5_send_to_kdc_x_desc;
    361 
    362 /* 1.2.752.43.13.12 */
    363 static gss_OID_desc gss_krb5_get_authtime_x_desc =
    364     {6, rk_UNCONST("\x2a\x85\x70\x2b\x0d\x0c")};
    365 
    366 gss_OID GSSAPI_LIB_VARIABLE GSS_KRB5_GET_AUTHTIME_X =
    367     &gss_krb5_get_authtime_x_desc;
    368 
    369 /* 1.2.752.43.13.13 */
    370 static gss_OID_desc gss_krb5_get_service_keyblock_x_desc =
    371     {6, rk_UNCONST("\x2a\x85\x70\x2b\x0d\x0d")};
    372 
    373 gss_OID GSSAPI_LIB_VARIABLE GSS_KRB5_GET_SERVICE_KEYBLOCK_X =
    374     &gss_krb5_get_service_keyblock_x_desc;
    375 
    376 /* 1.2.752.43.13.14 */
    377 static gss_OID_desc gss_krb5_set_allowable_enctypes_x_desc =
    378     {6, rk_UNCONST("\x2a\x85\x70\x2b\x0d\x0e")};
    379 
    380 gss_OID GSSAPI_LIB_VARIABLE GSS_KRB5_SET_ALLOWABLE_ENCTYPES_X =
    381     &gss_krb5_set_allowable_enctypes_x_desc;
    382 
    383 /* 1.2.752.43.13.15 */
    384 static gss_OID_desc gss_krb5_set_default_realm_x_desc =
    385     {6, rk_UNCONST("\x2a\x85\x70\x2b\x0d\x0f")};
    386 
    387 gss_OID GSSAPI_LIB_VARIABLE GSS_KRB5_SET_DEFAULT_REALM_X =
    388     &gss_krb5_set_default_realm_x_desc;
    389 
    390 /* 1.2.752.43.13.16 */
    391 static gss_OID_desc gss_krb5_ccache_name_x_desc =
    392     {6, rk_UNCONST("\x2a\x85\x70\x2b\x0d\x10")};
    393 
    394 gss_OID GSSAPI_LIB_VARIABLE GSS_KRB5_CCACHE_NAME_X =
    395     &gss_krb5_ccache_name_x_desc;
    396 
    397 /* 1.2.752.43.13.17 */
    398 static gss_OID_desc gss_krb5_set_time_offset_x_desc =
    399     {6, rk_UNCONST("\x2a\x85\x70\x2b\x0d\x11")};
    400 
    401 gss_OID GSSAPI_LIB_VARIABLE GSS_KRB5_SET_TIME_OFFSET_X =
    402     &gss_krb5_set_time_offset_x_desc;
    403 
    404 /* 1.2.752.43.13.18 */
    405 static gss_OID_desc gss_krb5_get_time_offset_x_desc =
    406     {6, rk_UNCONST("\x2a\x85\x70\x2b\x0d\x12")};
    407 
    408 gss_OID GSSAPI_LIB_VARIABLE GSS_KRB5_GET_TIME_OFFSET_X =
    409     &gss_krb5_get_time_offset_x_desc;
    410 
    411 /* 1.2.752.43.13.19 */
    412 static gss_OID_desc gss_krb5_plugin_register_x_desc =
    413     {6, rk_UNCONST("\x2a\x85\x70\x2b\x0d\x13")};
    414 
    415 gss_OID GSSAPI_LIB_VARIABLE GSS_KRB5_PLUGIN_REGISTER_X =
    416     &gss_krb5_plugin_register_x_desc;
    417 
    418 /* 1.2.752.43.14.1 */
    419 static gss_OID_desc gss_sasl_digest_md5_mechanism_desc =
    420     {6, rk_UNCONST("\x2a\x85\x70\x2b\x0e\x01") };
    421 
    422 gss_OID GSSAPI_LIB_VARIABLE GSS_SASL_DIGEST_MD5_MECHANISM =
    423     &gss_sasl_digest_md5_mechanism_desc;
    424 
    425174/*
    426175 * Context for krb5 calls.
    427176 */
     177
     178static gss_mo_desc krb5_mo[] = {
     179    {
     180        GSS_C_MA_SASL_MECH_NAME,
     181        GSS_MO_MA,
     182        "SASL mech name",
     183        "GS2-KRB5",
     184        _gss_mo_get_ctx_as_string,
     185        NULL
     186    },
     187    {
     188        GSS_C_MA_MECH_NAME,
     189        GSS_MO_MA,
     190        "Mechanism name",
     191        "KRB5",
     192        _gss_mo_get_ctx_as_string,
     193        NULL
     194    },
     195    {
     196        GSS_C_MA_MECH_DESCRIPTION,
     197        GSS_MO_MA,
     198        "Mechanism description",
     199        "Heimdal Kerberos 5 mech",
     200        _gss_mo_get_ctx_as_string,
     201        NULL
     202    },
     203    {
     204        GSS_C_MA_MECH_CONCRETE,
     205        GSS_MO_MA
     206    },
     207    {
     208        GSS_C_MA_ITOK_FRAMED,
     209        GSS_MO_MA
     210    },
     211    {
     212        GSS_C_MA_AUTH_INIT,
     213        GSS_MO_MA
     214    },
     215    {
     216        GSS_C_MA_AUTH_TARG,
     217        GSS_MO_MA
     218    },
     219    {
     220        GSS_C_MA_AUTH_INIT_ANON,
     221        GSS_MO_MA
     222    },
     223    {
     224        GSS_C_MA_DELEG_CRED,
     225        GSS_MO_MA
     226    },
     227    {
     228        GSS_C_MA_INTEG_PROT,
     229        GSS_MO_MA
     230    },
     231    {
     232        GSS_C_MA_CONF_PROT,
     233        GSS_MO_MA
     234    },
     235    {
     236        GSS_C_MA_MIC,
     237        GSS_MO_MA
     238    },
     239    {
     240        GSS_C_MA_WRAP,
     241        GSS_MO_MA
     242    },
     243    {
     244        GSS_C_MA_PROT_READY,
     245        GSS_MO_MA
     246    },
     247    {
     248        GSS_C_MA_REPLAY_DET,
     249        GSS_MO_MA
     250    },
     251    {
     252        GSS_C_MA_OOS_DET,
     253        GSS_MO_MA
     254    },
     255    {
     256        GSS_C_MA_CBINDINGS,
     257        GSS_MO_MA
     258    },
     259    {
     260        GSS_C_MA_PFS,
     261        GSS_MO_MA
     262    },
     263    {
     264        GSS_C_MA_CTX_TRANS,
     265        GSS_MO_MA
     266    }
     267};
    428268
    429269/*
     
    435275    "kerberos 5",
    436276    {9, "\x2a\x86\x48\x86\xf7\x12\x01\x02\x02" },
     277    0,
    437278    _gsskrb5_acquire_cred,
    438279    _gsskrb5_release_cred,
     
    474315    _gsskrb5_store_cred,
    475316    _gsskrb5_export_cred,
    476     _gsskrb5_import_cred
     317    _gsskrb5_import_cred,
     318    NULL,
     319    NULL,
     320    NULL,
     321    NULL,
     322    NULL,
     323    NULL,
     324    NULL,
     325    krb5_mo,
     326    sizeof(krb5_mo) / sizeof(krb5_mo[0])
    477327};
    478328
  • trunk/server/source4/heimdal/lib/gssapi/krb5/get_mic.c

    r414 r745  
    3434#include "gsskrb5_locl.h"
    3535
     36#ifdef HEIM_WEAK_CRYPTO
     37
    3638static OM_uint32
    3739mic_des
     
    4648{
    4749  u_char *p;
    48   MD5_CTX md5;
     50  EVP_MD_CTX *md5;
    4951  u_char hash[16];
    5052  DES_key_schedule schedule;
     53  EVP_CIPHER_CTX des_ctx;
    5154  DES_cblock deskey;
    5255  DES_cblock zero;
     
    8083
    8184  /* checksum */
    82   MD5_Init (&md5);
    83   MD5_Update (&md5, p - 24, 8);
    84   MD5_Update (&md5, message_buffer->value, message_buffer->length);
    85   MD5_Final (hash, &md5);
     85  md5 = EVP_MD_CTX_create();
     86  EVP_DigestInit_ex(md5, EVP_md5(), NULL);
     87  EVP_DigestUpdate(md5, p - 24, 8);
     88  EVP_DigestUpdate(md5, message_buffer->value, message_buffer->length);
     89  EVP_DigestFinal_ex(md5, hash, NULL);
     90  EVP_MD_CTX_destroy(md5);
    8691
    8792  memset (&zero, 0, sizeof(zero));
     
    107112          4);
    108113
    109   DES_set_key_unchecked (&deskey, &schedule);
    110   DES_cbc_encrypt ((void *)p, (void *)p, 8,
    111                    &schedule, (DES_cblock *)(p + 8), DES_ENCRYPT);
     114  EVP_CIPHER_CTX_init(&des_ctx);
     115  EVP_CipherInit_ex(&des_ctx, EVP_des_cbc(), NULL, key->keyvalue.data, p + 8, 1);
     116  EVP_Cipher(&des_ctx, p, p, 8);
     117  EVP_CIPHER_CTX_cleanup(&des_ctx);
    112118
    113119  krb5_auth_con_setlocalseqnumber (context,
     
    122128  return GSS_S_COMPLETE;
    123129}
     130#endif
    124131
    125132static OM_uint32
     
    267274}
    268275
    269 OM_uint32 _gsskrb5_get_mic
     276OM_uint32 GSSAPI_CALLCONV _gsskrb5_get_mic
    270277           (OM_uint32 * minor_status,
    271278            const gss_ctx_id_t context_handle,
     
    298305  switch (keytype) {
    299306  case KEYTYPE_DES :
     307#ifdef HEIM_WEAK_CRYPTO
    300308      ret = mic_des (minor_status, ctx, context, qop_req,
    301309                     message_buffer, message_token, key);
     310#else
     311      ret = GSS_S_FAILURE;
     312#endif
    302313      break;
    303314  case KEYTYPE_DES3 :
  • trunk/server/source4/heimdal/lib/gssapi/krb5/gsskrb5_locl.h

    r414 r745  
    5656typedef struct gsskrb5_ctx {
    5757  struct krb5_auth_context_data *auth_context;
     58  struct krb5_auth_context_data *deleg_auth_context;
    5859  krb5_principal source, target;
    5960#define IS_DCE_STYLE(ctx) (((ctx)->flags & GSS_C_DCE_STYLE) != 0)
     
    112113extern HEIMDAL_MUTEX gssapi_keytab_mutex;
    113114
    114 struct gssapi_thr_context {
    115     HEIMDAL_MUTEX mutex;
    116     char *error_string;
    117 };
    118 
    119115/*
    120116 * Prototypes
  • trunk/server/source4/heimdal/lib/gssapi/krb5/import_name.c

    r414 r745  
    216216}
    217217
    218 OM_uint32 _gsskrb5_import_name
     218OM_uint32 GSSAPI_CALLCONV _gsskrb5_import_name
    219219           (OM_uint32 * minor_status,
    220220            const gss_buffer_t input_name_buffer,
     
    236236                                      input_name_buffer,
    237237                                      output_name);
    238     else if (gss_oid_equal(input_name_type, GSS_C_NO_OID)
     238    else if (input_name_type == GSS_C_NO_OID
    239239             || gss_oid_equal(input_name_type, GSS_C_NT_USER_NAME)
    240240             || gss_oid_equal(input_name_type, GSS_KRB5_NT_PRINCIPAL_NAME))
  • trunk/server/source4/heimdal/lib/gssapi/krb5/import_sec_context.c

    r414 r745  
    3434#include "gsskrb5_locl.h"
    3535
    36 OM_uint32
     36OM_uint32 GSSAPI_CALLCONV
    3737_gsskrb5_import_sec_context (
    3838    OM_uint32 * minor_status,
     
    203203    krb5_storage_free (sp);
    204204
     205    _gsskrb5i_is_cfx(context, ctx, (ctx->more_flags & LOCAL) == 0);
     206
    205207    *context_handle = (gss_ctx_id_t)ctx;
    206208
  • trunk/server/source4/heimdal/lib/gssapi/krb5/indicate_mechs.c

    r414 r745  
    3434#include "gsskrb5_locl.h"
    3535
    36 OM_uint32 _gsskrb5_indicate_mechs
     36OM_uint32 GSSAPI_CALLCONV _gsskrb5_indicate_mechs
    3737           (OM_uint32 * minor_status,
    3838            gss_OID_set * mech_set
  • trunk/server/source4/heimdal/lib/gssapi/krb5/init_sec_context.c

    r414 r745  
    118118    }
    119119    ctx->auth_context           = NULL;
     120    ctx->deleg_auth_context     = NULL;
    120121    ctx->source                 = NULL;
    121122    ctx->target                 = NULL;
     
    140141    }
    141142
     143    kret = krb5_auth_con_init (context, &ctx->deleg_auth_context);
     144    if (kret) {
     145        *minor_status = kret;
     146        krb5_auth_con_free(context, ctx->auth_context);
     147        HEIMDAL_MUTEX_destroy(&ctx->ctx_id_mutex);
     148        return GSS_S_FAILURE;
     149    }
     150
    142151    kret = set_addresses(context, ctx->auth_context, input_chan_bindings);
    143152    if (kret) {
    144153        *minor_status = kret;
    145154
     155        krb5_auth_con_free(context, ctx->auth_context);
     156        krb5_auth_con_free(context, ctx->deleg_auth_context);
     157
    146158        HEIMDAL_MUTEX_destroy(&ctx->ctx_id_mutex);
    147159
     160        return GSS_S_BAD_BINDINGS;
     161    }
     162
     163    kret = set_addresses(context, ctx->deleg_auth_context, input_chan_bindings);
     164    if (kret) {
     165        *minor_status = kret;
     166
    148167        krb5_auth_con_free(context, ctx->auth_context);
     168        krb5_auth_con_free(context, ctx->deleg_auth_context);
     169
     170        HEIMDAL_MUTEX_destroy(&ctx->ctx_id_mutex);
    149171
    150172        return GSS_S_BAD_BINDINGS;
     
    157179    krb5_auth_con_addflags(context,
    158180                           ctx->auth_context,
     181                           KRB5_AUTH_CONTEXT_DO_SEQUENCE |
     182                           KRB5_AUTH_CONTEXT_CLEAR_FORWARDED_CRED,
     183                           NULL);
     184
     185    /*
     186     * We need a sequence number
     187     */
     188
     189    krb5_auth_con_addflags(context,
     190                           ctx->deleg_auth_context,
    159191                           KRB5_AUTH_CONTEXT_DO_SEQUENCE |
    160192                           KRB5_AUTH_CONTEXT_CLEAR_FORWARDED_CRED,
     
    176208        int use_dns,
    177209        OM_uint32 time_req,
    178         OM_uint32 * time_rec,
    179         krb5_creds ** cred)
     210        OM_uint32 * time_rec)
    180211{
    181212    OM_uint32 ret;
     
    184215    OM_uint32 lifetime_rec;
    185216
    186     *cred = NULL;
    187 
    188217    if (ctx->target) {
    189218        krb5_free_principal(context, ctx->target);
    190219        ctx->target = NULL;
     220    }
     221    if (ctx->kcred) {
     222        krb5_free_creds(context, ctx->kcred);
     223        ctx->kcred = NULL;
    191224    }
    192225
     
    215248                                ccache,
    216249                                &this_cred,
    217                                 cred);
     250                                &ctx->kcred);
    218251    if (kret) {
    219252        *minor_status = kret;
     
    221254    }
    222255
    223     ctx->lifetime = (*cred)->times.endtime;
     256    ctx->lifetime = ctx->kcred->times.endtime;
    224257
    225258    ret = _gsskrb5_lifetime_left(minor_status, context,
     
    255288    ctx->ccache = NULL;
    256289
    257     krb5_auth_getremoteseqnumber (context, ctx->auth_context, &seq_number);
     290    krb5_auth_con_getremoteseqnumber (context, ctx->auth_context, &seq_number);
    258291
    259292    _gsskrb5i_is_cfx(context, ctx, 0);
     
    297330        goto out;
    298331
    299     kret = krb5_build_principal(context,
    300                                 &creds.server,
    301                                 strlen(creds.client->realm),
    302                                 creds.client->realm,
    303                                 KRB5_TGS_NAME,
    304                                 creds.client->realm,
    305                                 NULL);
     332    kret = krb5_make_principal(context,
     333                               &creds.server,
     334                               creds.client->realm,
     335                               KRB5_TGS_NAME,
     336                               creds.client->realm,
     337                               NULL);
    306338    if (kret)
    307339        goto out;
     
    428460    ret = gsskrb5_get_creds(minor_status, context, ctx->ccache,
    429461                            ctx, name, 0, time_req,
    430                             time_rec, &ctx->kcred);
     462                            time_rec);
    431463    if (ret && allow_dns)
    432464        ret = gsskrb5_get_creds(minor_status, context, ctx->ccache,
    433465                                ctx, name, 1, time_req,
    434                                 time_rec, &ctx->kcred);
     466                                time_rec);
    435467    if (ret)
    436468        goto failure;
     
    539571    if (flagmask & GSS_C_DELEG_FLAG) {
    540572        do_delegation (context,
    541                        ctx->auth_context,
     573                       ctx->deleg_auth_context,
    542574                       ctx->ccache, ctx->kcred, ctx->target,
    543575                       &fwd_data, flagmask, &flags);
     
    610642    }
    611643
    612     kret = krb5_build_authenticator (context,
     644    kret = _krb5_build_authenticator(context,
    613645                                     ctx->auth_context,
    614646                                     enctype,
    615647                                     ctx->kcred,
    616648                                     &cksum,
    617                                      NULL,
    618649                                     &authenticator,
    619650                                     KRB5_KU_AP_REQ_AUTH);
     
    666697
    667698    return ret;
     699}
     700
     701static krb5_error_code
     702handle_error_packet(krb5_context context,
     703                    gsskrb5_ctx ctx,
     704                    krb5_data indata)
     705{
     706    krb5_error_code kret;
     707    KRB_ERROR error;
     708
     709    kret = krb5_rd_error(context, &indata, &error);
     710    if (kret == 0) {
     711        kret = krb5_error_from_rd_error(context, &error, NULL);
     712
     713        /* save the time skrew for this host */
     714        if (kret == KRB5KRB_AP_ERR_SKEW) {
     715            krb5_data timedata;
     716            unsigned char p[4];
     717            int32_t t = error.stime - time(NULL);
     718
     719            p[0] = (t >> 24) & 0xFF;
     720            p[1] = (t >> 16) & 0xFF;
     721            p[2] = (t >> 8)  & 0xFF;
     722            p[3] = (t >> 0)  & 0xFF;
     723
     724            timedata.data = p;
     725            timedata.length = sizeof(p);
     726
     727            krb5_cc_set_config(context, ctx->ccache, ctx->target,
     728                               "time-offset", &timedata);
     729
     730            if ((ctx->more_flags & RETRIED) == 0)
     731                 ctx->state = INITIATOR_RESTART;
     732            ctx->more_flags |= RETRIED;
     733        }
     734        free_KRB_ERROR (&error);
     735    }
     736    return kret;
    668737}
    669738
     
    700769        indata.length   = input_token->length;
    701770        indata.data     = input_token->value;
     771        kret = krb5_rd_rep(context,
     772                           ctx->auth_context,
     773                           &indata,
     774                           &repl);
     775        if (kret) {
     776            ret = _gsskrb5_decapsulate(minor_status,
     777                                       input_token,
     778                                       &indata,
     779                                       "\x03\x00",
     780                                       GSS_KRB5_MECHANISM);
     781            if (ret == GSS_S_COMPLETE) {
     782                *minor_status = handle_error_packet(context, ctx, indata);
     783            } else {
     784                *minor_status = kret;
     785            }
     786            return GSS_S_FAILURE;
     787        }
    702788    } else {
    703789        ret = _gsskrb5_decapsulate (minor_status,
     
    714800                                        GSS_KRB5_MECHANISM);
    715801            if (ret == GSS_S_COMPLETE) {
    716                 KRB_ERROR error;
    717                
    718                 kret = krb5_rd_error(context, &indata, &error);
    719                 if (kret == 0) {
    720                     kret = krb5_error_from_rd_error(context, &error, NULL);
    721 
    722                     /* save the time skrew for this host */
    723                     if (kret == KRB5KRB_AP_ERR_SKEW) {
    724                         krb5_data timedata;
    725                         unsigned char p[4];
    726                         int32_t t = error.stime - time(NULL);
    727 
    728                         p[0] = (t >> 24) & 0xFF;
    729                         p[1] = (t >> 16) & 0xFF;
    730                         p[2] = (t >> 8)  & 0xFF;
    731                         p[3] = (t >> 0)  & 0xFF;
    732 
    733                         timedata.data = p;
    734                         timedata.length = sizeof(p);
    735 
    736                         krb5_cc_set_config(context, ctx->ccache, ctx->target,
    737                                            "time-offset", &timedata);
    738 
    739                         if ((ctx->more_flags & RETRIED) == 0)
    740                             ctx->state = INITIATOR_RESTART;
    741                         ctx->more_flags |= RETRIED;
    742                     }
    743                     free_KRB_ERROR (&error);
    744                 }
    745                 *minor_status = kret;
     802                *minor_status = handle_error_packet(context, ctx, indata);
    746803                return GSS_S_FAILURE;
    747804            }
    748             return ret;
    749805        }
    750     }
    751 
    752     kret = krb5_rd_rep (context,
    753                         ctx->auth_context,
    754                         &indata,
    755                         &repl);
    756     if (kret) {
    757         *minor_status = kret;
    758         return GSS_S_FAILURE;
    759     }
     806        kret = krb5_rd_rep (context,
     807                            ctx->auth_context,
     808                            &indata,
     809                            &repl);
     810        if (kret) {
     811            *minor_status = kret;
     812            return GSS_S_FAILURE;
     813        }
     814    }
     815
    760816    krb5_free_ap_rep_enc_part (context,
    761817                               repl);
     
    784840         */
    785841
    786         krb5_auth_getremoteseqnumber(context, ctx->auth_context, &remote_seq);
     842        krb5_auth_con_getremoteseqnumber(context, ctx->auth_context, &remote_seq);
    787843        krb5_auth_con_getlocalseqnumber(context, ctx->auth_context, &local_seq);
    788844        krb5_auth_con_setlocalseqnumber(context, ctx->auth_context, remote_seq);
     
    808864 */
    809865
    810 OM_uint32 _gsskrb5_init_sec_context
     866OM_uint32 GSSAPI_CALLCONV _gsskrb5_init_sec_context
    811867(OM_uint32 * minor_status,
    812868 const gss_cred_id_t cred_handle,
  • trunk/server/source4/heimdal/lib/gssapi/krb5/inquire_context.c

    r414 r745  
    3434#include "gsskrb5_locl.h"
    3535
    36 OM_uint32 _gsskrb5_inquire_context (
     36OM_uint32 GSSAPI_CALLCONV _gsskrb5_inquire_context (
    3737    OM_uint32 * minor_status,
    3838        const gss_ctx_id_t context_handle,
  • trunk/server/source4/heimdal/lib/gssapi/krb5/inquire_cred.c

    r414 r745  
    3434#include "gsskrb5_locl.h"
    3535
    36 OM_uint32 _gsskrb5_inquire_cred
     36OM_uint32 GSSAPI_CALLCONV _gsskrb5_inquire_cred
    3737(OM_uint32 * minor_status,
    3838 const gss_cred_id_t cred_handle,
  • trunk/server/source4/heimdal/lib/gssapi/krb5/inquire_cred_by_mech.c

    r414 r745  
    3434#include "gsskrb5_locl.h"
    3535
    36 OM_uint32 _gsskrb5_inquire_cred_by_mech (
     36OM_uint32 GSSAPI_CALLCONV _gsskrb5_inquire_cred_by_mech (
    3737    OM_uint32 * minor_status,
    3838        const gss_cred_id_t cred_handle,
  • trunk/server/source4/heimdal/lib/gssapi/krb5/inquire_cred_by_oid.c

    r414 r745  
    3333#include "gsskrb5_locl.h"
    3434
    35 OM_uint32 _gsskrb5_inquire_cred_by_oid
     35OM_uint32 GSSAPI_CALLCONV _gsskrb5_inquire_cred_by_oid
    3636           (OM_uint32 * minor_status,
    3737            const gss_cred_id_t cred_handle,
  • trunk/server/source4/heimdal/lib/gssapi/krb5/inquire_mechs_for_name.c

    r414 r745  
    3434#include "gsskrb5_locl.h"
    3535
    36 OM_uint32 _gsskrb5_inquire_mechs_for_name (
     36OM_uint32 GSSAPI_CALLCONV _gsskrb5_inquire_mechs_for_name (
    3737            OM_uint32 * minor_status,
    3838            const gss_name_t input_name,
  • trunk/server/source4/heimdal/lib/gssapi/krb5/inquire_names_for_mech.c

    r414 r745  
    3434#include "gsskrb5_locl.h"
    3535
    36 static gss_OID *name_list[] = {
    37     &GSS_C_NT_HOSTBASED_SERVICE,
    38     &GSS_C_NT_USER_NAME,
    39     &GSS_KRB5_NT_PRINCIPAL_NAME,
    40     &GSS_C_NT_EXPORT_NAME,
     36static gss_OID name_list[] = {
     37    GSS_C_NT_HOSTBASED_SERVICE,
     38    GSS_C_NT_USER_NAME,
     39    GSS_KRB5_NT_PRINCIPAL_NAME,
     40    GSS_C_NT_EXPORT_NAME,
    4141    NULL
    4242};
    4343
    44 OM_uint32 _gsskrb5_inquire_names_for_mech (
     44OM_uint32 GSSAPI_CALLCONV _gsskrb5_inquire_names_for_mech (
    4545            OM_uint32 * minor_status,
    4646            const gss_OID mechanism,
     
    6565    for (i = 0; name_list[i] != NULL; i++) {
    6666        ret = gss_add_oid_set_member(minor_status,
    67                                      *(name_list[i]),
     67                                     name_list[i],
    6868                                     name_types);
    6969        if (ret != GSS_S_COMPLETE)
  • trunk/server/source4/heimdal/lib/gssapi/krb5/inquire_sec_context_by_oid.c

    r414 r745  
    303303    ret = krb5_store_uint32(sp, (uint32_t)number);
    304304    if (ret) goto out;
    305     krb5_auth_getremoteseqnumber (context,
    306                                   context_handle->auth_context,
    307                                   &number);
     305    krb5_auth_con_getremoteseqnumber (context,
     306                                      context_handle->auth_context,
     307                                      &number);
    308308    ret = krb5_store_uint32(sp, (uint32_t)0); /* store top half as zero */
    309309    if (ret) goto out;
     
    488488 */
    489489
    490 OM_uint32 _gsskrb5_inquire_sec_context_by_oid
     490OM_uint32 GSSAPI_CALLCONV _gsskrb5_inquire_sec_context_by_oid
    491491           (OM_uint32 *minor_status,
    492492            const gss_ctx_id_t context_handle,
  • trunk/server/source4/heimdal/lib/gssapi/krb5/prf.c

    r414 r745  
    3434#include "gsskrb5_locl.h"
    3535
    36 OM_uint32
     36OM_uint32 GSSAPI_CALLCONV
    3737_gsskrb5_pseudo_random(OM_uint32 *minor_status,
    3838                       gss_ctx_id_t context_handle,
     
    133133        num++;
    134134    }
     135    free(input.data);
    135136
    136137    krb5_crypto_destroy(context, crypto);
  • trunk/server/source4/heimdal/lib/gssapi/krb5/process_context_token.c

    r414 r745  
    3434#include "gsskrb5_locl.h"
    3535
    36 OM_uint32 _gsskrb5_process_context_token (
     36OM_uint32 GSSAPI_CALLCONV _gsskrb5_process_context_token (
    3737        OM_uint32          *minor_status,
    3838        const gss_ctx_id_t context_handle,
  • trunk/server/source4/heimdal/lib/gssapi/krb5/release_cred.c

    r414 r745  
    3434#include "gsskrb5_locl.h"
    3535
    36 OM_uint32 _gsskrb5_release_cred
     36OM_uint32 GSSAPI_CALLCONV _gsskrb5_release_cred
    3737           (OM_uint32 * minor_status,
    3838            gss_cred_id_t * cred_handle
  • trunk/server/source4/heimdal/lib/gssapi/krb5/release_name.c

    r414 r745  
    3434#include "gsskrb5_locl.h"
    3535
    36 OM_uint32 _gsskrb5_release_name
     36OM_uint32 GSSAPI_CALLCONV _gsskrb5_release_name
    3737           (OM_uint32 * minor_status,
    3838            gss_name_t * input_name
  • trunk/server/source4/heimdal/lib/gssapi/krb5/set_cred_option.c

    r414 r745  
    3232
    3333#include "gsskrb5_locl.h"
    34 
    35 /* 1.2.752.43.13.17 */
    36 static gss_OID_desc gss_krb5_cred_no_ci_flags_x_oid_desc =
    37 {6, rk_UNCONST("\x2a\x85\x70\x2b\x0d\x11")};
    38 
    39 gss_OID GSS_KRB5_CRED_NO_CI_FLAGS_X = &gss_krb5_cred_no_ci_flags_x_oid_desc;
    40 
    41 /* 1.2.752.43.13.18 */
    42 static gss_OID_desc gss_krb5_import_cred_x_oid_desc =
    43 {6, rk_UNCONST("\x2a\x85\x70\x2b\x0d\x12")};
    44 
    45 gss_OID GSS_KRB5_IMPORT_CRED_X = &gss_krb5_import_cred_x_oid_desc;
    46 
    47 
    4834
    4935static OM_uint32
     
    231217
    232218
    233 OM_uint32
     219OM_uint32 GSSAPI_CALLCONV
    234220_gsskrb5_set_cred_option
    235221           (OM_uint32 *minor_status,
  • trunk/server/source4/heimdal/lib/gssapi/krb5/set_sec_context_option.c

    r414 r745  
    9999}
    100100
    101 OM_uint32
     101OM_uint32 GSSAPI_CALLCONV
    102102_gsskrb5_set_sec_context_option
    103103           (OM_uint32 *minor_status,
  • trunk/server/source4/heimdal/lib/gssapi/krb5/store_cred.c

    r414 r745  
    3434#include "gsskrb5_locl.h"
    3535
    36 OM_uint32
     36OM_uint32 GSSAPI_CALLCONV
    3737_gsskrb5_store_cred(OM_uint32         *minor_status,
    3838                    gss_cred_id_t     input_cred_handle,
  • trunk/server/source4/heimdal/lib/gssapi/krb5/unwrap.c

    r414 r745  
    3434#include "gsskrb5_locl.h"
    3535
     36#ifdef HEIM_WEAK_CRYPTO
     37
    3638static OM_uint32
    3739unwrap_des
     
    4749  u_char *p, *seq;
    4850  size_t len;
    49   MD5_CTX md5;
     51  EVP_MD_CTX *md5;
    5052  u_char hash[16];
     53  EVP_CIPHER_CTX des_ctx;
    5154  DES_key_schedule schedule;
    5255  DES_cblock deskey;
     
    99102      for (i = 0; i < sizeof(deskey); ++i)
    100103          deskey[i] ^= 0xf0;
    101       DES_set_key_unchecked (&deskey, &schedule);
    102       memset (&zero, 0, sizeof(zero));
    103       DES_cbc_encrypt ((void *)p,
    104                        (void *)p,
    105                        input_message_buffer->length - len,
    106                        &schedule,
    107                        &zero,
    108                        DES_DECRYPT);
    109 
    110       memset (deskey, 0, sizeof(deskey));
     104
     105
     106      EVP_CIPHER_CTX_init(&des_ctx);
     107      EVP_CipherInit_ex(&des_ctx, EVP_des_cbc(), NULL, deskey, zero, 0);
     108      EVP_Cipher(&des_ctx, p, p, input_message_buffer->length - len);
     109      EVP_CIPHER_CTX_cleanup(&des_ctx);
     110
    111111      memset (&schedule, 0, sizeof(schedule));
    112112  }
     
    123123  }
    124124
    125   MD5_Init (&md5);
    126   MD5_Update (&md5, p - 24, 8);
    127   MD5_Update (&md5, p, input_message_buffer->length - len);
    128   MD5_Final (hash, &md5);
     125  md5 = EVP_MD_CTX_create();
     126  EVP_DigestInit_ex(md5, EVP_md5(), NULL);
     127  EVP_DigestUpdate(md5, p - 24, 8);
     128  EVP_DigestUpdate(md5, p, input_message_buffer->length - len);
     129  EVP_DigestFinal_ex(md5, hash, NULL);
     130  EVP_MD_CTX_destroy(md5);
    129131
    130132  memset (&zero, 0, sizeof(zero));
     
    133135  DES_cbc_cksum ((void *)hash, (void *)hash, sizeof(hash),
    134136                 &schedule, &zero);
    135   if (memcmp (p - 8, hash, 8) != 0)
     137  if (ct_memcmp (p - 8, hash, 8) != 0)
    136138    return GSS_S_BAD_MIC;
    137139
     
    141143
    142144  p -= 16;
    143   DES_set_key_unchecked (&deskey, &schedule);
    144   DES_cbc_encrypt ((void *)p, (void *)p, 8,
    145                    &schedule, (DES_cblock *)hash, DES_DECRYPT);
     145
     146  EVP_CIPHER_CTX_init(&des_ctx);
     147  EVP_CipherInit_ex(&des_ctx, EVP_des_cbc(), NULL, key->keyvalue.data, hash, 0);
     148  EVP_Cipher(&des_ctx, p, p, 8);
     149  EVP_CIPHER_CTX_cleanup(&des_ctx);
    146150
    147151  memset (deskey, 0, sizeof(deskey));
     
    152156
    153157  if (context_handle->more_flags & LOCAL)
    154       cmp = memcmp(&seq[4], "\xff\xff\xff\xff", 4);
     158      cmp = ct_memcmp(&seq[4], "\xff\xff\xff\xff", 4);
    155159  else
    156       cmp = memcmp(&seq[4], "\x00\x00\x00\x00", 4);
     160      cmp = ct_memcmp(&seq[4], "\x00\x00\x00\x00", 4);
    157161
    158162  if (cmp != 0) {
     
    181185  return GSS_S_COMPLETE;
    182186}
     187#endif
    183188
    184189static OM_uint32
     
    225230    return GSS_S_BAD_SIG;
    226231  p += 2;
    227   if (memcmp (p, "\x02\x00", 2) == 0) {
     232  if (ct_memcmp (p, "\x02\x00", 2) == 0) {
    228233    cstate = 1;
    229   } else if (memcmp (p, "\xff\xff", 2) == 0) {
     234  } else if (ct_memcmp (p, "\xff\xff", 2) == 0) {
    230235    cstate = 0;
    231236  } else
     
    234239  if(conf_state != NULL)
    235240    *conf_state = cstate;
    236   if (memcmp (p, "\xff\xff", 2) != 0)
     241  if (ct_memcmp (p, "\xff\xff", 2) != 0)
    237242    return GSS_S_DEFECTIVE_TOKEN;
    238243  p += 2;
     
    315320
    316321  if (context_handle->more_flags & LOCAL)
    317       cmp = memcmp(&seq[4], "\xff\xff\xff\xff", 4);
     322      cmp = ct_memcmp(&seq[4], "\xff\xff\xff\xff", 4);
    318323  else
    319       cmp = memcmp(&seq[4], "\x00\x00\x00\x00", 4);
     324      cmp = ct_memcmp(&seq[4], "\x00\x00\x00\x00", 4);
    320325
    321326  krb5_data_free (&seq_data);
     
    375380}
    376381
    377 OM_uint32 _gsskrb5_unwrap
     382OM_uint32 GSSAPI_CALLCONV _gsskrb5_unwrap
    378383           (OM_uint32 * minor_status,
    379384            const gss_ctx_id_t context_handle,
     
    415420  switch (keytype) {
    416421  case KEYTYPE_DES :
     422#ifdef HEIM_WEAK_CRYPTO
    417423      ret = unwrap_des (minor_status, ctx,
    418424                        input_message_buffer, output_message_buffer,
    419425                        conf_state, qop_state, key);
     426#else
     427      ret = GSS_S_FAILURE;
     428#endif
    420429      break;
    421430  case KEYTYPE_DES3 :
  • trunk/server/source4/heimdal/lib/gssapi/krb5/verify_mic.c

    r414 r745  
    3333
    3434#include "gsskrb5_locl.h"
     35
     36#ifdef HEIM_WEAK_CRYPTO
    3537
    3638static OM_uint32
     
    4749{
    4850  u_char *p;
    49   MD5_CTX md5;
     51  EVP_MD_CTX *md5;
    5052  u_char hash[16], *seq;
    5153  DES_key_schedule schedule;
     54  EVP_CIPHER_CTX des_ctx;
    5255  DES_cblock zero;
    5356  DES_cblock deskey;
     
    7376
    7477  /* verify checksum */
    75   MD5_Init (&md5);
    76   MD5_Update (&md5, p - 24, 8);
    77   MD5_Update (&md5, message_buffer->value,
    78              message_buffer->length);
    79   MD5_Final (hash, &md5);
     78  md5 = EVP_MD_CTX_create();
     79  EVP_DigestInit_ex(md5, EVP_md5(), NULL);
     80  EVP_DigestUpdate(md5, p - 24, 8);
     81  EVP_DigestUpdate(md5, message_buffer->value, message_buffer->length);
     82  EVP_DigestFinal_ex(md5, hash, NULL);
     83  EVP_MD_CTX_destroy(md5);
    8084
    8185  memset (&zero, 0, sizeof(zero));
     
    8589  DES_cbc_cksum ((void *)hash, (void *)hash, sizeof(hash),
    8690                 &schedule, &zero);
    87   if (memcmp (p - 8, hash, 8) != 0) {
     91  if (ct_memcmp (p - 8, hash, 8) != 0) {
    8892    memset (deskey, 0, sizeof(deskey));
    8993    memset (&schedule, 0, sizeof(schedule));
     
    96100
    97101  p -= 16;
    98   DES_set_key_unchecked (&deskey, &schedule);
    99   DES_cbc_encrypt ((void *)p, (void *)p, 8,
    100                    &schedule, (DES_cblock *)hash, DES_DECRYPT);
     102
     103  EVP_CIPHER_CTX_init(&des_ctx);
     104  EVP_CipherInit_ex(&des_ctx, EVP_des_cbc(), NULL, key->keyvalue.data, hash, 0);
     105  EVP_Cipher(&des_ctx, p, p, 8);
     106  EVP_CIPHER_CTX_cleanup(&des_ctx);
    101107
    102108  memset (deskey, 0, sizeof(deskey));
     
    107113
    108114  if (context_handle->more_flags & LOCAL)
    109       cmp = memcmp(&seq[4], "\xff\xff\xff\xff", 4);
     115      cmp = ct_memcmp(&seq[4], "\xff\xff\xff\xff", 4);
    110116  else
    111       cmp = memcmp(&seq[4], "\x00\x00\x00\x00", 4);
     117      cmp = ct_memcmp(&seq[4], "\x00\x00\x00\x00", 4);
    112118
    113119  if (cmp != 0) {
     
    126132  return GSS_S_COMPLETE;
    127133}
     134#endif
    128135
    129136static OM_uint32
     
    208215
    209216  if (context_handle->more_flags & LOCAL)
    210       cmp = memcmp(&seq[4], "\xff\xff\xff\xff", 4);
     217      cmp = ct_memcmp(&seq[4], "\xff\xff\xff\xff", 4);
    211218  else
    212       cmp = memcmp(&seq[4], "\x00\x00\x00\x00", 4);
     219      cmp = ct_memcmp(&seq[4], "\x00\x00\x00\x00", 4);
    213220
    214221  krb5_data_free (&seq_data);
     
    293300    switch (keytype) {
    294301    case KEYTYPE_DES :
     302#ifdef HEIM_WEAK_CRYPTO
    295303        ret = verify_mic_des (minor_status, ctx, context,
    296304                              message_buffer, token_buffer, qop_state, key,
    297305                              type);
     306#else
     307      ret = GSS_S_FAILURE;
     308#endif
    298309        break;
    299310    case KEYTYPE_DES3 :
     
    317328}
    318329
    319 OM_uint32
     330OM_uint32 GSSAPI_CALLCONV
    320331_gsskrb5_verify_mic
    321332           (OM_uint32 * minor_status,
  • trunk/server/source4/heimdal/lib/gssapi/krb5/wrap.c

    r414 r745  
    135135}
    136136
    137 OM_uint32
     137OM_uint32 GSSAPI_CALLCONV
    138138_gsskrb5_wrap_size_limit (
    139139            OM_uint32 * minor_status,
     
    169169  switch (keytype) {
    170170  case KEYTYPE_DES :
     171#ifdef HEIM_WEAK_CRYPTO
    171172      ret = sub_wrap_size(req_output_size, max_input_size, 8, 22);
     173#else
     174      ret = GSS_S_FAILURE;
     175#endif
    172176      break;
    173177  case KEYTYPE_ARCFOUR:
     
    188192  return ret;
    189193}
     194
     195#ifdef HEIM_WEAK_CRYPTO
    190196
    191197static OM_uint32
     
    203209{
    204210  u_char *p;
    205   MD5_CTX md5;
     211  EVP_MD_CTX *md5;
    206212  u_char hash[16];
    207213  DES_key_schedule schedule;
     214  EVP_CIPHER_CTX des_ctx;
    208215  DES_cblock deskey;
    209216  DES_cblock zero;
     
    263270
    264271  /* checksum */
    265   MD5_Init (&md5);
    266   MD5_Update (&md5, p - 24, 8);
    267   MD5_Update (&md5, p, datalen);
    268   MD5_Final (hash, &md5);
     272  md5 = EVP_MD_CTX_create();
     273  EVP_DigestInit_ex(md5, EVP_md5(), NULL);
     274  EVP_DigestUpdate(md5, p - 24, 8);
     275  EVP_DigestUpdate(md5, p, datalen);
     276  EVP_DigestFinal_ex(md5, hash, NULL);
     277  EVP_MD_CTX_destroy(md5);
    269278
    270279  memset (&zero, 0, sizeof(zero));
     
    290299          4);
    291300
    292   DES_set_key_unchecked (&deskey, &schedule);
    293   DES_cbc_encrypt ((void *)p, (void *)p, 8,
    294                    &schedule, (DES_cblock *)(p + 8), DES_ENCRYPT);
     301  EVP_CIPHER_CTX_init(&des_ctx);
     302  EVP_CipherInit_ex(&des_ctx, EVP_des_cbc(), NULL, key->keyvalue.data, p + 8, 1);
     303  EVP_Cipher(&des_ctx, p, p, 8);
     304  EVP_CIPHER_CTX_cleanup(&des_ctx);
    295305
    296306  krb5_auth_con_setlocalseqnumber (context,
     
    307317      for (i = 0; i < sizeof(deskey); ++i)
    308318          deskey[i] ^= 0xf0;
    309       DES_set_key_unchecked (&deskey, &schedule);
    310       memset (&zero, 0, sizeof(zero));
    311       DES_cbc_encrypt ((void *)p,
    312                        (void *)p,
    313                        datalen,
    314                        &schedule,
    315                        &zero,
    316                        DES_ENCRYPT);
     319
     320      EVP_CIPHER_CTX_init(&des_ctx);
     321      EVP_CipherInit_ex(&des_ctx, EVP_des_cbc(), NULL, deskey, zero, 1);
     322      EVP_Cipher(&des_ctx, p, p, datalen);
     323      EVP_CIPHER_CTX_cleanup(&des_ctx);
    317324  }
    318325  memset (deskey, 0, sizeof(deskey));
     
    324331  return GSS_S_COMPLETE;
    325332}
     333
     334#endif
    326335
    327336static OM_uint32
     
    516525}
    517526
    518 OM_uint32 _gsskrb5_wrap
     527OM_uint32 GSSAPI_CALLCONV
     528_gsskrb5_wrap
    519529           (OM_uint32 * minor_status,
    520530            const gss_ctx_id_t context_handle,
     
    553563  switch (keytype) {
    554564  case KEYTYPE_DES :
     565#ifdef HEIM_WEAK_CRYPTO
    555566      ret = wrap_des (minor_status, ctx, context, conf_req_flag,
    556567                      qop_req, input_message_buffer, conf_state,
    557568                      output_message_buffer, key);
     569#else
     570      ret = GSS_S_FAILURE;
     571#endif
    558572      break;
    559573  case KEYTYPE_DES3 :
  • trunk/server/source4/heimdal/lib/gssapi/mech/context.c

    r414 r745  
    11#include "mech_locl.h"
    22#include "heim_threads.h"
    3 
    4 RCSID("$Id$");
    53
    64struct mg_thread_ctx {
     
    8886        if (value != mg->maj_stat || mg->maj_error.length == 0)
    8987            break;
    90         string->value = malloc(mg->maj_error.length);
     88        string->value = malloc(mg->maj_error.length + 1);
    9189        string->length = mg->maj_error.length;
    9290        memcpy(string->value, mg->maj_error.value, mg->maj_error.length);
     91        ((char *) string->value)[string->length] = '\0';
    9392        return GSS_S_COMPLETE;
    9493    }
     
    9695        if (value != mg->min_stat || mg->min_error.length == 0)
    9796            break;
    98         string->value = malloc(mg->min_error.length);
     97        string->value = malloc(mg->min_error.length + 1);
    9998        string->length = mg->min_error.length;
    10099        memcpy(string->value, mg->min_error.value, mg->min_error.length);
     100        ((char *) string->value)[string->length] = '\0';
    101101        return GSS_S_COMPLETE;
    102102    }
  • trunk/server/source4/heimdal/lib/gssapi/mech/cred.h

    r414 r745  
    2929
    3030struct _gss_mechanism_cred {
    31         SLIST_ENTRY(_gss_mechanism_cred) gmc_link;
     31        HEIM_SLIST_ENTRY(_gss_mechanism_cred) gmc_link;
    3232        gssapi_mech_interface   gmc_mech;       /* mechanism ops for MC */
    3333        gss_OID                 gmc_mech_oid;   /* mechanism oid for MC */
    3434        gss_cred_id_t           gmc_cred;       /* underlying MC */
    3535};
    36 SLIST_HEAD(_gss_mechanism_cred_list, _gss_mechanism_cred);
     36HEIM_SLIST_HEAD(_gss_mechanism_cred_list, _gss_mechanism_cred);
    3737
    3838struct _gss_cred {
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_accept_sec_context.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    3231static OM_uint32
     
    143142
    144143
    145 OM_uint32 gss_accept_sec_context(OM_uint32 *minor_status,
     144GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
     145gss_accept_sec_context(OM_uint32 *minor_status,
    146146    gss_ctx_id_t *context_handle,
    147147    const gss_cred_id_t acceptor_cred_handle,
     
    162162        gss_cred_id_t acceptor_mc, delegated_mc;
    163163        gss_name_t src_mn;
     164        gss_OID mech_ret_type = NULL;
    164165
    165166        *minor_status = 0;
     
    209210
    210211        if (cred) {
    211                 SLIST_FOREACH(mc, &cred->gc_mc, gmc_link)
     212                HEIM_SLIST_FOREACH(mc, &cred->gc_mc, gmc_link)
    212213                        if (mc->gmc_mech == m)
    213214                                break;
     
    229230            input_chan_bindings,
    230231            &src_mn,
    231             mech_type,
     232            &mech_ret_type,
    232233            output_token,
    233234            &mech_ret_flags,
     
    242243        }
    243244
     245        if (mech_type)
     246            *mech_type = mech_ret_type;
     247
    244248        if (src_name && src_mn) {
    245249                /*
     
    261265                if (!delegated_cred_handle) {
    262266                        m->gm_release_cred(minor_status, &delegated_mc);
    263                         if (ret_flags)
    264                                 *ret_flags &= ~GSS_C_DELEG_FLAG;
     267                        mech_ret_flags &=
     268                            ~(GSS_C_DELEG_FLAG|GSS_C_DELEG_POLICY_FLAG);
     269                } else if (gss_oid_equal(mech_ret_type, &m->gm_mech_oid) == 0) {
     270                        /*
     271                         * If the returned mech_type is not the same
     272                         * as the mech, assume its pseudo mech type
     273                         * and the returned type is already a
     274                         * mech-glue object
     275                         */
     276                        *delegated_cred_handle = delegated_mc;
     277
    265278                } else if (delegated_mc) {
    266279                        struct _gss_cred *dcred;
     
    273286                                return (GSS_S_FAILURE);
    274287                        }
    275                         SLIST_INIT(&dcred->gc_mc);
     288                        HEIM_SLIST_INIT(&dcred->gc_mc);
    276289                        dmc = malloc(sizeof(struct _gss_mechanism_cred));
    277290                        if (!dmc) {
     
    284297                        dmc->gmc_mech_oid = &m->gm_mech_oid;
    285298                        dmc->gmc_cred = delegated_mc;
    286                         SLIST_INSERT_HEAD(&dcred->gc_mc, dmc, gmc_link);
     299                        HEIM_SLIST_INSERT_HEAD(&dcred->gc_mc, dmc, gmc_link);
    287300
    288301                        *delegated_cred_handle = (gss_cred_id_t) dcred;
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_acquire_cred.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    32 OM_uint32 GSSAPI_LIB_FUNCTION
     31GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3332gss_acquire_cred(OM_uint32 *minor_status,
    3433    const gss_name_t desired_name,
     
    9291                return (GSS_S_FAILURE);
    9392        }
    94         SLIST_INIT(&cred->gc_mc);
     93        HEIM_SLIST_INIT(&cred->gc_mc);
    9594
    9695        if (mechs == GSS_C_NO_OID_SET)
     
    147146                }
    148147
    149                 SLIST_INSERT_HEAD(&cred->gc_mc, mc, gmc_link);
     148                HEIM_SLIST_INSERT_HEAD(&cred->gc_mc, mc, gmc_link);
    150149        }
    151150
     
    154153         * an error.
    155154         */
    156         if (!SLIST_FIRST(&cred->gc_mc)) {
     155        if (!HEIM_SLIST_FIRST(&cred->gc_mc)) {
    157156                free(cred);
    158157                if (actual_mechs)
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_add_cred.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    3231static struct _gss_mechanism_cred *
     
    7271}
    7372
    74 OM_uint32 GSSAPI_LIB_FUNCTION
     73GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    7574gss_add_cred(OM_uint32 *minor_status,
    7675    const gss_cred_id_t input_cred_handle,
     
    108107                return (GSS_S_FAILURE);
    109108        }
    110         SLIST_INIT(&new_cred->gc_mc);
     109        HEIM_SLIST_INIT(&new_cred->gc_mc);
    111110
    112111        /*
     
    118117        target_mc = 0;
    119118        if (cred) {
    120                 SLIST_FOREACH(mc, &cred->gc_mc, gmc_link) {
     119                HEIM_SLIST_FOREACH(mc, &cred->gc_mc, gmc_link) {
    121120                        if (gss_oid_equal(mc->gmc_mech_oid, desired_mech)) {
    122121                                target_mc = mc;
     
    129128                                return (GSS_S_FAILURE);
    130129                        }
    131                         SLIST_INSERT_HEAD(&new_cred->gc_mc, copy_mc, gmc_link);
     130                        HEIM_SLIST_INSERT_HEAD(&new_cred->gc_mc, copy_mc, gmc_link);
    132131                }
    133132        }
     
    180179                return (major_status);
    181180        }
    182         SLIST_INSERT_HEAD(&new_cred->gc_mc, mc, gmc_link);
     181        HEIM_SLIST_INSERT_HEAD(&new_cred->gc_mc, mc, gmc_link);
    183182        *output_cred_handle = (gss_cred_id_t) new_cred;
    184183
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_add_oid_set_member.c

    r414 r745  
    3333
    3434#include "mech_locl.h"
    35 RCSID("$Id$");
    3635
    37 OM_uint32 GSSAPI_LIB_FUNCTION
     36/**
     37 * Add a oid to the oid set, function does not make a copy of the oid,
     38 * so the pointer to member_oid needs to be stable for the whole time
     39 * oid_set is used.
     40 *
     41 * If there is a duplicate member of the oid, the new member is not
     42 * added to to the set.
     43 *
     44 * @param minor_status minor status code.
     45 * @param member_oid member to add to the oid set
     46 * @param oid_set oid set to add the member too
     47 *
     48 * @returns a gss_error code, see gss_display_status() about printing
     49 *          the error code.
     50 *       
     51 * @ingroup gssapi
     52 */
     53
     54GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3855gss_add_oid_set_member (OM_uint32 * minor_status,
    3956                        const gss_OID member_oid,
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_aeap.c

    r414 r745  
    4444
    4545
    46 OM_uint32 GSSAPI_LIB_FUNCTION
     46GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    4747gss_wrap_iov(OM_uint32 * minor_status,
    4848             gss_ctx_id_t  context_handle,
     
    8282 */
    8383
    84 OM_uint32 GSSAPI_LIB_FUNCTION
     84GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    8585gss_unwrap_iov(OM_uint32 *minor_status,
    8686               gss_ctx_id_t context_handle,
     
    125125 */
    126126
    127 OM_uint32 GSSAPI_LIB_FUNCTION
     127GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    128128gss_wrap_iov_length(OM_uint32 * minor_status,
    129129                    gss_ctx_id_t context_handle,
     
    158158/**
    159159 * Free all buffer allocated by gss_wrap_iov() or gss_unwrap_iov() by
    160  * looking at the GSS_IOV_BUFFER_TYPE_FLAG_ALLOCATED flag.
    161  *
    162  * @ingroup gssapi
    163  */
    164 
    165 OM_uint32 GSSAPI_LIB_FUNCTION
     160 * looking at the GSS_IOV_BUFFER_FLAG_ALLOCATED flag.
     161 *
     162 * @ingroup gssapi
     163 */
     164
     165GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    166166gss_release_iov_buffer(OM_uint32 *minor_status,
    167167                       gss_iov_buffer_desc *iov,
     
    177177
    178178    for (i = 0; i < iov_count; i++) {
    179         if ((iov[i].type & GSS_IOV_BUFFER_TYPE_FLAG_ALLOCATED) == 0)
     179        if ((iov[i].type & GSS_IOV_BUFFER_FLAG_ALLOCATED) == 0)
    180180            continue;
    181181        gss_release_buffer(&junk, &iov[i].buffer);
    182         iov[i].type &= ~GSS_IOV_BUFFER_TYPE_FLAG_ALLOCATED;
     182        iov[i].type &= ~GSS_IOV_BUFFER_FLAG_ALLOCATED;
    183183    }
    184184    return GSS_S_COMPLETE;
     
    195195 */
    196196
    197 static gss_OID_desc gss_c_attr_stream_sizes_desc =
     197gss_OID_desc GSSAPI_LIB_FUNCTION __gss_c_attr_stream_sizes_oid_desc =
    198198    {10, rk_UNCONST("\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x03")};
    199199
    200 gss_OID GSSAPI_LIB_VARIABLE GSS_C_ATTR_STREAM_SIZES =
    201     &gss_c_attr_stream_sizes_desc;
    202 
    203 OM_uint32 GSSAPI_LIB_FUNCTION
     200GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    204201gss_context_query_attributes(OM_uint32 *minor_status,
    205                              gss_OID attribute,
     202                             const gss_ctx_id_t context_handle,
     203                             const gss_OID attribute,
    206204                             void *data,
    207205                             size_t len)
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_buffer_set.c

    r414 r745  
    3232
    3333#include "mech_locl.h"
    34 RCSID("$Id$");
    3534
    36 OM_uint32 GSSAPI_LIB_FUNCTION
     35GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3736gss_create_empty_buffer_set
    3837           (OM_uint32 * minor_status,
     
    5655}
    5756
    58 OM_uint32 GSSAPI_LIB_FUNCTION
     57GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    5958gss_add_buffer_set_member
    6059           (OM_uint32 * minor_status,
     
    9897}
    9998
    100 OM_uint32 GSSAPI_LIB_FUNCTION
     99GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    101100gss_release_buffer_set(OM_uint32 * minor_status,
    102101                       gss_buffer_set_t *buffer_set)
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_canonicalize_name.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    3231/**
     
    5453 */
    5554
    56 OM_uint32 GSSAPI_LIB_FUNCTION
     55GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    5756gss_canonicalize_name(OM_uint32 *minor_status,
    5857    const gss_name_t input_name,
     
    101100        }
    102101
    103         SLIST_INIT(&name->gn_mn);
     102        HEIM_SLIST_INIT(&name->gn_mn);
    104103        mn->gmn_mech = m;
    105104        mn->gmn_mech_oid = &m->gm_mech_oid;
    106105        mn->gmn_name = new_canonical_name;
    107         SLIST_INSERT_HEAD(&name->gn_mn, mn, gmn_link);
     106        HEIM_SLIST_INSERT_HEAD(&name->gn_mn, mn, gmn_link);
    108107
    109108        *output_name = (gss_name_t) name;
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_compare_name.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    32 OM_uint32 GSSAPI_LIB_FUNCTION
     31GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3332gss_compare_name(OM_uint32 *minor_status,
    3433    const gss_name_t name1_arg,
     
    5756                struct _gss_mechanism_name *mn2;
    5857
    59                 SLIST_FOREACH(mn1, &name1->gn_mn, gmn_link) {
     58                HEIM_SLIST_FOREACH(mn1, &name1->gn_mn, gmn_link) {
    6059                        OM_uint32 major_status;
    6160
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_context_time.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    32 OM_uint32 GSSAPI_LIB_FUNCTION
     31GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3332gss_context_time(OM_uint32 *minor_status,
    3433    const gss_ctx_id_t context_handle,
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_create_empty_oid_set.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    32 OM_uint32 GSSAPI_LIB_FUNCTION
     31GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3332gss_create_empty_oid_set(OM_uint32 *minor_status,
    3433    gss_OID_set *oid_set)
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_cred.c

    r414 r745  
    4343*/
    4444
    45 OM_uint32 GSSAPI_LIB_FUNCTION
     45GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    4646gss_export_cred(OM_uint32 * minor_status,
    4747                gss_cred_id_t cred_handle,
     
    6363    }
    6464
    65     SLIST_FOREACH(mc, &cred->gc_mc, gmc_link) {
     65    HEIM_SLIST_FOREACH(mc, &cred->gc_mc, gmc_link) {
    6666        if (mc->gmc_mech->gm_export_cred == NULL) {
    6767            *minor_status = 0;
     
    7676    }
    7777
    78     SLIST_FOREACH(mc, &cred->gc_mc, gmc_link) {
     78    HEIM_SLIST_FOREACH(mc, &cred->gc_mc, gmc_link) {
    7979
    8080        major = mc->gmc_mech->gm_export_cred(minor_status,
     
    108108}
    109109
    110 OM_uint32 GSSAPI_LIB_FUNCTION
     110GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    111111gss_import_cred(OM_uint32 * minor_status,
    112112                gss_buffer_t token,
     
    139139        return GSS_S_FAILURE;
    140140    }
    141     SLIST_INIT(&cred->gc_mc);
     141    HEIM_SLIST_INIT(&cred->gc_mc);
    142142
    143143    *cred_handle = (gss_cred_id_t)cred;
     
    202202        mc->gmc_cred = mcred;
    203203
    204         SLIST_INSERT_HEAD(&cred->gc_mc, mc, gmc_link);
     204        HEIM_SLIST_INSERT_HEAD(&cred->gc_mc, mc, gmc_link);
    205205    }
    206206    krb5_storage_free(sp);
    207207    sp = NULL;
    208208
    209     if (SLIST_EMPTY(&cred->gc_mc)) {
     209    if (HEIM_SLIST_EMPTY(&cred->gc_mc)) {
    210210        major = GSS_S_NO_CRED;
    211211        goto out;
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_decapsulate_token.c

    r414 r745  
    3333
    3434#include "mech_locl.h"
    35 RCSID("$Id$");
    3635
    37 OM_uint32 GSSAPI_LIB_FUNCTION
    38 gss_decapsulate_token(gss_buffer_t input_token,
    39                       gss_OID oid,
     36GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
     37gss_decapsulate_token(const gss_buffer_t input_token,
     38                      const gss_OID oid,
    4039                      gss_buffer_t output_token)
    4140{
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_delete_sec_context.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    32 OM_uint32 GSSAPI_LIB_FUNCTION
     31GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3332gss_delete_sec_context(OM_uint32 *minor_status,
    3433    gss_ctx_id_t *context_handle,
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_display_name.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    32 OM_uint32 GSSAPI_LIB_FUNCTION
     31GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3332gss_display_name(OM_uint32 *minor_status,
    3433    const gss_name_t input_name,
     
    6968                return (GSS_S_COMPLETE);
    7069        } else {
    71                 SLIST_FOREACH(mn, &name->gn_mn, gmn_link) {
     70                HEIM_SLIST_FOREACH(mn, &name->gn_mn, gmn_link) {
    7271                        major_status = mn->gmn_mech->gm_display_name(
    7372                                minor_status, mn->gmn_name,
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_display_status.c

    r414 r745  
    6060
    6161#include "mech_locl.h"
    62 RCSID("$Id$");
    6362
    6463static const char *
     
    137136
    138137
    139 OM_uint32 GSSAPI_LIB_FUNCTION
     138GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    140139gss_display_status(OM_uint32 *minor_status,
    141140    OM_uint32 status_value,
     
    162161        switch (status_type) {
    163162        case GSS_C_GSS_CODE: {
    164                 char *buf;
     163                char *buf = NULL;
     164                int e;
    165165
    166166                if (GSS_SUPPLEMENTARY_INFO(status_value))
    167                     asprintf(&buf, "%s", supplementary_error(
     167                    e = asprintf(&buf, "%s", supplementary_error(
    168168                        GSS_SUPPLEMENTARY_INFO(status_value)));
    169169                else
    170                     asprintf (&buf, "%s %s",
     170                    e = asprintf (&buf, "%s %s",
    171171                        calling_error(GSS_CALLING_ERROR(status_value)),
    172172                        routine_error(GSS_ROUTINE_ERROR(status_value)));
    173173
    174                 if (buf == NULL)
     174                if (e < 0 || buf == NULL)
    175175                    break;
    176176
     
    183183                OM_uint32 maj_junk, min_junk;
    184184                gss_buffer_desc oid;
    185                 char *buf;
     185                char *buf = NULL;
     186                int e;
    186187
    187188                maj_junk = gss_oid_to_str(&min_junk, mech_type, &oid);
     
    190191                    oid.length = 7;
    191192                }
    192 
    193                 asprintf (&buf, "unknown mech-code %lu for mech %.*s",
     193               
     194                e = asprintf (&buf, "unknown mech-code %lu for mech %.*s",
    194195                          (unsigned long)status_value,
    195196                          (int)oid.length, (char *)oid.value);
     
    197198                    gss_release_buffer(&min_junk, &oid);
    198199
    199                 if (buf == NULL)
     200                if (e < 0 || buf == NULL)
    200201                    break;
    201202
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_duplicate_name.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    32 OM_uint32 gss_duplicate_name(OM_uint32 *minor_status,
     31GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
     32gss_duplicate_name(OM_uint32 *minor_status,
    3333    const gss_name_t src_name,
    3434    gss_name_t *dest_name)
     
    5454                new_name = (struct _gss_name *) *dest_name;
    5555               
    56                 SLIST_FOREACH(mn, &name->gn_mn, gmn_link) {
     56                HEIM_SLIST_FOREACH(mn, &name->gn_mn, gmn_link) {
    5757                    struct _gss_mechanism_name *mn2;
    5858                    _gss_find_mn(minor_status, new_name,
     
    6666                }
    6767                memset(new_name, 0, sizeof(struct _gss_name));
    68                 SLIST_INIT(&new_name->gn_mn);
     68                HEIM_SLIST_INIT(&new_name->gn_mn);
    6969                *dest_name = (gss_name_t) new_name;
    7070               
    71                 SLIST_FOREACH(mn, &name->gn_mn, gmn_link) {
     71                HEIM_SLIST_FOREACH(mn, &name->gn_mn, gmn_link) {
    7272                        struct _gss_mechanism_name *new_mn;
    7373                       
     
    8787                                continue;
    8888                        }
    89                         SLIST_INSERT_HEAD(&new_name->gn_mn, new_mn, gmn_link);
     89                        HEIM_SLIST_INSERT_HEAD(&new_name->gn_mn, new_mn, gmn_link);
    9090                }
    9191
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_duplicate_oid.c

    r414 r745  
    3333
    3434#include "mech_locl.h"
    35 RCSID("$Id$");
    3635
    37 OM_uint32 gss_duplicate_oid (
     36GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
     37gss_duplicate_oid (
    3838        OM_uint32 *minor_status,
    3939        gss_OID src_oid,
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_encapsulate_token.c

    r414 r745  
    3333
    3434#include "mech_locl.h"
    35 RCSID("$Id$");
    3635
    37 OM_uint32 GSSAPI_LIB_FUNCTION
    38 gss_encapsulate_token(gss_buffer_t input_token,
    39                       gss_OID oid,
     36GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
     37gss_encapsulate_token(const gss_buffer_t input_token,
     38                      const gss_OID oid,
    4039                      gss_buffer_t output_token)
    4140{
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_export_name.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    32 OM_uint32 GSSAPI_LIB_FUNCTION
     31GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3332gss_export_name(OM_uint32 *minor_status,
    3433    const gss_name_t input_name,
     
    4544         * list.
    4645         */
    47         mn = SLIST_FIRST(&name->gn_mn);
     46        mn = HEIM_SLIST_FIRST(&name->gn_mn);
    4847        if (!mn) {
    4948                *minor_status = 0;
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_export_sec_context.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    32 OM_uint32 GSSAPI_LIB_FUNCTION
     31GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3332gss_export_sec_context(OM_uint32 *minor_status,
    3433    gss_ctx_id_t *context_handle,
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_get_mic.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    32 OM_uint32 GSSAPI_LIB_FUNCTION
     31GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3332gss_get_mic(OM_uint32 *minor_status,
    3433    const gss_ctx_id_t context_handle,
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_import_name.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    3231static OM_uint32
     
    140139}
    141140
    142 OM_uint32 GSSAPI_LIB_FUNCTION
     141/**
     142 * Import a name internal or mechanism name
     143 *
     144 * Type of name and their format:
     145 * - GSS_C_NO_OID
     146 * - GSS_C_NT_USER_NAME
     147 * - GSS_C_NT_HOSTBASED_SERVICE
     148 * - GSS_C_NT_EXPORT_NAME
     149 * - GSS_C_NT_ANONYMOUS
     150 * - GSS_KRB5_NT_PRINCIPAL_NAME
     151 *
     152 * For more information about @ref internalVSmechname.
     153 *
     154 * @param minor_status minor status code
     155 * @param input_name_buffer import name buffer
     156 * @param input_name_type type of the import name buffer
     157 * @param output_name the resulting type, release with
     158 *        gss_release_name(), independent of input_name
     159 *
     160 * @returns a gss_error code, see gss_display_status() about printing
     161 *        the error code.
     162 * 
     163 * @ingroup gssapi
     164 */
     165
     166GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    143167gss_import_name(OM_uint32 *minor_status,
    144168    const gss_buffer_t input_name_buffer,
     
    186210        }
    187211
    188         SLIST_INIT(&name->gn_mn);
     212        HEIM_SLIST_INIT(&name->gn_mn);
    189213
    190214        major_status = _gss_copy_oid(minor_status,
     
    205229         */
    206230
    207         SLIST_FOREACH(m, &_gss_mechs, gm_link) {
     231        HEIM_SLIST_FOREACH(m, &_gss_mechs, gm_link) {
    208232                int present = 0;
    209233
     
    234258                mn->gmn_mech = &m->gm_mech;
    235259                mn->gmn_mech_oid = &m->gm_mech_oid;
    236                 SLIST_INSERT_HEAD(&name->gn_mn, mn, gmn_link);
     260                HEIM_SLIST_INSERT_HEAD(&name->gn_mn, mn, gmn_link);
    237261        }
    238262
     
    241265         */
    242266
    243         mn = SLIST_FIRST(&name->gn_mn);
     267        mn = HEIM_SLIST_FIRST(&name->gn_mn);
    244268        if (!mn) {
    245269                *minor_status = 0;
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_import_sec_context.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    32 OM_uint32 GSSAPI_LIB_FUNCTION
     31GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3332gss_import_sec_context(OM_uint32 *minor_status,
    3433    const gss_buffer_t interprocess_token,
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_indicate_mechs.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    32 OM_uint32 GSSAPI_LIB_FUNCTION
     31GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3332gss_indicate_mechs(OM_uint32 *minor_status,
    3433    gss_OID_set *mech_set)
     
    4544                return (major_status);
    4645       
    47         SLIST_FOREACH(m, &_gss_mechs, gm_link) {
     46        HEIM_SLIST_FOREACH(m, &_gss_mechs, gm_link) {
    4847                if (m->gm_mech.gm_indicate_mechs) {
    4948                        major_status = m->gm_mech.gm_indicate_mechs(
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_init_sec_context.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    3231static gss_cred_id_t
     
    3938                return GSS_C_NO_CREDENTIAL;
    4039
    41         SLIST_FOREACH(mc, &cred->gc_mc, gmc_link) {
     40        HEIM_SLIST_FOREACH(mc, &cred->gc_mc, gmc_link) {
    4241                if (gss_oid_equal(mech_type, mc->gmc_mech_oid))
    4342                        return mc->gmc_cred;
     
    4645}
    4746
    48 OM_uint32 GSSAPI_LIB_FUNCTION
     47/**
     48 * As the initiator build a context with an acceptor.
     49 *
     50 * Returns in the major
     51 * - GSS_S_COMPLETE - if the context if build
     52 * - GSS_S_CONTINUE_NEEDED -  if the caller needs  to continue another
     53 *      round of gss_i nit_sec_context
     54 * - error code - any other error code
     55 *
     56 * @param minor_status minor status code.
     57 *
     58 * @param initiator_cred_handle the credential to use when building
     59 *        the context, if GSS_C_NO_CREDENTIAL is passed, the default
     60 *        credential for the mechanism will be used.
     61 *
     62 * @param context_handle a pointer to a context handle, will be
     63 *        returned as long as there is not an error.
     64 *
     65 * @param target_name the target name of acceptor, created using
     66 *        gss_import_name(). The name is can be of any name types the
     67 *        mechanism supports, check supported name types with
     68 *        gss_inquire_names_for_mech().
     69 *
     70 * @param input_mech_type mechanism type to use, if GSS_C_NO_OID is
     71 *        used, Kerberos (GSS_KRB5_MECHANISM) will be tried. Other
     72 *        available mechanism are listed in the @ref gssapi_mechs_intro
     73 *        section.
     74 *
     75 * @param req_flags flags using when building the context, see @ref
     76 *        gssapi_context_flags
     77 *
     78 * @param time_req time requested this context should be valid in
     79 *        seconds, common used value is GSS_C_INDEFINITE
     80 *
     81 * @param input_chan_bindings Channel bindings used, if not exepected
     82 *        otherwise, used GSS_C_NO_CHANNEL_BINDINGS
     83 *
     84 * @param input_token input token sent from the acceptor, for the
     85 *        initial packet the buffer of { NULL, 0 } should be used.
     86 *
     87 * @param actual_mech_type the actual mech used, MUST NOT be freed
     88 *        since it pointing to static memory.
     89 *
     90 * @param output_token if there is an output token, regardless of
     91 *        complete, continue_needed, or error it should be sent to the
     92 *        acceptor
     93 *
     94 * @param ret_flags return what flags was negotitated, caller should
     95 *        check if they are accetable. For example, if
     96 *        GSS_C_MUTUAL_FLAG was negotiated with the acceptor or not.
     97 *
     98 * @param time_rec amount of time this context is valid for
     99 *
     100 * @returns a gss_error code, see gss_display_status() about printing
     101 *          the error code.
     102 *       
     103 * @ingroup gssapi
     104 */
     105
     106
     107
     108GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    49109gss_init_sec_context(OM_uint32 * minor_status,
    50110    const gss_cred_id_t initiator_cred_handle,
     
    120180         * If we have a cred, find the cred for this mechanism.
    121181         */
    122         cred_handle = _gss_mech_cred_find(initiator_cred_handle, mech_type);
     182        if (m->gm_flags & GM_USE_MG_CRED)
     183                cred_handle = initiator_cred_handle;
     184        else
     185                cred_handle = _gss_mech_cred_find(initiator_cred_handle, mech_type);
    123186
    124187        major_status = m->gm_init_sec_context(minor_status,
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_inquire_context.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    32 OM_uint32 GSSAPI_LIB_FUNCTION
     31GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3332gss_inquire_context(OM_uint32 *minor_status,
    3433    const gss_ctx_id_t context_handle,
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_inquire_cred.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    3231#define AUSAGE 1
     
    4443}
    4544
    46 OM_uint32 GSSAPI_LIB_FUNCTION
     45GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    4746gss_inquire_cred(OM_uint32 *minor_status,
    4847    const gss_cred_id_t cred_handle,
     
    8079                        return (GSS_S_FAILURE);
    8180                }
    82                 SLIST_INIT(&name->gn_mn);
     81                HEIM_SLIST_INIT(&name->gn_mn);
    8382        } else {
    8483                name = NULL;
     
    9897                struct _gss_mechanism_cred *mc;
    9998
    100                 SLIST_FOREACH(mc, &cred->gc_mc, gmc_link) {
     99                HEIM_SLIST_FOREACH(mc, &cred->gc_mc, gmc_link) {
    101100                        gss_name_t mc_name;
    102101                        OM_uint32 mc_lifetime;
     
    118117                                mn->gmn_mech_oid = mc->gmc_mech_oid;
    119118                                mn->gmn_name = mc_name;
    120                                 SLIST_INSERT_HEAD(&name->gn_mn, mn, gmn_link);
     119                                HEIM_SLIST_INSERT_HEAD(&name->gn_mn, mn, gmn_link);
    121120                        } else {
    122121                                mc->gmc_mech->gm_release_name(minor_status,
     
    133132                }
    134133        } else {
    135                 SLIST_FOREACH(m, &_gss_mechs, gm_link) {
     134                HEIM_SLIST_FOREACH(m, &_gss_mechs, gm_link) {
    136135                        gss_name_t mc_name;
    137136                        OM_uint32 mc_lifetime;
     
    155154                                mn->gmn_mech_oid = &m->gm_mech_oid;
    156155                                mn->gmn_name = mc_name;
    157                                 SLIST_INSERT_HEAD(&name->gn_mn, mn, gmn_link);
     156                                HEIM_SLIST_INSERT_HEAD(&name->gn_mn, mn, gmn_link);
    158157                        } else if (mc_name) {
    159158                                m->gm_mech.gm_release_name(minor_status,
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_inquire_cred_by_mech.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    32 OM_uint32 GSSAPI_LIB_FUNCTION
     31GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3332gss_inquire_cred_by_mech(OM_uint32 *minor_status,
    3433    const gss_cred_id_t cred_handle,
     
    6261        if (cred_handle != GSS_C_NO_CREDENTIAL) {
    6362                struct _gss_cred *cred = (struct _gss_cred *) cred_handle;
    64                 SLIST_FOREACH(mcp, &cred->gc_mc, gmc_link)
     63                HEIM_SLIST_FOREACH(mcp, &cred->gc_mc, gmc_link)
    6564                        if (mcp->gmc_mech == m)
    6665                                break;
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_inquire_cred_by_oid.c

    r414 r745  
    3232
    3333#include "mech_locl.h"
    34 RCSID("$Id$");
    3534
    36 OM_uint32 GSSAPI_LIB_FUNCTION
     35GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3736gss_inquire_cred_by_oid (OM_uint32 *minor_status,
    3837                         const gss_cred_id_t cred_handle,
     
    5251                return GSS_S_NO_CRED;
    5352
    54         SLIST_FOREACH(mc, &cred->gc_mc, gmc_link) {
     53        HEIM_SLIST_FOREACH(mc, &cred->gc_mc, gmc_link) {
    5554                gss_buffer_set_t rset = GSS_C_NO_BUFFER_SET;
    5655                int i;
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_inquire_mechs_for_name.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    32 OM_uint32 GSSAPI_LIB_FUNCTION
     31GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3332gss_inquire_mechs_for_name(OM_uint32 *minor_status,
    3433    const gss_name_t input_name,
     
    5453         * the mechanism to the set.
    5554         */
    56         SLIST_FOREACH(m, &_gss_mechs, gm_link) {
     55        HEIM_SLIST_FOREACH(m, &_gss_mechs, gm_link) {
    5756                major_status = gss_inquire_names_for_mech(minor_status,
    5857                    &m->gm_mech_oid, &name_types);
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_inquire_names_for_mech.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    32 OM_uint32 GSSAPI_LIB_FUNCTION
     31GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3332gss_inquire_names_for_mech(OM_uint32 *minor_status,
    3433    const gss_OID mechanism,
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_inquire_sec_context_by_oid.c

    r414 r745  
    3232
    3333#include "mech_locl.h"
    34 RCSID("$Id$");
    3534
    36 OM_uint32 GSSAPI_LIB_FUNCTION
     35GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3736gss_inquire_sec_context_by_oid (OM_uint32 *minor_status,
    3837                                const gss_ctx_id_t context_handle,
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_krb5.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    3231#include <krb5.h>
     
    3433
    3534
    36 OM_uint32 GSSAPI_LIB_FUNCTION
     35GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3736gss_krb5_copy_ccache(OM_uint32 *minor_status,
    3837                     gss_cred_id_t cred,
     
    4443    krb5_ccache id;
    4544    OM_uint32 ret;
    46     char *str;
     45    char *str = NULL;
    4746
    4847    ret = gss_inquire_cred_by_oid(minor_status,
     
    6968                    (char *)data_set->elements[0].value);
    7069    gss_release_buffer_set(minor_status, &data_set);
    71     if (kret == -1) {
     70    if (kret < 0 || str == NULL) {
    7271        *minor_status = ENOMEM;
    7372        return GSS_S_FAILURE;
     
    9291}
    9392
    94 OM_uint32 GSSAPI_LIB_FUNCTION
     93GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    9594gss_krb5_import_cred(OM_uint32 *minor_status,
    9695                     krb5_ccache id,
     
    187186}
    188187
    189 OM_uint32 GSSAPI_LIB_FUNCTION
     188GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    190189gsskrb5_register_acceptor_identity(const char *identity)
    191190{
     
    199198        buffer.length = strlen(identity);
    200199
    201         SLIST_FOREACH(m, &_gss_mechs, gm_link) {
     200        HEIM_SLIST_FOREACH(m, &_gss_mechs, gm_link) {
    202201                if (m->gm_mech.gm_set_sec_context_option == NULL)
    203202                        continue;
     
    209208}
    210209
    211 OM_uint32 GSSAPI_LIB_FUNCTION
     210GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    212211krb5_gss_register_acceptor_identity(const char *identity)
    213212{
     
    216215
    217216
    218 OM_uint32 GSSAPI_LIB_FUNCTION
     217GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    219218gsskrb5_set_dns_canonicalize(int flag)
    220219{
     
    229228        buffer.length = sizeof(b);
    230229
    231         SLIST_FOREACH(m, &_gss_mechs, gm_link) {
     230        HEIM_SLIST_FOREACH(m, &_gss_mechs, gm_link) {
    232231                if (m->gm_mech.gm_set_sec_context_option == NULL)
    233232                        continue;
     
    261260}
    262261
    263 OM_uint32 GSSAPI_LIB_FUNCTION
     262GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    264263gss_krb5_export_lucid_sec_context(OM_uint32 *minor_status,
    265264                                  gss_ctx_id_t *context_handle,
     
    404403}
    405404
    406 OM_uint32 GSSAPI_LIB_FUNCTION
     405GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    407406gss_krb5_free_lucid_sec_context(OM_uint32 *minor_status, void *c)
    408407{
     
    432431 */
    433432
    434 OM_uint32 GSSAPI_LIB_FUNCTION
     433GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    435434gss_krb5_set_allowable_enctypes(OM_uint32 *minor_status,
    436435                                gss_cred_id_t cred,
     
    486485 */
    487486
    488 OM_uint32 GSSAPI_LIB_FUNCTION
     487GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    489488gsskrb5_set_send_to_kdc(struct gsskrb5_send_to_kdc *c)
    490489{
     
    503502    }
    504503
    505     SLIST_FOREACH(m, &_gss_mechs, gm_link) {
     504    HEIM_SLIST_FOREACH(m, &_gss_mechs, gm_link) {
    506505        if (m->gm_mech.gm_set_sec_context_option == NULL)
    507506            continue;
     
    517516 */
    518517
    519 OM_uint32 GSSAPI_LIB_FUNCTION
     518GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    520519gss_krb5_ccache_name(OM_uint32 *minor_status,
    521520                     const char *name,
     
    534533    buffer.length = strlen(name);
    535534
    536     SLIST_FOREACH(m, &_gss_mechs, gm_link) {
     535    HEIM_SLIST_FOREACH(m, &_gss_mechs, gm_link) {
    537536        if (m->gm_mech.gm_set_sec_context_option == NULL)
    538537            continue;
     
    549548 */
    550549
    551 OM_uint32 GSSAPI_LIB_FUNCTION
     550GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    552551gsskrb5_extract_authtime_from_sec_context(OM_uint32 *minor_status,
    553552                                          gss_ctx_id_t context_handle,
     
    604603 */
    605604
    606 OM_uint32 GSSAPI_LIB_FUNCTION
     605GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    607606gsskrb5_extract_authz_data_from_sec_context(OM_uint32 *minor_status,
    608607                                            gss_ctx_id_t context_handle,
     
    777776 */
    778777
    779 OM_uint32 GSSAPI_LIB_FUNCTION
     778GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    780779gsskrb5_extract_service_keyblock(OM_uint32 *minor_status,
    781780                                 gss_ctx_id_t context_handle,
     
    788787}
    789788
    790 OM_uint32 GSSAPI_LIB_FUNCTION
     789GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    791790gsskrb5_get_initiator_subkey(OM_uint32 *minor_status,
    792791                             gss_ctx_id_t context_handle,
     
    799798}
    800799
    801 OM_uint32 GSSAPI_LIB_FUNCTION
     800GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    802801gsskrb5_get_subkey(OM_uint32 *minor_status,
    803802                   gss_ctx_id_t context_handle,
     
    810809}
    811810
    812 OM_uint32 GSSAPI_LIB_FUNCTION
     811GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    813812gsskrb5_set_default_realm(const char *realm)
    814813{
     
    822821        buffer.length = strlen(realm);
    823822
    824         SLIST_FOREACH(m, &_gss_mechs, gm_link) {
     823        HEIM_SLIST_FOREACH(m, &_gss_mechs, gm_link) {
    825824                if (m->gm_mech.gm_set_sec_context_option == NULL)
    826825                        continue;
     
    832831}
    833832
    834 OM_uint32 GSSAPI_LIB_FUNCTION
     833GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    835834gss_krb5_get_tkt_flags(OM_uint32 *minor_status,
    836835                       gss_ctx_id_t context_handle,
     
    871870}
    872871
    873 OM_uint32 GSSAPI_LIB_FUNCTION
     872GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    874873gsskrb5_set_time_offset(int offset)
    875874{
     
    884883        buffer.length = sizeof(o);
    885884
    886         SLIST_FOREACH(m, &_gss_mechs, gm_link) {
     885        HEIM_SLIST_FOREACH(m, &_gss_mechs, gm_link) {
    887886                if (m->gm_mech.gm_set_sec_context_option == NULL)
    888887                        continue;
     
    894893}
    895894
    896 OM_uint32 GSSAPI_LIB_FUNCTION
     895GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    897896gsskrb5_get_time_offset(int *offset)
    898897{
     
    907906        buffer.length = sizeof(o);
    908907
    909         SLIST_FOREACH(m, &_gss_mechs, gm_link) {
     908        HEIM_SLIST_FOREACH(m, &_gss_mechs, gm_link) {
    910909                if (m->gm_mech.gm_set_sec_context_option == NULL)
    911910                        continue;
     
    922921}
    923922
    924 OM_uint32 GSSAPI_LIB_FUNCTION
     923GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    925924gsskrb5_plugin_register(struct gsskrb5_krb5_plugin *c)
    926925{
     
    934933    buffer.length = sizeof(*c);
    935934
    936     SLIST_FOREACH(m, &_gss_mechs, gm_link) {
     935    HEIM_SLIST_FOREACH(m, &_gss_mechs, gm_link) {
    937936        if (m->gm_mech.gm_set_sec_context_option == NULL)
    938937            continue;
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_mech_switch.c

    r414 r745  
    2929#include "mech_locl.h"
    3030#include <heim_threads.h>
    31 RCSID("$Id$");
    3231
    3332#ifndef _PATH_GSS_MECH
     
    178177        return 0;
    179178
    180     m = malloc(sizeof(*m));
     179    m = calloc(1, sizeof(*m));
    181180    if (m == NULL)
    182         return 1;
     181        return ENOMEM;
    183182    m->gm_so = NULL;
    184183    m->gm_mech = *mech;
     
    189188    /* pick up the oid sets of names */
    190189
    191     if (m->gm_mech.gm_inquire_names_for_mech) {
     190    if (m->gm_mech.gm_inquire_names_for_mech)
    192191        (*m->gm_mech.gm_inquire_names_for_mech)(&minor_status,
    193192            &m->gm_mech.gm_mech_oid, &m->gm_name_types);
    194     } else {
     193
     194    if (m->gm_name_types == NULL)
    195195        gss_create_empty_oid_set(&minor_status, &m->gm_name_types);
    196     }
    197 
    198     SLIST_INSERT_HEAD(&_gss_mechs, m, gm_link);
     196
     197    HEIM_SLIST_INSERT_HEAD(&_gss_mechs, m, gm_link);
    199198    return 0;
    200199}
     
    213212        struct _gss_mech_switch *m;
    214213        void            *so;
     214        gss_OID_desc    mech_oid;
     215        int             found;
    215216
    216217
    217218        HEIMDAL_MUTEX_lock(&_gss_mech_mutex);
    218219
    219         if (SLIST_FIRST(&_gss_mechs)) {
     220        if (HEIM_SLIST_FIRST(&_gss_mechs)) {
    220221                HEIMDAL_MUTEX_unlock(&_gss_mech_mutex);
    221222                return;
     
    242243
    243244        while (fgets(buf, sizeof(buf), fp)) {
     245                _gss_mo_init *mi;
     246
    244247                if (*buf == '#')
    245248                        continue;
     
    255258                        continue;
    256259
     260                if (_gss_string_to_oid(oid, &mech_oid))
     261                        continue;
     262
     263                /*
     264                 * Check for duplicates, already loaded mechs.
     265                 */
     266                found = 0;
     267                HEIM_SLIST_FOREACH(m, &_gss_mechs, gm_link) {
     268                        if (gss_oid_equal(&m->gm_mech.gm_mech_oid, &mech_oid)) {
     269                                found = 1;
     270                                free(mech_oid.elements);
     271                                break;
     272                        }
     273                }
     274                if (found)
     275                        continue;
     276
    257277#ifndef RTLD_LOCAL
    258278#define RTLD_LOCAL 0
    259279#endif
    260280
    261                 so = dlopen(lib, RTLD_LAZY | RTLD_LOCAL);
     281#ifndef RTLD_GROUP
     282#define RTLD_GROUP 0
     283#endif
     284
     285                so = dlopen(lib, RTLD_LAZY | RTLD_LOCAL | RTLD_GROUP);
    262286                if (!so) {
    263287/*                      fprintf(stderr, "dlopen: %s\n", dlerror()); */
     288                        free(mech_oid.elements);
    264289                        continue;
    265290                }
    266291
    267292                m = malloc(sizeof(*m));
    268                 if (!m)
     293                if (!m) {
     294                        free(mech_oid.elements);
    269295                        break;
     296                }
    270297                m->gm_so = so;
    271                 if (_gss_string_to_oid(oid, &m->gm_mech.gm_mech_oid)) {
    272                         free(m);
    273                         continue;
    274                 }
     298                m->gm_mech.gm_mech_oid = mech_oid;
     299                m->gm_mech.gm_flags = 0;
    275300               
    276301                major_status = gss_add_oid_set_member(&minor_status,
     
    319344                OPTSYM(unwrap_iov);
    320345                OPTSYM(wrap_iov_length);
    321 
    322                 SLIST_INSERT_HEAD(&_gss_mechs, m, gm_link);
     346                OPTSYM(display_name_ext);
     347                OPTSYM(inquire_name);
     348                OPTSYM(get_name_attribute);
     349                OPTSYM(set_name_attribute);
     350                OPTSYM(delete_name_attribute);
     351                OPTSYM(export_name_composite);
     352
     353                mi = dlsym(so, "gss_mo_init");
     354                if (mi != NULL) {
     355                        major_status = mi(&minor_status,
     356                                          &mech_oid,
     357                                          &m->gm_mech.gm_mo,
     358                                          &m->gm_mech.gm_mo_num);
     359                        if (GSS_ERROR(major_status))
     360                                goto bad;
     361                }
     362
     363                HEIM_SLIST_INSERT_HEAD(&_gss_mechs, m, gm_link);
    323364                continue;
    324365
     
    335376
    336377gssapi_mech_interface
    337 __gss_get_mechanism(gss_OID mech)
     378__gss_get_mechanism(gss_const_OID mech)
    338379{
    339380        struct _gss_mech_switch *m;
    340381
    341382        _gss_load_mech();
    342         SLIST_FOREACH(m, &_gss_mechs, gm_link) {
     383        HEIM_SLIST_FOREACH(m, &_gss_mechs, gm_link) {
    343384                if (gss_oid_equal(&m->gm_mech.gm_mech_oid, mech))
    344385                        return &m->gm_mech;
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_names.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    3231OM_uint32
     
    4039        *output_mn = NULL;
    4140
    42         SLIST_FOREACH(mn, &name->gn_mn, gmn_link) {
     41        HEIM_SLIST_FOREACH(mn, &name->gn_mn, gmn_link) {
    4342                if (gss_oid_equal(mech, mn->gmn_mech_oid))
    4443                        break;
     
    7473                mn->gmn_mech = m;
    7574                mn->gmn_mech_oid = &m->gm_mech_oid;
    76                 SLIST_INSERT_HEAD(&name->gn_mn, mn, gmn_link);
     75                HEIM_SLIST_INSERT_HEAD(&name->gn_mn, mn, gmn_link);
    7776        }
    7877        *output_mn = mn;
     
    101100        }
    102101
    103         SLIST_INIT(&name->gn_mn);
     102        HEIM_SLIST_INIT(&name->gn_mn);
    104103        mn->gmn_mech = m;
    105104        mn->gmn_mech_oid = &m->gm_mech_oid;
    106105        mn->gmn_name = new_mn;
    107         SLIST_INSERT_HEAD(&name->gn_mn, mn, gmn_link);
     106        HEIM_SLIST_INSERT_HEAD(&name->gn_mn, mn, gmn_link);
    108107
    109108        return (name);
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_oid_equal.c

    r414 r745  
    3333
    3434#include "mech_locl.h"
    35 RCSID("$Id$");
    3635
    37 int GSSAPI_LIB_FUNCTION
    38 gss_oid_equal(const gss_OID a, const gss_OID b)
     36/**
     37 * Compare two GSS-API OIDs with each other.
     38 *
     39 * GSS_C_NO_OID matches nothing, not even it-self.
     40 *
     41 * @param a first oid to compare
     42 * @param b second oid to compare
     43 *
     44 * @return non-zero when both oid are the same OID, zero when they are
     45 *         not the same.
     46 *         
     47 * @ingroup gssapi
     48 */
     49
     50GSSAPI_LIB_FUNCTION int GSSAPI_LIB_CALL
     51gss_oid_equal(gss_const_OID a, gss_const_OID b)
    3952{
    40     if (a == b)
     53    if (a == b && a != GSS_C_NO_OID)
    4154        return 1;
    4255    if (a == GSS_C_NO_OID || b == GSS_C_NO_OID || a->length != b->length)
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_oid_to_str.c

    r414 r745  
    3333
    3434#include "mech_locl.h"
    35 RCSID("$Id$");
    3635
    37 OM_uint32 GSSAPI_LIB_FUNCTION
     36GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3837gss_oid_to_str(OM_uint32 *minor_status, gss_OID oid, gss_buffer_t oid_str)
    3938{
     
    6766    return GSS_S_COMPLETE;
    6867}
     68
     69GSSAPI_LIB_FUNCTION const char * GSSAPI_LIB_CALL
     70gss_oid_to_name(gss_const_OID oid)
     71{
     72    size_t i;
     73
     74    for (i = 0; _gss_ont_mech[i].oid; i++) {
     75        if (gss_oid_equal(oid, _gss_ont_mech[i].oid))
     76            return _gss_ont_mech[i].name;
     77    }
     78    return NULL;
     79}
     80
     81GSSAPI_LIB_FUNCTION gss_OID GSSAPI_LIB_CALL
     82gss_name_to_oid(const char *name)
     83{
     84    size_t i, partial = (size_t)-1;
     85
     86    for (i = 0; _gss_ont_mech[i].oid; i++) {
     87        if (strcasecmp(name, _gss_ont_mech[i].short_desc) == 0)
     88            return _gss_ont_mech[i].oid;
     89        if (strncasecmp(name, _gss_ont_mech[i].short_desc, strlen(name)) == 0) {
     90            if (partial != (size_t)-1)
     91                return NULL;
     92            partial = i;
     93        }
     94    }
     95    if (partial != (size_t)-1)
     96        return _gss_ont_mech[partial].oid;
     97    return NULL;
     98}
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_process_context_token.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    32 OM_uint32 GSSAPI_LIB_FUNCTION
     31GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3332gss_process_context_token(OM_uint32 *minor_status,
    3433    const gss_ctx_id_t context_handle,
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_pseudo_random.c

    r414 r745  
    3535
    3636#include "mech_locl.h"
    37 RCSID("$Id$");
    3837
    39 OM_uint32 GSSAPI_LIB_FUNCTION
     38GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    4039gss_pseudo_random(OM_uint32 *minor_status,
    4140                  gss_ctx_id_t context,
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_release_buffer.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    32 OM_uint32 GSSAPI_LIB_FUNCTION
     31GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3332gss_release_buffer(OM_uint32 *minor_status,
    3433                   gss_buffer_t buffer)
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_release_cred.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    32 OM_uint32 GSSAPI_LIB_FUNCTION
     31/**
     32 * Release a credentials
     33 *
     34 * Its ok to release the GSS_C_NO_CREDENTIAL/NULL credential, it will
     35 * return a GSS_S_COMPLETE error code. On return cred_handle is set ot
     36 * GSS_C_NO_CREDENTIAL.
     37 *
     38 * Example:
     39 *
     40 * @code
     41 * gss_cred_id_t cred = GSS_C_NO_CREDENTIAL;
     42 * major = gss_release_cred(&minor, &cred);
     43 * @endcode
     44 *
     45 * @param minor_status minor status return code, mech specific
     46 * @param cred_handle a pointer to the credential too release
     47 *
     48 * @return an gssapi error code
     49 *
     50 * @ingroup gssapi
     51 */
     52
     53GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3354gss_release_cred(OM_uint32 *minor_status, gss_cred_id_t *cred_handle)
    3455{
     
    3960            return (GSS_S_COMPLETE);
    4061
    41         while (SLIST_FIRST(&cred->gc_mc)) {
    42                 mc = SLIST_FIRST(&cred->gc_mc);
    43                 SLIST_REMOVE_HEAD(&cred->gc_mc, gmc_link);
     62        while (HEIM_SLIST_FIRST(&cred->gc_mc)) {
     63                mc = HEIM_SLIST_FIRST(&cred->gc_mc);
     64                HEIM_SLIST_REMOVE_HEAD(&cred->gc_mc, gmc_link);
    4465                mc->gmc_mech->gm_release_cred(minor_status, &mc->gmc_cred);
    4566                free(mc);
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_release_name.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    32 OM_uint32 GSSAPI_LIB_FUNCTION
     31/**
     32 * Free a name
     33 *
     34 * import_name can point to NULL or be NULL, or a pointer to a
     35 * gss_name_t structure. If it was a pointer to gss_name_t, the
     36 * pointer will be set to NULL on success and failure.
     37 *
     38 * @param minor_status minor status code
     39 * @param input_name name to free
     40 *
     41 * @returns a gss_error code, see gss_display_status() about printing
     42 *        the error code.
     43 * 
     44 * @ingroup gssapi
     45 */
     46GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3347gss_release_name(OM_uint32 *minor_status,
    3448    gss_name_t *input_name)
     
    4559        if (name->gn_type.elements)
    4660                free(name->gn_type.elements);
    47         while (SLIST_FIRST(&name->gn_mn)) {
     61        while (HEIM_SLIST_FIRST(&name->gn_mn)) {
    4862                struct _gss_mechanism_name *mn;
    49                 mn = SLIST_FIRST(&name->gn_mn);
    50                 SLIST_REMOVE_HEAD(&name->gn_mn, gmn_link);
     63                mn = HEIM_SLIST_FIRST(&name->gn_mn);
     64                HEIM_SLIST_REMOVE_HEAD(&name->gn_mn, gmn_link);
    5165                mn->gmn_mech->gm_release_name(minor_status,
    5266                                              &mn->gmn_name);
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_release_oid.c

    r414 r745  
    3434#include "mech_locl.h"
    3535
    36 RCSID("$Id$");
    3736
    38 OM_uint32 GSSAPI_LIB_FUNCTION
     37GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3938gss_release_oid(OM_uint32 *minor_status, gss_OID *oid)
    4039{
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_release_oid_set.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    32 OM_uint32 GSSAPI_LIB_FUNCTION
     31GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3332gss_release_oid_set(OM_uint32 *minor_status,
    3433    gss_OID_set *set)
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_seal.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    32 OM_uint32 GSSAPI_LIB_FUNCTION
     31GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3332gss_seal(OM_uint32 *minor_status,
    3433    gss_ctx_id_t context_handle,
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_set_cred_option.c

    r414 r745  
    3232
    3333#include "mech_locl.h"
    34 RCSID("$Id$");
    3534
    36 OM_uint32 GSSAPI_LIB_FUNCTION
     35GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3736gss_set_cred_option (OM_uint32 *minor_status,
    3837                     gss_cred_id_t *cred_handle,
     
    5655                    return GSS_S_FAILURE;
    5756
    58                 SLIST_INIT(&cred->gc_mc);
     57                HEIM_SLIST_INIT(&cred->gc_mc);
    5958
    60                 SLIST_FOREACH(m, &_gss_mechs, gm_link) {
     59                HEIM_SLIST_FOREACH(m, &_gss_mechs, gm_link) {
    6160
    6261                        if (m->gm_mech.gm_set_cred_option == NULL)
     
    8382                        }
    8483                        one_ok = 1;
    85                         SLIST_INSERT_HEAD(&cred->gc_mc, mc, gmc_link);
     84                        HEIM_SLIST_INSERT_HEAD(&cred->gc_mc, mc, gmc_link);
    8685                }
    8786                *cred_handle = (gss_cred_id_t)cred;
     
    9392                gssapi_mech_interface   m;
    9493
    95                 SLIST_FOREACH(mc, &cred->gc_mc, gmc_link) {
     94                HEIM_SLIST_FOREACH(mc, &cred->gc_mc, gmc_link) {
    9695                        m = mc->gmc_mech;
    9796       
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_set_sec_context_option.c

    r414 r745  
    3232
    3333#include "mech_locl.h"
    34 RCSID("$Id$");
    3534
    36 OM_uint32 GSSAPI_LIB_FUNCTION
     35GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3736gss_set_sec_context_option (OM_uint32 *minor_status,
    3837                            gss_ctx_id_t *context_handle,
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_sign.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    32 OM_uint32 GSSAPI_LIB_FUNCTION
     31GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3332gss_sign(OM_uint32 *minor_status,
    3433    gss_ctx_id_t context_handle,
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_test_oid_set_member.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    32 OM_uint32 GSSAPI_LIB_FUNCTION
     31GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3332gss_test_oid_set_member(OM_uint32 *minor_status,
    3433    const gss_OID member,
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_unseal.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    32 OM_uint32 GSSAPI_LIB_FUNCTION
     31GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3332gss_unseal(OM_uint32 *minor_status,
    3433    gss_ctx_id_t context_handle,
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_unwrap.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    32 OM_uint32 GSSAPI_LIB_FUNCTION
     31GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3332gss_unwrap(OM_uint32 *minor_status,
    3433    const gss_ctx_id_t context_handle,
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_utils.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    3231OM_uint32
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_verify.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    32 OM_uint32 GSSAPI_LIB_FUNCTION
     31GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3332gss_verify(OM_uint32 *minor_status,
    3433    gss_ctx_id_t context_handle,
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_verify_mic.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    32 OM_uint32 GSSAPI_LIB_FUNCTION
     31GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3332gss_verify_mic(OM_uint32 *minor_status,
    3433    const gss_ctx_id_t context_handle,
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_wrap.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    32 OM_uint32 GSSAPI_LIB_FUNCTION
     31/**
     32 * Wrap a message using either confidentiality (encryption +
     33 * signature) or sealing (signature).
     34 *
     35 * @param minor_status minor status code.
     36 * @param context_handle context handle.
     37 * @param conf_req_flag if non zero, confidentiality is requestd.
     38 * @param qop_req type of protection needed, in most cases it GSS_C_QOP_DEFAULT should be passed in.
     39 * @param input_message_buffer messages to wrap
     40 * @param conf_state returns non zero if confidentiality was honoured.
     41 * @param output_message_buffer the resulting buffer, release with gss_release_buffer().
     42 *
     43 * @ingroup gssapi
     44 */
     45
     46GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3347gss_wrap(OM_uint32 *minor_status,
    3448    const gss_ctx_id_t context_handle,
  • trunk/server/source4/heimdal/lib/gssapi/mech/gss_wrap_size_limit.c

    r414 r745  
    2828
    2929#include "mech_locl.h"
    30 RCSID("$Id$");
    3130
    32 OM_uint32 GSSAPI_LIB_FUNCTION
     31GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
    3332gss_wrap_size_limit(OM_uint32 *minor_status,
    3433    const gss_ctx_id_t context_handle,
  • trunk/server/source4/heimdal/lib/gssapi/mech/mech_locl.h

    r414 r745  
    6565
    6666#define _mg_buffer_zero(buffer) \
    67         do { (buffer)->value = NULL; (buffer)->length = 0; } while(0)
     67        do {                                    \
     68                if (buffer) {                   \
     69                        (buffer)->value = NULL; \
     70                        (buffer)->length = 0;   \
     71                 }                              \
     72        } while(0)
     73
     74#define _mg_oid_set_zero(oid_set) \
     75        do {                                            \
     76                if (oid_set) {                          \
     77                        (oid_set)->elements = NULL;     \
     78                        (oid_set)->count = 0;           \
     79                 }                                      \
     80        } while(0)
  • trunk/server/source4/heimdal/lib/gssapi/mech/mech_switch.h

    r414 r745  
    3131
    3232struct _gss_mech_switch {
    33         SLIST_ENTRY(_gss_mech_switch)   gm_link;
     33        HEIM_SLIST_ENTRY(_gss_mech_switch)      gm_link;
    3434        gss_OID_desc                    gm_mech_oid;
    3535        gss_OID_set                     gm_name_types;
     
    3737        gssapi_mech_interface_desc      gm_mech;
    3838};
    39 SLIST_HEAD(_gss_mech_switch_list, _gss_mech_switch);
     39HEIM_SLIST_HEAD(_gss_mech_switch_list, _gss_mech_switch);
    4040extern struct _gss_mech_switch_list _gss_mechs;
    4141extern gss_OID_set _gss_mech_oids;
  • trunk/server/source4/heimdal/lib/gssapi/mech/mechqueue.h

    r414 r745  
    3535#define _MECHQUEUE_H_
    3636
    37 #ifndef SLIST_HEAD
    38 
    3937/*
    4038 * Singly-linked List definitions.
    4139 */
    42 #define SLIST_HEAD(name, type)                                          \
     40#define HEIM_SLIST_HEAD(name, type)                                             \
    4341struct name {                                                           \
    4442        struct type *slh_first; /* first element */                     \
    4543}
    4644
    47 #define SLIST_HEAD_INITIALIZER(head)                                    \
     45#define HEIM_SLIST_HEAD_INITIALIZER(head)                                       \
    4846        { NULL }
    4947
    50 #define SLIST_ENTRY(type)                                               \
     48#define HEIM_SLIST_ENTRY(type)                                          \
    5149struct {                                                                \
    5250        struct type *sle_next;  /* next element */                      \
     
    5654 * Singly-linked List functions.
    5755 */
    58 #define SLIST_INIT(head) do {                                           \
     56#define HEIM_SLIST_INIT(head) do {                                              \
    5957        (head)->slh_first = NULL;                                       \
    6058} while (/*CONSTCOND*/0)
    6159
    62 #define SLIST_INSERT_AFTER(slistelm, elm, field) do {                   \
     60#define HEIM_SLIST_INSERT_AFTER(slistelm, elm, field) do {                      \
    6361        (elm)->field.sle_next = (slistelm)->field.sle_next;             \
    6462        (slistelm)->field.sle_next = (elm);                             \
    6563} while (/*CONSTCOND*/0)
    6664
    67 #define SLIST_INSERT_HEAD(head, elm, field) do {                        \
     65#define HEIM_SLIST_INSERT_HEAD(head, elm, field) do {                   \
    6866        (elm)->field.sle_next = (head)->slh_first;                      \
    6967        (head)->slh_first = (elm);                                      \
    7068} while (/*CONSTCOND*/0)
    7169
    72 #define SLIST_REMOVE_HEAD(head, field) do {                             \
     70#define HEIM_SLIST_REMOVE_HEAD(head, field) do {                                \
    7371        (head)->slh_first = (head)->slh_first->field.sle_next;          \
    7472} while (/*CONSTCOND*/0)
    7573
    76 #define SLIST_REMOVE(head, elm, type, field) do {                       \
     74#define HEIM_SLIST_REMOVE(head, elm, type, field) do {                  \
    7775        if ((head)->slh_first == (elm)) {                               \
    78                 SLIST_REMOVE_HEAD((head), field);                       \
     76                HEIM_SLIST_REMOVE_HEAD((head), field);                  \
    7977        }                                                               \
    8078        else {                                                          \
     
    8785} while (/*CONSTCOND*/0)
    8886
    89 #define SLIST_FOREACH(var, head, field)                                 \
     87#define HEIM_SLIST_FOREACH(var, head, field)                                    \
    9088        for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next)
    9189
     
    9391 * Singly-linked List access methods.
    9492 */
    95 #define SLIST_EMPTY(head)       ((head)->slh_first == NULL)
    96 #define SLIST_FIRST(head)       ((head)->slh_first)
    97 #define SLIST_NEXT(elm, field)  ((elm)->field.sle_next)
    98 
    99 #endif /* SLIST_HEAD */
     93#define HEIM_SLIST_EMPTY(head)  ((head)->slh_first == NULL)
     94#define HEIM_SLIST_FIRST(head)  ((head)->slh_first)
     95#define HEIM_SLIST_NEXT(elm, field)     ((elm)->field.sle_next)
    10096
    10197#endif  /* !_MECHQUEUE_H_ */
  • trunk/server/source4/heimdal/lib/gssapi/mech/name.h

    r414 r745  
    2929
    3030struct _gss_mechanism_name {
    31         SLIST_ENTRY(_gss_mechanism_name) gmn_link;
     31        HEIM_SLIST_ENTRY(_gss_mechanism_name) gmn_link;
    3232        gssapi_mech_interface   gmn_mech;       /* mechanism ops for MN */
    3333        gss_OID                 gmn_mech_oid;   /* mechanism oid for MN */
    3434        gss_name_t              gmn_name;       /* underlying MN */
    3535};
    36 SLIST_HEAD(_gss_mechanism_name_list, _gss_mechanism_name);
     36HEIM_SLIST_HEAD(_gss_mechanism_name_list, _gss_mechanism_name);
    3737
    3838struct _gss_name {
  • trunk/server/source4/heimdal/lib/gssapi/spnego/accept_sec_context.c

    r414 r745  
    3434#include "spnego_locl.h"
    3535
    36 RCSID("$Id$");
    37 
    3836static OM_uint32
    3937send_reject (OM_uint32 *minor_status,
     
    375373                return GSS_S_FAILURE;
    376374            }
    377             asprintf(&str, "host@%s", hostname);
     375            i = asprintf(&str, "host@%s", hostname);
     376            if (i < 0 || str == NULL) {
     377                *minor_status = ENOMEM;
     378                return GSS_S_FAILURE;
     379            }
    378380            host = str;
    379381        }
     
    471473
    472474
    473 static OM_uint32
     475static OM_uint32 GSSAPI_CALLCONV
    474476acceptor_start
    475477           (OM_uint32 * minor_status,
     
    497499    gss_OID preferred_mech_type = GSS_C_NO_OID;
    498500    gssspnego_ctx ctx;
    499     gssspnego_cred acceptor_cred = (gssspnego_cred)acceptor_cred_handle;
    500501    int get_mic = 0;
    501502    int first_ok = 0;
     
    565566
    566567    if (ret == 0 && ni->mechToken != NULL) {
    567         gss_cred_id_t mech_delegated_cred = GSS_C_NO_CREDENTIAL;
    568         gss_cred_id_t mech_cred;
    569568        gss_buffer_desc ibuf;
    570569
     
    573572        mech_input_token = &ibuf;
    574573
    575         if (acceptor_cred != NULL)
    576             mech_cred = acceptor_cred->negotiated_cred_id;
    577         else
    578             mech_cred = GSS_C_NO_CREDENTIAL;
    579        
    580574        if (ctx->mech_src_name != GSS_C_NO_NAME)
    581575            gss_release_name(&junk, &ctx->mech_src_name);
     
    583577        ret = gss_accept_sec_context(minor_status,
    584578                                     &ctx->negotiated_ctx_id,
    585                                      mech_cred,
     579                                     acceptor_cred_handle,
    586580                                     mech_input_token,
    587581                                     input_chan_bindings,
     
    591585                                     &ctx->mech_flags,
    592586                                     &ctx->mech_time_rec,
    593                                      &mech_delegated_cred);
    594 
    595         if (mech_delegated_cred && delegated_cred_handle) {
    596             _gss_spnego_alloc_cred(&junk,
    597                                    mech_delegated_cred,
    598                                    delegated_cred_handle);
    599         } else if (mech_delegated_cred != GSS_C_NO_CREDENTIAL)
    600             gss_release_cred(&junk, &mech_delegated_cred);
     587                                     delegated_cred_handle);
    601588
    602589        if (ret == GSS_S_COMPLETE || ret == GSS_S_CONTINUE_NEEDED) {
    603590            ctx->preferred_mech_type = preferred_mech_type;
    604             ctx->negotiated_mech_type = preferred_mech_type;
    605591            if (ret == GSS_S_COMPLETE)
    606592                ctx->open = 1;
     
    647633
    648634        ctx->preferred_mech_type = preferred_mech_type;
    649         ctx->negotiated_mech_type = preferred_mech_type;
    650635    }
    651636
     
    705690
    706691
    707 static OM_uint32
     692static OM_uint32 GSSAPI_CALLCONV
    708693acceptor_continue
    709694           (OM_uint32 * minor_status,
     
    720705           )
    721706{
    722     OM_uint32 ret, ret2, minor, junk;
     707    OM_uint32 ret, ret2, minor;
    723708    NegotiationToken nt;
    724709    size_t nt_len;
     
    729714    gss_buffer_desc mech_buf;
    730715    gssspnego_ctx ctx;
    731     gssspnego_cred acceptor_cred = (gssspnego_cred)acceptor_cred_handle;
    732716
    733717    mech_buf.value = NULL;
     
    775759
    776760        if (mech_input_token != GSS_C_NO_BUFFER) {
    777             gss_cred_id_t mech_cred;
    778             gss_cred_id_t mech_delegated_cred = GSS_C_NO_CREDENTIAL;
    779 
    780             if (acceptor_cred != NULL)
    781                 mech_cred = acceptor_cred->negotiated_cred_id;
    782             else
    783                 mech_cred = GSS_C_NO_CREDENTIAL;
    784761
    785762            if (ctx->mech_src_name != GSS_C_NO_NAME)
     
    788765            ret = gss_accept_sec_context(&minor,
    789766                                         &ctx->negotiated_ctx_id,
    790                                          mech_cred,
     767                                         acceptor_cred_handle,
    791768                                         mech_input_token,
    792769                                         input_chan_bindings,
     
    796773                                         &ctx->mech_flags,
    797774                                         &ctx->mech_time_rec,
    798                                          &mech_delegated_cred);
    799 
    800             if (mech_delegated_cred && delegated_cred_handle) {
    801                 _gss_spnego_alloc_cred(&junk,
    802                                        mech_delegated_cred,
    803                                        delegated_cred_handle);
    804             } else if (mech_delegated_cred != GSS_C_NO_CREDENTIAL)
    805                 gss_release_cred(&junk, &mech_delegated_cred);
     775                                         delegated_cred_handle);
    806776
    807777            if (ret == GSS_S_COMPLETE || ret == GSS_S_CONTINUE_NEEDED) {
     
    907877}
    908878
    909 OM_uint32
     879OM_uint32 GSSAPI_CALLCONV
    910880_gss_spnego_accept_sec_context
    911881           (OM_uint32 * minor_status,
  • trunk/server/source4/heimdal/lib/gssapi/spnego/compat.c

    r414 r745  
    3333#include "spnego_locl.h"
    3434
    35 RCSID("$Id$");
    36 
    3735/*
    3836 * Apparently Microsoft got the OID wrong, and used
     
    5250 * Allocate a SPNEGO context handle
    5351 */
    54 OM_uint32 _gss_spnego_alloc_sec_context (OM_uint32 * minor_status,
    55                                          gss_ctx_id_t *context_handle)
     52OM_uint32 GSSAPI_CALLCONV
     53_gss_spnego_alloc_sec_context (OM_uint32 * minor_status,
     54                               gss_ctx_id_t *context_handle)
    5655{
    5756    gssspnego_ctx ctx;
     
    9493 * the lock before this is called.
    9594 */
    96 OM_uint32 _gss_spnego_internal_delete_sec_context
     95OM_uint32 GSSAPI_CALLCONV _gss_spnego_internal_delete_sec_context
    9796           (OM_uint32 *minor_status,
    9897            gss_ctx_id_t *context_handle,
     
    143142
    144143    free(ctx);
    145     *context_handle = NULL;
    146144
    147145    return ret;
     
    154152 */
    155153
    156 OM_uint32
     154OM_uint32 GSSAPI_CALLCONV
    157155_gss_spnego_require_mechlist_mic(OM_uint32 *minor_status,
    158156                                 gssspnego_ctx ctx,
     
    232230
    233231
    234 OM_uint32
     232OM_uint32 GSSAPI_CALLCONV
    235233_gss_spnego_indicate_mechtypelist (OM_uint32 *minor_status,
    236234                                   gss_name_t target_name,
    237235                                   OM_uint32 (*func)(gss_name_t, gss_OID),
    238236                                   int includeMSCompatOID,
    239                                    const gssspnego_cred cred_handle,
     237                                   const gss_cred_id_t cred_handle,
    240238                                   MechTypeList *mechtypelist,
    241239                                   gss_OID *preferred_mech)
     
    249247    mechtypelist->val = NULL;
    250248
    251     if (cred_handle != NULL) {
     249    if (cred_handle) {
    252250        ret = gss_inquire_cred(minor_status,
    253                                cred_handle->negotiated_cred_id,
     251                               cred_handle,
    254252                               NULL,
    255253                               NULL,
  • trunk/server/source4/heimdal/lib/gssapi/spnego/context_stubs.c

    r414 r745  
    3333#include "spnego_locl.h"
    3434
    35 RCSID("$Id$");
    36 
    3735static OM_uint32
    3836spnego_supported_mechs(OM_uint32 *minor_status, gss_OID_set *mechs)
     
    6967
    7068
    71 OM_uint32 _gss_spnego_process_context_token
     69OM_uint32 GSSAPI_CALLCONV _gss_spnego_process_context_token
    7270           (OM_uint32 *minor_status,
    7371            const gss_ctx_id_t context_handle,
     
    102100}
    103101
    104 OM_uint32 _gss_spnego_delete_sec_context
     102OM_uint32 GSSAPI_CALLCONV _gss_spnego_delete_sec_context
    105103           (OM_uint32 *minor_status,
    106104            gss_ctx_id_t *context_handle,
     
    122120}
    123121
    124 OM_uint32 _gss_spnego_context_time
     122OM_uint32 GSSAPI_CALLCONV _gss_spnego_context_time
    125123           (OM_uint32 *minor_status,
    126124            const gss_ctx_id_t context_handle,
     
    146144}
    147145
    148 OM_uint32 _gss_spnego_get_mic
     146OM_uint32 GSSAPI_CALLCONV _gss_spnego_get_mic
    149147           (OM_uint32 *minor_status,
    150148            const gss_ctx_id_t context_handle,
     
    172170}
    173171
    174 OM_uint32 _gss_spnego_verify_mic
     172OM_uint32 GSSAPI_CALLCONV _gss_spnego_verify_mic
    175173           (OM_uint32 * minor_status,
    176174            const gss_ctx_id_t context_handle,
     
    201199}
    202200
    203 OM_uint32 _gss_spnego_wrap
     201OM_uint32 GSSAPI_CALLCONV _gss_spnego_wrap
    204202           (OM_uint32 * minor_status,
    205203            const gss_ctx_id_t context_handle,
     
    234232}
    235233
    236 OM_uint32 _gss_spnego_unwrap
     234OM_uint32 GSSAPI_CALLCONV _gss_spnego_unwrap
    237235           (OM_uint32 * minor_status,
    238236            const gss_ctx_id_t context_handle,
     
    265263}
    266264
    267 OM_uint32 _gss_spnego_compare_name
     265OM_uint32 GSSAPI_CALLCONV _gss_spnego_compare_name
    268266           (OM_uint32 *minor_status,
    269267            const gss_name_t name1,
     
    289287}
    290288
    291 OM_uint32 _gss_spnego_display_name
     289OM_uint32 GSSAPI_CALLCONV _gss_spnego_display_name
    292290           (OM_uint32 * minor_status,
    293291            const gss_name_t input_name,
     
    307305}
    308306
    309 OM_uint32 _gss_spnego_import_name
     307OM_uint32 GSSAPI_CALLCONV _gss_spnego_import_name
    310308           (OM_uint32 * minor_status,
    311309            const gss_buffer_t name_buffer,
     
    343341}
    344342
    345 OM_uint32 _gss_spnego_export_name
     343OM_uint32 GSSAPI_CALLCONV _gss_spnego_export_name
    346344           (OM_uint32  * minor_status,
    347345            const gss_name_t input_name,
     
    362360}
    363361
    364 OM_uint32 _gss_spnego_release_name
     362OM_uint32 GSSAPI_CALLCONV _gss_spnego_release_name
    365363           (OM_uint32 * minor_status,
    366364            gss_name_t * input_name
     
    383381}
    384382
    385 OM_uint32 _gss_spnego_inquire_context (
     383OM_uint32 GSSAPI_CALLCONV _gss_spnego_inquire_context (
    386384            OM_uint32 * minor_status,
    387385            const gss_ctx_id_t context_handle,
     
    450448}
    451449
    452 OM_uint32 _gss_spnego_wrap_size_limit (
     450OM_uint32 GSSAPI_CALLCONV _gss_spnego_wrap_size_limit (
    453451            OM_uint32 * minor_status,
    454452            const gss_ctx_id_t context_handle,
     
    481479}
    482480
    483 OM_uint32 _gss_spnego_export_sec_context (
     481OM_uint32 GSSAPI_CALLCONV _gss_spnego_export_sec_context (
    484482            OM_uint32 * minor_status,
    485483            gss_ctx_id_t * context_handle,
     
    524522}
    525523
    526 OM_uint32 _gss_spnego_import_sec_context (
     524OM_uint32 GSSAPI_CALLCONV _gss_spnego_import_sec_context (
    527525            OM_uint32 * minor_status,
    528526            const gss_buffer_t interprocess_token,
     
    560558}
    561559
    562 OM_uint32 _gss_spnego_inquire_names_for_mech (
     560OM_uint32 GSSAPI_CALLCONV _gss_spnego_inquire_names_for_mech (
    563561            OM_uint32 * minor_status,
    564562            const gss_OID mechanism,
     
    603601}
    604602
    605 OM_uint32 _gss_spnego_inquire_mechs_for_name (
     603OM_uint32 GSSAPI_CALLCONV _gss_spnego_inquire_mechs_for_name (
    606604            OM_uint32 * minor_status,
    607605            const gss_name_t input_name,
     
    624622}
    625623
    626 OM_uint32 _gss_spnego_canonicalize_name (
     624OM_uint32 GSSAPI_CALLCONV _gss_spnego_canonicalize_name (
    627625            OM_uint32 * minor_status,
    628626            const gss_name_t input_name,
     
    635633}
    636634
    637 OM_uint32 _gss_spnego_duplicate_name (
     635OM_uint32 GSSAPI_CALLCONV _gss_spnego_duplicate_name (
    638636            OM_uint32 * minor_status,
    639637            const gss_name_t src_name,
     
    644642}
    645643
     644OM_uint32 GSSAPI_CALLCONV
     645_gss_spnego_wrap_iov(OM_uint32 * minor_status,
     646                     gss_ctx_id_t  context_handle,
     647                     int conf_req_flag,
     648                     gss_qop_t qop_req,
     649                     int * conf_state,
     650                     gss_iov_buffer_desc *iov,
     651                     int iov_count)
     652{
     653    gssspnego_ctx ctx = (gssspnego_ctx)context_handle;
     654
     655    *minor_status = 0;
     656
     657    if (ctx == NULL || ctx->negotiated_ctx_id == GSS_C_NO_CONTEXT)
     658        return GSS_S_NO_CONTEXT;
     659
     660    return gss_wrap_iov(minor_status, ctx->negotiated_ctx_id,
     661                        conf_req_flag, qop_req, conf_state,
     662                        iov, iov_count);
     663}
     664
     665OM_uint32 GSSAPI_CALLCONV
     666_gss_spnego_unwrap_iov(OM_uint32 *minor_status,
     667                       gss_ctx_id_t context_handle,
     668                       int *conf_state,
     669                       gss_qop_t *qop_state,
     670                       gss_iov_buffer_desc *iov,
     671                       int iov_count)
     672{
     673    gssspnego_ctx ctx = (gssspnego_ctx)context_handle;
     674
     675    *minor_status = 0;
     676
     677    if (ctx == NULL || ctx->negotiated_ctx_id == GSS_C_NO_CONTEXT)
     678        return GSS_S_NO_CONTEXT;
     679
     680    return gss_unwrap_iov(minor_status,
     681                          ctx->negotiated_ctx_id,
     682                          conf_state, qop_state,
     683                          iov, iov_count);
     684}
     685
     686OM_uint32 GSSAPI_CALLCONV
     687_gss_spnego_wrap_iov_length(OM_uint32 * minor_status,
     688                            gss_ctx_id_t context_handle,
     689                            int conf_req_flag,
     690                            gss_qop_t qop_req,
     691                            int *conf_state,
     692                            gss_iov_buffer_desc *iov,
     693                            int iov_count)
     694{
     695    gssspnego_ctx ctx = (gssspnego_ctx)context_handle;
     696
     697    *minor_status = 0;
     698
     699    if (ctx == NULL || ctx->negotiated_ctx_id == GSS_C_NO_CONTEXT)
     700        return GSS_S_NO_CONTEXT;
     701
     702    return gss_wrap_iov_length(minor_status, ctx->negotiated_ctx_id,
     703                               conf_req_flag, qop_req, conf_state,
     704                               iov, iov_count);
     705}
     706
    646707#if 0
    647 OM_uint32 _gss_spnego_unwrap_ex
    648            (OM_uint32 * minor_status,
    649             const gss_ctx_id_t context_handle,
    650             const gss_buffer_t token_header_buffer,
    651             const gss_buffer_t associated_data_buffer,
    652             const gss_buffer_t input_message_buffer,
    653             gss_buffer_t output_message_buffer,
    654             int * conf_state,
    655             gss_qop_t * qop_state)
    656 {
    657     gssspnego_ctx ctx;
    658 
    659     *minor_status = 0;
    660 
    661     if (context_handle == GSS_C_NO_CONTEXT) {
    662         return GSS_S_NO_CONTEXT;
    663     }
    664 
    665     ctx = (gssspnego_ctx)context_handle;
    666 
    667     if (ctx->negotiated_ctx_id == GSS_C_NO_CONTEXT) {
    668         return GSS_S_NO_CONTEXT;
    669     }
    670 
    671     return gss_unwrap_ex(minor_status,
    672                          ctx->negotiated_ctx_id,
    673                          token_header_buffer,
    674                          associated_data_buffer,
    675                          input_message_buffer,
    676                          output_message_buffer,
    677                          conf_state,
    678                          qop_state);
    679 }
    680 
    681 OM_uint32 _gss_spnego_wrap_ex
    682            (OM_uint32 * minor_status,
    683             const gss_ctx_id_t context_handle,
    684             int conf_req_flag,
    685             gss_qop_t qop_req,
    686             const gss_buffer_t associated_data_buffer,
    687             const gss_buffer_t input_message_buffer,
    688             int * conf_state,
    689             gss_buffer_t output_token_buffer,
    690             gss_buffer_t output_message_buffer
    691            )
    692 {
    693     gssspnego_ctx ctx;
    694 
    695     *minor_status = 0;
    696 
    697     if (context_handle == GSS_C_NO_CONTEXT) {
    698         return GSS_S_NO_CONTEXT;
    699     }
    700 
    701     ctx = (gssspnego_ctx)context_handle;
    702 
    703     if (ctx->negotiated_ctx_id == GSS_C_NO_CONTEXT) {
    704         return GSS_S_NO_CONTEXT;
    705     }
    706 
    707     if ((ctx->mech_flags & GSS_C_DCE_STYLE) == 0 &&
    708         associated_data_buffer->length != input_message_buffer->length) {
    709         *minor_status = EINVAL;
    710         return GSS_S_BAD_QOP;
    711     }
    712 
    713     return gss_wrap_ex(minor_status,
    714                        ctx->negotiated_ctx_id,
    715                        conf_req_flag,
    716                        qop_req,
    717                        associated_data_buffer,
    718                        input_message_buffer,
    719                        conf_state,
    720                        output_token_buffer,
    721                        output_message_buffer);
    722 }
    723 
    724 OM_uint32 _gss_spnego_complete_auth_token
     708OM_uint32 GSSAPI_CALLCONV _gss_spnego_complete_auth_token
    725709           (OM_uint32 * minor_status,
    726710            const gss_ctx_id_t context_handle,
     
    747731#endif
    748732
    749 OM_uint32 _gss_spnego_inquire_sec_context_by_oid
     733OM_uint32 GSSAPI_CALLCONV _gss_spnego_inquire_sec_context_by_oid
    750734           (OM_uint32 * minor_status,
    751735            const gss_ctx_id_t context_handle,
     
    773757}
    774758
    775 OM_uint32 _gss_spnego_set_sec_context_option
     759OM_uint32 GSSAPI_CALLCONV _gss_spnego_set_sec_context_option
    776760           (OM_uint32 * minor_status,
    777761            gss_ctx_id_t * context_handle,
     
    800784
    801785
    802 OM_uint32
     786OM_uint32 GSSAPI_CALLCONV
    803787_gss_spnego_pseudo_random(OM_uint32 *minor_status,
    804788                          gss_ctx_id_t context_handle,
  • trunk/server/source4/heimdal/lib/gssapi/spnego/cred_stubs.c

    r414 r745  
    3333#include "spnego_locl.h"
    3434
    35 RCSID("$Id$");
    36 
    37 OM_uint32
     35OM_uint32 GSSAPI_CALLCONV
    3836_gss_spnego_release_cred(OM_uint32 *minor_status, gss_cred_id_t *cred_handle)
    3937{
    40     gssspnego_cred cred;
    4138    OM_uint32 ret;
    4239
    4340    *minor_status = 0;
    4441
    45     if (*cred_handle == GSS_C_NO_CREDENTIAL) {
     42    if (cred_handle == NULL || *cred_handle == GSS_C_NO_CREDENTIAL)
    4643        return GSS_S_COMPLETE;
    47     }
    48     cred = (gssspnego_cred)*cred_handle;
    49 
    50     ret = gss_release_cred(minor_status, &cred->negotiated_cred_id);
    51 
    52     free(cred);
     44
     45    ret = gss_release_cred(minor_status, cred_handle);
     46
    5347    *cred_handle = GSS_C_NO_CREDENTIAL;
    5448
    5549    return ret;
    56 }
    57 
    58 OM_uint32
    59 _gss_spnego_alloc_cred(OM_uint32 *minor_status,
    60                        gss_cred_id_t mech_cred_handle,
    61                        gss_cred_id_t *cred_handle)
    62 {
    63     gssspnego_cred cred;
    64 
    65     if (*cred_handle != GSS_C_NO_CREDENTIAL) {
    66         *minor_status = EINVAL;
    67         return GSS_S_FAILURE;
    68     }
    69 
    70     cred = calloc(1, sizeof(*cred));
    71     if (cred == NULL) {
    72         *cred_handle = GSS_C_NO_CREDENTIAL;
    73         *minor_status = ENOMEM;
    74         return GSS_S_FAILURE;
    75     }
    76 
    77     cred->negotiated_cred_id = mech_cred_handle;
    78 
    79     *cred_handle = (gss_cred_id_t)cred;
    80 
    81     return GSS_S_COMPLETE;
    8250}
    8351
     
    8755 * more functionality.
    8856 */
    89 OM_uint32 _gss_spnego_acquire_cred
     57OM_uint32 GSSAPI_CALLCONV _gss_spnego_acquire_cred
    9058(OM_uint32 *minor_status,
    9159 const gss_name_t desired_name,
     
    10472    gss_OID_set mechs;
    10573    int i, j;
    106     gss_cred_id_t cred_handle = GSS_C_NO_CREDENTIAL;
    107     gssspnego_cred cred;
    10874
    10975    *output_cred_handle = GSS_C_NO_CREDENTIAL;
     
    141107    actual_desired_mechs.count = j;
    142108
    143     ret = _gss_spnego_alloc_cred(minor_status, GSS_C_NO_CREDENTIAL,
    144                                  &cred_handle);
    145     if (ret != GSS_S_COMPLETE)
    146         goto out;
    147 
    148     cred = (gssspnego_cred)cred_handle;
    149109    ret = gss_acquire_cred(minor_status, name,
    150110                           time_req, &actual_desired_mechs,
    151111                           cred_usage,
    152                            &cred->negotiated_cred_id,
     112                           output_cred_handle,
    153113                           actual_mechs, time_rec);
    154114    if (ret != GSS_S_COMPLETE)
    155115        goto out;
    156 
    157     *output_cred_handle = cred_handle;
    158116
    159117out:
     
    164122    }
    165123    if (ret != GSS_S_COMPLETE) {
    166         _gss_spnego_release_cred(&tmp, &cred_handle);
    167     }
    168 
    169     return ret;
    170 }
    171 
    172 OM_uint32 _gss_spnego_inquire_cred
     124        _gss_spnego_release_cred(&tmp, output_cred_handle);
     125    }
     126
     127    return ret;
     128}
     129
     130OM_uint32 GSSAPI_CALLCONV _gss_spnego_inquire_cred
    173131           (OM_uint32 * minor_status,
    174132            const gss_cred_id_t cred_handle,
     
    179137           )
    180138{
    181     gssspnego_cred cred;
    182139    spnego_name sname = NULL;
    183140    OM_uint32 ret;
     
    196153    }
    197154
    198     cred = (gssspnego_cred)cred_handle;
    199 
    200155    ret = gss_inquire_cred(minor_status,
    201                            cred->negotiated_cred_id,
     156                           cred_handle,
    202157                           sname ? &sname->mech : NULL,
    203158                           lifetime,
     
    215170}
    216171
    217 OM_uint32 _gss_spnego_add_cred (
    218             OM_uint32 * minor_status,
    219             const gss_cred_id_t input_cred_handle,
    220             const gss_name_t desired_name,
    221             const gss_OID desired_mech,
    222             gss_cred_usage_t cred_usage,
    223             OM_uint32 initiator_time_req,
    224             OM_uint32 acceptor_time_req,
    225             gss_cred_id_t * output_cred_handle,
    226             gss_OID_set * actual_mechs,
    227             OM_uint32 * initiator_time_rec,
    228             OM_uint32 * acceptor_time_rec
    229            )
    230 {
    231     gss_cred_id_t spnego_output_cred_handle = GSS_C_NO_CREDENTIAL;
    232     OM_uint32 ret, tmp;
    233     gssspnego_cred input_cred, output_cred;
    234 
    235     *output_cred_handle = GSS_C_NO_CREDENTIAL;
    236 
    237     ret = _gss_spnego_alloc_cred(minor_status, GSS_C_NO_CREDENTIAL,
    238                                  &spnego_output_cred_handle);
    239     if (ret)
    240         return ret;
    241 
    242     input_cred = (gssspnego_cred)input_cred_handle;
    243     output_cred = (gssspnego_cred)spnego_output_cred_handle;
    244 
    245     ret = gss_add_cred(minor_status,
    246                        input_cred->negotiated_cred_id,
    247                        desired_name,
    248                        desired_mech,
    249                        cred_usage,
    250                        initiator_time_req,
    251                        acceptor_time_req,
    252                        &output_cred->negotiated_cred_id,
    253                        actual_mechs,
    254                        initiator_time_rec,
    255                        acceptor_time_rec);
    256     if (ret) {
    257         _gss_spnego_release_cred(&tmp, &spnego_output_cred_handle);
    258         return ret;
    259     }
    260 
    261     *output_cred_handle = spnego_output_cred_handle;
    262 
    263     return GSS_S_COMPLETE;
    264 }
    265 
    266 OM_uint32 _gss_spnego_inquire_cred_by_mech (
     172OM_uint32 GSSAPI_CALLCONV _gss_spnego_inquire_cred_by_mech (
    267173            OM_uint32 * minor_status,
    268174            const gss_cred_id_t cred_handle,
     
    274180           )
    275181{
    276     gssspnego_cred cred;
    277182    spnego_name sname = NULL;
    278183    OM_uint32 ret;
     
    291196    }
    292197
    293     cred = (gssspnego_cred)cred_handle;
    294 
    295198    ret = gss_inquire_cred_by_mech(minor_status,
    296                                    cred->negotiated_cred_id,
     199                                   cred_handle,
    297200                                   mech_type,
    298201                                   sname ? &sname->mech : NULL,
     
    312215}
    313216
    314 OM_uint32 _gss_spnego_inquire_cred_by_oid
     217OM_uint32 GSSAPI_CALLCONV _gss_spnego_inquire_cred_by_oid
    315218           (OM_uint32 * minor_status,
    316219            const gss_cred_id_t cred_handle,
     
    318221            gss_buffer_set_t *data_set)
    319222{
    320     gssspnego_cred cred;
    321223    OM_uint32 ret;
    322224
     
    325227        return GSS_S_NO_CRED;
    326228    }
    327     cred = (gssspnego_cred)cred_handle;
    328229
    329230    ret = gss_inquire_cred_by_oid(minor_status,
    330                                   cred->negotiated_cred_id,
     231                                  cred_handle,
    331232                                  desired_object,
    332233                                  data_set);
     
    335236}
    336237
    337 OM_uint32
     238OM_uint32 GSSAPI_CALLCONV
    338239_gss_spnego_set_cred_option (OM_uint32 *minor_status,
    339240                             gss_cred_id_t *cred_handle,
     
    341242                             const gss_buffer_t value)
    342243{
    343     gssspnego_cred cred;
    344 
    345244    if (cred_handle == NULL || *cred_handle == GSS_C_NO_CREDENTIAL) {
    346245        *minor_status = 0;
     
    348247    }
    349248
    350     cred = (gssspnego_cred)*cred_handle;
    351249    return gss_set_cred_option(minor_status,
    352                               &cred->negotiated_cred_id,
     250                              cred_handle,
    353251                              object,
    354252                              value);
     
    356254
    357255
    358 OM_uint32
     256OM_uint32 GSSAPI_CALLCONV
    359257_gss_spnego_export_cred (OM_uint32 *minor_status,
    360258                         gss_cred_id_t cred_handle,
    361259                         gss_buffer_t value)
    362260{
    363     gssspnego_cred cred = (gssspnego_cred)cred_handle;
    364 
    365     return gss_export_cred(minor_status, cred->negotiated_cred_id, value);
    366 }
    367 
    368 OM_uint32
     261    return gss_export_cred(minor_status, cred_handle, value);
     262}
     263
     264OM_uint32 GSSAPI_CALLCONV
    369265_gss_spnego_import_cred (OM_uint32 *minor_status,
    370266                         gss_buffer_t value,
    371267                         gss_cred_id_t *cred_handle)
    372268{
    373     gssspnego_cred cred;
    374     OM_uint32 major;
    375 
    376     *cred_handle = GSS_C_NO_CREDENTIAL;
    377 
    378     cred = calloc(1, sizeof(*cred));
    379     if (cred == NULL) {
    380         *minor_status = ENOMEM;
    381         return GSS_S_FAILURE;
    382     }
    383    
    384     major = gss_import_cred(minor_status, value, &cred->negotiated_cred_id);
    385     if (major == GSS_S_COMPLETE)
    386         *cred_handle = (gss_cred_id_t)cred;
    387     else
    388         free(cred);
    389 
    390     return major;
    391 }
    392 
     269    return gss_import_cred(minor_status, value, cred_handle);
     270}
     271
  • trunk/server/source4/heimdal/lib/gssapi/spnego/external.c

    r414 r745  
    3434#include <gssapi_mech.h>
    3535
    36 RCSID("$Id$");
    37 
    3836/*
    3937 * RFC2478, SPNEGO:
     
    4341 */
    4442
     43static gss_mo_desc spnego_mo[] = {
     44    {
     45        GSS_C_MA_SASL_MECH_NAME,
     46        GSS_MO_MA,
     47        "SASL mech name",
     48        "SPNEGO",
     49        _gss_mo_get_ctx_as_string,
     50        NULL
     51    },
     52    {
     53        GSS_C_MA_MECH_NAME,
     54        GSS_MO_MA,
     55        "Mechanism name",
     56        "SPNEGO",
     57        _gss_mo_get_ctx_as_string,
     58        NULL
     59    },
     60    {
     61        GSS_C_MA_MECH_DESCRIPTION,
     62        GSS_MO_MA,
     63        "Mechanism description",
     64        "Heimdal SPNEGO Mechanism",
     65        _gss_mo_get_ctx_as_string,
     66        NULL
     67    },
     68    {
     69        GSS_C_MA_MECH_NEGO,
     70        GSS_MO_MA
     71    },
     72    {
     73        GSS_C_MA_MECH_PSEUDO,
     74        GSS_MO_MA
     75    }
     76};
     77
    4578static gssapi_mech_interface_desc spnego_mech = {
    4679    GMI_VERSION,
    4780    "spnego",
    4881    {6, (void *)"\x2b\x06\x01\x05\x05\x02"},
     82    0,
    4983    _gss_spnego_acquire_cred,
    5084    _gss_spnego_release_cred,
     
    68102    _gss_spnego_inquire_context,
    69103    _gss_spnego_wrap_size_limit,
    70     _gss_spnego_add_cred,
     104    gss_add_cred,
    71105    _gss_spnego_inquire_cred_by_mech,
    72106    _gss_spnego_export_sec_context,
     
    81115    _gss_spnego_set_cred_option,
    82116    _gss_spnego_pseudo_random,
     117    _gss_spnego_wrap_iov,
     118    _gss_spnego_unwrap_iov,
     119    _gss_spnego_wrap_iov_length,
     120    NULL,
     121    _gss_spnego_export_cred,
     122    _gss_spnego_import_cred,
    83123    NULL,
    84124    NULL,
    85125    NULL,
    86126    NULL,
    87     _gss_spnego_export_cred,
    88     _gss_spnego_import_cred
     127    NULL,
     128    NULL,
     129    NULL,
     130    spnego_mo,
     131    sizeof(spnego_mo) / sizeof(spnego_mo[0])
    89132};
    90133
     
    94137        return &spnego_mech;
    95138}
    96 
    97 static gss_OID_desc _gss_spnego_mechanism_desc =
    98     {6, (void *)"\x2b\x06\x01\x05\x05\x02"};
    99 
    100 gss_OID GSS_SPNEGO_MECHANISM = &_gss_spnego_mechanism_desc;
  • trunk/server/source4/heimdal/lib/gssapi/spnego/init_sec_context.c

    r414 r745  
    3434#include "spnego_locl.h"
    3535
    36 RCSID("$Id$");
    37 
    3836/*
    3937 * Is target_name an sane target for `mechÂŽ.
     
    180178spnego_initial
    181179           (OM_uint32 * minor_status,
    182             gssspnego_cred cred,
     180            gss_cred_id_t cred,
    183181            gss_ctx_id_t * context_handle,
    184182            const gss_name_t target_name,
     
    255253    /* generate optimistic token */
    256254    sub = gss_init_sec_context(&minor,
    257                                (cred != NULL) ? cred->negotiated_cred_id :
    258                                   GSS_C_NO_CREDENTIAL,
     255                               cred,
    259256                               &ctx->negotiated_ctx_id,
    260257                               ctx->target_name,
     
    378375spnego_reply
    379376           (OM_uint32 * minor_status,
    380             const gssspnego_cred cred,
     377            const gss_cred_id_t cred,
    381378            gss_ctx_id_t * context_handle,
    382379            const gss_name_t target_name,
     
    499496           was requested explicitly */
    500497        ret = gss_init_sec_context(&minor,
    501                                    (cred != NULL) ? cred->negotiated_cred_id :
    502                                        GSS_C_NO_CREDENTIAL,
     498                                   cred,
    503499                                   &ctx->negotiated_ctx_id,
    504500                                   ctx->target_name,
     
    614610}
    615611
    616 OM_uint32 _gss_spnego_init_sec_context
     612OM_uint32 GSSAPI_CALLCONV
     613_gss_spnego_init_sec_context
    617614           (OM_uint32 * minor_status,
    618615            const gss_cred_id_t initiator_cred_handle,
     
    630627           )
    631628{
    632     gssspnego_cred cred = (gssspnego_cred)initiator_cred_handle;
    633 
    634629    if (*context_handle == GSS_C_NO_CONTEXT)
    635630        return spnego_initial (minor_status,
    636                                cred,
     631                               initiator_cred_handle,
    637632                               context_handle,
    638633                               target_name,
     
    648643    else
    649644        return spnego_reply (minor_status,
    650                              cred,
     645                             initiator_cred_handle,
    651646                             context_handle,
    652647                             target_name,
  • trunk/server/source4/heimdal/lib/gssapi/spnego/spnego_locl.h

    r414 r745  
    4545#endif
    4646
     47#include <roken.h>
     48
    4749#ifdef HAVE_PTHREAD_H
    4850#include <pthread.h>
     
    7072#include <der.h>
    7173
    72 #include <roken.h>
    73 
    7474#define ALLOC(X, N) (X) = calloc((N), sizeof(*(X)))
    75 
    76 typedef struct {
    77         gss_cred_id_t           negotiated_cred_id;
    78 } *gssspnego_cred;
    7975
    8076typedef struct {
Note: See TracChangeset for help on using the changeset viewer.