1   /*
   2    * Copyright (c) 1996,1997, by Sun Microsystems, Inc.
   3    * All rights reserved.
   4    */
   5   
   6 | #pragma ident        "@(#)g_seal.c        1.20        04/09/08 SMI"
   6 | #pragma ident        "@(#)g_seal.c        1.19        98/04/21 SMI"
   7   
   8   /*
   9    *  glue routine for gss_seal
  10    */
  11   
  12   #include <mechglueP.h>
  13   
  14   /*ARGSUSED*/
  15 | OM_uint32 INTERFACE
  15 | OM_uint32
  16   gss_seal(minor_status,
  17                   context_handle,
  18                   conf_req_flag,
  19                   qop_req,
  20                   input_message_buffer,
  21                   conf_state,
  22                   output_message_buffer)
  23   
  24   OM_uint32 *                        minor_status;
  25   gss_ctx_id_t                        context_handle;
  26   int                                conf_req_flag;
  27   int                                qop_req;
  28   gss_buffer_t                        input_message_buffer;
  29   int *                                conf_state;
  31 - 
  30   gss_buffer_t                        output_message_buffer;
  31   {
  32   /* EXPORT DELETE START */
  33   
  34           OM_uint32                status;
  35           gss_union_ctx_id_t        ctx;
  36           gss_mechanism                mech;
  37   
  38   
  39 +         if (minor_status == NULL)
  40 +                 return (GSS_S_CALL_INACCESSIBLE_WRITE);
  41 +         *minor_status = 0;
  42 + 
  43           if (context_handle == GSS_C_NO_CONTEXT)
  41 |                 return (GSS_S_NO_CONTEXT);
  44 |                 return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT);
  45   
  46 +         if (input_message_buffer == NULL)
  47 +                 return (GSS_S_CALL_INACCESSIBLE_READ);
  48 + 
  49 +         if (output_message_buffer == NULL)
  50 +                 return (GSS_S_CALL_INACCESSIBLE_WRITE);
  51 + 
  52           /*
  53            * select the approprate underlying mechanism routine and
  54            * call it.
  55            */
  56   
  57           ctx = (gss_union_ctx_id_t) context_handle;
  58           mech = __gss_get_mechanism(ctx->mech_type);
  59   
  60           if (mech) {
  61                   if (mech->gss_seal)
  62                           status = mech->gss_seal(
  63                                                   mech->context,
  64                                                   minor_status,
  65                                                   ctx->internal_ctx_id,
  66                                                   conf_req_flag,
  67                                                   qop_req,
  68                                                   input_message_buffer,
  69                                                   conf_state,
  70                                                   output_message_buffer);
  71                   else
  63 |                         status = GSS_S_BAD_BINDINGS;
  72 |                         status = GSS_S_UNAVAILABLE;
  73   
  74                   return (status);
  75           }
  76   /* EXPORT DELETE END */
  77   
  69 |         return (GSS_S_NO_CONTEXT);
  78 |         return (GSS_S_BAD_MECH);
  79   }
  80   
  72 | OM_uint32 INTERFACE
  81 | OM_uint32
  82   gss_wrap(minor_status,
  83                   context_handle,
  84                   conf_req_flag,
  85                   qop_req,
  86                   input_message_buffer,
  87                   conf_state,
  88                   output_message_buffer)
  89   
  90   OM_uint32 *                        minor_status;
  91   const gss_ctx_id_t                context_handle;
  92   int                                conf_req_flag;
  93   gss_qop_t                        qop_req;
  94   const gss_buffer_t                input_message_buffer;
  95   int *                                conf_state;
  96   gss_buffer_t                        output_message_buffer;
  97   
  98   {
  90 |                 return gss_seal(minor_status, context_handle, conf_req_flag,
  91 |                                 (int) qop_req, input_message_buffer, conf_state,
  99 |         return gss_seal(minor_status, (gss_ctx_id_t)context_handle,
 100 |                         conf_req_flag, (int) qop_req,
 101 +                         (gss_buffer_t)input_message_buffer, conf_state,
 102                           output_message_buffer);
 103   }
 104   
 105   /*
 106    * New for V2
 107    */
  98 | OM_uint32 INTERFACE
 108 | OM_uint32
 109   gss_wrap_size_limit(minor_status, context_handle, conf_req_flag,
 110                                   qop_req, req_output_size, max_input_size)
 111           OM_uint32                *minor_status;
 112           const gss_ctx_id_t        context_handle;
 113           int                        conf_req_flag;
 114           gss_qop_t                qop_req;
 115           OM_uint32                req_output_size;
 116           OM_uint32                *max_input_size;
 108 -         OM_uint32                status;
 117   {
 118           gss_union_ctx_id_t        ctx;
 119           gss_mechanism                mech;
 120   
 112 |         gss_initialize();
 121 |         if (minor_status == NULL)
 122 +                 return (GSS_S_CALL_INACCESSIBLE_WRITE);
 123 +         *minor_status = 0;
 124   
 125           if (context_handle == GSS_C_NO_CONTEXT)
 115 |                 return (GSS_S_NO_CONTEXT);
 126 |                 return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT);
 127   
 128 +         if (max_input_size == NULL)
 129 +                 return (GSS_S_CALL_INACCESSIBLE_WRITE);
 130 + 
 131           /*
 132            * select the approprate underlying mechanism routine and
 133            * call it.
 134            */
 135   
 136           ctx = (gss_union_ctx_id_t) context_handle;
 137           mech = __gss_get_mechanism(ctx->mech_type);
 138   
 139           if (!mech)
 126 |                 return (GSS_S_NO_CONTEXT);
 140 |                 return (GSS_S_BAD_MECH);
 141   
 142           if (!mech->gss_wrap_size_limit)
 129 |                 return (GSS_S_BAD_BINDINGS);
 143 |                 return (GSS_S_UNAVAILABLE);
 144   
 131 |         status = mech->gss_wrap_size_limit(mech->context, minor_status,
 132 |                                                         context_handle,
 133 |                                                         conf_req_flag,
 145 |         return (mech->gss_wrap_size_limit(mech->context, minor_status,
 146 |                                 ctx->internal_ctx_id, conf_req_flag, qop_req,
 147 |                                 req_output_size, max_input_size));
 134 -                                                         qop_req,
 135 -                                                         req_output_size,
 136 -                                                         max_input_size);
 137 -         return (status);
 148   }

 ----Unchanged portion omitted----