xref: /OK3568_Linux_fs/kernel/include/linux/sunrpc/gss_asn1.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  *  linux/include/linux/sunrpc/gss_asn1.h
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  *  minimal asn1 for generic encoding/decoding of gss tokens
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  *  Adapted from MIT Kerberos 5-1.2.1 lib/include/krb5.h,
7*4882a593Smuzhiyun  *  lib/gssapi/krb5/gssapiP_krb5.h, and others
8*4882a593Smuzhiyun  *
9*4882a593Smuzhiyun  *  Copyright (c) 2000 The Regents of the University of Michigan.
10*4882a593Smuzhiyun  *  All rights reserved.
11*4882a593Smuzhiyun  *
12*4882a593Smuzhiyun  *  Andy Adamson   <andros@umich.edu>
13*4882a593Smuzhiyun  */
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun /*
16*4882a593Smuzhiyun  * Copyright 1995 by the Massachusetts Institute of Technology.
17*4882a593Smuzhiyun  * All Rights Reserved.
18*4882a593Smuzhiyun  *
19*4882a593Smuzhiyun  * Export of this software from the United States of America may
20*4882a593Smuzhiyun  *   require a specific license from the United States Government.
21*4882a593Smuzhiyun  *   It is the responsibility of any person or organization contemplating
22*4882a593Smuzhiyun  *   export to obtain such a license before exporting.
23*4882a593Smuzhiyun  *
24*4882a593Smuzhiyun  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
25*4882a593Smuzhiyun  * distribute this software and its documentation for any purpose and
26*4882a593Smuzhiyun  * without fee is hereby granted, provided that the above copyright
27*4882a593Smuzhiyun  * notice appear in all copies and that both that copyright notice and
28*4882a593Smuzhiyun  * this permission notice appear in supporting documentation, and that
29*4882a593Smuzhiyun  * the name of M.I.T. not be used in advertising or publicity pertaining
30*4882a593Smuzhiyun  * to distribution of the software without specific, written prior
31*4882a593Smuzhiyun  * permission.  Furthermore if you modify this software you must label
32*4882a593Smuzhiyun  * your software as modified software and not distribute it in such a
33*4882a593Smuzhiyun  * fashion that it might be confused with the original M.I.T. software.
34*4882a593Smuzhiyun  * M.I.T. makes no representations about the suitability of
35*4882a593Smuzhiyun  * this software for any purpose.  It is provided "as is" without express
36*4882a593Smuzhiyun  * or implied warranty.
37*4882a593Smuzhiyun  *
38*4882a593Smuzhiyun  */
39*4882a593Smuzhiyun 
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun #include <linux/sunrpc/gss_api.h>
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun #define SIZEOF_INT 4
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun /* from gssapi_err_generic.h */
46*4882a593Smuzhiyun #define G_BAD_SERVICE_NAME                       (-2045022976L)
47*4882a593Smuzhiyun #define G_BAD_STRING_UID                         (-2045022975L)
48*4882a593Smuzhiyun #define G_NOUSER                                 (-2045022974L)
49*4882a593Smuzhiyun #define G_VALIDATE_FAILED                        (-2045022973L)
50*4882a593Smuzhiyun #define G_BUFFER_ALLOC                           (-2045022972L)
51*4882a593Smuzhiyun #define G_BAD_MSG_CTX                            (-2045022971L)
52*4882a593Smuzhiyun #define G_WRONG_SIZE                             (-2045022970L)
53*4882a593Smuzhiyun #define G_BAD_USAGE                              (-2045022969L)
54*4882a593Smuzhiyun #define G_UNKNOWN_QOP                            (-2045022968L)
55*4882a593Smuzhiyun #define G_NO_HOSTNAME                            (-2045022967L)
56*4882a593Smuzhiyun #define G_BAD_HOSTNAME                           (-2045022966L)
57*4882a593Smuzhiyun #define G_WRONG_MECH                             (-2045022965L)
58*4882a593Smuzhiyun #define G_BAD_TOK_HEADER                         (-2045022964L)
59*4882a593Smuzhiyun #define G_BAD_DIRECTION                          (-2045022963L)
60*4882a593Smuzhiyun #define G_TOK_TRUNC                              (-2045022962L)
61*4882a593Smuzhiyun #define G_REFLECT                                (-2045022961L)
62*4882a593Smuzhiyun #define G_WRONG_TOKID                            (-2045022960L)
63*4882a593Smuzhiyun 
64*4882a593Smuzhiyun #define g_OID_equal(o1,o2) \
65*4882a593Smuzhiyun    (((o1)->len == (o2)->len) && \
66*4882a593Smuzhiyun     (memcmp((o1)->data,(o2)->data,(int) (o1)->len) == 0))
67*4882a593Smuzhiyun 
68*4882a593Smuzhiyun u32 g_verify_token_header(
69*4882a593Smuzhiyun      struct xdr_netobj *mech,
70*4882a593Smuzhiyun      int *body_size,
71*4882a593Smuzhiyun      unsigned char **buf_in,
72*4882a593Smuzhiyun      int toksize);
73*4882a593Smuzhiyun 
74*4882a593Smuzhiyun int g_token_size(
75*4882a593Smuzhiyun      struct xdr_netobj *mech,
76*4882a593Smuzhiyun      unsigned int body_size);
77*4882a593Smuzhiyun 
78*4882a593Smuzhiyun void g_make_token_header(
79*4882a593Smuzhiyun      struct xdr_netobj *mech,
80*4882a593Smuzhiyun      int body_size,
81*4882a593Smuzhiyun      unsigned char **buf);
82