/src/krb5/src/lib/gssapi/mechglue/g_prf.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright 2009 by the Massachusetts Institute of Technology. |
3 | | * All Rights Reserved. |
4 | | * |
5 | | * Export of this software from the United States of America may |
6 | | * require a specific license from the United States Government. |
7 | | * It is the responsibility of any person or organization contemplating |
8 | | * export to obtain such a license before exporting. |
9 | | * |
10 | | * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and |
11 | | * distribute this software and its documentation for any purpose and |
12 | | * without fee is hereby granted, provided that the above copyright |
13 | | * notice appear in all copies and that both that copyright notice and |
14 | | * this permission notice appear in supporting documentation, and that |
15 | | * the name of M.I.T. not be used in advertising or publicity pertaining |
16 | | * to distribution of the software without specific, written prior |
17 | | * permission. Furthermore if you modify this software you must label |
18 | | * your software as modified software and not distribute it in such a |
19 | | * fashion that it might be confused with the original M.I.T. software. |
20 | | * M.I.T. makes no representations about the suitability of |
21 | | * this software for any purpose. It is provided "as is" without express |
22 | | * or implied warranty. |
23 | | */ |
24 | | |
25 | | /* Glue routine for gss_pseudo_random */ |
26 | | |
27 | | #include "mglueP.h" |
28 | | |
29 | | OM_uint32 KRB5_CALLCONV |
30 | | gss_pseudo_random (OM_uint32 *minor_status, |
31 | | gss_ctx_id_t context_handle, |
32 | | int prf_key, |
33 | | const gss_buffer_t prf_in, |
34 | | ssize_t desired_output_len, |
35 | | gss_buffer_t prf_out) |
36 | 0 | { |
37 | 0 | OM_uint32 status; |
38 | 0 | gss_union_ctx_id_t ctx; |
39 | 0 | gss_mechanism mech; |
40 | |
|
41 | 0 | if (minor_status != NULL) |
42 | 0 | *minor_status = 0; |
43 | |
|
44 | 0 | if (prf_out != GSS_C_NO_BUFFER) { |
45 | 0 | prf_out->length = 0; |
46 | 0 | prf_out->value = NULL; |
47 | 0 | } |
48 | |
|
49 | 0 | if (minor_status == NULL) |
50 | 0 | return GSS_S_CALL_INACCESSIBLE_WRITE; |
51 | | |
52 | 0 | if (context_handle == GSS_C_NO_CONTEXT) |
53 | 0 | return GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT; |
54 | | |
55 | 0 | if (prf_in == GSS_C_NO_BUFFER) |
56 | 0 | return GSS_S_CALL_INACCESSIBLE_READ; |
57 | | |
58 | 0 | if (prf_out == GSS_C_NO_BUFFER) |
59 | 0 | return GSS_S_CALL_INACCESSIBLE_WRITE; |
60 | | |
61 | 0 | prf_out->length = 0; |
62 | 0 | prf_out->value = NULL; |
63 | | |
64 | | /* |
65 | | * select the approprate underlying mechanism routine and |
66 | | * call it. |
67 | | */ |
68 | |
|
69 | 0 | ctx = (gss_union_ctx_id_t) context_handle; |
70 | 0 | if (ctx->internal_ctx_id == GSS_C_NO_CONTEXT) |
71 | 0 | return GSS_S_NO_CONTEXT; |
72 | 0 | mech = gssint_get_mechanism (ctx->mech_type); |
73 | |
|
74 | 0 | if (mech != NULL) { |
75 | 0 | if (mech->gss_pseudo_random != NULL) { |
76 | 0 | status = mech->gss_pseudo_random(minor_status, |
77 | 0 | ctx->internal_ctx_id, |
78 | 0 | prf_key, |
79 | 0 | prf_in, |
80 | 0 | desired_output_len, |
81 | 0 | prf_out); |
82 | 0 | if (status != GSS_S_COMPLETE) |
83 | 0 | map_error(minor_status, mech); |
84 | 0 | } else |
85 | 0 | status = GSS_S_UNAVAILABLE; |
86 | |
|
87 | 0 | return status; |
88 | 0 | } |
89 | | |
90 | 0 | return GSS_S_BAD_MECH; |
91 | 0 | } |