auth_des.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /* Copyright (C) 1996-2020 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <https://www.gnu.org/licenses/>. */
  14. #ifndef _RPC_AUTH_DES_H
  15. #define _RPC_AUTH_DES_H 1
  16. #include <sys/cdefs.h>
  17. #include <rpc/auth.h>
  18. __BEGIN_DECLS
  19. /* There are two kinds of "names": fullnames and nicknames */
  20. enum authdes_namekind
  21. {
  22. ADN_FULLNAME,
  23. ADN_NICKNAME
  24. };
  25. /* A fullname contains the network name of the client,
  26. a conversation key and the window */
  27. struct authdes_fullname
  28. {
  29. char *name; /* network name of client, up to MAXNETNAMELEN */
  30. des_block key; /* conversation key */
  31. uint32_t window; /* associated window */
  32. };
  33. /* A credential */
  34. struct authdes_cred
  35. {
  36. enum authdes_namekind adc_namekind;
  37. struct authdes_fullname adc_fullname;
  38. uint32_t adc_nickname;
  39. };
  40. /* A timeval replacement for !32bit platforms */
  41. struct rpc_timeval
  42. {
  43. uint32_t tv_sec; /* Seconds. */
  44. uint32_t tv_usec; /* Microseconds. */
  45. };
  46. /* A des authentication verifier */
  47. struct authdes_verf
  48. {
  49. union
  50. {
  51. struct rpc_timeval adv_ctime; /* clear time */
  52. des_block adv_xtime; /* crypt time */
  53. }
  54. adv_time_u;
  55. uint32_t adv_int_u;
  56. };
  57. /* des authentication verifier: client variety
  58. adv_timestamp is the current time.
  59. adv_winverf is the credential window + 1.
  60. Both are encrypted using the conversation key. */
  61. #define adv_timestamp adv_time_u.adv_ctime
  62. #define adv_xtimestamp adv_time_u.adv_xtime
  63. #define adv_winverf adv_int_u
  64. /* des authentication verifier: server variety
  65. adv_timeverf is the client's timestamp + client's window
  66. adv_nickname is the server's nickname for the client.
  67. adv_timeverf is encrypted using the conversation key. */
  68. #define adv_timeverf adv_time_u.adv_ctime
  69. #define adv_xtimeverf adv_time_u.adv_xtime
  70. #define adv_nickname adv_int_u
  71. /* Map a des credential into a unix cred. */
  72. extern int authdes_getucred (const struct authdes_cred * __adc,
  73. uid_t * __uid, gid_t * __gid,
  74. short *__grouplen, gid_t * __groups) __THROW;
  75. /* Get the public key for NAME and place it in KEY. NAME can only be
  76. up to MAXNETNAMELEN bytes long and the destination buffer KEY should
  77. have HEXKEYBYTES + 1 bytes long to fit all characters from the key. */
  78. extern int getpublickey (const char *__name, char *__key) __THROW;
  79. /* Get the secret key for NAME and place it in KEY. PASSWD is used to
  80. decrypt the encrypted key stored in the database. NAME can only be
  81. up to MAXNETNAMELEN bytes long and the destination buffer KEY
  82. should have HEXKEYBYTES + 1 bytes long to fit all characters from
  83. the key. */
  84. extern int getsecretkey (const char *__name, char *__key,
  85. const char *__passwd) __THROW;
  86. extern int rtime (struct sockaddr_in *__addrp, struct rpc_timeval *__timep,
  87. struct rpc_timeval *__timeout) __THROW;
  88. __END_DECLS
  89. #endif /* rpc/auth_des.h */