ReactOS  0.4.13-dev-100-gc8611ae
auth_des.c File Reference
#include <wintirpc.h>
#include <reentrant.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <rpc/des_crypt.h>
#include <rpc/types.h>
#include <rpc/auth.h>
#include <rpc/auth_des.h>
#include <rpc/clnt.h>
#include <rpc/xdr.h>
#include <rpcsvc/nis.h>
Include dependency graph for auth_des.c:

Go to the source code of this file.

Classes

struct  ad_private
 

Macros

#define USEC_PER_SEC   1000000
 
#define RTIME_TIMEOUT   5 /* seconds to wait for sync */
 
#define AUTH_PRIVATE(auth)   (struct ad_private *) auth->ah_private
 
#define ALLOC(object_type)   (object_type *) mem_alloc(sizeof(object_type))
 
#define FREE(ptr, size)   mem_free((char *)(ptr), (int) size)
 
#define ATTEMPT(xdr_op)   if (!(xdr_op)) return (FALSE)
 

Functions

bool_t xdr_authdes_cred (XDR *, struct authdes_cred *)
 
bool_t xdr_authdes_verf (XDR *, struct authdes_verf *)
 
int key_encryptsession_pk ()
 
bool_t __rpc_get_time_offset (struct timeval *, nis_server *, char *, char **, char **)
 
static void authdes_nextverf (AUTH *)
 
static bool_t authdes_marshal (AUTH *, XDR *)
 
static bool_t authdes_validate (AUTH *, struct opaque_auth *)
 
static bool_t authdes_refresh (AUTH *, void *)
 
static void authdes_destroy (AUTH *)
 
static struct auth_ops * authdes_ops (void)
 
AUTHauthdes_pk_seccreate (const char *, netobj *, u_int, const char *, const des_block *, nis_server *)
 
AUTHauthdes_seccreate (const char *servername, const u_int win, const char *timehost, const des_block *ckey)
 

Macro Definition Documentation

◆ ALLOC

#define ALLOC (   object_type)    (object_type *) mem_alloc(sizeof(object_type))

Definition at line 63 of file auth_des.c.

◆ ATTEMPT

#define ATTEMPT (   xdr_op)    if (!(xdr_op)) return (FALSE)

Definition at line 65 of file auth_des.c.

◆ AUTH_PRIVATE

#define AUTH_PRIVATE (   auth)    (struct ad_private *) auth->ah_private

Definition at line 62 of file auth_des.c.

◆ FREE

#define FREE (   ptr,
  size 
)    mem_free((char *)(ptr), (int) size)

Definition at line 64 of file auth_des.c.

◆ RTIME_TIMEOUT

#define RTIME_TIMEOUT   5 /* seconds to wait for sync */

Definition at line 60 of file auth_des.c.

◆ USEC_PER_SEC

#define USEC_PER_SEC   1000000

Definition at line 59 of file auth_des.c.

Function Documentation

◆ __rpc_get_time_offset()

bool_t __rpc_get_time_offset ( struct timeval ,
nis_server ,
char ,
char **  ,
char **   
)

Referenced by authdes_refresh().

◆ authdes_destroy()

static void authdes_destroy ( AUTH auth)
static

Definition at line 464 of file auth_des.c.

465 {
466 /* LINTED pointer alignment */
467  struct ad_private *ad = AUTH_PRIVATE(auth);
468 
469  FREE(ad->ad_fullname, ad->ad_fullnamelen + 1);
470  FREE(ad->ad_servername, ad->ad_servernamelen + 1);
471  if (ad->ad_timehost)
472  FREE(ad->ad_timehost, strlen(ad->ad_timehost) + 1);
473  if (ad->ad_netid)
474  FREE(ad->ad_netid, strlen(ad->ad_netid) + 1);
475  if (ad->ad_uaddr)
476  FREE(ad->ad_uaddr, strlen(ad->ad_uaddr) + 1);
477  FREE(ad, sizeof (struct ad_private));
478  FREE(auth, sizeof(AUTH));
479 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
Definition: auth.h:205
char * ad_servername
Definition: auth_des.c:91
char * ad_timehost
Definition: auth_des.c:96
char * ad_fullname
Definition: auth_des.c:89
#define FREE(ptr, size)
Definition: auth_des.c:64
#define AUTH_PRIVATE(auth)
Definition: auth_des.c:62
u_int ad_servernamelen
Definition: auth_des.c:92
char * ad_netid
Definition: auth_des.c:104
char * ad_uaddr
Definition: auth_des.c:105
u_int ad_fullnamelen
Definition: auth_des.c:90

Referenced by authdes_ops().

◆ authdes_marshal()

static bool_t authdes_marshal ( AUTH auth,
XDR xdrs 
)
static

Definition at line 269 of file auth_des.c.

270 {
271 /* LINTED pointer alignment */
272  struct ad_private *ad = AUTH_PRIVATE(auth);
273  struct authdes_cred *cred = &ad->ad_cred;
274  struct authdes_verf *verf = &ad->ad_verf;
275  des_block cryptbuf[2];
276  des_block ivec;
277  int status;
278  int len;
279  rpc_inline_t *ixdr;
280 
281  /*
282  * Figure out the "time", accounting for any time difference
283  * with the server if necessary.
284  */
285  (void) gettimeofday(&ad->ad_timestamp, (struct timezone *)NULL);
286  ad->ad_timestamp.tv_sec += ad->ad_timediff.tv_sec;
287  ad->ad_timestamp.tv_usec += ad->ad_timediff.tv_usec;
288  while (ad->ad_timestamp.tv_usec >= USEC_PER_SEC) {
289  ad->ad_timestamp.tv_usec -= USEC_PER_SEC;
290  ad->ad_timestamp.tv_sec++;
291  }
292 
293  /*
294  * XDR the timestamp and possibly some other things, then
295  * encrypt them.
296  */
297  ixdr = (rpc_inline_t *)cryptbuf;
298  IXDR_PUT_INT32(ixdr, ad->ad_timestamp.tv_sec);
299  IXDR_PUT_INT32(ixdr, ad->ad_timestamp.tv_usec);
300  if (ad->ad_cred.adc_namekind == ADN_FULLNAME) {
301  IXDR_PUT_U_INT32(ixdr, ad->ad_window);
302  IXDR_PUT_U_INT32(ixdr, ad->ad_window - 1);
303  ivec.key.high = ivec.key.low = 0;
304  status = cbc_crypt((char *)&auth->ah_key, (char *)cryptbuf,
305  (u_int) 2 * sizeof (des_block),
306  DES_ENCRYPT | DES_HW, (char *)&ivec);
307  } else {
308  status = ecb_crypt((char *)&auth->ah_key, (char *)cryptbuf,
309  (u_int) sizeof (des_block),
310  DES_ENCRYPT | DES_HW);
311  }
312  if (DES_FAILED(status)) {
313  //syslog(LOG_ERR, "authdes_marshal: DES encryption failure");
314  return (FALSE);
315  }
316  ad->ad_verf.adv_xtimestamp = cryptbuf[0];
317  if (ad->ad_cred.adc_namekind == ADN_FULLNAME) {
318  ad->ad_cred.adc_fullname.window = cryptbuf[1].key.high;
319  ad->ad_verf.adv_winverf = cryptbuf[1].key.low;
320  } else {
321  ad->ad_cred.adc_nickname = ad->ad_nickname;
322  ad->ad_verf.adv_winverf = 0;
323  }
324 
325  /*
326  * Serialize the credential and verifier into opaque
327  * authentication data.
328  */
329  if (ad->ad_cred.adc_namekind == ADN_FULLNAME) {
330  len = ((1 + 1 + 2 + 1)*BYTES_PER_XDR_UNIT + ad->ad_fullnamelen);
331  } else {
332  len = (1 + 1)*BYTES_PER_XDR_UNIT;
333  }
334 
335  if ((ixdr = xdr_inline(xdrs, 2*BYTES_PER_XDR_UNIT))) {
336  IXDR_PUT_INT32(ixdr, AUTH_DES);
337  IXDR_PUT_INT32(ixdr, len);
338  } else {
339  ATTEMPT(xdr_putint32(xdrs, (int *)&auth->ah_cred.oa_flavor));
340  ATTEMPT(xdr_putint32(xdrs, &len));
341  }
342  ATTEMPT(xdr_authdes_cred(xdrs, cred));
343 
344  len = (2 + 1)*BYTES_PER_XDR_UNIT;
345  if ((ixdr = xdr_inline(xdrs, 2*BYTES_PER_XDR_UNIT))) {
346  IXDR_PUT_INT32(ixdr, AUTH_DES);
347  IXDR_PUT_INT32(ixdr, len);
348  } else {
349  ATTEMPT(xdr_putint32(xdrs, (int *)&auth->ah_verf.oa_flavor));
350  ATTEMPT(xdr_putint32(xdrs, &len));
351  }
352  ATTEMPT(xdr_authdes_verf(xdrs, verf));
353  return (TRUE);
354 }
#define IXDR_PUT_INT32(buf, v)
Definition: rpcb_prot.h:15
#define TRUE
Definition: types.h:120
bool_t xdr_authdes_verf(XDR *, struct authdes_verf *)
Definition: authdes_prot.c:74
#define xdr_inline(xdrs, len)
Definition: xdr.h:211
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
struct des_block::@179 key
struct timeval ad_timestamp
Definition: auth_des.c:101
#define DES_FAILED(err)
Definition: des_crypt.h:65
int cbc_crypt(char *key, char *buf, unsigned len, unsigned mode, char *ivec)
Definition: des_crypt.c:75
struct authdes_verf ad_verf
Definition: auth_des.c:100
struct authdes_cred ad_cred
Definition: auth_des.c:99
struct timeval ad_timediff
Definition: auth_des.c:97
#define gettimeofday(tv, tz)
Definition: adns_win32.h:159
#define DES_ENCRYPT
Definition: des_crypt.h:51
#define DES_HW
Definition: des_crypt.h:56
smooth NULL
Definition: ftsmooth.c:416
union des_block ah_key
Definition: auth.h:208
#define IXDR_PUT_U_INT32(buf, v)
Definition: rpcb_prot.h:21
static __inline int xdr_putint32(XDR *xdrs, int32_t *ip)
Definition: xdr.h:178
int ecb_crypt(char *key, char *buf, unsigned len, unsigned mode)
Definition: des_crypt.c:102
bool_t xdr_authdes_cred(XDR *, struct authdes_cred *)
Definition: authdes_prot.c:46
struct opaque_auth ah_verf
Definition: auth.h:207
u_int ad_nickname
Definition: auth_des.c:98
#define AUTH_PRIVATE(auth)
Definition: auth_des.c:62
GLenum GLsizei len
Definition: glext.h:6722
UINT32 u_int
Definition: types.h:82
#define ATTEMPT(xdr_op)
Definition: auth_des.c:65
#define USEC_PER_SEC
Definition: auth_des.c:59
#define AUTH_DES
Definition: auth.h:407
u_int ad_window
Definition: auth_des.c:93
struct opaque_auth ah_cred
Definition: auth.h:206
Definition: fake.h:14
u_int ad_fullnamelen
Definition: auth_des.c:90
static SERVICE_STATUS status
Definition: service.c:31
int32_t rpc_inline_t
Definition: types.h:109
#define BYTES_PER_XDR_UNIT
Definition: xdr.h:93
Definition: ps.c:97

Referenced by authdes_ops().

◆ authdes_nextverf()

static void authdes_nextverf ( AUTH auth)
static

Definition at line 259 of file auth_des.c.

260 {
261  /* what the heck am I supposed to do??? */
262 }

Referenced by authdes_ops().

◆ authdes_ops()

static struct auth_ops * authdes_ops ( void  )
static

Definition at line 482 of file auth_des.c.

483 {
484  static struct auth_ops ops;
485  extern mutex_t authdes_ops_lock;
486 
487  /* VARIABLES PROTECTED BY ops_lock: ops */
488 
490  if (ops.ah_nextverf == NULL) {
491  ops.ah_nextverf = authdes_nextverf;
492  ops.ah_marshal = authdes_marshal;
493  ops.ah_validate = authdes_validate;
494  ops.ah_refresh = authdes_refresh;
495  ops.ah_destroy = authdes_destroy;
496  }
498  return (&ops);
499 }
static bool_t authdes_validate(AUTH *, struct opaque_auth *)
Definition: auth_des.c:361
#define mutex_lock(m)
Definition: reentrant.h:128
static void authdes_destroy(AUTH *)
Definition: auth_des.c:464
#define mutex_unlock(m)
Definition: reentrant.h:129
smooth NULL
Definition: ftsmooth.c:416
mutex_t authdes_ops_lock
Definition: mt_misc.c:31
static bool_t authdes_marshal(AUTH *, XDR *)
Definition: auth_des.c:269
static void authdes_nextverf(AUTH *)
Definition: auth_des.c:259
Definition: module.h:446
static bool_t authdes_refresh(AUTH *, void *)
Definition: auth_des.c:420

Referenced by authdes_pk_seccreate().

◆ authdes_pk_seccreate()

AUTH * authdes_pk_seccreate ( const char servername,
netobj pkey,
u_int  window,
const char timehost,
const des_block ckey,
nis_server srvr 
)

Definition at line 150 of file auth_des.c.

152 {
153  AUTH *auth;
154  struct ad_private *ad;
155  char namebuf[MAXNETNAMELEN+1];
156 
157  /*
158  * Allocate everything now
159  */
160  auth = ALLOC(AUTH);
161  if (auth == NULL) {
162  //syslog(LOG_ERR, "authdes_pk_seccreate: out of memory");
163  return (NULL);
164  }
165  ad = ALLOC(struct ad_private);
166  if (ad == NULL) {
167  //syslog(LOG_ERR, "authdes_pk_seccreate: out of memory");
168  goto failed;
169  }
170  ad->ad_fullname = ad->ad_servername = NULL; /* Sanity reasons */
171  ad->ad_timehost = NULL;
172  ad->ad_netid = NULL;
173  ad->ad_uaddr = NULL;
174  ad->ad_nis_srvr = NULL;
175  ad->ad_timediff.tv_sec = 0;
176  ad->ad_timediff.tv_usec = 0;
177  memcpy(ad->ad_pkey, pkey->n_bytes, pkey->n_len);
178  if (!getnetname(namebuf))
179  goto failed;
180  ad->ad_fullnamelen = RNDUP((u_int) strlen(namebuf));
181  ad->ad_fullname = (char *)mem_alloc(ad->ad_fullnamelen + 1);
182  ad->ad_servernamelen = strlen(servername);
183  ad->ad_servername = (char *)mem_alloc(ad->ad_servernamelen + 1);
184 
185  if (ad->ad_fullname == NULL || ad->ad_servername == NULL) {
186  //syslog(LOG_ERR, "authdes_seccreate: out of memory");
187  goto failed;
188  }
189  if (timehost != NULL) {
190  ad->ad_timehost = (char *)mem_alloc(strlen(timehost) + 1);
191  if (ad->ad_timehost == NULL) {
192  //syslog(LOG_ERR, "authdes_seccreate: out of memory");
193  goto failed;
194  }
195  memcpy(ad->ad_timehost, timehost, strlen(timehost) + 1);
196  ad->ad_dosync = TRUE;
197  } else if (srvr != NULL) {
198  ad->ad_nis_srvr = srvr; /* transient */
199  ad->ad_dosync = TRUE;
200  } else {
201  ad->ad_dosync = FALSE;
202  }
203  memcpy(ad->ad_fullname, namebuf, ad->ad_fullnamelen + 1);
204  memcpy(ad->ad_servername, servername, ad->ad_servernamelen + 1);
205  ad->ad_window = window;
206  if (ckey == NULL) {
207  if (key_gendes(&auth->ah_key) < 0) {
208  //syslog(LOG_ERR,
209  // "authdes_seccreate: keyserv(1m) is unable to generate session key");
210  goto failed;
211  }
212  } else {
213  auth->ah_key = *ckey;
214  }
215 
216  /*
217  * Set up auth handle
218  */
219  auth->ah_cred.oa_flavor = AUTH_DES;
220  auth->ah_verf.oa_flavor = AUTH_DES;
221  auth->ah_ops = authdes_ops();
222  auth->ah_private = (caddr_t)ad;
223 
224  if (!authdes_refresh(auth, NULL)) {
225  goto failed;
226  }
227  ad->ad_nis_srvr = NULL; /* not needed any longer */
228  return (auth);
229 
230 failed:
231  if (auth)
232  FREE(auth, sizeof (AUTH));
233  if (ad) {
234  if (ad->ad_fullname)
235  FREE(ad->ad_fullname, ad->ad_fullnamelen + 1);
236  if (ad->ad_servername)
237  FREE(ad->ad_servername, ad->ad_servernamelen + 1);
238  if (ad->ad_timehost)
239  FREE(ad->ad_timehost, strlen(ad->ad_timehost) + 1);
240  if (ad->ad_netid)
241  FREE(ad->ad_netid, strlen(ad->ad_netid) + 1);
242  if (ad->ad_uaddr)
243  FREE(ad->ad_uaddr, strlen(ad->ad_uaddr) + 1);
244  FREE(ad, sizeof (struct ad_private));
245  }
246  return (NULL);
247 }
#define TRUE
Definition: types.h:120
u_char ad_pkey[1024]
Definition: auth_des.c:103
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
bool_t ad_dosync
Definition: auth_des.c:94
Definition: auth.h:205
int key_gendes(des_block *key)
Definition: key_call.c:225
struct timeval ad_timediff
Definition: auth_des.c:97
#define mem_alloc(bsize)
Definition: types.h:123
#define ALLOC(object_type)
Definition: auth_des.c:63
smooth NULL
Definition: ftsmooth.c:416
union des_block ah_key
Definition: auth.h:208
void * ah_private
Definition: auth.h:225
char * ad_servername
Definition: auth_des.c:91
int getnetname(name)
Definition: netname.c:78
struct opaque_auth ah_verf
Definition: auth.h:207
char * ad_timehost
Definition: auth_des.c:96
u_int n_len
Definition: xdr.h:333
nis_server * ad_nis_srvr
Definition: auth_des.c:106
char * ad_fullname
Definition: auth_des.c:89
#define FREE(ptr, size)
Definition: auth_des.c:64
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define RNDUP(x)
Definition: xdr.h:94
static IHTMLWindow2 * window
Definition: events.c:77
u_int ad_servernamelen
Definition: auth_des.c:92
#define MAXNETNAMELEN
Definition: auth.h:78
char * n_bytes
Definition: xdr.h:334
#define caddr_t
Definition: ftp.c:24
UINT32 u_int
Definition: types.h:82
struct __auth::auth_ops * ah_ops
char * ad_netid
Definition: auth_des.c:104
static struct auth_ops * authdes_ops(void)
Definition: auth_des.c:482
#define AUTH_DES
Definition: auth.h:407
u_int ad_window
Definition: auth_des.c:93
struct opaque_auth ah_cred
Definition: auth.h:206
char * ad_uaddr
Definition: auth_des.c:105
u_int ad_fullnamelen
Definition: auth_des.c:90
static bool_t authdes_refresh(AUTH *, void *)
Definition: auth_des.c:420

Referenced by authdes_seccreate().

◆ authdes_refresh()

static bool_t authdes_refresh ( AUTH auth,
void dummy 
)
static

Definition at line 420 of file auth_des.c.

421 {
422 /* LINTED pointer alignment */
423  struct ad_private *ad = AUTH_PRIVATE(auth);
424  struct authdes_cred *cred = &ad->ad_cred;
425  int ok;
426  netobj pkey;
427 
428  if (ad->ad_dosync) {
429 #if 1 // WINDOWS
430  ok = 1;
431 #else
433  ad->ad_timehost, &(ad->ad_uaddr),
434  &(ad->ad_netid));
435 #endif
436  if (! ok) {
437  /*
438  * Hope the clocks are synced!
439  */
440  ad->ad_dosync = 0;
441  //syslog(LOG_DEBUG,
442  // "authdes_refresh: unable to synchronize clock");
443  }
444  }
445  ad->ad_xkey = auth->ah_key;
446  pkey.n_bytes = (char *)(ad->ad_pkey);
447  pkey.n_len = (u_int)strlen((char *)ad->ad_pkey) + 1;
448  if (key_encryptsession_pk(ad->ad_servername, &pkey, &ad->ad_xkey) < 0) {
449  //syslog(LOG_INFO,
450  // "authdes_refresh: keyserv(1m) is unable to encrypt session key");
451  return (FALSE);
452  }
453  cred->adc_fullname.key = ad->ad_xkey;
454  cred->adc_namekind = ADN_FULLNAME;
455  cred->adc_fullname.name = ad->ad_fullname;
456  return (TRUE);
457 }
#define TRUE
Definition: types.h:120
u_char ad_pkey[1024]
Definition: auth_des.c:103
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
bool_t __rpc_get_time_offset(struct timeval *, nis_server *, char *, char **, char **)
bool_t ad_dosync
Definition: auth_des.c:94
struct authdes_cred ad_cred
Definition: auth_des.c:99
struct authdes_fullname adc_fullname
Definition: auth_des.h:72
struct timeval ad_timediff
Definition: auth_des.c:97
Definition: xdr.h:332
#define ok(value,...)
union des_block ah_key
Definition: auth.h:208
char * ad_servername
Definition: auth_des.c:91
char * ad_timehost
Definition: auth_des.c:96
int key_encryptsession_pk()
u_int n_len
Definition: xdr.h:333
nis_server * ad_nis_srvr
Definition: auth_des.c:106
char * ad_fullname
Definition: auth_des.c:89
#define AUTH_PRIVATE(auth)
Definition: auth_des.c:62
enum authdes_namekind adc_namekind
Definition: auth_des.h:71
char * n_bytes
Definition: xdr.h:334
UINT32 u_int
Definition: types.h:82
char * ad_netid
Definition: auth_des.c:104
des_block ad_xkey
Definition: auth_des.c:102
char * ad_uaddr
Definition: auth_des.c:105

Referenced by authdes_ops(), and authdes_pk_seccreate().

◆ authdes_seccreate()

AUTH* authdes_seccreate ( const char servername,
const u_int  win,
const char timehost,
const des_block ckey 
)

Definition at line 123 of file auth_des.c.

125 {
126  u_char pkey_data[1024];
127  netobj pkey;
128  AUTH *dummy;
129 
130  if (! getpublickey(servername, (char *) pkey_data)) {
131  //syslog(LOG_ERR,
132  // "authdes_seccreate: no public key found for %s",
133  // servername);
134  return (NULL);
135  }
136 
137  pkey.n_bytes = (char *) pkey_data;
138  pkey.n_len = (u_int)strlen((char *)pkey_data) + 1;
139  dummy = authdes_pk_seccreate(servername, &pkey, win, timehost,
140  ckey, NULL);
141  return (dummy);
142 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
AUTH * authdes_pk_seccreate(const char *, netobj *, u_int, const char *, const des_block *, nis_server *)
Definition: auth_des.c:150
Definition: auth.h:205
Definition: xdr.h:332
smooth NULL
Definition: ftsmooth.c:416
u_int n_len
Definition: xdr.h:333
static real win[4][36]
char * n_bytes
Definition: xdr.h:334
int getpublickey(char *netname, char *publickey) const
Definition: getpublickey.c:166
UINT32 u_int
Definition: types.h:82
unsigned char dummy
Definition: maze.c:118
UCHAR u_char
Definition: types.h:80

◆ authdes_validate()

static bool_t authdes_validate ( AUTH auth,
struct opaque_auth rverf 
)
static

Definition at line 361 of file auth_des.c.

362 {
363 /* LINTED pointer alignment */
364  struct ad_private *ad = AUTH_PRIVATE(auth);
365  struct authdes_verf verf;
366  int status;
367  uint32_t *ixdr;
368  des_block buf;
369 
370  if (rverf->oa_length != (2 + 1) * BYTES_PER_XDR_UNIT) {
371  return (FALSE);
372  }
373 /* LINTED pointer alignment */
374  ixdr = (uint32_t *)rverf->oa_base;
375  buf.key.high = (uint32_t)*ixdr++;
376  buf.key.low = (uint32_t)*ixdr++;
377  verf.adv_int_u = (uint32_t)*ixdr++;
378 
379  /*
380  * Decrypt the timestamp
381  */
382  status = ecb_crypt((char *)&auth->ah_key, (char *)&buf,
384 
385  if (DES_FAILED(status)) {
386  //syslog(LOG_ERR, "authdes_validate: DES decryption failure");
387  return (FALSE);
388  }
389 
390  /*
391  * xdr the decrypted timestamp
392  */
393 /* LINTED pointer alignment */
394  ixdr = (uint32_t *)buf.c;
395  verf.adv_timestamp.tv_sec = IXDR_GET_INT32(ixdr) + 1;
396  verf.adv_timestamp.tv_usec = IXDR_GET_INT32(ixdr);
397 
398  /*
399  * validate
400  */
401  if (bcmp((char *)&ad->ad_timestamp, (char *)&verf.adv_timestamp,
402  sizeof(struct timeval)) != 0) {
403  //syslog(LOG_DEBUG, "authdes_validate: verifier mismatch");
404  return (FALSE);
405  }
406 
407  /*
408  * We have a nickname now, let's use it
409  */
410  ad->ad_nickname = verf.adv_nickname;
411  ad->ad_cred.adc_namekind = ADN_NICKNAME;
412  return (TRUE);
413 }
#define TRUE
Definition: types.h:120
#define bcmp(s1, s2, n)
Definition: various.h:26
#define DES_DECRYPT
Definition: des_crypt.h:52
u_int oa_length
Definition: auth.h:198
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define IXDR_GET_INT32(buf)
Definition: rpcb_prot.h:12
struct timeval ad_timestamp
Definition: auth_des.c:101
caddr_t oa_base
Definition: auth.h:197
#define DES_FAILED(err)
Definition: des_crypt.h:65
struct authdes_cred ad_cred
Definition: auth_des.c:99
#define DES_HW
Definition: des_crypt.h:56
union des_block ah_key
Definition: auth.h:208
int ecb_crypt(char *key, char *buf, unsigned len, unsigned mode)
Definition: des_crypt.c:102
u_int ad_nickname
Definition: auth_des.c:98
#define AUTH_PRIVATE(auth)
Definition: auth_des.c:62
UINT32 u_int
Definition: types.h:82
UINT32 uint32_t
Definition: types.h:75
#define uint32_t
Definition: nsiface.idl:61
static SERVICE_STATUS status
Definition: service.c:31
#define BYTES_PER_XDR_UNIT
Definition: xdr.h:93
Definition: ps.c:97

Referenced by authdes_ops().

◆ key_encryptsession_pk()

int key_encryptsession_pk ( )

Referenced by authdes_refresh().

◆ xdr_authdes_cred()

bool_t xdr_authdes_cred ( XDR ,
struct authdes_cred  
)

Definition at line 46 of file authdes_prot.c.

49 {
50  /*
51  * Unrolled xdr
52  */
53  ATTEMPT(xdr_enum(xdrs, (enum_t *)&cred->adc_namekind));
54  switch (cred->adc_namekind) {
55  case ADN_FULLNAME:
56  ATTEMPT(xdr_string(xdrs, &cred->adc_fullname.name,
57  MAXNETNAMELEN));
58  ATTEMPT(xdr_opaque(xdrs, (caddr_t)&cred->adc_fullname.key,
59  sizeof(des_block)));
60  ATTEMPT(xdr_opaque(xdrs, (caddr_t)&cred->adc_fullname.window,
61  sizeof(cred->adc_fullname.window)));
62  return (TRUE);
63  case ADN_NICKNAME:
64  ATTEMPT(xdr_opaque(xdrs, (caddr_t)&cred->adc_nickname,
65  sizeof(cred->adc_nickname)));
66  return (TRUE);
67  default:
68  return (FALSE);
69  }
70 }
#define TRUE
Definition: types.h:120
bool_t xdr_string(XDR *xdrs, char **cpp, u_int maxsize)
Definition: xdr.c:678
char * caddr_t
Definition: rosdhcp.h:36
bool_t xdr_enum(XDR *xdrs, enum_t *ep)
Definition: xdr.c:458
int32_t enum_t
Definition: types.h:102
bool_t xdr_opaque(XDR *xdrs, caddr_t cp, u_int cnt)
Definition: xdr.c:484
#define MAXNETNAMELEN
Definition: auth.h:78
#define ATTEMPT(xdr_op)
Definition: authdes_prot.c:43

Referenced by authdes_marshal().

◆ xdr_authdes_verf()

bool_t xdr_authdes_verf ( XDR ,
struct authdes_verf  
)

Definition at line 74 of file authdes_prot.c.

77 {
78  /*
79  * Unrolled xdr
80  */
81  ATTEMPT(xdr_opaque(xdrs, (caddr_t)&verf->adv_xtimestamp,
82  sizeof(des_block)));
83  ATTEMPT(xdr_opaque(xdrs, (caddr_t)&verf->adv_int_u,
84  sizeof(verf->adv_int_u)));
85  return (TRUE);
86 }
#define TRUE
Definition: types.h:120
char * caddr_t
Definition: rosdhcp.h:36
bool_t xdr_opaque(XDR *xdrs, caddr_t cp, u_int cnt)
Definition: xdr.c:484
#define ATTEMPT(xdr_op)
Definition: authdes_prot.c:43

Referenced by authdes_marshal().