Whamcloud - gitweb
91d1a4b5a95207313da438d9776bf9a87caf2a57
[fs/lustre-release.git] / lustre / ptlrpc / gss / gss_crypto.h
1 /*
2  * Modifications for Lustre
3  *
4  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
5  *
6  * Author: Eric Mei <ericm@clusterfs.com>
7  */
8
9 /*
10  *  linux/include/linux/sunrpc/gss_krb5_types.h
11  *
12  *  Adapted from MIT Kerberos 5-1.2.1 lib/include/krb5.h,
13  *  lib/gssapi/krb5/gssapiP_krb5.h, and others
14  *
15  *  Copyright (c) 2000 The Regents of the University of Michigan.
16  *  All rights reserved.
17  *
18  *  Andy Adamson   <andros@umich.edu>
19  *  Bruce Fields   <bfields@umich.edu>
20  */
21
22 /*
23  * Copyright 1995 by the Massachusetts Institute of Technology.
24  * All Rights Reserved.
25  *
26  * Export of this software from the United States of America may
27  *   require a specific license from the United States Government.
28  *   It is the responsibility of any person or organization contemplating
29  *   export to obtain such a license before exporting.
30  *
31  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
32  * distribute this software and its documentation for any purpose and
33  * without fee is hereby granted, provided that the above copyright
34  * notice appear in all copies and that both that copyright notice and
35  * this permission notice appear in supporting documentation, and that
36  * the name of M.I.T. not be used in advertising or publicity pertaining
37  * to distribution of the software without specific, written prior
38  * permission.  Furthermore if you modify this software you must label
39  * your software as modified software and not distribute it in such a
40  * fashion that it might be confused with the original M.I.T. software.
41  * M.I.T. makes no representations about the suitability of
42  * this software for any purpose.  It is provided "as is" without express
43  * or implied warranty.
44  *
45  */
46
47 #ifndef PTLRPC_GSS_UTILS_H
48 #define PTLRPC_GSS_UTILS_H
49
50 #include "gss_internal.h"
51
52 struct gss_keyblock {
53         rawobj_t                 kb_key;
54         struct crypto_blkcipher *kb_tfm;
55 };
56
57 int gss_keyblock_init(struct gss_keyblock *kb, char *alg_name,
58                       const int alg_mode);
59 void gss_keyblock_free(struct gss_keyblock *kb);
60 int gss_keyblock_dup(struct gss_keyblock *new, struct gss_keyblock *kb);
61 int gss_get_bytes(char **ptr, const char *end, void *res, size_t len);
62 int gss_get_rawobj(char **ptr, const char *end, rawobj_t *res);
63 int gss_get_keyblock(char **ptr, const char *end, struct gss_keyblock *kb,
64                      __u32 keysize);
65 int gss_setup_sgtable(struct sg_table *sgt, struct scatterlist *prealloc_sg,
66                       const void *buf, unsigned int buf_len);
67 void gss_teardown_sgtable(struct sg_table *sgt);
68 int gss_crypt_generic(struct crypto_blkcipher *tfm, int decrypt, void *iv,
69                         void *in, void *out, int length);
70 int gss_digest_hmac(struct crypto_hash *tfm, rawobj_t *key, rawobj_t *hdr,
71                     int msgcnt, rawobj_t *msgs, int iovcnt, lnet_kiov_t *iovs,
72                     rawobj_t *cksum);
73 int gss_digest_norm(struct crypto_hash *tfm, struct gss_keyblock *kb,
74                     rawobj_t *hdr, int msgcnt, rawobj_t *msgs, int iovcnt,
75                     lnet_kiov_t *iovs, rawobj_t *cksum);
76 int gss_add_padding(rawobj_t *msg, int msg_buflen, int blocksize);
77 int gss_crypt_rawobjs(struct crypto_blkcipher *tfm, int use_internal_iv,
78                       int inobj_cnt, rawobj_t *inobjs, rawobj_t *outobj,
79                       int enc);
80
81 #endif /* PTLRPC_GSS_UTILS_H */