- Kill files that do not belong to the laters heimdal version imported.
This commit is contained in:
parent
0ab8d01835
commit
100a21d381
@ -1,28 +0,0 @@
|
|||||||
dnl $Id: broken-getnameinfo.m4,v 1.2.12.1 2004/04/01 07:27:32 joda Exp $
|
|
||||||
dnl
|
|
||||||
dnl test for broken AIX getnameinfo
|
|
||||||
|
|
||||||
AC_DEFUN([rk_BROKEN_GETNAMEINFO],[
|
|
||||||
AC_CACHE_CHECK([if getnameinfo is broken], ac_cv_func_getnameinfo_broken,
|
|
||||||
AC_TRY_RUN([[#include <stdio.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <netdb.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
struct sockaddr_in sin;
|
|
||||||
char host[256];
|
|
||||||
memset(&sin, 0, sizeof(sin));
|
|
||||||
#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
|
|
||||||
sin.sin_len = sizeof(sin);
|
|
||||||
#endif
|
|
||||||
sin.sin_family = AF_INET;
|
|
||||||
sin.sin_addr.s_addr = 0xffffffff;
|
|
||||||
sin.sin_port = 0;
|
|
||||||
return getnameinfo((struct sockaddr*)&sin, sizeof(sin), host, sizeof(host),
|
|
||||||
NULL, 0, 0);
|
|
||||||
}
|
|
||||||
]], ac_cv_func_getnameinfo_broken=no, ac_cv_func_getnameinfo_broken=yes))])
|
|
@ -1,25 +0,0 @@
|
|||||||
dnl $Id: check-declaration.m4,v 1.3.34.1 2004/04/01 07:27:32 joda Exp $
|
|
||||||
dnl
|
|
||||||
dnl
|
|
||||||
dnl Check if we need the declaration of a variable
|
|
||||||
dnl
|
|
||||||
|
|
||||||
dnl AC_HAVE_DECLARATION(includes, variable)
|
|
||||||
AC_DEFUN([AC_CHECK_DECLARATION], [
|
|
||||||
AC_MSG_CHECKING([if $2 is properly declared])
|
|
||||||
AC_CACHE_VAL(ac_cv_var_$2_declaration, [
|
|
||||||
AC_TRY_COMPILE([$1
|
|
||||||
extern struct { int foo; } $2;],
|
|
||||||
[$2.foo = 1;],
|
|
||||||
eval "ac_cv_var_$2_declaration=no",
|
|
||||||
eval "ac_cv_var_$2_declaration=yes")
|
|
||||||
])
|
|
||||||
|
|
||||||
define(foo, [HAVE_]translit($2, [a-z], [A-Z])[_DECLARATION])
|
|
||||||
|
|
||||||
AC_MSG_RESULT($ac_cv_var_$2_declaration)
|
|
||||||
if eval "test \"\$ac_cv_var_$2_declaration\" = yes"; then
|
|
||||||
AC_DEFINE(foo, 1, [define if your system declares $2])
|
|
||||||
fi
|
|
||||||
undefine([foo])
|
|
||||||
])
|
|
1016
kadmin/version4.c
1016
kadmin/version4.c
File diff suppressed because it is too large
Load Diff
@ -1,40 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1998 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "kuser_locl.h"
|
|
||||||
RCSID("$Id: kauth_options.c,v 1.2 1999/12/02 17:05:00 joda Exp $");
|
|
||||||
|
|
||||||
#ifdef KRB4
|
|
||||||
int do_afslog = 1;
|
|
||||||
int get_v4_tgt = 1;
|
|
||||||
#endif
|
|
@ -1,40 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1998 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "kuser_locl.h"
|
|
||||||
RCSID("$Id: kinit_options.c,v 1.2 1999/12/02 17:05:01 joda Exp $");
|
|
||||||
|
|
||||||
#ifdef KRB4
|
|
||||||
int do_afslog = 0;
|
|
||||||
int get_v4_tgt = 0;
|
|
||||||
#endif
|
|
@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* $Id: gen.h,v 1.4 1999/12/02 17:05:02 joda Exp $ */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "symbol.h"
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
|||||||
X509 DEFINITIONS ::= BEGIN
|
|
||||||
|
|
||||||
CertificateSerialNumber ::= INTEGER -- X.509 '97
|
|
||||||
|
|
||||||
AttributeType ::= OBJECT-IDENTIFIER
|
|
||||||
|
|
||||||
AttributeValue ::= OCTET STRING --ANY DEFINED BY AttributeType
|
|
||||||
|
|
||||||
AttributeTypeAndValue ::= SEQUENCE {
|
|
||||||
type AttributeType,
|
|
||||||
value AttributeValue
|
|
||||||
}
|
|
||||||
|
|
||||||
RelativeDistinguishedName ::= --SET
|
|
||||||
SEQUENCE OF AttributeTypeAndValue
|
|
||||||
|
|
||||||
RDNSequence ::= SEQUENCE OF RelativeDistinguishedName
|
|
||||||
|
|
||||||
Name ::= CHOICE { -- RFC2459
|
|
||||||
x RDNSequence
|
|
||||||
}
|
|
||||||
|
|
||||||
END
|
|
@ -1,251 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997 - 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: 8003.c,v 1.12.2.2 2003/09/18 21:30:57 lha Exp $");
|
|
||||||
|
|
||||||
krb5_error_code
|
|
||||||
gssapi_encode_om_uint32(OM_uint32 n, u_char *p)
|
|
||||||
{
|
|
||||||
p[0] = (n >> 0) & 0xFF;
|
|
||||||
p[1] = (n >> 8) & 0xFF;
|
|
||||||
p[2] = (n >> 16) & 0xFF;
|
|
||||||
p[3] = (n >> 24) & 0xFF;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
krb5_error_code
|
|
||||||
gssapi_encode_be_om_uint32(OM_uint32 n, u_char *p)
|
|
||||||
{
|
|
||||||
p[0] = (n >> 24) & 0xFF;
|
|
||||||
p[1] = (n >> 16) & 0xFF;
|
|
||||||
p[2] = (n >> 8) & 0xFF;
|
|
||||||
p[3] = (n >> 0) & 0xFF;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
krb5_error_code
|
|
||||||
gssapi_decode_om_uint32(u_char *p, OM_uint32 *n)
|
|
||||||
{
|
|
||||||
*n = (p[0] << 0) | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
krb5_error_code
|
|
||||||
gssapi_decode_be_om_uint32(u_char *p, OM_uint32 *n)
|
|
||||||
{
|
|
||||||
*n = (p[0] <<24) | (p[1] << 16) | (p[2] << 8) | (p[3] << 0);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static krb5_error_code
|
|
||||||
hash_input_chan_bindings (const gss_channel_bindings_t b,
|
|
||||||
u_char *p)
|
|
||||||
{
|
|
||||||
u_char num[4];
|
|
||||||
MD5_CTX md5;
|
|
||||||
|
|
||||||
MD5_Init(&md5);
|
|
||||||
gssapi_encode_om_uint32 (b->initiator_addrtype, num);
|
|
||||||
MD5_Update (&md5, num, sizeof(num));
|
|
||||||
gssapi_encode_om_uint32 (b->initiator_address.length, num);
|
|
||||||
MD5_Update (&md5, num, sizeof(num));
|
|
||||||
if (b->initiator_address.length)
|
|
||||||
MD5_Update (&md5,
|
|
||||||
b->initiator_address.value,
|
|
||||||
b->initiator_address.length);
|
|
||||||
gssapi_encode_om_uint32 (b->acceptor_addrtype, num);
|
|
||||||
MD5_Update (&md5, num, sizeof(num));
|
|
||||||
gssapi_encode_om_uint32 (b->acceptor_address.length, num);
|
|
||||||
MD5_Update (&md5, num, sizeof(num));
|
|
||||||
if (b->acceptor_address.length)
|
|
||||||
MD5_Update (&md5,
|
|
||||||
b->acceptor_address.value,
|
|
||||||
b->acceptor_address.length);
|
|
||||||
gssapi_encode_om_uint32 (b->application_data.length, num);
|
|
||||||
MD5_Update (&md5, num, sizeof(num));
|
|
||||||
if (b->application_data.length)
|
|
||||||
MD5_Update (&md5,
|
|
||||||
b->application_data.value,
|
|
||||||
b->application_data.length);
|
|
||||||
MD5_Final (p, &md5);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* create a checksum over the chanel bindings in
|
|
||||||
* `input_chan_bindings', `flags' and `fwd_data' and return it in
|
|
||||||
* `result'
|
|
||||||
*/
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
gssapi_krb5_create_8003_checksum (
|
|
||||||
OM_uint32 *minor_status,
|
|
||||||
const gss_channel_bindings_t input_chan_bindings,
|
|
||||||
OM_uint32 flags,
|
|
||||||
const krb5_data *fwd_data,
|
|
||||||
Checksum *result)
|
|
||||||
{
|
|
||||||
u_char *p;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* see rfc1964 (section 1.1.1 (Initial Token), and the checksum value
|
|
||||||
* field's format) */
|
|
||||||
result->cksumtype = 0x8003;
|
|
||||||
if (fwd_data->length > 0 && (flags & GSS_C_DELEG_FLAG))
|
|
||||||
result->checksum.length = 24 + 4 + fwd_data->length;
|
|
||||||
else
|
|
||||||
result->checksum.length = 24;
|
|
||||||
result->checksum.data = malloc (result->checksum.length);
|
|
||||||
if (result->checksum.data == NULL) {
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
p = result->checksum.data;
|
|
||||||
gssapi_encode_om_uint32 (16, p);
|
|
||||||
p += 4;
|
|
||||||
if (input_chan_bindings == GSS_C_NO_CHANNEL_BINDINGS) {
|
|
||||||
memset (p, 0, 16);
|
|
||||||
} else {
|
|
||||||
hash_input_chan_bindings (input_chan_bindings, p);
|
|
||||||
}
|
|
||||||
p += 16;
|
|
||||||
gssapi_encode_om_uint32 (flags, p);
|
|
||||||
p += 4;
|
|
||||||
|
|
||||||
if (fwd_data->length > 0 && (flags & GSS_C_DELEG_FLAG)) {
|
|
||||||
#if 0
|
|
||||||
u_char *tmp;
|
|
||||||
|
|
||||||
result->checksum.length = 28 + fwd_data->length;
|
|
||||||
tmp = realloc(result->checksum.data, result->checksum.length);
|
|
||||||
if (tmp == NULL)
|
|
||||||
return ENOMEM;
|
|
||||||
result->checksum.data = tmp;
|
|
||||||
|
|
||||||
p = (u_char*)result->checksum.data + 24;
|
|
||||||
#endif
|
|
||||||
*p++ = (1 >> 0) & 0xFF; /* DlgOpt */ /* == 1 */
|
|
||||||
*p++ = (1 >> 8) & 0xFF; /* DlgOpt */ /* == 0 */
|
|
||||||
*p++ = (fwd_data->length >> 0) & 0xFF; /* Dlgth */
|
|
||||||
*p++ = (fwd_data->length >> 8) & 0xFF; /* Dlgth */
|
|
||||||
memcpy(p, (unsigned char *) fwd_data->data, fwd_data->length);
|
|
||||||
|
|
||||||
p += fwd_data->length;
|
|
||||||
}
|
|
||||||
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* verify the checksum in `cksum' over `input_chan_bindings'
|
|
||||||
* returning `flags' and `fwd_data'
|
|
||||||
*/
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
gssapi_krb5_verify_8003_checksum(
|
|
||||||
OM_uint32 *minor_status,
|
|
||||||
const gss_channel_bindings_t input_chan_bindings,
|
|
||||||
const Checksum *cksum,
|
|
||||||
OM_uint32 *flags,
|
|
||||||
krb5_data *fwd_data)
|
|
||||||
{
|
|
||||||
unsigned char hash[16];
|
|
||||||
unsigned char *p;
|
|
||||||
OM_uint32 length;
|
|
||||||
int DlgOpt;
|
|
||||||
static unsigned char zeros[16];
|
|
||||||
|
|
||||||
/* XXX should handle checksums > 24 bytes */
|
|
||||||
if(cksum->cksumtype != 0x8003 || cksum->checksum.length < 24) {
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_BAD_BINDINGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
p = cksum->checksum.data;
|
|
||||||
gssapi_decode_om_uint32(p, &length);
|
|
||||||
if(length != sizeof(hash)) {
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_BAD_BINDINGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
p += 4;
|
|
||||||
|
|
||||||
if (input_chan_bindings != GSS_C_NO_CHANNEL_BINDINGS
|
|
||||||
&& memcmp(p, zeros, sizeof(zeros)) != 0) {
|
|
||||||
if(hash_input_chan_bindings(input_chan_bindings, hash) != 0) {
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_BAD_BINDINGS;
|
|
||||||
}
|
|
||||||
if(memcmp(hash, p, sizeof(hash)) != 0) {
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_BAD_BINDINGS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
p += sizeof(hash);
|
|
||||||
|
|
||||||
gssapi_decode_om_uint32(p, flags);
|
|
||||||
p += 4;
|
|
||||||
|
|
||||||
if (cksum->checksum.length > 24 && (*flags & GSS_C_DELEG_FLAG)) {
|
|
||||||
if(cksum->checksum.length < 28) {
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_BAD_BINDINGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
DlgOpt = (p[0] << 0) | (p[1] << 8);
|
|
||||||
p += 2;
|
|
||||||
if (DlgOpt != 1) {
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_BAD_BINDINGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
fwd_data->length = (p[0] << 0) | (p[1] << 8);
|
|
||||||
p += 2;
|
|
||||||
if(cksum->checksum.length < 28 + fwd_data->length) {
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_BAD_BINDINGS;
|
|
||||||
}
|
|
||||||
fwd_data->data = malloc(fwd_data->length);
|
|
||||||
if (fwd_data->data == NULL) {
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
memcpy(fwd_data->data, p, fwd_data->length);
|
|
||||||
}
|
|
||||||
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
@ -1,445 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997 - 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: accept_sec_context.c,v 1.33.2.2 2003/12/19 00:37:06 lha Exp $");
|
|
||||||
|
|
||||||
krb5_keytab gssapi_krb5_keytab;
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
gsskrb5_register_acceptor_identity (const char *identity)
|
|
||||||
{
|
|
||||||
krb5_error_code ret;
|
|
||||||
char *p;
|
|
||||||
|
|
||||||
ret = gssapi_krb5_init();
|
|
||||||
if(ret)
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
|
|
||||||
if(gssapi_krb5_keytab != NULL) {
|
|
||||||
krb5_kt_close(gssapi_krb5_context, gssapi_krb5_keytab);
|
|
||||||
gssapi_krb5_keytab = NULL;
|
|
||||||
}
|
|
||||||
asprintf(&p, "FILE:%s", identity);
|
|
||||||
if(p == NULL)
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
ret = krb5_kt_resolve(gssapi_krb5_context, p, &gssapi_krb5_keytab);
|
|
||||||
free(p);
|
|
||||||
if(ret)
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
gss_accept_sec_context
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
gss_ctx_id_t * context_handle,
|
|
||||||
const gss_cred_id_t acceptor_cred_handle,
|
|
||||||
const gss_buffer_t input_token_buffer,
|
|
||||||
const gss_channel_bindings_t input_chan_bindings,
|
|
||||||
gss_name_t * src_name,
|
|
||||||
gss_OID * mech_type,
|
|
||||||
gss_buffer_t output_token,
|
|
||||||
OM_uint32 * ret_flags,
|
|
||||||
OM_uint32 * time_rec,
|
|
||||||
gss_cred_id_t * delegated_cred_handle
|
|
||||||
)
|
|
||||||
{
|
|
||||||
krb5_error_code kret;
|
|
||||||
OM_uint32 ret = GSS_S_COMPLETE;
|
|
||||||
krb5_data indata;
|
|
||||||
krb5_flags ap_options;
|
|
||||||
OM_uint32 flags;
|
|
||||||
krb5_ticket *ticket = NULL;
|
|
||||||
krb5_keytab keytab = NULL;
|
|
||||||
krb5_data fwd_data;
|
|
||||||
OM_uint32 minor;
|
|
||||||
|
|
||||||
GSSAPI_KRB5_INIT();
|
|
||||||
|
|
||||||
krb5_data_zero (&fwd_data);
|
|
||||||
output_token->length = 0;
|
|
||||||
output_token->value = NULL;
|
|
||||||
|
|
||||||
if (src_name != NULL)
|
|
||||||
*src_name = NULL;
|
|
||||||
if (mech_type)
|
|
||||||
*mech_type = GSS_KRB5_MECHANISM;
|
|
||||||
|
|
||||||
if (*context_handle == GSS_C_NO_CONTEXT) {
|
|
||||||
*context_handle = malloc(sizeof(**context_handle));
|
|
||||||
if (*context_handle == GSS_C_NO_CONTEXT) {
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
(*context_handle)->auth_context = NULL;
|
|
||||||
(*context_handle)->source = NULL;
|
|
||||||
(*context_handle)->target = NULL;
|
|
||||||
(*context_handle)->flags = 0;
|
|
||||||
(*context_handle)->more_flags = 0;
|
|
||||||
(*context_handle)->ticket = NULL;
|
|
||||||
(*context_handle)->lifetime = GSS_C_INDEFINITE;
|
|
||||||
|
|
||||||
kret = krb5_auth_con_init (gssapi_krb5_context,
|
|
||||||
&(*context_handle)->auth_context);
|
|
||||||
if (kret) {
|
|
||||||
ret = GSS_S_FAILURE;
|
|
||||||
*minor_status = kret;
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (input_chan_bindings != GSS_C_NO_CHANNEL_BINDINGS
|
|
||||||
&& input_chan_bindings->application_data.length ==
|
|
||||||
2 * sizeof((*context_handle)->auth_context->local_port)
|
|
||||||
) {
|
|
||||||
|
|
||||||
/* Port numbers are expected to be in application_data.value,
|
|
||||||
* initator's port first */
|
|
||||||
|
|
||||||
krb5_address initiator_addr, acceptor_addr;
|
|
||||||
|
|
||||||
memset(&initiator_addr, 0, sizeof(initiator_addr));
|
|
||||||
memset(&acceptor_addr, 0, sizeof(acceptor_addr));
|
|
||||||
|
|
||||||
(*context_handle)->auth_context->remote_port =
|
|
||||||
*(int16_t *) input_chan_bindings->application_data.value;
|
|
||||||
|
|
||||||
(*context_handle)->auth_context->local_port =
|
|
||||||
*((int16_t *) input_chan_bindings->application_data.value + 1);
|
|
||||||
|
|
||||||
|
|
||||||
kret = gss_address_to_krb5addr(input_chan_bindings->acceptor_addrtype,
|
|
||||||
&input_chan_bindings->acceptor_address,
|
|
||||||
(*context_handle)->auth_context->local_port,
|
|
||||||
&acceptor_addr);
|
|
||||||
if (kret) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
ret = GSS_S_BAD_BINDINGS;
|
|
||||||
*minor_status = kret;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
kret = gss_address_to_krb5addr(input_chan_bindings->initiator_addrtype,
|
|
||||||
&input_chan_bindings->initiator_address,
|
|
||||||
(*context_handle)->auth_context->remote_port,
|
|
||||||
&initiator_addr);
|
|
||||||
if (kret) {
|
|
||||||
krb5_free_address (gssapi_krb5_context, &acceptor_addr);
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
ret = GSS_S_BAD_BINDINGS;
|
|
||||||
*minor_status = kret;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
kret = krb5_auth_con_setaddrs(gssapi_krb5_context,
|
|
||||||
(*context_handle)->auth_context,
|
|
||||||
&acceptor_addr, /* local address */
|
|
||||||
&initiator_addr); /* remote address */
|
|
||||||
|
|
||||||
krb5_free_address (gssapi_krb5_context, &initiator_addr);
|
|
||||||
krb5_free_address (gssapi_krb5_context, &acceptor_addr);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
free(input_chan_bindings->application_data.value);
|
|
||||||
input_chan_bindings->application_data.value = NULL;
|
|
||||||
input_chan_bindings->application_data.length = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (kret) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
ret = GSS_S_BAD_BINDINGS;
|
|
||||||
*minor_status = kret;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{
|
|
||||||
int32_t tmp;
|
|
||||||
|
|
||||||
krb5_auth_con_getflags(gssapi_krb5_context,
|
|
||||||
(*context_handle)->auth_context,
|
|
||||||
&tmp);
|
|
||||||
tmp |= KRB5_AUTH_CONTEXT_DO_SEQUENCE;
|
|
||||||
krb5_auth_con_setflags(gssapi_krb5_context,
|
|
||||||
(*context_handle)->auth_context,
|
|
||||||
tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = gssapi_krb5_decapsulate (minor_status,
|
|
||||||
input_token_buffer,
|
|
||||||
&indata,
|
|
||||||
"\x01\x00");
|
|
||||||
if (ret)
|
|
||||||
goto failure;
|
|
||||||
|
|
||||||
if (acceptor_cred_handle == GSS_C_NO_CREDENTIAL) {
|
|
||||||
if (gssapi_krb5_keytab != NULL) {
|
|
||||||
keytab = gssapi_krb5_keytab;
|
|
||||||
}
|
|
||||||
} else if (acceptor_cred_handle->keytab != NULL) {
|
|
||||||
keytab = acceptor_cred_handle->keytab;
|
|
||||||
}
|
|
||||||
|
|
||||||
kret = krb5_rd_req (gssapi_krb5_context,
|
|
||||||
&(*context_handle)->auth_context,
|
|
||||||
&indata,
|
|
||||||
(acceptor_cred_handle == GSS_C_NO_CREDENTIAL) ? NULL
|
|
||||||
: acceptor_cred_handle->principal,
|
|
||||||
keytab,
|
|
||||||
&ap_options,
|
|
||||||
&ticket);
|
|
||||||
if (kret) {
|
|
||||||
ret = GSS_S_FAILURE;
|
|
||||||
*minor_status = kret;
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
kret = krb5_copy_principal (gssapi_krb5_context,
|
|
||||||
ticket->client,
|
|
||||||
&(*context_handle)->source);
|
|
||||||
if (kret) {
|
|
||||||
ret = GSS_S_FAILURE;
|
|
||||||
*minor_status = kret;
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
kret = krb5_copy_principal (gssapi_krb5_context,
|
|
||||||
ticket->server,
|
|
||||||
&(*context_handle)->target);
|
|
||||||
if (kret) {
|
|
||||||
ret = GSS_S_FAILURE;
|
|
||||||
*minor_status = kret;
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = _gss_DES3_get_mic_compat(minor_status, *context_handle);
|
|
||||||
if (ret)
|
|
||||||
goto failure;
|
|
||||||
|
|
||||||
if (src_name != NULL) {
|
|
||||||
kret = krb5_copy_principal (gssapi_krb5_context,
|
|
||||||
ticket->client,
|
|
||||||
src_name);
|
|
||||||
if (kret) {
|
|
||||||
ret = GSS_S_FAILURE;
|
|
||||||
*minor_status = kret;
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
krb5_authenticator authenticator;
|
|
||||||
|
|
||||||
kret = krb5_auth_con_getauthenticator(gssapi_krb5_context,
|
|
||||||
(*context_handle)->auth_context,
|
|
||||||
&authenticator);
|
|
||||||
if(kret) {
|
|
||||||
ret = GSS_S_FAILURE;
|
|
||||||
*minor_status = kret;
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = gssapi_krb5_verify_8003_checksum(minor_status,
|
|
||||||
input_chan_bindings,
|
|
||||||
authenticator->cksum,
|
|
||||||
&flags,
|
|
||||||
&fwd_data);
|
|
||||||
krb5_free_authenticator(gssapi_krb5_context, &authenticator);
|
|
||||||
if (ret)
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fwd_data.length > 0 && (flags & GSS_C_DELEG_FLAG)) {
|
|
||||||
krb5_ccache ccache;
|
|
||||||
int32_t ac_flags;
|
|
||||||
|
|
||||||
if (delegated_cred_handle == NULL)
|
|
||||||
/* XXX Create a new delegated_cred_handle? */
|
|
||||||
kret = krb5_cc_default (gssapi_krb5_context, &ccache);
|
|
||||||
else if (*delegated_cred_handle == NULL) {
|
|
||||||
if ((*delegated_cred_handle =
|
|
||||||
calloc(1, sizeof(**delegated_cred_handle))) == NULL) {
|
|
||||||
ret = GSS_S_FAILURE;
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
krb5_set_error_string(gssapi_krb5_context, "out of memory");
|
|
||||||
gssapi_krb5_set_error_string();
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
if ((ret = gss_duplicate_name(minor_status, ticket->client,
|
|
||||||
&(*delegated_cred_handle)->principal)) != 0) {
|
|
||||||
flags &= ~GSS_C_DELEG_FLAG;
|
|
||||||
free(*delegated_cred_handle);
|
|
||||||
*delegated_cred_handle = NULL;
|
|
||||||
goto end_fwd;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (delegated_cred_handle != NULL &&
|
|
||||||
(*delegated_cred_handle)->ccache == NULL) {
|
|
||||||
kret = krb5_cc_gen_new (gssapi_krb5_context,
|
|
||||||
&krb5_mcc_ops,
|
|
||||||
&(*delegated_cred_handle)->ccache);
|
|
||||||
ccache = (*delegated_cred_handle)->ccache;
|
|
||||||
}
|
|
||||||
if (delegated_cred_handle != NULL &&
|
|
||||||
(*delegated_cred_handle)->mechanisms == NULL) {
|
|
||||||
ret = gss_create_empty_oid_set(minor_status,
|
|
||||||
&(*delegated_cred_handle)->mechanisms);
|
|
||||||
if (ret)
|
|
||||||
goto failure;
|
|
||||||
ret = gss_add_oid_set_member(minor_status, GSS_KRB5_MECHANISM,
|
|
||||||
&(*delegated_cred_handle)->mechanisms);
|
|
||||||
if (ret)
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (kret) {
|
|
||||||
flags &= ~GSS_C_DELEG_FLAG;
|
|
||||||
goto end_fwd;
|
|
||||||
}
|
|
||||||
|
|
||||||
kret = krb5_cc_initialize(gssapi_krb5_context,
|
|
||||||
ccache,
|
|
||||||
*src_name);
|
|
||||||
if (kret) {
|
|
||||||
flags &= ~GSS_C_DELEG_FLAG;
|
|
||||||
goto end_fwd;
|
|
||||||
}
|
|
||||||
|
|
||||||
krb5_auth_con_getflags(gssapi_krb5_context,
|
|
||||||
(*context_handle)->auth_context,
|
|
||||||
&ac_flags);
|
|
||||||
krb5_auth_con_setflags(gssapi_krb5_context,
|
|
||||||
(*context_handle)->auth_context,
|
|
||||||
ac_flags & ~KRB5_AUTH_CONTEXT_DO_TIME);
|
|
||||||
kret = krb5_rd_cred2(gssapi_krb5_context,
|
|
||||||
(*context_handle)->auth_context,
|
|
||||||
ccache,
|
|
||||||
&fwd_data);
|
|
||||||
krb5_auth_con_setflags(gssapi_krb5_context,
|
|
||||||
(*context_handle)->auth_context,
|
|
||||||
ac_flags);
|
|
||||||
if (kret) {
|
|
||||||
flags &= ~GSS_C_DELEG_FLAG;
|
|
||||||
goto end_fwd;
|
|
||||||
}
|
|
||||||
|
|
||||||
end_fwd:
|
|
||||||
free(fwd_data.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
flags |= GSS_C_TRANS_FLAG;
|
|
||||||
|
|
||||||
if (ret_flags)
|
|
||||||
*ret_flags = flags;
|
|
||||||
(*context_handle)->lifetime = ticket->ticket.endtime;
|
|
||||||
(*context_handle)->flags = flags;
|
|
||||||
(*context_handle)->more_flags |= OPEN;
|
|
||||||
|
|
||||||
if (mech_type)
|
|
||||||
*mech_type = GSS_KRB5_MECHANISM;
|
|
||||||
|
|
||||||
if (time_rec) {
|
|
||||||
ret = gssapi_lifetime_left(minor_status,
|
|
||||||
(*context_handle)->lifetime,
|
|
||||||
time_rec);
|
|
||||||
if (ret)
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(flags & GSS_C_MUTUAL_FLAG) {
|
|
||||||
krb5_data outbuf;
|
|
||||||
|
|
||||||
kret = krb5_mk_rep (gssapi_krb5_context,
|
|
||||||
(*context_handle)->auth_context,
|
|
||||||
&outbuf);
|
|
||||||
if (kret) {
|
|
||||||
ret = GSS_S_FAILURE;
|
|
||||||
*minor_status = kret;
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
ret = gssapi_krb5_encapsulate (minor_status,
|
|
||||||
&outbuf,
|
|
||||||
output_token,
|
|
||||||
"\x02\x00");
|
|
||||||
krb5_data_free (&outbuf);
|
|
||||||
if (ret)
|
|
||||||
goto failure;
|
|
||||||
} else {
|
|
||||||
output_token->length = 0;
|
|
||||||
output_token->value = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
(*context_handle)->ticket = ticket;
|
|
||||||
ticket = NULL;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
krb5_free_ticket (context, ticket);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
|
|
||||||
failure:
|
|
||||||
if (fwd_data.length > 0)
|
|
||||||
free(fwd_data.data);
|
|
||||||
if (ticket != NULL)
|
|
||||||
krb5_free_ticket (gssapi_krb5_context, ticket);
|
|
||||||
krb5_auth_con_free (gssapi_krb5_context,
|
|
||||||
(*context_handle)->auth_context);
|
|
||||||
if((*context_handle)->source)
|
|
||||||
krb5_free_principal (gssapi_krb5_context,
|
|
||||||
(*context_handle)->source);
|
|
||||||
if((*context_handle)->target)
|
|
||||||
krb5_free_principal (gssapi_krb5_context,
|
|
||||||
(*context_handle)->target);
|
|
||||||
free (*context_handle);
|
|
||||||
if (src_name != NULL) {
|
|
||||||
gss_release_name (&minor, src_name);
|
|
||||||
*src_name = NULL;
|
|
||||||
}
|
|
||||||
*context_handle = GSS_C_NO_CONTEXT;
|
|
||||||
return ret;
|
|
||||||
}
|
|
@ -1,309 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997 - 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: acquire_cred.c,v 1.13.2.1 2003/08/15 14:18:24 lha Exp $");
|
|
||||||
|
|
||||||
static krb5_error_code
|
|
||||||
get_keytab(krb5_keytab *keytab)
|
|
||||||
{
|
|
||||||
char kt_name[256];
|
|
||||||
krb5_error_code kret;
|
|
||||||
|
|
||||||
if (gssapi_krb5_keytab != NULL) {
|
|
||||||
kret = krb5_kt_get_name(gssapi_krb5_context,
|
|
||||||
gssapi_krb5_keytab,
|
|
||||||
kt_name, sizeof(kt_name));
|
|
||||||
if (kret == 0)
|
|
||||||
kret = krb5_kt_resolve(gssapi_krb5_context, kt_name, keytab);
|
|
||||||
} else
|
|
||||||
kret = krb5_kt_default(gssapi_krb5_context, keytab);
|
|
||||||
return (kret);
|
|
||||||
}
|
|
||||||
|
|
||||||
static OM_uint32 acquire_initiator_cred
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
const gss_name_t desired_name,
|
|
||||||
OM_uint32 time_req,
|
|
||||||
const gss_OID_set desired_mechs,
|
|
||||||
gss_cred_usage_t cred_usage,
|
|
||||||
gss_cred_id_t handle,
|
|
||||||
gss_OID_set * actual_mechs,
|
|
||||||
OM_uint32 * time_rec
|
|
||||||
)
|
|
||||||
{
|
|
||||||
OM_uint32 ret;
|
|
||||||
krb5_creds cred;
|
|
||||||
krb5_principal def_princ;
|
|
||||||
krb5_get_init_creds_opt opt;
|
|
||||||
krb5_ccache ccache;
|
|
||||||
krb5_keytab keytab;
|
|
||||||
krb5_error_code kret;
|
|
||||||
|
|
||||||
keytab = NULL;
|
|
||||||
ccache = NULL;
|
|
||||||
def_princ = NULL;
|
|
||||||
ret = GSS_S_FAILURE;
|
|
||||||
memset(&cred, 0, sizeof(cred));
|
|
||||||
|
|
||||||
kret = krb5_cc_default(gssapi_krb5_context, &ccache);
|
|
||||||
if (kret)
|
|
||||||
goto end;
|
|
||||||
kret = krb5_cc_get_principal(gssapi_krb5_context, ccache,
|
|
||||||
&def_princ);
|
|
||||||
if (kret != 0) {
|
|
||||||
/* we'll try to use a keytab below */
|
|
||||||
krb5_cc_destroy(gssapi_krb5_context, ccache);
|
|
||||||
ccache = NULL;
|
|
||||||
kret = 0;
|
|
||||||
} else if (handle->principal == NULL) {
|
|
||||||
kret = krb5_copy_principal(gssapi_krb5_context, def_princ,
|
|
||||||
&handle->principal);
|
|
||||||
if (kret)
|
|
||||||
goto end;
|
|
||||||
} else if (handle->principal != NULL &&
|
|
||||||
krb5_principal_compare(gssapi_krb5_context, handle->principal,
|
|
||||||
def_princ) == FALSE) {
|
|
||||||
/* Before failing, lets check the keytab */
|
|
||||||
krb5_free_principal(gssapi_krb5_context, def_princ);
|
|
||||||
def_princ = NULL;
|
|
||||||
}
|
|
||||||
if (def_princ == NULL) {
|
|
||||||
/* We have no existing credentials cache,
|
|
||||||
* so attempt to get a TGT using a keytab.
|
|
||||||
*/
|
|
||||||
if (handle->principal == NULL) {
|
|
||||||
kret = krb5_get_default_principal(gssapi_krb5_context,
|
|
||||||
&handle->principal);
|
|
||||||
if (kret)
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
kret = get_keytab(&keytab);
|
|
||||||
if (kret)
|
|
||||||
goto end;
|
|
||||||
krb5_get_init_creds_opt_init(&opt);
|
|
||||||
kret = krb5_get_init_creds_keytab(gssapi_krb5_context, &cred,
|
|
||||||
handle->principal, keytab, 0, NULL, &opt);
|
|
||||||
if (kret)
|
|
||||||
goto end;
|
|
||||||
kret = krb5_cc_gen_new(gssapi_krb5_context, &krb5_mcc_ops,
|
|
||||||
&ccache);
|
|
||||||
if (kret)
|
|
||||||
goto end;
|
|
||||||
kret = krb5_cc_initialize(gssapi_krb5_context, ccache, cred.client);
|
|
||||||
if (kret)
|
|
||||||
goto end;
|
|
||||||
kret = krb5_cc_store_cred(gssapi_krb5_context, ccache, &cred);
|
|
||||||
if (kret)
|
|
||||||
goto end;
|
|
||||||
handle->lifetime = cred.times.endtime;
|
|
||||||
} else {
|
|
||||||
krb5_creds in_cred, *out_cred;
|
|
||||||
krb5_const_realm realm;
|
|
||||||
|
|
||||||
memset(&in_cred, 0, sizeof(in_cred));
|
|
||||||
in_cred.client = handle->principal;
|
|
||||||
|
|
||||||
realm = krb5_principal_get_realm(gssapi_krb5_context,
|
|
||||||
handle->principal);
|
|
||||||
if (realm == NULL) {
|
|
||||||
kret = KRB5_PRINC_NOMATCH; /* XXX */
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
kret = krb5_make_principal(gssapi_krb5_context, &in_cred.server,
|
|
||||||
realm, KRB5_TGS_NAME, realm, NULL);
|
|
||||||
if (kret)
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
kret = krb5_get_credentials(gssapi_krb5_context, 0,
|
|
||||||
ccache, &in_cred, &out_cred);
|
|
||||||
krb5_free_principal(gssapi_krb5_context, in_cred.server);
|
|
||||||
if (kret)
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
handle->lifetime = out_cred->times.endtime;
|
|
||||||
krb5_free_creds(gssapi_krb5_context, out_cred);
|
|
||||||
}
|
|
||||||
|
|
||||||
handle->ccache = ccache;
|
|
||||||
ret = GSS_S_COMPLETE;
|
|
||||||
|
|
||||||
end:
|
|
||||||
if (cred.client != NULL)
|
|
||||||
krb5_free_creds_contents(gssapi_krb5_context, &cred);
|
|
||||||
if (def_princ != NULL)
|
|
||||||
krb5_free_principal(gssapi_krb5_context, def_princ);
|
|
||||||
if (keytab != NULL)
|
|
||||||
krb5_kt_close(gssapi_krb5_context, keytab);
|
|
||||||
if (ret != GSS_S_COMPLETE) {
|
|
||||||
if (ccache != NULL)
|
|
||||||
krb5_cc_close(gssapi_krb5_context, ccache);
|
|
||||||
if (kret != 0) {
|
|
||||||
*minor_status = kret;
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
static OM_uint32 acquire_acceptor_cred
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
const gss_name_t desired_name,
|
|
||||||
OM_uint32 time_req,
|
|
||||||
const gss_OID_set desired_mechs,
|
|
||||||
gss_cred_usage_t cred_usage,
|
|
||||||
gss_cred_id_t handle,
|
|
||||||
gss_OID_set * actual_mechs,
|
|
||||||
OM_uint32 * time_rec
|
|
||||||
)
|
|
||||||
{
|
|
||||||
OM_uint32 ret;
|
|
||||||
krb5_error_code kret;
|
|
||||||
|
|
||||||
kret = 0;
|
|
||||||
ret = GSS_S_FAILURE;
|
|
||||||
kret = get_keytab(&handle->keytab);
|
|
||||||
if (kret)
|
|
||||||
goto end;
|
|
||||||
ret = GSS_S_COMPLETE;
|
|
||||||
|
|
||||||
end:
|
|
||||||
if (ret != GSS_S_COMPLETE) {
|
|
||||||
if (handle->keytab != NULL)
|
|
||||||
krb5_kt_close(gssapi_krb5_context, handle->keytab);
|
|
||||||
if (kret != 0) {
|
|
||||||
*minor_status = kret;
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
OM_uint32 gss_acquire_cred
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
const gss_name_t desired_name,
|
|
||||||
OM_uint32 time_req,
|
|
||||||
const gss_OID_set desired_mechs,
|
|
||||||
gss_cred_usage_t cred_usage,
|
|
||||||
gss_cred_id_t * output_cred_handle,
|
|
||||||
gss_OID_set * actual_mechs,
|
|
||||||
OM_uint32 * time_rec
|
|
||||||
)
|
|
||||||
{
|
|
||||||
gss_cred_id_t handle;
|
|
||||||
OM_uint32 ret;
|
|
||||||
|
|
||||||
GSSAPI_KRB5_INIT ();
|
|
||||||
|
|
||||||
*output_cred_handle = NULL;
|
|
||||||
if (time_rec)
|
|
||||||
*time_rec = 0;
|
|
||||||
if (actual_mechs)
|
|
||||||
*actual_mechs = GSS_C_NO_OID_SET;
|
|
||||||
|
|
||||||
if (desired_mechs) {
|
|
||||||
OM_uint32 present = 0;
|
|
||||||
|
|
||||||
ret = gss_test_oid_set_member(minor_status, GSS_KRB5_MECHANISM,
|
|
||||||
desired_mechs, &present);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
if (!present) {
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_BAD_MECH;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handle = (gss_cred_id_t)malloc(sizeof(*handle));
|
|
||||||
if (handle == GSS_C_NO_CREDENTIAL) {
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
return (GSS_S_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(handle, 0, sizeof (*handle));
|
|
||||||
|
|
||||||
if (desired_name != GSS_C_NO_NAME) {
|
|
||||||
ret = gss_duplicate_name(minor_status, desired_name,
|
|
||||||
&handle->principal);
|
|
||||||
if (ret != GSS_S_COMPLETE) {
|
|
||||||
free(handle);
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (cred_usage == GSS_C_INITIATE || cred_usage == GSS_C_BOTH) {
|
|
||||||
ret = acquire_initiator_cred(minor_status, desired_name, time_req,
|
|
||||||
desired_mechs, cred_usage, handle, actual_mechs, time_rec);
|
|
||||||
if (ret != GSS_S_COMPLETE) {
|
|
||||||
free(handle);
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
} else if (cred_usage == GSS_C_ACCEPT || cred_usage == GSS_C_BOTH) {
|
|
||||||
ret = acquire_acceptor_cred(minor_status, desired_name, time_req,
|
|
||||||
desired_mechs, cred_usage, handle, actual_mechs, time_rec);
|
|
||||||
if (ret != GSS_S_COMPLETE) {
|
|
||||||
free(handle);
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
free(handle);
|
|
||||||
*minor_status = GSS_KRB5_S_G_BAD_USAGE;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
ret = gss_create_empty_oid_set(minor_status, &handle->mechanisms);
|
|
||||||
if (ret == GSS_S_COMPLETE)
|
|
||||||
ret = gss_add_oid_set_member(minor_status, GSS_KRB5_MECHANISM,
|
|
||||||
&handle->mechanisms);
|
|
||||||
if (ret == GSS_S_COMPLETE)
|
|
||||||
ret = gss_inquire_cred(minor_status, handle, NULL, time_rec, NULL,
|
|
||||||
actual_mechs);
|
|
||||||
if (ret != GSS_S_COMPLETE) {
|
|
||||||
if (handle->mechanisms != NULL)
|
|
||||||
gss_release_oid_set(NULL, &handle->mechanisms);
|
|
||||||
free(handle);
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
*minor_status = 0;
|
|
||||||
if (time_rec) {
|
|
||||||
ret = gssapi_lifetime_left(minor_status,
|
|
||||||
handle->lifetime,
|
|
||||||
time_rec);
|
|
||||||
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
handle->usage = cred_usage;
|
|
||||||
*output_cred_handle = handle;
|
|
||||||
return (GSS_S_COMPLETE);
|
|
||||||
}
|
|
@ -1,234 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: add_cred.c,v 1.2.2.1 2003/10/21 21:00:47 lha Exp $");
|
|
||||||
|
|
||||||
OM_uint32 gss_add_cred (
|
|
||||||
OM_uint32 *minor_status,
|
|
||||||
const gss_cred_id_t input_cred_handle,
|
|
||||||
const gss_name_t desired_name,
|
|
||||||
const gss_OID desired_mech,
|
|
||||||
gss_cred_usage_t cred_usage,
|
|
||||||
OM_uint32 initiator_time_req,
|
|
||||||
OM_uint32 acceptor_time_req,
|
|
||||||
gss_cred_id_t *output_cred_handle,
|
|
||||||
gss_OID_set *actual_mechs,
|
|
||||||
OM_uint32 *initiator_time_rec,
|
|
||||||
OM_uint32 *acceptor_time_rec)
|
|
||||||
{
|
|
||||||
OM_uint32 ret, lifetime;
|
|
||||||
gss_cred_id_t cred, handle;
|
|
||||||
|
|
||||||
handle = NULL;
|
|
||||||
cred = input_cred_handle;
|
|
||||||
|
|
||||||
if (gss_oid_equal(desired_mech, GSS_KRB5_MECHANISM) == 0) {
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_BAD_MECH;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cred == GSS_C_NO_CREDENTIAL && output_cred_handle == NULL) {
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_NO_CRED;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* check if requested output usage is compatible with output usage */
|
|
||||||
if (output_cred_handle != NULL &&
|
|
||||||
(cred->usage != cred_usage && cred->usage != GSS_C_BOTH)) {
|
|
||||||
*minor_status = GSS_KRB5_S_G_BAD_USAGE;
|
|
||||||
return(GSS_S_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* check that we have the same name */
|
|
||||||
if (desired_name != GSS_C_NO_NAME &&
|
|
||||||
krb5_principal_compare(gssapi_krb5_context, desired_name,
|
|
||||||
cred->principal) != FALSE) {
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_BAD_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* make a copy */
|
|
||||||
if (output_cred_handle) {
|
|
||||||
|
|
||||||
handle = (gss_cred_id_t)malloc(sizeof(*handle));
|
|
||||||
if (handle == GSS_C_NO_CREDENTIAL) {
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
return (GSS_S_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(handle, 0, sizeof (*handle));
|
|
||||||
|
|
||||||
handle->usage = cred_usage;
|
|
||||||
handle->lifetime = cred->lifetime;
|
|
||||||
handle->principal = NULL;
|
|
||||||
handle->keytab = NULL;
|
|
||||||
handle->ccache = NULL;
|
|
||||||
handle->mechanisms = NULL;
|
|
||||||
|
|
||||||
ret = GSS_S_FAILURE;
|
|
||||||
|
|
||||||
ret = gss_duplicate_name(minor_status, cred->principal,
|
|
||||||
&handle->principal);
|
|
||||||
if (ret) {
|
|
||||||
free(handle);
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cred->keytab) {
|
|
||||||
krb5_error_code kret;
|
|
||||||
char name[KRB5_KT_PREFIX_MAX_LEN + MAXPATHLEN];
|
|
||||||
int len;
|
|
||||||
|
|
||||||
ret = GSS_S_FAILURE;
|
|
||||||
|
|
||||||
kret = krb5_kt_get_type(gssapi_krb5_context, cred->keytab,
|
|
||||||
name, KRB5_KT_PREFIX_MAX_LEN);
|
|
||||||
if (kret) {
|
|
||||||
*minor_status = kret;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
len = strlen(name);
|
|
||||||
name[len++] = ':';
|
|
||||||
|
|
||||||
kret = krb5_kt_get_name(gssapi_krb5_context, cred->keytab,
|
|
||||||
name + len,
|
|
||||||
sizeof(name) - len);
|
|
||||||
if (kret) {
|
|
||||||
*minor_status = kret;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
kret = krb5_kt_resolve(gssapi_krb5_context, name,
|
|
||||||
&handle->keytab);
|
|
||||||
if (kret){
|
|
||||||
*minor_status = kret;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cred->ccache) {
|
|
||||||
krb5_error_code kret;
|
|
||||||
const char *type, *name;
|
|
||||||
char *type_name;
|
|
||||||
|
|
||||||
ret = GSS_S_FAILURE;
|
|
||||||
|
|
||||||
type = krb5_cc_get_type(gssapi_krb5_context, cred->ccache);
|
|
||||||
if (type == NULL){
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strcmp(type, "MEMORY") == 0) {
|
|
||||||
ret = krb5_cc_gen_new(gssapi_krb5_context, &krb5_mcc_ops,
|
|
||||||
&handle->ccache);
|
|
||||||
if (ret) {
|
|
||||||
*minor_status = ret;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = krb5_cc_copy_cache(gssapi_krb5_context, cred->ccache,
|
|
||||||
handle->ccache);
|
|
||||||
if (ret) {
|
|
||||||
*minor_status = ret;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
name = krb5_cc_get_name(gssapi_krb5_context, cred->ccache);
|
|
||||||
if (name == NULL) {
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
asprintf(&type_name, "%s:%s", type, name);
|
|
||||||
if (type_name == NULL) {
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
kret = krb5_cc_resolve(gssapi_krb5_context, type_name,
|
|
||||||
&handle->ccache);
|
|
||||||
free(type_name);
|
|
||||||
if (kret) {
|
|
||||||
*minor_status = kret;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = gss_create_empty_oid_set(minor_status, &handle->mechanisms);
|
|
||||||
if (ret)
|
|
||||||
goto failure;
|
|
||||||
|
|
||||||
ret = gss_add_oid_set_member(minor_status, GSS_KRB5_MECHANISM,
|
|
||||||
&handle->mechanisms);
|
|
||||||
if (ret)
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = gss_inquire_cred(minor_status, cred, NULL, &lifetime,
|
|
||||||
NULL, actual_mechs);
|
|
||||||
if (ret)
|
|
||||||
goto failure;
|
|
||||||
|
|
||||||
if (initiator_time_rec)
|
|
||||||
*initiator_time_rec = lifetime;
|
|
||||||
if (acceptor_time_rec)
|
|
||||||
*acceptor_time_rec = lifetime;
|
|
||||||
|
|
||||||
if (output_cred_handle)
|
|
||||||
*output_cred_handle = handle;
|
|
||||||
|
|
||||||
*minor_status = 0;
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
failure:
|
|
||||||
|
|
||||||
if (handle) {
|
|
||||||
if (handle->principal)
|
|
||||||
gss_release_name(NULL, &handle->principal);
|
|
||||||
if (handle->keytab)
|
|
||||||
krb5_kt_close(gssapi_krb5_context, handle->keytab);
|
|
||||||
if (handle->ccache)
|
|
||||||
krb5_cc_destroy(gssapi_krb5_context, handle->ccache);
|
|
||||||
if (handle->mechanisms)
|
|
||||||
gss_release_oid_set(NULL, &handle->mechanisms);
|
|
||||||
free(handle);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
@ -1,69 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997 - 2001, 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: add_oid_set_member.c,v 1.8 2003/03/16 17:50:49 lha Exp $");
|
|
||||||
|
|
||||||
OM_uint32 gss_add_oid_set_member (
|
|
||||||
OM_uint32 * minor_status,
|
|
||||||
const gss_OID member_oid,
|
|
||||||
gss_OID_set * oid_set
|
|
||||||
)
|
|
||||||
{
|
|
||||||
gss_OID tmp;
|
|
||||||
size_t n;
|
|
||||||
OM_uint32 res;
|
|
||||||
int present;
|
|
||||||
|
|
||||||
res = gss_test_oid_set_member(minor_status, member_oid, *oid_set, &present);
|
|
||||||
if (res != GSS_S_COMPLETE)
|
|
||||||
return res;
|
|
||||||
|
|
||||||
if (present) {
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
||||||
|
|
||||||
n = (*oid_set)->count + 1;
|
|
||||||
tmp = realloc ((*oid_set)->elements, n * sizeof(gss_OID_desc));
|
|
||||||
if (tmp == NULL) {
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
(*oid_set)->elements = tmp;
|
|
||||||
(*oid_set)->count = n;
|
|
||||||
(*oid_set)->elements[n-1] = *member_oid;
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
@ -1,76 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2000 - 2001 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
#include <roken.h>
|
|
||||||
|
|
||||||
krb5_error_code
|
|
||||||
gss_address_to_krb5addr(OM_uint32 gss_addr_type,
|
|
||||||
gss_buffer_desc *gss_addr,
|
|
||||||
int16_t port,
|
|
||||||
krb5_address *address)
|
|
||||||
{
|
|
||||||
int addr_type;
|
|
||||||
struct sockaddr sa;
|
|
||||||
int sa_size = sizeof(sa);
|
|
||||||
krb5_error_code problem;
|
|
||||||
|
|
||||||
if (gss_addr == NULL)
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
|
|
||||||
switch (gss_addr_type) {
|
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
case GSS_C_AF_INET6: addr_type = AF_INET6;
|
|
||||||
break;
|
|
||||||
#endif /* HAVE_IPV6 */
|
|
||||||
|
|
||||||
case GSS_C_AF_INET: addr_type = AF_INET;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
problem = krb5_h_addr2sockaddr (gssapi_krb5_context,
|
|
||||||
addr_type,
|
|
||||||
gss_addr->value,
|
|
||||||
&sa,
|
|
||||||
&sa_size,
|
|
||||||
port);
|
|
||||||
if (problem)
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
|
|
||||||
problem = krb5_sockaddr2address (gssapi_krb5_context, &sa, address);
|
|
||||||
|
|
||||||
return problem;
|
|
||||||
}
|
|
@ -1,623 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Implements draft-brezak-win2k-krb-rc4-hmac-04.txt
|
|
||||||
*/
|
|
||||||
|
|
||||||
RCSID("$Id: arcfour.c,v 1.12.2.3 2003/09/19 15:15:11 lha Exp $");
|
|
||||||
|
|
||||||
static krb5_error_code
|
|
||||||
arcfour_mic_key(krb5_context context, krb5_keyblock *key,
|
|
||||||
void *cksum_data, size_t cksum_size,
|
|
||||||
void *key6_data, size_t key6_size)
|
|
||||||
{
|
|
||||||
krb5_error_code ret;
|
|
||||||
|
|
||||||
Checksum cksum_k5;
|
|
||||||
krb5_keyblock key5;
|
|
||||||
char k5_data[16];
|
|
||||||
|
|
||||||
Checksum cksum_k6;
|
|
||||||
|
|
||||||
char T[4];
|
|
||||||
|
|
||||||
memset(T, 0, 4);
|
|
||||||
cksum_k5.checksum.data = k5_data;
|
|
||||||
cksum_k5.checksum.length = sizeof(k5_data);
|
|
||||||
|
|
||||||
if (key->keytype == KEYTYPE_ARCFOUR_56) {
|
|
||||||
char L40[14] = "fortybits";
|
|
||||||
|
|
||||||
memcpy(L40 + 10, T, sizeof(T));
|
|
||||||
ret = krb5_hmac(context, CKSUMTYPE_RSA_MD5,
|
|
||||||
L40, 14, 0, key, &cksum_k5);
|
|
||||||
memset(&k5_data[7], 0xAB, 9);
|
|
||||||
} else {
|
|
||||||
ret = krb5_hmac(context, CKSUMTYPE_RSA_MD5,
|
|
||||||
T, 4, 0, key, &cksum_k5);
|
|
||||||
}
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
key5.keytype = KEYTYPE_ARCFOUR;
|
|
||||||
key5.keyvalue = cksum_k5.checksum;
|
|
||||||
|
|
||||||
cksum_k6.checksum.data = key6_data;
|
|
||||||
cksum_k6.checksum.length = key6_size;
|
|
||||||
|
|
||||||
return krb5_hmac(context, CKSUMTYPE_RSA_MD5,
|
|
||||||
cksum_data, cksum_size, 0, &key5, &cksum_k6);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static krb5_error_code
|
|
||||||
arcfour_mic_cksum(krb5_keyblock *key, unsigned usage,
|
|
||||||
u_char *sgn_cksum, size_t sgn_cksum_sz,
|
|
||||||
const char *v1, size_t l1,
|
|
||||||
const void *v2, size_t l2,
|
|
||||||
const void *v3, size_t l3)
|
|
||||||
{
|
|
||||||
Checksum CKSUM;
|
|
||||||
u_char *ptr;
|
|
||||||
size_t len;
|
|
||||||
krb5_crypto crypto;
|
|
||||||
krb5_error_code ret;
|
|
||||||
|
|
||||||
assert(sgn_cksum_sz == 8);
|
|
||||||
|
|
||||||
len = l1 + l2 + l3;
|
|
||||||
|
|
||||||
ptr = malloc(len);
|
|
||||||
if (ptr == NULL)
|
|
||||||
return ENOMEM;
|
|
||||||
|
|
||||||
memcpy(ptr, v1, l1);
|
|
||||||
memcpy(ptr + l1, v2, l2);
|
|
||||||
memcpy(ptr + l1 + l2, v3, l3);
|
|
||||||
|
|
||||||
ret = krb5_crypto_init(gssapi_krb5_context, key, 0, &crypto);
|
|
||||||
if (ret) {
|
|
||||||
free(ptr);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = krb5_create_checksum(gssapi_krb5_context,
|
|
||||||
crypto,
|
|
||||||
usage,
|
|
||||||
0,
|
|
||||||
ptr, len,
|
|
||||||
&CKSUM);
|
|
||||||
free(ptr);
|
|
||||||
if (ret == 0) {
|
|
||||||
memcpy(sgn_cksum, CKSUM.checksum.data, sgn_cksum_sz);
|
|
||||||
free_Checksum(&CKSUM);
|
|
||||||
}
|
|
||||||
krb5_crypto_destroy(gssapi_krb5_context, crypto);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
_gssapi_get_mic_arcfour(OM_uint32 * minor_status,
|
|
||||||
const gss_ctx_id_t context_handle,
|
|
||||||
gss_qop_t qop_req,
|
|
||||||
const gss_buffer_t message_buffer,
|
|
||||||
gss_buffer_t message_token,
|
|
||||||
krb5_keyblock *key)
|
|
||||||
{
|
|
||||||
krb5_error_code ret;
|
|
||||||
int32_t seq_number;
|
|
||||||
size_t len, total_len;
|
|
||||||
u_char k6_data[16], *p0, *p;
|
|
||||||
RC4_KEY rc4_key;
|
|
||||||
|
|
||||||
gssapi_krb5_encap_length (22, &len, &total_len);
|
|
||||||
|
|
||||||
message_token->length = total_len;
|
|
||||||
message_token->value = malloc (total_len);
|
|
||||||
if (message_token->value == NULL) {
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
p0 = _gssapi_make_mech_header(message_token->value,
|
|
||||||
len);
|
|
||||||
p = p0;
|
|
||||||
|
|
||||||
*p++ = 0x01; /* TOK_ID */
|
|
||||||
*p++ = 0x01;
|
|
||||||
*p++ = 0x11; /* SGN_ALG */
|
|
||||||
*p++ = 0x00;
|
|
||||||
*p++ = 0xff; /* Filler */
|
|
||||||
*p++ = 0xff;
|
|
||||||
*p++ = 0xff;
|
|
||||||
*p++ = 0xff;
|
|
||||||
|
|
||||||
p = NULL;
|
|
||||||
|
|
||||||
ret = arcfour_mic_cksum(key, KRB5_KU_USAGE_SIGN,
|
|
||||||
p0 + 16, 8, /* SGN_CKSUM */
|
|
||||||
p0, 8, /* TOK_ID, SGN_ALG, Filer */
|
|
||||||
message_buffer->value, message_buffer->length,
|
|
||||||
NULL, 0);
|
|
||||||
if (ret) {
|
|
||||||
gss_release_buffer(minor_status, message_token);
|
|
||||||
*minor_status = ret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = arcfour_mic_key(gssapi_krb5_context, key,
|
|
||||||
p0 + 16, 8, /* SGN_CKSUM */
|
|
||||||
k6_data, sizeof(k6_data));
|
|
||||||
if (ret) {
|
|
||||||
gss_release_buffer(minor_status, message_token);
|
|
||||||
*minor_status = ret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
krb5_auth_con_getlocalseqnumber (gssapi_krb5_context,
|
|
||||||
context_handle->auth_context,
|
|
||||||
&seq_number);
|
|
||||||
p = p0 + 8; /* SND_SEQ */
|
|
||||||
gssapi_encode_be_om_uint32(seq_number, p);
|
|
||||||
|
|
||||||
krb5_auth_con_setlocalseqnumber (gssapi_krb5_context,
|
|
||||||
context_handle->auth_context,
|
|
||||||
++seq_number);
|
|
||||||
|
|
||||||
memset (p + 4, (context_handle->more_flags & LOCAL) ? 0 : 0xff, 4);
|
|
||||||
|
|
||||||
RC4_set_key (&rc4_key, sizeof(k6_data), k6_data);
|
|
||||||
RC4 (&rc4_key, 8, p, p);
|
|
||||||
|
|
||||||
memset(&rc4_key, 0, sizeof(rc4_key));
|
|
||||||
memset(k6_data, 0, sizeof(k6_data));
|
|
||||||
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
_gssapi_verify_mic_arcfour(OM_uint32 * minor_status,
|
|
||||||
const gss_ctx_id_t context_handle,
|
|
||||||
const gss_buffer_t message_buffer,
|
|
||||||
const gss_buffer_t token_buffer,
|
|
||||||
gss_qop_t * qop_state,
|
|
||||||
krb5_keyblock *key,
|
|
||||||
char *type)
|
|
||||||
{
|
|
||||||
krb5_error_code ret;
|
|
||||||
int32_t seq_number, seq_number2;
|
|
||||||
OM_uint32 omret;
|
|
||||||
char cksum_data[8], k6_data[16], SND_SEQ[8];
|
|
||||||
u_char *p;
|
|
||||||
int cmp;
|
|
||||||
|
|
||||||
if (qop_state)
|
|
||||||
*qop_state = 0;
|
|
||||||
|
|
||||||
p = token_buffer->value;
|
|
||||||
omret = gssapi_krb5_verify_header (&p,
|
|
||||||
token_buffer->length,
|
|
||||||
type);
|
|
||||||
if (omret)
|
|
||||||
return omret;
|
|
||||||
|
|
||||||
if (memcmp(p, "\x11\x00", 2) != 0) /* SGN_ALG = HMAC MD5 ARCFOUR */
|
|
||||||
return GSS_S_BAD_SIG;
|
|
||||||
p += 2;
|
|
||||||
if (memcmp (p, "\xff\xff\xff\xff", 4) != 0)
|
|
||||||
return GSS_S_BAD_MIC;
|
|
||||||
p += 4;
|
|
||||||
|
|
||||||
ret = arcfour_mic_cksum(key, KRB5_KU_USAGE_SIGN,
|
|
||||||
cksum_data, sizeof(cksum_data),
|
|
||||||
p - 8, 8,
|
|
||||||
message_buffer->value, message_buffer->length,
|
|
||||||
NULL, 0);
|
|
||||||
if (ret) {
|
|
||||||
*minor_status = ret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = arcfour_mic_key(gssapi_krb5_context, key,
|
|
||||||
cksum_data, sizeof(cksum_data),
|
|
||||||
k6_data, sizeof(k6_data));
|
|
||||||
if (ret) {
|
|
||||||
*minor_status = ret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
cmp = memcmp(cksum_data, p + 8, 8);
|
|
||||||
if (cmp) {
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_BAD_MIC;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
RC4_KEY rc4_key;
|
|
||||||
|
|
||||||
RC4_set_key (&rc4_key, sizeof(k6_data), k6_data);
|
|
||||||
RC4 (&rc4_key, 8, p, SND_SEQ);
|
|
||||||
|
|
||||||
memset(&rc4_key, 0, sizeof(rc4_key));
|
|
||||||
memset(k6_data, 0, sizeof(k6_data));
|
|
||||||
}
|
|
||||||
|
|
||||||
gssapi_decode_be_om_uint32(SND_SEQ, &seq_number);
|
|
||||||
|
|
||||||
if (context_handle->more_flags & LOCAL)
|
|
||||||
cmp = memcmp(&SND_SEQ[4], "\xff\xff\xff\xff", 4);
|
|
||||||
else
|
|
||||||
cmp = memcmp(&SND_SEQ[4], "\x00\x00\x00\x00", 4);
|
|
||||||
|
|
||||||
memset(SND_SEQ, 0, sizeof(SND_SEQ));
|
|
||||||
if (cmp != 0) {
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_BAD_MIC;
|
|
||||||
}
|
|
||||||
|
|
||||||
krb5_auth_con_getlocalseqnumber (gssapi_krb5_context,
|
|
||||||
context_handle->auth_context,
|
|
||||||
&seq_number2);
|
|
||||||
|
|
||||||
if (seq_number != seq_number2) {
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_UNSEQ_TOKEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
krb5_auth_con_setlocalseqnumber (gssapi_krb5_context,
|
|
||||||
context_handle->auth_context,
|
|
||||||
++seq_number2);
|
|
||||||
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
_gssapi_wrap_arcfour(OM_uint32 * minor_status,
|
|
||||||
const gss_ctx_id_t context_handle,
|
|
||||||
int conf_req_flag,
|
|
||||||
gss_qop_t qop_req,
|
|
||||||
const gss_buffer_t input_message_buffer,
|
|
||||||
int * conf_state,
|
|
||||||
gss_buffer_t output_message_buffer,
|
|
||||||
krb5_keyblock *key)
|
|
||||||
{
|
|
||||||
u_char Klocaldata[16], k6_data[16], *p, *p0;
|
|
||||||
size_t len, total_len, datalen;
|
|
||||||
krb5_keyblock Klocal;
|
|
||||||
krb5_error_code ret;
|
|
||||||
int32_t seq_number;
|
|
||||||
|
|
||||||
if (conf_state)
|
|
||||||
*conf_state = 0;
|
|
||||||
|
|
||||||
datalen = input_message_buffer->length + 1 /* padding */;
|
|
||||||
len = datalen + 30;
|
|
||||||
gssapi_krb5_encap_length (len, &len, &total_len);
|
|
||||||
|
|
||||||
output_message_buffer->length = total_len;
|
|
||||||
output_message_buffer->value = malloc (total_len);
|
|
||||||
if (output_message_buffer->value == NULL) {
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
p0 = _gssapi_make_mech_header(output_message_buffer->value,
|
|
||||||
len);
|
|
||||||
p = p0;
|
|
||||||
|
|
||||||
*p++ = 0x02; /* TOK_ID */
|
|
||||||
*p++ = 0x01;
|
|
||||||
*p++ = 0x11; /* SGN_ALG */
|
|
||||||
*p++ = 0x00;
|
|
||||||
if (conf_req_flag) {
|
|
||||||
*p++ = 0x10; /* SEAL_ALG */
|
|
||||||
*p++ = 0x00;
|
|
||||||
} else {
|
|
||||||
*p++ = 0xff; /* SEAL_ALG */
|
|
||||||
*p++ = 0xff;
|
|
||||||
}
|
|
||||||
*p++ = 0xff; /* Filler */
|
|
||||||
*p++ = 0xff;
|
|
||||||
|
|
||||||
p = NULL;
|
|
||||||
|
|
||||||
krb5_auth_con_getlocalseqnumber (gssapi_krb5_context,
|
|
||||||
context_handle->auth_context,
|
|
||||||
&seq_number);
|
|
||||||
|
|
||||||
gssapi_encode_be_om_uint32(seq_number, p0 + 8);
|
|
||||||
|
|
||||||
krb5_auth_con_setlocalseqnumber (gssapi_krb5_context,
|
|
||||||
context_handle->auth_context,
|
|
||||||
++seq_number);
|
|
||||||
|
|
||||||
memset (p0 + 8 + 4,
|
|
||||||
(context_handle->more_flags & LOCAL) ? 0 : 0xff,
|
|
||||||
4);
|
|
||||||
|
|
||||||
krb5_generate_random_block(p0 + 24, 8); /* fill in Confounder */
|
|
||||||
|
|
||||||
/* p points to data */
|
|
||||||
p = p0 + GSS_ARCFOUR_WRAP_TOKEN_SIZE;
|
|
||||||
memcpy(p, input_message_buffer->value, input_message_buffer->length);
|
|
||||||
p[input_message_buffer->length] = 1; /* PADDING */
|
|
||||||
|
|
||||||
ret = arcfour_mic_cksum(key, KRB5_KU_USAGE_SEAL,
|
|
||||||
p0 + 16, 8, /* SGN_CKSUM */
|
|
||||||
p0, 8, /* TOK_ID, SGN_ALG, SEAL_ALG, Filler */
|
|
||||||
p0 + 24, 8, /* Confounder */
|
|
||||||
p0 + GSS_ARCFOUR_WRAP_TOKEN_SIZE,
|
|
||||||
datalen);
|
|
||||||
if (ret) {
|
|
||||||
*minor_status = ret;
|
|
||||||
gss_release_buffer(minor_status, output_message_buffer);
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
Klocal.keytype = key->keytype;
|
|
||||||
Klocal.keyvalue.data = Klocaldata;
|
|
||||||
Klocal.keyvalue.length = sizeof(Klocaldata);
|
|
||||||
|
|
||||||
for (i = 0; i < 16; i++)
|
|
||||||
Klocaldata[i] = ((u_char *)key->keyvalue.data)[i] ^ 0xF0;
|
|
||||||
}
|
|
||||||
ret = arcfour_mic_key(gssapi_krb5_context, &Klocal,
|
|
||||||
p0 + 8, 4, /* SND_SEQ */
|
|
||||||
k6_data, sizeof(k6_data));
|
|
||||||
memset(Klocaldata, 0, sizeof(Klocaldata));
|
|
||||||
if (ret) {
|
|
||||||
gss_release_buffer(minor_status, output_message_buffer);
|
|
||||||
*minor_status = ret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(conf_req_flag) {
|
|
||||||
RC4_KEY rc4_key;
|
|
||||||
|
|
||||||
RC4_set_key (&rc4_key, sizeof(k6_data), k6_data);
|
|
||||||
/* XXX ? */
|
|
||||||
RC4 (&rc4_key, 8 + datalen, p0 + 24, p0 + 24); /* Confounder + data */
|
|
||||||
memset(&rc4_key, 0, sizeof(rc4_key));
|
|
||||||
}
|
|
||||||
memset(k6_data, 0, sizeof(k6_data));
|
|
||||||
|
|
||||||
ret = arcfour_mic_key(gssapi_krb5_context, key,
|
|
||||||
p0 + 16, 8, /* SGN_CKSUM */
|
|
||||||
k6_data, sizeof(k6_data));
|
|
||||||
if (ret) {
|
|
||||||
gss_release_buffer(minor_status, output_message_buffer);
|
|
||||||
*minor_status = ret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
RC4_KEY rc4_key;
|
|
||||||
|
|
||||||
RC4_set_key (&rc4_key, sizeof(k6_data), k6_data);
|
|
||||||
RC4 (&rc4_key, 8, p0 + 8, p0 + 8); /* SND_SEQ */
|
|
||||||
memset(&rc4_key, 0, sizeof(rc4_key));
|
|
||||||
memset(k6_data, 0, sizeof(k6_data));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (conf_state)
|
|
||||||
*conf_state = conf_req_flag;
|
|
||||||
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
||||||
|
|
||||||
OM_uint32 _gssapi_unwrap_arcfour(OM_uint32 *minor_status,
|
|
||||||
const gss_ctx_id_t context_handle,
|
|
||||||
const gss_buffer_t input_message_buffer,
|
|
||||||
gss_buffer_t output_message_buffer,
|
|
||||||
int *conf_state,
|
|
||||||
gss_qop_t *qop_state,
|
|
||||||
krb5_keyblock *key)
|
|
||||||
{
|
|
||||||
u_char Klocaldata[16];
|
|
||||||
krb5_keyblock Klocal;
|
|
||||||
krb5_error_code ret;
|
|
||||||
int32_t seq_number, seq_number2;
|
|
||||||
size_t datalen;
|
|
||||||
OM_uint32 omret;
|
|
||||||
char k6_data[16], SND_SEQ[8], Confounder[8];
|
|
||||||
char cksum_data[8];
|
|
||||||
u_char *p, *p0;
|
|
||||||
int cmp;
|
|
||||||
int conf_flag;
|
|
||||||
size_t padlen;
|
|
||||||
|
|
||||||
if (conf_state)
|
|
||||||
*conf_state = 0;
|
|
||||||
if (qop_state)
|
|
||||||
*qop_state = 0;
|
|
||||||
|
|
||||||
p0 = input_message_buffer->value;
|
|
||||||
omret = _gssapi_verify_mech_header(&p0,
|
|
||||||
input_message_buffer->length);
|
|
||||||
if (omret)
|
|
||||||
return omret;
|
|
||||||
p = p0;
|
|
||||||
|
|
||||||
datalen = input_message_buffer->length -
|
|
||||||
(p - ((u_char *)input_message_buffer->value)) -
|
|
||||||
GSS_ARCFOUR_WRAP_TOKEN_SIZE;
|
|
||||||
|
|
||||||
if (memcmp(p, "\x02\x01", 2) != 0)
|
|
||||||
return GSS_S_BAD_SIG;
|
|
||||||
p += 2;
|
|
||||||
if (memcmp(p, "\x11\x00", 2) != 0) /* SGN_ALG = HMAC MD5 ARCFOUR */
|
|
||||||
return GSS_S_BAD_SIG;
|
|
||||||
p += 2;
|
|
||||||
|
|
||||||
if (memcmp (p, "\x10\x00", 2) == 0)
|
|
||||||
conf_flag = 1;
|
|
||||||
else if (memcmp (p, "\xff\xff", 2) == 0)
|
|
||||||
conf_flag = 0;
|
|
||||||
else
|
|
||||||
return GSS_S_BAD_SIG;
|
|
||||||
|
|
||||||
p += 2;
|
|
||||||
if (memcmp (p, "\xff\xff", 2) != 0)
|
|
||||||
return GSS_S_BAD_MIC;
|
|
||||||
p = NULL;
|
|
||||||
|
|
||||||
ret = arcfour_mic_key(gssapi_krb5_context, key,
|
|
||||||
p0 + 16, 8, /* SGN_CKSUM */
|
|
||||||
k6_data, sizeof(k6_data));
|
|
||||||
if (ret) {
|
|
||||||
*minor_status = ret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
RC4_KEY rc4_key;
|
|
||||||
|
|
||||||
RC4_set_key (&rc4_key, sizeof(k6_data), k6_data);
|
|
||||||
RC4 (&rc4_key, 8, p0 + 8, SND_SEQ); /* SND_SEQ */
|
|
||||||
memset(&rc4_key, 0, sizeof(rc4_key));
|
|
||||||
memset(k6_data, 0, sizeof(k6_data));
|
|
||||||
}
|
|
||||||
|
|
||||||
gssapi_decode_be_om_uint32(SND_SEQ, &seq_number);
|
|
||||||
|
|
||||||
if (context_handle->more_flags & LOCAL)
|
|
||||||
cmp = memcmp(&SND_SEQ[4], "\xff\xff\xff\xff", 4);
|
|
||||||
else
|
|
||||||
cmp = memcmp(&SND_SEQ[4], "\x00\x00\x00\x00", 4);
|
|
||||||
|
|
||||||
if (cmp != 0) {
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_BAD_MIC;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
Klocal.keytype = key->keytype;
|
|
||||||
Klocal.keyvalue.data = Klocaldata;
|
|
||||||
Klocal.keyvalue.length = sizeof(Klocaldata);
|
|
||||||
|
|
||||||
for (i = 0; i < 16; i++)
|
|
||||||
Klocaldata[i] = ((u_char *)key->keyvalue.data)[i] ^ 0xF0;
|
|
||||||
}
|
|
||||||
ret = arcfour_mic_key(gssapi_krb5_context, &Klocal,
|
|
||||||
SND_SEQ, 4,
|
|
||||||
k6_data, sizeof(k6_data));
|
|
||||||
memset(Klocaldata, 0, sizeof(Klocaldata));
|
|
||||||
if (ret) {
|
|
||||||
*minor_status = ret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
output_message_buffer->value = malloc(datalen);
|
|
||||||
if (output_message_buffer->value == NULL) {
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
output_message_buffer->length = datalen;
|
|
||||||
|
|
||||||
if(conf_flag) {
|
|
||||||
RC4_KEY rc4_key;
|
|
||||||
|
|
||||||
RC4_set_key (&rc4_key, sizeof(k6_data), k6_data);
|
|
||||||
RC4 (&rc4_key, 8, p0 + 24, Confounder); /* Confounder */
|
|
||||||
RC4 (&rc4_key, datalen, p0 + GSS_ARCFOUR_WRAP_TOKEN_SIZE,
|
|
||||||
output_message_buffer->value);
|
|
||||||
memset(&rc4_key, 0, sizeof(rc4_key));
|
|
||||||
} else {
|
|
||||||
memcpy(Confounder, p0 + 24, 8); /* Confounder */
|
|
||||||
memcpy(output_message_buffer->value,
|
|
||||||
p0 + GSS_ARCFOUR_WRAP_TOKEN_SIZE,
|
|
||||||
datalen);
|
|
||||||
}
|
|
||||||
memset(k6_data, 0, sizeof(k6_data));
|
|
||||||
|
|
||||||
ret = _gssapi_verify_pad(output_message_buffer, datalen, &padlen);
|
|
||||||
if (ret) {
|
|
||||||
gss_release_buffer(minor_status, output_message_buffer);
|
|
||||||
*minor_status = 0;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
output_message_buffer->length -= padlen;
|
|
||||||
|
|
||||||
ret = arcfour_mic_cksum(key, KRB5_KU_USAGE_SEAL,
|
|
||||||
cksum_data, sizeof(cksum_data),
|
|
||||||
p0, 8,
|
|
||||||
Confounder, sizeof(Confounder),
|
|
||||||
output_message_buffer->value,
|
|
||||||
output_message_buffer->length + padlen);
|
|
||||||
if (ret) {
|
|
||||||
gss_release_buffer(minor_status, output_message_buffer);
|
|
||||||
*minor_status = ret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
cmp = memcmp(cksum_data, p0 + 16, 8); /* SGN_CKSUM */
|
|
||||||
if (cmp) {
|
|
||||||
gss_release_buffer(minor_status, output_message_buffer);
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_BAD_MIC;
|
|
||||||
}
|
|
||||||
|
|
||||||
krb5_auth_getremoteseqnumber (gssapi_krb5_context,
|
|
||||||
context_handle->auth_context,
|
|
||||||
&seq_number2);
|
|
||||||
|
|
||||||
if (seq_number != seq_number2) {
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_UNSEQ_TOKEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
krb5_auth_con_setremoteseqnumber (gssapi_krb5_context,
|
|
||||||
context_handle->auth_context,
|
|
||||||
++seq_number2);
|
|
||||||
|
|
||||||
if (conf_state)
|
|
||||||
*conf_state = conf_flag;
|
|
||||||
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
@ -1,98 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* $Id: arcfour.h,v 1.3.2.2 2003/09/19 15:14:14 lha Exp $ */
|
|
||||||
|
|
||||||
#ifndef GSSAPI_ARCFOUR_H_
|
|
||||||
#define GSSAPI_ARCFOUR_H_ 1
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The arcfour message have the following formats, these are only here
|
|
||||||
* for reference and is not used.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
typedef struct gss_arcfour_mic_token {
|
|
||||||
u_char TOK_ID[2]; /* 01 01 */
|
|
||||||
u_char SGN_ALG[2]; /* 11 00 */
|
|
||||||
u_char Filler[4];
|
|
||||||
u_char SND_SEQ[8];
|
|
||||||
u_char SGN_CKSUM[8];
|
|
||||||
} gss_arcfour_mic_token_desc, *gss_arcfour_mic_token;
|
|
||||||
|
|
||||||
typedef struct gss_arcfour_wrap_token {
|
|
||||||
u_char TOK_ID[2]; /* 02 01 */
|
|
||||||
u_char SGN_ALG[2];
|
|
||||||
u_char SEAL_ALG[2];
|
|
||||||
u_char Filler[2];
|
|
||||||
u_char SND_SEQ[8];
|
|
||||||
u_char SGN_CKSUM[8];
|
|
||||||
u_char Confounder[8];
|
|
||||||
} gss_arcfour_wrap_token_desc, *gss_arcfour_wrap_token;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define GSS_ARCFOUR_WRAP_TOKEN_SIZE 32
|
|
||||||
|
|
||||||
OM_uint32 _gssapi_wrap_arcfour(OM_uint32 *minor_status,
|
|
||||||
const gss_ctx_id_t context_handle,
|
|
||||||
int conf_req_flag,
|
|
||||||
gss_qop_t qop_req,
|
|
||||||
const gss_buffer_t input_message_buffer,
|
|
||||||
int *conf_state,
|
|
||||||
gss_buffer_t output_message_buffer,
|
|
||||||
krb5_keyblock *key);
|
|
||||||
|
|
||||||
OM_uint32 _gssapi_unwrap_arcfour(OM_uint32 *minor_status,
|
|
||||||
const gss_ctx_id_t context_handle,
|
|
||||||
const gss_buffer_t input_message_buffer,
|
|
||||||
gss_buffer_t output_message_buffer,
|
|
||||||
int *conf_state,
|
|
||||||
gss_qop_t *qop_state,
|
|
||||||
krb5_keyblock *key);
|
|
||||||
|
|
||||||
OM_uint32 _gssapi_get_mic_arcfour(OM_uint32 *minor_status,
|
|
||||||
const gss_ctx_id_t context_handle,
|
|
||||||
gss_qop_t qop_req,
|
|
||||||
const gss_buffer_t message_buffer,
|
|
||||||
gss_buffer_t message_token,
|
|
||||||
krb5_keyblock *key);
|
|
||||||
|
|
||||||
OM_uint32 _gssapi_verify_mic_arcfour(OM_uint32 *minor_status,
|
|
||||||
const gss_ctx_id_t context_handle,
|
|
||||||
const gss_buffer_t message_buffer,
|
|
||||||
const gss_buffer_t token_buffer,
|
|
||||||
gss_qop_t *qop_state,
|
|
||||||
krb5_keyblock *key,
|
|
||||||
char *type);
|
|
||||||
|
|
||||||
#endif /* GSSAPI_ARCFOUR_H_ */
|
|
@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: canonicalize_name.c,v 1.2 1999/12/02 17:05:03 joda Exp $");
|
|
||||||
|
|
||||||
OM_uint32 gss_canonicalize_name (
|
|
||||||
OM_uint32 * minor_status,
|
|
||||||
const gss_name_t input_name,
|
|
||||||
const gss_OID mech_type,
|
|
||||||
gss_name_t * output_name
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return gss_duplicate_name (minor_status, input_name, output_name);
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997-2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: compare_name.c,v 1.4 2003/03/16 17:50:07 lha Exp $");
|
|
||||||
|
|
||||||
OM_uint32 gss_compare_name
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
const gss_name_t name1,
|
|
||||||
const gss_name_t name2,
|
|
||||||
int * name_equal
|
|
||||||
)
|
|
||||||
{
|
|
||||||
GSSAPI_KRB5_INIT();
|
|
||||||
|
|
||||||
*name_equal = krb5_principal_compare (gssapi_krb5_context,
|
|
||||||
name1, name2);
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
@ -1,113 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: compat.c,v 1.2.2.2 2003/04/28 13:58:09 lha Exp $");
|
|
||||||
|
|
||||||
|
|
||||||
static krb5_error_code
|
|
||||||
check_compat(OM_uint32 *minor_status, gss_name_t name,
|
|
||||||
const char *option, krb5_boolean *compat,
|
|
||||||
krb5_boolean match_val)
|
|
||||||
{
|
|
||||||
krb5_error_code ret = 0;
|
|
||||||
char **p, **q;
|
|
||||||
krb5_principal match;
|
|
||||||
|
|
||||||
|
|
||||||
p = krb5_config_get_strings(gssapi_krb5_context, NULL, "gssapi",
|
|
||||||
option, NULL);
|
|
||||||
if(p == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
for(q = p; *q; q++) {
|
|
||||||
|
|
||||||
ret = krb5_parse_name(gssapi_krb5_context, *q, &match);
|
|
||||||
if (ret)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (krb5_principal_match(gssapi_krb5_context, name, match)) {
|
|
||||||
*compat = match_val;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
krb5_free_principal(gssapi_krb5_context, match);
|
|
||||||
}
|
|
||||||
krb5_config_free_strings(p);
|
|
||||||
|
|
||||||
if (ret) {
|
|
||||||
*minor_status = ret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
_gss_DES3_get_mic_compat(OM_uint32 *minor_status, gss_ctx_id_t ctx)
|
|
||||||
{
|
|
||||||
krb5_boolean use_compat = TRUE;
|
|
||||||
OM_uint32 ret;
|
|
||||||
|
|
||||||
if ((ctx->more_flags & COMPAT_OLD_DES3_SELECTED) == 0) {
|
|
||||||
ret = check_compat(minor_status, ctx->target,
|
|
||||||
"broken_des3_mic", &use_compat, TRUE);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
ret = check_compat(minor_status, ctx->target,
|
|
||||||
"correct_des3_mic", &use_compat, FALSE);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
if (use_compat)
|
|
||||||
ctx->more_flags |= COMPAT_OLD_DES3;
|
|
||||||
ctx->more_flags |= COMPAT_OLD_DES3_SELECTED;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
gss_krb5_compat_des3_mic(OM_uint32 *minor_status, gss_ctx_id_t ctx, int on)
|
|
||||||
{
|
|
||||||
*minor_status = 0;
|
|
||||||
|
|
||||||
if (on) {
|
|
||||||
ctx->more_flags |= COMPAT_OLD_DES3;
|
|
||||||
} else {
|
|
||||||
ctx->more_flags &= ~COMPAT_OLD_DES3;
|
|
||||||
}
|
|
||||||
ctx->more_flags |= COMPAT_OLD_DES3_SELECTED;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,85 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997 - 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: context_time.c,v 1.7.2.1 2003/08/15 14:25:50 lha Exp $");
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
gssapi_lifetime_left(OM_uint32 *minor_status,
|
|
||||||
OM_uint32 lifetime,
|
|
||||||
OM_uint32 *lifetime_rec)
|
|
||||||
{
|
|
||||||
krb5_timestamp timeret;
|
|
||||||
krb5_error_code kret;
|
|
||||||
|
|
||||||
kret = krb5_timeofday(gssapi_krb5_context, &timeret);
|
|
||||||
if (kret) {
|
|
||||||
*minor_status = kret;
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lifetime < timeret)
|
|
||||||
*lifetime_rec = 0;
|
|
||||||
else
|
|
||||||
*lifetime_rec = lifetime - timeret;
|
|
||||||
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
OM_uint32 gss_context_time
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
const gss_ctx_id_t context_handle,
|
|
||||||
OM_uint32 * time_rec
|
|
||||||
)
|
|
||||||
{
|
|
||||||
OM_uint32 lifetime;
|
|
||||||
OM_uint32 major_status;
|
|
||||||
|
|
||||||
GSSAPI_KRB5_INIT ();
|
|
||||||
|
|
||||||
lifetime = context_handle->lifetime;
|
|
||||||
|
|
||||||
major_status = gssapi_lifetime_left(minor_status, lifetime, time_rec);
|
|
||||||
if (major_status != GSS_S_COMPLETE)
|
|
||||||
return major_status;
|
|
||||||
|
|
||||||
*minor_status = 0;
|
|
||||||
|
|
||||||
if (*time_rec == 0)
|
|
||||||
return GSS_S_CONTEXT_EXPIRED;
|
|
||||||
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2000 - 2001, 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: copy_ccache.c,v 1.3 2003/03/16 17:47:44 lha Exp $");
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
gss_krb5_copy_ccache(OM_uint32 *minor_status,
|
|
||||||
gss_cred_id_t cred,
|
|
||||||
krb5_ccache out)
|
|
||||||
{
|
|
||||||
krb5_error_code kret;
|
|
||||||
|
|
||||||
if (cred->ccache == NULL) {
|
|
||||||
*minor_status = EINVAL;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
kret = krb5_cc_copy_cache(gssapi_krb5_context, cred->ccache, out);
|
|
||||||
if (kret) {
|
|
||||||
*minor_status = kret;
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997 - 2001, 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: create_emtpy_oid_set.c,v 1.5 2003/03/16 17:47:07 lha Exp $");
|
|
||||||
|
|
||||||
OM_uint32 gss_create_empty_oid_set (
|
|
||||||
OM_uint32 * minor_status,
|
|
||||||
gss_OID_set * oid_set
|
|
||||||
)
|
|
||||||
{
|
|
||||||
*oid_set = malloc(sizeof(**oid_set));
|
|
||||||
if (*oid_set == NULL) {
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
(*oid_set)->count = 0;
|
|
||||||
(*oid_set)->elements = NULL;
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
@ -1,184 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997 - 2001 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: decapsulate.c,v 1.7.6.1 2003/09/18 22:00:41 lha Exp $");
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
gssapi_krb5_verify_header(u_char **str,
|
|
||||||
size_t total_len,
|
|
||||||
char *type)
|
|
||||||
{
|
|
||||||
size_t len, len_len, mech_len, foo;
|
|
||||||
int e;
|
|
||||||
u_char *p = *str;
|
|
||||||
|
|
||||||
if (total_len < 1)
|
|
||||||
return GSS_S_DEFECTIVE_TOKEN;
|
|
||||||
if (*p++ != 0x60)
|
|
||||||
return GSS_S_DEFECTIVE_TOKEN;
|
|
||||||
e = der_get_length (p, total_len - 1, &len, &len_len);
|
|
||||||
if (e || 1 + len_len + len != total_len)
|
|
||||||
return GSS_S_DEFECTIVE_TOKEN;
|
|
||||||
p += len_len;
|
|
||||||
if (*p++ != 0x06)
|
|
||||||
return GSS_S_DEFECTIVE_TOKEN;
|
|
||||||
e = der_get_length (p, total_len - 1 - len_len - 1,
|
|
||||||
&mech_len, &foo);
|
|
||||||
if (e)
|
|
||||||
return GSS_S_DEFECTIVE_TOKEN;
|
|
||||||
p += foo;
|
|
||||||
if (mech_len != GSS_KRB5_MECHANISM->length)
|
|
||||||
return GSS_S_BAD_MECH;
|
|
||||||
if (memcmp(p,
|
|
||||||
GSS_KRB5_MECHANISM->elements,
|
|
||||||
GSS_KRB5_MECHANISM->length) != 0)
|
|
||||||
return GSS_S_BAD_MECH;
|
|
||||||
p += mech_len;
|
|
||||||
if (memcmp (p, type, 2) != 0)
|
|
||||||
return GSS_S_DEFECTIVE_TOKEN;
|
|
||||||
p += 2;
|
|
||||||
*str = p;
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t
|
|
||||||
gssapi_krb5_get_mech (const u_char *ptr,
|
|
||||||
size_t total_len,
|
|
||||||
const u_char **mech_ret)
|
|
||||||
{
|
|
||||||
size_t len, len_len, mech_len, foo;
|
|
||||||
const u_char *p = ptr;
|
|
||||||
int e;
|
|
||||||
|
|
||||||
if (total_len < 1)
|
|
||||||
return -1;
|
|
||||||
if (*p++ != 0x60)
|
|
||||||
return -1;
|
|
||||||
e = der_get_length (p, total_len - 1, &len, &len_len);
|
|
||||||
if (e || 1 + len_len + len != total_len)
|
|
||||||
return -1;
|
|
||||||
p += len_len;
|
|
||||||
if (*p++ != 0x06)
|
|
||||||
return -1;
|
|
||||||
e = der_get_length (p, total_len - 1 - len_len - 1,
|
|
||||||
&mech_len, &foo);
|
|
||||||
if (e)
|
|
||||||
return -1;
|
|
||||||
p += foo;
|
|
||||||
*mech_ret = p;
|
|
||||||
return mech_len;
|
|
||||||
}
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
_gssapi_verify_mech_header(u_char **str,
|
|
||||||
size_t total_len)
|
|
||||||
{
|
|
||||||
const u_char *p;
|
|
||||||
ssize_t mech_len;
|
|
||||||
|
|
||||||
mech_len = gssapi_krb5_get_mech (*str, total_len, &p);
|
|
||||||
if (mech_len < 0)
|
|
||||||
return GSS_S_DEFECTIVE_TOKEN;
|
|
||||||
|
|
||||||
if (mech_len != GSS_KRB5_MECHANISM->length)
|
|
||||||
return GSS_S_BAD_MECH;
|
|
||||||
if (memcmp(p,
|
|
||||||
GSS_KRB5_MECHANISM->elements,
|
|
||||||
GSS_KRB5_MECHANISM->length) != 0)
|
|
||||||
return GSS_S_BAD_MECH;
|
|
||||||
p += mech_len;
|
|
||||||
*str = (char *)p;
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Remove the GSS-API wrapping from `in_token' giving `out_data.
|
|
||||||
* Does not copy data, so just free `in_token'.
|
|
||||||
*/
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
gssapi_krb5_decapsulate(
|
|
||||||
OM_uint32 *minor_status,
|
|
||||||
gss_buffer_t input_token_buffer,
|
|
||||||
krb5_data *out_data,
|
|
||||||
char *type
|
|
||||||
)
|
|
||||||
{
|
|
||||||
u_char *p;
|
|
||||||
OM_uint32 ret;
|
|
||||||
|
|
||||||
p = input_token_buffer->value;
|
|
||||||
ret = gssapi_krb5_verify_header(&p,
|
|
||||||
input_token_buffer->length,
|
|
||||||
type);
|
|
||||||
if (ret) {
|
|
||||||
*minor_status = 0;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
out_data->length = input_token_buffer->length -
|
|
||||||
(p - (u_char *)input_token_buffer->value);
|
|
||||||
out_data->data = p;
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Verify padding of a gss wrapped message and return its length.
|
|
||||||
*/
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
_gssapi_verify_pad(gss_buffer_t wrapped_token,
|
|
||||||
size_t datalen,
|
|
||||||
size_t *padlen)
|
|
||||||
{
|
|
||||||
u_char *pad;
|
|
||||||
size_t padlength;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
pad = (u_char *)wrapped_token->value + wrapped_token->length - 1;
|
|
||||||
padlength = *pad;
|
|
||||||
|
|
||||||
if (padlength > datalen)
|
|
||||||
return GSS_S_BAD_MECH;
|
|
||||||
|
|
||||||
for (i = padlength; i > 0 && *pad == padlength; i--, pad--)
|
|
||||||
;
|
|
||||||
if (i != 0)
|
|
||||||
return GSS_S_BAD_MIC;
|
|
||||||
|
|
||||||
*padlen = padlength;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,69 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997 - 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: delete_sec_context.c,v 1.11 2003/03/16 17:46:40 lha Exp $");
|
|
||||||
|
|
||||||
OM_uint32 gss_delete_sec_context
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
gss_ctx_id_t * context_handle,
|
|
||||||
gss_buffer_t output_token
|
|
||||||
)
|
|
||||||
{
|
|
||||||
GSSAPI_KRB5_INIT ();
|
|
||||||
|
|
||||||
if (output_token) {
|
|
||||||
output_token->length = 0;
|
|
||||||
output_token->value = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
krb5_auth_con_free (gssapi_krb5_context,
|
|
||||||
(*context_handle)->auth_context);
|
|
||||||
if((*context_handle)->source)
|
|
||||||
krb5_free_principal (gssapi_krb5_context,
|
|
||||||
(*context_handle)->source);
|
|
||||||
if((*context_handle)->target)
|
|
||||||
krb5_free_principal (gssapi_krb5_context,
|
|
||||||
(*context_handle)->target);
|
|
||||||
if ((*context_handle)->ticket) {
|
|
||||||
krb5_free_ticket (gssapi_krb5_context,
|
|
||||||
(*context_handle)->ticket);
|
|
||||||
free((*context_handle)->ticket);
|
|
||||||
}
|
|
||||||
|
|
||||||
free (*context_handle);
|
|
||||||
*context_handle = GSS_C_NO_CONTEXT;
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
@ -1,73 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997 - 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: display_name.c,v 1.9 2003/03/16 17:46:11 lha Exp $");
|
|
||||||
|
|
||||||
OM_uint32 gss_display_name
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
const gss_name_t input_name,
|
|
||||||
gss_buffer_t output_name_buffer,
|
|
||||||
gss_OID * output_name_type
|
|
||||||
)
|
|
||||||
{
|
|
||||||
krb5_error_code kret;
|
|
||||||
char *buf;
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
GSSAPI_KRB5_INIT ();
|
|
||||||
kret = krb5_unparse_name (gssapi_krb5_context,
|
|
||||||
input_name,
|
|
||||||
&buf);
|
|
||||||
if (kret) {
|
|
||||||
*minor_status = kret;
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
len = strlen (buf);
|
|
||||||
output_name_buffer->length = len;
|
|
||||||
output_name_buffer->value = malloc(len + 1);
|
|
||||||
if (output_name_buffer->value == NULL) {
|
|
||||||
free (buf);
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
memcpy (output_name_buffer->value, buf, len);
|
|
||||||
((char *)output_name_buffer->value)[len] = '\0';
|
|
||||||
free (buf);
|
|
||||||
if (output_name_type)
|
|
||||||
*output_name_type = GSS_KRB5_NT_PRINCIPAL_NAME;
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
@ -1,187 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1998 - 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: display_status.c,v 1.9 2003/03/16 17:45:36 lha Exp $");
|
|
||||||
|
|
||||||
static char *krb5_error_string;
|
|
||||||
|
|
||||||
static char *
|
|
||||||
calling_error(OM_uint32 v)
|
|
||||||
{
|
|
||||||
static char *msgs[] = {
|
|
||||||
NULL, /* 0 */
|
|
||||||
"A required input parameter could not be read.", /* */
|
|
||||||
"A required output parameter could not be written.", /* */
|
|
||||||
"A parameter was malformed"
|
|
||||||
};
|
|
||||||
|
|
||||||
v >>= GSS_C_CALLING_ERROR_OFFSET;
|
|
||||||
|
|
||||||
if (v == 0)
|
|
||||||
return "";
|
|
||||||
else if (v >= sizeof(msgs)/sizeof(*msgs))
|
|
||||||
return "unknown calling error";
|
|
||||||
else
|
|
||||||
return msgs[v];
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
|
||||||
routine_error(OM_uint32 v)
|
|
||||||
{
|
|
||||||
static char *msgs[] = {
|
|
||||||
NULL, /* 0 */
|
|
||||||
"An unsupported mechanism was requested",
|
|
||||||
"An invalid name was supplied",
|
|
||||||
"A supplied name was of an unsupported type",
|
|
||||||
"Incorrect channel bindings were supplied",
|
|
||||||
"An invalid status code was supplied",
|
|
||||||
"A token had an invalid MIC",
|
|
||||||
"No credentials were supplied, "
|
|
||||||
"or the credentials were unavailable or inaccessible.",
|
|
||||||
"No context has been established",
|
|
||||||
"A token was invalid",
|
|
||||||
"A credential was invalid",
|
|
||||||
"The referenced credentials have expired",
|
|
||||||
"The context has expired",
|
|
||||||
"Miscellaneous failure (see text)",
|
|
||||||
"The quality-of-protection requested could not be provide",
|
|
||||||
"The operation is forbidden by local security policy",
|
|
||||||
"The operation or option is not available",
|
|
||||||
"The requested credential element already exists",
|
|
||||||
"The provided name was not a mechanism name.",
|
|
||||||
};
|
|
||||||
|
|
||||||
v >>= GSS_C_ROUTINE_ERROR_OFFSET;
|
|
||||||
|
|
||||||
if (v == 0)
|
|
||||||
return "";
|
|
||||||
else if (v >= sizeof(msgs)/sizeof(*msgs))
|
|
||||||
return "unknown routine error";
|
|
||||||
else
|
|
||||||
return msgs[v];
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
|
||||||
supplementary_error(OM_uint32 v)
|
|
||||||
{
|
|
||||||
static char *msgs[] = {
|
|
||||||
"normal completion",
|
|
||||||
"continuation call to routine required",
|
|
||||||
"duplicate per-message token detected",
|
|
||||||
"timed-out per-message token detected",
|
|
||||||
"reordered (early) per-message token detected",
|
|
||||||
"skipped predecessor token(s) detected"
|
|
||||||
};
|
|
||||||
|
|
||||||
v >>= GSS_C_SUPPLEMENTARY_OFFSET;
|
|
||||||
|
|
||||||
if (v >= sizeof(msgs)/sizeof(*msgs))
|
|
||||||
return "unknown routine error";
|
|
||||||
else
|
|
||||||
return msgs[v];
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gssapi_krb5_set_error_string (void)
|
|
||||||
{
|
|
||||||
krb5_error_string = krb5_get_error_string(gssapi_krb5_context);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
|
||||||
gssapi_krb5_get_error_string (void)
|
|
||||||
{
|
|
||||||
char *ret = krb5_error_string;
|
|
||||||
krb5_error_string = NULL;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
OM_uint32 gss_display_status
|
|
||||||
(OM_uint32 *minor_status,
|
|
||||||
OM_uint32 status_value,
|
|
||||||
int status_type,
|
|
||||||
const gss_OID mech_type,
|
|
||||||
OM_uint32 *message_context,
|
|
||||||
gss_buffer_t status_string)
|
|
||||||
{
|
|
||||||
char *buf;
|
|
||||||
|
|
||||||
GSSAPI_KRB5_INIT ();
|
|
||||||
|
|
||||||
status_string->length = 0;
|
|
||||||
status_string->value = NULL;
|
|
||||||
|
|
||||||
if (gss_oid_equal(mech_type, GSS_C_NO_OID) == 0 &&
|
|
||||||
gss_oid_equal(mech_type, GSS_KRB5_MECHANISM) == 0) {
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_C_GSS_CODE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status_type == GSS_C_GSS_CODE) {
|
|
||||||
if (GSS_SUPPLEMENTARY_INFO(status_value))
|
|
||||||
asprintf(&buf, "%s",
|
|
||||||
supplementary_error(GSS_SUPPLEMENTARY_INFO(status_value)));
|
|
||||||
else
|
|
||||||
asprintf (&buf, "%s %s",
|
|
||||||
calling_error(GSS_CALLING_ERROR(status_value)),
|
|
||||||
routine_error(GSS_ROUTINE_ERROR(status_value)));
|
|
||||||
} else if (status_type == GSS_C_MECH_CODE) {
|
|
||||||
buf = gssapi_krb5_get_error_string ();
|
|
||||||
if (buf == NULL) {
|
|
||||||
const char *tmp = krb5_get_err_text (gssapi_krb5_context,
|
|
||||||
status_value);
|
|
||||||
if (tmp == NULL)
|
|
||||||
asprintf(&buf, "unknown mech error-code %u",
|
|
||||||
(unsigned)status_value);
|
|
||||||
else
|
|
||||||
buf = strdup(tmp);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
*minor_status = EINVAL;
|
|
||||||
return GSS_S_BAD_STATUS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buf == NULL) {
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
*message_context = 0;
|
|
||||||
*minor_status = 0;
|
|
||||||
|
|
||||||
status_string->length = strlen(buf);
|
|
||||||
status_string->value = buf;
|
|
||||||
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997 - 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: duplicate_name.c,v 1.7 2003/03/16 17:44:26 lha Exp $");
|
|
||||||
|
|
||||||
OM_uint32 gss_duplicate_name (
|
|
||||||
OM_uint32 * minor_status,
|
|
||||||
const gss_name_t src_name,
|
|
||||||
gss_name_t * dest_name
|
|
||||||
)
|
|
||||||
{
|
|
||||||
krb5_error_code kret;
|
|
||||||
|
|
||||||
GSSAPI_KRB5_INIT ();
|
|
||||||
|
|
||||||
kret = krb5_copy_principal (gssapi_krb5_context,
|
|
||||||
src_name,
|
|
||||||
dest_name);
|
|
||||||
if (kret) {
|
|
||||||
*minor_status = kret;
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
} else {
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,122 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997 - 2001 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: encapsulate.c,v 1.6.6.1 2003/09/18 21:47:44 lha Exp $");
|
|
||||||
|
|
||||||
void
|
|
||||||
gssapi_krb5_encap_length (size_t data_len,
|
|
||||||
size_t *len,
|
|
||||||
size_t *total_len)
|
|
||||||
{
|
|
||||||
size_t len_len;
|
|
||||||
|
|
||||||
*len = 1 + 1 + GSS_KRB5_MECHANISM->length + 2 + data_len;
|
|
||||||
|
|
||||||
len_len = length_len(*len);
|
|
||||||
|
|
||||||
*total_len = 1 + len_len + *len;
|
|
||||||
}
|
|
||||||
|
|
||||||
u_char *
|
|
||||||
gssapi_krb5_make_header (u_char *p,
|
|
||||||
size_t len,
|
|
||||||
u_char *type)
|
|
||||||
{
|
|
||||||
int e;
|
|
||||||
size_t len_len, foo;
|
|
||||||
|
|
||||||
*p++ = 0x60;
|
|
||||||
len_len = length_len(len);
|
|
||||||
e = der_put_length (p + len_len - 1, len_len, len, &foo);
|
|
||||||
if(e || foo != len_len)
|
|
||||||
abort ();
|
|
||||||
p += len_len;
|
|
||||||
*p++ = 0x06;
|
|
||||||
*p++ = GSS_KRB5_MECHANISM->length;
|
|
||||||
memcpy (p, GSS_KRB5_MECHANISM->elements, GSS_KRB5_MECHANISM->length);
|
|
||||||
p += GSS_KRB5_MECHANISM->length;
|
|
||||||
memcpy (p, type, 2);
|
|
||||||
p += 2;
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
u_char *
|
|
||||||
_gssapi_make_mech_header(u_char *p,
|
|
||||||
size_t len)
|
|
||||||
{
|
|
||||||
int e;
|
|
||||||
size_t len_len, foo;
|
|
||||||
|
|
||||||
*p++ = 0x60;
|
|
||||||
len_len = length_len(len);
|
|
||||||
e = der_put_length (p + len_len - 1, len_len, len, &foo);
|
|
||||||
if(e || foo != len_len)
|
|
||||||
abort ();
|
|
||||||
p += len_len;
|
|
||||||
*p++ = 0x06;
|
|
||||||
*p++ = GSS_KRB5_MECHANISM->length;
|
|
||||||
memcpy (p, GSS_KRB5_MECHANISM->elements, GSS_KRB5_MECHANISM->length);
|
|
||||||
p += GSS_KRB5_MECHANISM->length;
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Give it a krb5_data and it will encapsulate with extra GSS-API wrappings.
|
|
||||||
*/
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
gssapi_krb5_encapsulate(
|
|
||||||
OM_uint32 *minor_status,
|
|
||||||
const krb5_data *in_data,
|
|
||||||
gss_buffer_t output_token,
|
|
||||||
u_char *type
|
|
||||||
)
|
|
||||||
{
|
|
||||||
size_t len, outer_len;
|
|
||||||
u_char *p;
|
|
||||||
|
|
||||||
gssapi_krb5_encap_length (in_data->length, &len, &outer_len);
|
|
||||||
|
|
||||||
output_token->length = outer_len;
|
|
||||||
output_token->value = malloc (outer_len);
|
|
||||||
if (output_token->value == NULL) {
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
p = gssapi_krb5_make_header (output_token->value, len, type);
|
|
||||||
memcpy (p, in_data->data, in_data->length);
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
@ -1,94 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997, 1999, 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: export_name.c,v 1.5 2003/03/16 17:34:46 lha Exp $");
|
|
||||||
|
|
||||||
OM_uint32 gss_export_name
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
const gss_name_t input_name,
|
|
||||||
gss_buffer_t exported_name
|
|
||||||
)
|
|
||||||
{
|
|
||||||
krb5_error_code kret;
|
|
||||||
char *buf, *name;
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
GSSAPI_KRB5_INIT ();
|
|
||||||
kret = krb5_unparse_name (gssapi_krb5_context,
|
|
||||||
input_name,
|
|
||||||
&name);
|
|
||||||
if (kret) {
|
|
||||||
*minor_status = kret;
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
len = strlen (name);
|
|
||||||
|
|
||||||
exported_name->length = 10 + len + GSS_KRB5_MECHANISM->length;
|
|
||||||
exported_name->value = malloc(exported_name->length);
|
|
||||||
if (exported_name->value == NULL) {
|
|
||||||
free (name);
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* TOK, MECH_OID_LEN, DER(MECH_OID), NAME_LEN, NAME */
|
|
||||||
|
|
||||||
buf = exported_name->value;
|
|
||||||
memcpy(buf, "\x04\x01", 2);
|
|
||||||
buf += 2;
|
|
||||||
buf[0] = ((GSS_KRB5_MECHANISM->length + 2) >> 8) & 0xff;
|
|
||||||
buf[1] = (GSS_KRB5_MECHANISM->length + 2) & 0xff;
|
|
||||||
buf+= 2;
|
|
||||||
buf[0] = 0x06;
|
|
||||||
buf[1] = (GSS_KRB5_MECHANISM->length) & 0xFF;
|
|
||||||
buf+= 2;
|
|
||||||
|
|
||||||
memcpy(buf, GSS_KRB5_MECHANISM->elements, GSS_KRB5_MECHANISM->length);
|
|
||||||
buf += GSS_KRB5_MECHANISM->length;
|
|
||||||
|
|
||||||
buf[0] = (len >> 24) & 0xff;
|
|
||||||
buf[1] = (len >> 16) & 0xff;
|
|
||||||
buf[2] = (len >> 8) & 0xff;
|
|
||||||
buf[3] = (len) & 0xff;
|
|
||||||
buf += 4;
|
|
||||||
|
|
||||||
memcpy (buf, name, len);
|
|
||||||
|
|
||||||
free (name);
|
|
||||||
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
@ -1,223 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1999 - 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: export_sec_context.c,v 1.6 2003/03/16 18:02:52 lha Exp $");
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
gss_export_sec_context (
|
|
||||||
OM_uint32 * minor_status,
|
|
||||||
gss_ctx_id_t * context_handle,
|
|
||||||
gss_buffer_t interprocess_token
|
|
||||||
)
|
|
||||||
{
|
|
||||||
krb5_storage *sp;
|
|
||||||
krb5_auth_context ac;
|
|
||||||
OM_uint32 ret = GSS_S_COMPLETE;
|
|
||||||
krb5_data data;
|
|
||||||
gss_buffer_desc buffer;
|
|
||||||
int flags;
|
|
||||||
OM_uint32 minor;
|
|
||||||
krb5_error_code kret;
|
|
||||||
|
|
||||||
GSSAPI_KRB5_INIT ();
|
|
||||||
if (!((*context_handle)->flags & GSS_C_TRANS_FLAG)) {
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_UNAVAILABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
sp = krb5_storage_emem ();
|
|
||||||
if (sp == NULL) {
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
ac = (*context_handle)->auth_context;
|
|
||||||
|
|
||||||
/* flagging included fields */
|
|
||||||
|
|
||||||
flags = 0;
|
|
||||||
if (ac->local_address)
|
|
||||||
flags |= SC_LOCAL_ADDRESS;
|
|
||||||
if (ac->remote_address)
|
|
||||||
flags |= SC_REMOTE_ADDRESS;
|
|
||||||
if (ac->keyblock)
|
|
||||||
flags |= SC_KEYBLOCK;
|
|
||||||
if (ac->local_subkey)
|
|
||||||
flags |= SC_LOCAL_SUBKEY;
|
|
||||||
if (ac->remote_subkey)
|
|
||||||
flags |= SC_REMOTE_SUBKEY;
|
|
||||||
|
|
||||||
kret = krb5_store_int32 (sp, flags);
|
|
||||||
if (kret) {
|
|
||||||
*minor_status = kret;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* marshall auth context */
|
|
||||||
|
|
||||||
kret = krb5_store_int32 (sp, ac->flags);
|
|
||||||
if (kret) {
|
|
||||||
*minor_status = kret;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
if (ac->local_address) {
|
|
||||||
kret = krb5_store_address (sp, *ac->local_address);
|
|
||||||
if (kret) {
|
|
||||||
*minor_status = kret;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ac->remote_address) {
|
|
||||||
kret = krb5_store_address (sp, *ac->remote_address);
|
|
||||||
if (kret) {
|
|
||||||
*minor_status = kret;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
kret = krb5_store_int16 (sp, ac->local_port);
|
|
||||||
if (kret) {
|
|
||||||
*minor_status = kret;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
kret = krb5_store_int16 (sp, ac->remote_port);
|
|
||||||
if (kret) {
|
|
||||||
*minor_status = kret;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
if (ac->keyblock) {
|
|
||||||
kret = krb5_store_keyblock (sp, *ac->keyblock);
|
|
||||||
if (kret) {
|
|
||||||
*minor_status = kret;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ac->local_subkey) {
|
|
||||||
kret = krb5_store_keyblock (sp, *ac->local_subkey);
|
|
||||||
if (kret) {
|
|
||||||
*minor_status = kret;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ac->remote_subkey) {
|
|
||||||
kret = krb5_store_keyblock (sp, *ac->remote_subkey);
|
|
||||||
if (kret) {
|
|
||||||
*minor_status = kret;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
kret = krb5_store_int32 (sp, ac->local_seqnumber);
|
|
||||||
if (kret) {
|
|
||||||
*minor_status = kret;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
kret = krb5_store_int32 (sp, ac->remote_seqnumber);
|
|
||||||
if (kret) {
|
|
||||||
*minor_status = kret;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
kret = krb5_store_int32 (sp, ac->keytype);
|
|
||||||
if (kret) {
|
|
||||||
*minor_status = kret;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
kret = krb5_store_int32 (sp, ac->cksumtype);
|
|
||||||
if (kret) {
|
|
||||||
*minor_status = kret;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* names */
|
|
||||||
|
|
||||||
ret = gss_export_name (minor_status, (*context_handle)->source, &buffer);
|
|
||||||
if (ret)
|
|
||||||
goto failure;
|
|
||||||
data.data = buffer.value;
|
|
||||||
data.length = buffer.length;
|
|
||||||
kret = krb5_store_data (sp, data);
|
|
||||||
gss_release_buffer (&minor, &buffer);
|
|
||||||
if (kret) {
|
|
||||||
*minor_status = kret;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = gss_export_name (minor_status, (*context_handle)->target, &buffer);
|
|
||||||
if (ret)
|
|
||||||
goto failure;
|
|
||||||
data.data = buffer.value;
|
|
||||||
data.length = buffer.length;
|
|
||||||
|
|
||||||
ret = GSS_S_FAILURE;
|
|
||||||
|
|
||||||
kret = krb5_store_data (sp, data);
|
|
||||||
gss_release_buffer (&minor, &buffer);
|
|
||||||
if (kret) {
|
|
||||||
*minor_status = kret;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
kret = krb5_store_int32 (sp, (*context_handle)->flags);
|
|
||||||
if (kret) {
|
|
||||||
*minor_status = kret;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
kret = krb5_store_int32 (sp, (*context_handle)->more_flags);
|
|
||||||
if (kret) {
|
|
||||||
*minor_status = kret;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
kret = krb5_store_int32 (sp, (*context_handle)->lifetime);
|
|
||||||
if (kret) {
|
|
||||||
*minor_status = kret;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
kret = krb5_storage_to_data (sp, &data);
|
|
||||||
krb5_storage_free (sp);
|
|
||||||
if (kret) {
|
|
||||||
*minor_status = kret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
interprocess_token->length = data.length;
|
|
||||||
interprocess_token->value = data.data;
|
|
||||||
ret = gss_delete_sec_context (minor_status, context_handle,
|
|
||||||
GSS_C_NO_BUFFER);
|
|
||||||
if (ret != GSS_S_COMPLETE)
|
|
||||||
gss_release_buffer (NULL, interprocess_token);
|
|
||||||
*minor_status = 0;
|
|
||||||
return ret;
|
|
||||||
failure:
|
|
||||||
krb5_storage_free (sp);
|
|
||||||
return ret;
|
|
||||||
}
|
|
@ -1,235 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997 - 2000 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: external.c,v 1.5 2000/07/22 03:45:28 assar Exp $");
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The implementation must reserve static storage for a
|
|
||||||
* gss_OID_desc object containing the value
|
|
||||||
* {10, (void *)"\x2a\x86\x48\x86\xf7\x12"
|
|
||||||
* "\x01\x02\x01\x01"},
|
|
||||||
* corresponding to an object-identifier value of
|
|
||||||
* {iso(1) member-body(2) United States(840) mit(113554)
|
|
||||||
* infosys(1) gssapi(2) generic(1) user_name(1)}. The constant
|
|
||||||
* GSS_C_NT_USER_NAME should be initialized to point
|
|
||||||
* to that gss_OID_desc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static gss_OID_desc gss_c_nt_user_name_oid_desc =
|
|
||||||
{10, (void *)"\x2a\x86\x48\x86\xf7\x12"
|
|
||||||
"\x01\x02\x01\x01"};
|
|
||||||
|
|
||||||
gss_OID GSS_C_NT_USER_NAME = &gss_c_nt_user_name_oid_desc;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The implementation must reserve static storage for a
|
|
||||||
* gss_OID_desc object containing the value
|
|
||||||
* {10, (void *)"\x2a\x86\x48\x86\xf7\x12"
|
|
||||||
* "\x01\x02\x01\x02"},
|
|
||||||
* corresponding to an object-identifier value of
|
|
||||||
* {iso(1) member-body(2) United States(840) mit(113554)
|
|
||||||
* infosys(1) gssapi(2) generic(1) machine_uid_name(2)}.
|
|
||||||
* The constant GSS_C_NT_MACHINE_UID_NAME should be
|
|
||||||
* initialized to point to that gss_OID_desc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static gss_OID_desc gss_c_nt_machine_uid_name_oid_desc =
|
|
||||||
{10, (void *)"\x2a\x86\x48\x86\xf7\x12"
|
|
||||||
"\x01\x02\x01\x02"};
|
|
||||||
|
|
||||||
gss_OID GSS_C_NT_MACHINE_UID_NAME = &gss_c_nt_machine_uid_name_oid_desc;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The implementation must reserve static storage for a
|
|
||||||
* gss_OID_desc object containing the value
|
|
||||||
* {10, (void *)"\x2a\x86\x48\x86\xf7\x12"
|
|
||||||
* "\x01\x02\x01\x03"},
|
|
||||||
* corresponding to an object-identifier value of
|
|
||||||
* {iso(1) member-body(2) United States(840) mit(113554)
|
|
||||||
* infosys(1) gssapi(2) generic(1) string_uid_name(3)}.
|
|
||||||
* The constant GSS_C_NT_STRING_UID_NAME should be
|
|
||||||
* initialized to point to that gss_OID_desc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static gss_OID_desc gss_c_nt_string_uid_name_oid_desc =
|
|
||||||
{10, (void *)"\x2a\x86\x48\x86\xf7\x12"
|
|
||||||
"\x01\x02\x01\x03"};
|
|
||||||
|
|
||||||
gss_OID GSS_C_NT_STRING_UID_NAME = &gss_c_nt_string_uid_name_oid_desc;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The implementation must reserve static storage for a
|
|
||||||
* gss_OID_desc object containing the value
|
|
||||||
* {6, (void *)"\x2b\x06\x01\x05\x06\x02"},
|
|
||||||
* corresponding to an object-identifier value of
|
|
||||||
* {iso(1) org(3) dod(6) internet(1) security(5)
|
|
||||||
* nametypes(6) gss-host-based-services(2)). The constant
|
|
||||||
* GSS_C_NT_HOSTBASED_SERVICE_X should be initialized to point
|
|
||||||
* to that gss_OID_desc. This is a deprecated OID value, and
|
|
||||||
* implementations wishing to support hostbased-service names
|
|
||||||
* should instead use the GSS_C_NT_HOSTBASED_SERVICE OID,
|
|
||||||
* defined below, to identify such names;
|
|
||||||
* GSS_C_NT_HOSTBASED_SERVICE_X should be accepted a synonym
|
|
||||||
* for GSS_C_NT_HOSTBASED_SERVICE when presented as an input
|
|
||||||
* parameter, but should not be emitted by GSS-API
|
|
||||||
* implementations
|
|
||||||
*/
|
|
||||||
|
|
||||||
static gss_OID_desc gss_c_nt_hostbased_service_x_oid_desc =
|
|
||||||
{6, (void *)"\x2b\x06\x01\x05\x06\x02"};
|
|
||||||
|
|
||||||
gss_OID GSS_C_NT_HOSTBASED_SERVICE_X = &gss_c_nt_hostbased_service_x_oid_desc;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The implementation must reserve static storage for a
|
|
||||||
* gss_OID_desc object containing the value
|
|
||||||
* {10, (void *)"\x2a\x86\x48\x86\xf7\x12"
|
|
||||||
* "\x01\x02\x01\x04"}, corresponding to an
|
|
||||||
* object-identifier value of {iso(1) member-body(2)
|
|
||||||
* Unites States(840) mit(113554) infosys(1) gssapi(2)
|
|
||||||
* generic(1) service_name(4)}. The constant
|
|
||||||
* GSS_C_NT_HOSTBASED_SERVICE should be initialized
|
|
||||||
* to point to that gss_OID_desc.
|
|
||||||
*/
|
|
||||||
static gss_OID_desc gss_c_nt_hostbased_service_oid_desc =
|
|
||||||
{10, (void *)"\x2a\x86\x48\x86\xf7\x12" "\x01\x02\x01\x04"};
|
|
||||||
|
|
||||||
gss_OID GSS_C_NT_HOSTBASED_SERVICE = &gss_c_nt_hostbased_service_oid_desc;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The implementation must reserve static storage for a
|
|
||||||
* gss_OID_desc object containing the value
|
|
||||||
* {6, (void *)"\x2b\x06\01\x05\x06\x03"},
|
|
||||||
* corresponding to an object identifier value of
|
|
||||||
* {1(iso), 3(org), 6(dod), 1(internet), 5(security),
|
|
||||||
* 6(nametypes), 3(gss-anonymous-name)}. The constant
|
|
||||||
* and GSS_C_NT_ANONYMOUS should be initialized to point
|
|
||||||
* to that gss_OID_desc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static gss_OID_desc gss_c_nt_anonymous_oid_desc =
|
|
||||||
{6, (void *)"\x2b\x06\01\x05\x06\x03"};
|
|
||||||
|
|
||||||
gss_OID GSS_C_NT_ANONYMOUS = &gss_c_nt_anonymous_oid_desc;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The implementation must reserve static storage for a
|
|
||||||
* gss_OID_desc object containing the value
|
|
||||||
* {6, (void *)"\x2b\x06\x01\x05\x06\x04"},
|
|
||||||
* corresponding to an object-identifier value of
|
|
||||||
* {1(iso), 3(org), 6(dod), 1(internet), 5(security),
|
|
||||||
* 6(nametypes), 4(gss-api-exported-name)}. The constant
|
|
||||||
* GSS_C_NT_EXPORT_NAME should be initialized to point
|
|
||||||
* to that gss_OID_desc.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static gss_OID_desc gss_c_nt_export_name_oid_desc =
|
|
||||||
{6, (void *)"\x2b\x06\x01\x05\x06\x04"};
|
|
||||||
|
|
||||||
gss_OID GSS_C_NT_EXPORT_NAME = &gss_c_nt_export_name_oid_desc;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This name form shall be represented by the Object Identifier {iso(1)
|
|
||||||
* member-body(2) United States(840) mit(113554) infosys(1) gssapi(2)
|
|
||||||
* krb5(2) krb5_name(1)}. The recommended symbolic name for this type
|
|
||||||
* is "GSS_KRB5_NT_PRINCIPAL_NAME".
|
|
||||||
*/
|
|
||||||
|
|
||||||
static gss_OID_desc gss_krb5_nt_principal_name_oid_desc =
|
|
||||||
{10, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x02\x01"};
|
|
||||||
|
|
||||||
gss_OID GSS_KRB5_NT_PRINCIPAL_NAME = &gss_krb5_nt_principal_name_oid_desc;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This name form shall be represented by the Object Identifier {iso(1)
|
|
||||||
* member-body(2) United States(840) mit(113554) infosys(1) gssapi(2)
|
|
||||||
* generic(1) user_name(1)}. The recommended symbolic name for this
|
|
||||||
* type is "GSS_KRB5_NT_USER_NAME".
|
|
||||||
*/
|
|
||||||
|
|
||||||
gss_OID GSS_KRB5_NT_USER_NAME = &gss_c_nt_user_name_oid_desc;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This name form shall be represented by the Object Identifier {iso(1)
|
|
||||||
* member-body(2) United States(840) mit(113554) infosys(1) gssapi(2)
|
|
||||||
* generic(1) machine_uid_name(2)}. The recommended symbolic name for
|
|
||||||
* this type is "GSS_KRB5_NT_MACHINE_UID_NAME".
|
|
||||||
*/
|
|
||||||
|
|
||||||
gss_OID GSS_KRB5_NT_MACHINE_UID_NAME = &gss_c_nt_machine_uid_name_oid_desc;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This name form shall be represented by the Object Identifier {iso(1)
|
|
||||||
* member-body(2) United States(840) mit(113554) infosys(1) gssapi(2)
|
|
||||||
* generic(1) string_uid_name(3)}. The recommended symbolic name for
|
|
||||||
* this type is "GSS_KRB5_NT_STRING_UID_NAME".
|
|
||||||
*/
|
|
||||||
|
|
||||||
gss_OID GSS_KRB5_NT_STRING_UID_NAME = &gss_c_nt_string_uid_name_oid_desc;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* To support ongoing experimentation, testing, and evolution of the
|
|
||||||
* specification, the Kerberos V5 GSS-API mechanism as defined in this
|
|
||||||
* and any successor memos will be identified with the following Object
|
|
||||||
* Identifier, as defined in RFC-1510, until the specification is
|
|
||||||
* advanced to the level of Proposed Standard RFC:
|
|
||||||
*
|
|
||||||
* {iso(1), org(3), dod(5), internet(1), security(5), kerberosv5(2)}
|
|
||||||
*
|
|
||||||
* Upon advancement to the level of Proposed Standard RFC, the Kerberos
|
|
||||||
* V5 GSS-API mechanism will be identified by an Object Identifier
|
|
||||||
* having the value:
|
|
||||||
*
|
|
||||||
* {iso(1) member-body(2) United States(840) mit(113554) infosys(1)
|
|
||||||
* gssapi(2) krb5(2)}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if 0 /* This is the old OID */
|
|
||||||
|
|
||||||
static gss_OID_desc gss_krb5_mechanism_oid_desc =
|
|
||||||
{5, (void *)"\x2b\x05\x01\x05\x02"};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static gss_OID_desc gss_krb5_mechanism_oid_desc =
|
|
||||||
{9, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x02"};
|
|
||||||
|
|
||||||
gss_OID GSS_KRB5_MECHANISM = &gss_krb5_mechanism_oid_desc;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Context for krb5 calls.
|
|
||||||
*/
|
|
||||||
|
|
||||||
krb5_context gssapi_krb5_context;
|
|
@ -1,295 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997 - 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: get_mic.c,v 1.21.2.1 2003/09/18 22:05:12 lha Exp $");
|
|
||||||
|
|
||||||
static OM_uint32
|
|
||||||
mic_des
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
const gss_ctx_id_t context_handle,
|
|
||||||
gss_qop_t qop_req,
|
|
||||||
const gss_buffer_t message_buffer,
|
|
||||||
gss_buffer_t message_token,
|
|
||||||
krb5_keyblock *key
|
|
||||||
)
|
|
||||||
{
|
|
||||||
u_char *p;
|
|
||||||
MD5_CTX md5;
|
|
||||||
u_char hash[16];
|
|
||||||
des_key_schedule schedule;
|
|
||||||
des_cblock deskey;
|
|
||||||
des_cblock zero;
|
|
||||||
int32_t seq_number;
|
|
||||||
size_t len, total_len;
|
|
||||||
|
|
||||||
gssapi_krb5_encap_length (22, &len, &total_len);
|
|
||||||
|
|
||||||
message_token->length = total_len;
|
|
||||||
message_token->value = malloc (total_len);
|
|
||||||
if (message_token->value == NULL) {
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
p = gssapi_krb5_make_header(message_token->value,
|
|
||||||
len,
|
|
||||||
"\x01\x01"); /* TOK_ID */
|
|
||||||
|
|
||||||
memcpy (p, "\x00\x00", 2); /* SGN_ALG = DES MAC MD5 */
|
|
||||||
p += 2;
|
|
||||||
|
|
||||||
memcpy (p, "\xff\xff\xff\xff", 4); /* Filler */
|
|
||||||
p += 4;
|
|
||||||
|
|
||||||
/* Fill in later (SND-SEQ) */
|
|
||||||
memset (p, 0, 16);
|
|
||||||
p += 16;
|
|
||||||
|
|
||||||
/* checksum */
|
|
||||||
MD5_Init (&md5);
|
|
||||||
MD5_Update (&md5, p - 24, 8);
|
|
||||||
MD5_Update (&md5, message_buffer->value, message_buffer->length);
|
|
||||||
MD5_Final (hash, &md5);
|
|
||||||
|
|
||||||
memset (&zero, 0, sizeof(zero));
|
|
||||||
memcpy (&deskey, key->keyvalue.data, sizeof(deskey));
|
|
||||||
des_set_key (&deskey, schedule);
|
|
||||||
des_cbc_cksum ((void *)hash, (void *)hash, sizeof(hash),
|
|
||||||
schedule, &zero);
|
|
||||||
memcpy (p - 8, hash, 8); /* SGN_CKSUM */
|
|
||||||
|
|
||||||
/* sequence number */
|
|
||||||
krb5_auth_con_getlocalseqnumber (gssapi_krb5_context,
|
|
||||||
context_handle->auth_context,
|
|
||||||
&seq_number);
|
|
||||||
|
|
||||||
p -= 16; /* SND_SEQ */
|
|
||||||
p[0] = (seq_number >> 0) & 0xFF;
|
|
||||||
p[1] = (seq_number >> 8) & 0xFF;
|
|
||||||
p[2] = (seq_number >> 16) & 0xFF;
|
|
||||||
p[3] = (seq_number >> 24) & 0xFF;
|
|
||||||
memset (p + 4,
|
|
||||||
(context_handle->more_flags & LOCAL) ? 0 : 0xFF,
|
|
||||||
4);
|
|
||||||
|
|
||||||
des_set_key (&deskey, schedule);
|
|
||||||
des_cbc_encrypt ((void *)p, (void *)p, 8,
|
|
||||||
schedule, (des_cblock *)(p + 8), DES_ENCRYPT);
|
|
||||||
|
|
||||||
krb5_auth_con_setlocalseqnumber (gssapi_krb5_context,
|
|
||||||
context_handle->auth_context,
|
|
||||||
++seq_number);
|
|
||||||
|
|
||||||
memset (deskey, 0, sizeof(deskey));
|
|
||||||
memset (schedule, 0, sizeof(schedule));
|
|
||||||
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static OM_uint32
|
|
||||||
mic_des3
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
const gss_ctx_id_t context_handle,
|
|
||||||
gss_qop_t qop_req,
|
|
||||||
const gss_buffer_t message_buffer,
|
|
||||||
gss_buffer_t message_token,
|
|
||||||
krb5_keyblock *key
|
|
||||||
)
|
|
||||||
{
|
|
||||||
u_char *p;
|
|
||||||
Checksum cksum;
|
|
||||||
u_char seq[8];
|
|
||||||
|
|
||||||
int32_t seq_number;
|
|
||||||
size_t len, total_len;
|
|
||||||
|
|
||||||
krb5_crypto crypto;
|
|
||||||
krb5_error_code kret;
|
|
||||||
krb5_data encdata;
|
|
||||||
char *tmp;
|
|
||||||
char ivec[8];
|
|
||||||
|
|
||||||
gssapi_krb5_encap_length (36, &len, &total_len);
|
|
||||||
|
|
||||||
message_token->length = total_len;
|
|
||||||
message_token->value = malloc (total_len);
|
|
||||||
if (message_token->value == NULL) {
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
p = gssapi_krb5_make_header(message_token->value,
|
|
||||||
len,
|
|
||||||
"\x01\x01"); /* TOK-ID */
|
|
||||||
|
|
||||||
memcpy (p, "\x04\x00", 2); /* SGN_ALG = HMAC SHA1 DES3-KD */
|
|
||||||
p += 2;
|
|
||||||
|
|
||||||
memcpy (p, "\xff\xff\xff\xff", 4); /* filler */
|
|
||||||
p += 4;
|
|
||||||
|
|
||||||
/* this should be done in parts */
|
|
||||||
|
|
||||||
tmp = malloc (message_buffer->length + 8);
|
|
||||||
if (tmp == NULL) {
|
|
||||||
free (message_token->value);
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
memcpy (tmp, p - 8, 8);
|
|
||||||
memcpy (tmp + 8, message_buffer->value, message_buffer->length);
|
|
||||||
|
|
||||||
kret = krb5_crypto_init(gssapi_krb5_context, key, 0, &crypto);
|
|
||||||
if (kret) {
|
|
||||||
free (message_token->value);
|
|
||||||
free (tmp);
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
*minor_status = kret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
kret = krb5_create_checksum (gssapi_krb5_context,
|
|
||||||
crypto,
|
|
||||||
KRB5_KU_USAGE_SIGN,
|
|
||||||
0,
|
|
||||||
tmp,
|
|
||||||
message_buffer->length + 8,
|
|
||||||
&cksum);
|
|
||||||
free (tmp);
|
|
||||||
krb5_crypto_destroy (gssapi_krb5_context, crypto);
|
|
||||||
if (kret) {
|
|
||||||
free (message_token->value);
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
*minor_status = kret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy (p + 8, cksum.checksum.data, cksum.checksum.length);
|
|
||||||
|
|
||||||
/* sequence number */
|
|
||||||
krb5_auth_con_getlocalseqnumber (gssapi_krb5_context,
|
|
||||||
context_handle->auth_context,
|
|
||||||
&seq_number);
|
|
||||||
|
|
||||||
seq[0] = (seq_number >> 0) & 0xFF;
|
|
||||||
seq[1] = (seq_number >> 8) & 0xFF;
|
|
||||||
seq[2] = (seq_number >> 16) & 0xFF;
|
|
||||||
seq[3] = (seq_number >> 24) & 0xFF;
|
|
||||||
memset (seq + 4,
|
|
||||||
(context_handle->more_flags & LOCAL) ? 0 : 0xFF,
|
|
||||||
4);
|
|
||||||
|
|
||||||
kret = krb5_crypto_init(gssapi_krb5_context, key,
|
|
||||||
ETYPE_DES3_CBC_NONE, &crypto);
|
|
||||||
if (kret) {
|
|
||||||
free (message_token->value);
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
*minor_status = kret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (context_handle->more_flags & COMPAT_OLD_DES3)
|
|
||||||
memset(ivec, 0, 8);
|
|
||||||
else
|
|
||||||
memcpy(ivec, p + 8, 8);
|
|
||||||
|
|
||||||
kret = krb5_encrypt_ivec (gssapi_krb5_context,
|
|
||||||
crypto,
|
|
||||||
KRB5_KU_USAGE_SEQ,
|
|
||||||
seq, 8, &encdata, ivec);
|
|
||||||
krb5_crypto_destroy (gssapi_krb5_context, crypto);
|
|
||||||
if (kret) {
|
|
||||||
free (message_token->value);
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
*minor_status = kret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
assert (encdata.length == 8);
|
|
||||||
|
|
||||||
memcpy (p, encdata.data, encdata.length);
|
|
||||||
krb5_data_free (&encdata);
|
|
||||||
|
|
||||||
krb5_auth_con_setlocalseqnumber (gssapi_krb5_context,
|
|
||||||
context_handle->auth_context,
|
|
||||||
++seq_number);
|
|
||||||
|
|
||||||
free_Checksum (&cksum);
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
||||||
|
|
||||||
OM_uint32 gss_get_mic
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
const gss_ctx_id_t context_handle,
|
|
||||||
gss_qop_t qop_req,
|
|
||||||
const gss_buffer_t message_buffer,
|
|
||||||
gss_buffer_t message_token
|
|
||||||
)
|
|
||||||
{
|
|
||||||
krb5_keyblock *key;
|
|
||||||
OM_uint32 ret;
|
|
||||||
krb5_keytype keytype;
|
|
||||||
|
|
||||||
ret = gss_krb5_get_localkey(context_handle, &key);
|
|
||||||
if (ret) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
*minor_status = ret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
krb5_enctype_to_keytype (gssapi_krb5_context, key->keytype, &keytype);
|
|
||||||
|
|
||||||
switch (keytype) {
|
|
||||||
case KEYTYPE_DES :
|
|
||||||
ret = mic_des (minor_status, context_handle, qop_req,
|
|
||||||
message_buffer, message_token, key);
|
|
||||||
break;
|
|
||||||
case KEYTYPE_DES3 :
|
|
||||||
ret = mic_des3 (minor_status, context_handle, qop_req,
|
|
||||||
message_buffer, message_token, key);
|
|
||||||
break;
|
|
||||||
case KEYTYPE_ARCFOUR:
|
|
||||||
ret = _gssapi_get_mic_arcfour (minor_status, context_handle, qop_req,
|
|
||||||
message_buffer, message_token, key);
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
*minor_status = KRB5_PROG_ETYPE_NOSUPP;
|
|
||||||
ret = GSS_S_FAILURE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
krb5_free_keyblock (gssapi_krb5_context, key);
|
|
||||||
return ret;
|
|
||||||
}
|
|
@ -1,179 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997 - 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* $Id: gssapi_locl.h,v 1.24.2.5 2003/09/18 22:01:52 lha Exp $ */
|
|
||||||
|
|
||||||
#ifndef GSSAPI_LOCL_H
|
|
||||||
#define GSSAPI_LOCL_H
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include <config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <krb5_locl.h>
|
|
||||||
#include <gssapi.h>
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include "arcfour.h"
|
|
||||||
|
|
||||||
extern krb5_context gssapi_krb5_context;
|
|
||||||
|
|
||||||
extern krb5_keytab gssapi_krb5_keytab;
|
|
||||||
|
|
||||||
krb5_error_code gssapi_krb5_init (void);
|
|
||||||
|
|
||||||
#define GSSAPI_KRB5_INIT() do { \
|
|
||||||
krb5_error_code kret; \
|
|
||||||
if((kret = gssapi_krb5_init ()) != 0) { \
|
|
||||||
*minor_status = kret; \
|
|
||||||
return GSS_S_FAILURE; \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
gssapi_krb5_create_8003_checksum (
|
|
||||||
OM_uint32 *minor_status,
|
|
||||||
const gss_channel_bindings_t input_chan_bindings,
|
|
||||||
OM_uint32 flags,
|
|
||||||
const krb5_data *fwd_data,
|
|
||||||
Checksum *result);
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
gssapi_krb5_verify_8003_checksum (
|
|
||||||
OM_uint32 *minor_status,
|
|
||||||
const gss_channel_bindings_t input_chan_bindings,
|
|
||||||
const Checksum *cksum,
|
|
||||||
OM_uint32 *flags,
|
|
||||||
krb5_data *fwd_data);
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
gssapi_krb5_encapsulate(
|
|
||||||
OM_uint32 *minor_status,
|
|
||||||
const krb5_data *in_data,
|
|
||||||
gss_buffer_t output_token,
|
|
||||||
u_char *type);
|
|
||||||
|
|
||||||
u_char *
|
|
||||||
_gssapi_make_mech_header(u_char *p,
|
|
||||||
size_t len);
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
gssapi_krb5_decapsulate(
|
|
||||||
OM_uint32 *minor_status,
|
|
||||||
gss_buffer_t input_token_buffer,
|
|
||||||
krb5_data *out_data,
|
|
||||||
char *type);
|
|
||||||
|
|
||||||
void
|
|
||||||
gssapi_krb5_encap_length (size_t data_len,
|
|
||||||
size_t *len,
|
|
||||||
size_t *total_len);
|
|
||||||
|
|
||||||
u_char *
|
|
||||||
gssapi_krb5_make_header (u_char *p,
|
|
||||||
size_t len,
|
|
||||||
u_char *type);
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
gssapi_krb5_verify_header(u_char **str,
|
|
||||||
size_t total_len,
|
|
||||||
char *type);
|
|
||||||
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
_gssapi_verify_mech_header(u_char **str,
|
|
||||||
size_t total_len);
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
_gssapi_verify_pad(gss_buffer_t, size_t, size_t *);
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
gss_verify_mic_internal(OM_uint32 * minor_status,
|
|
||||||
const gss_ctx_id_t context_handle,
|
|
||||||
const gss_buffer_t message_buffer,
|
|
||||||
const gss_buffer_t token_buffer,
|
|
||||||
gss_qop_t * qop_state,
|
|
||||||
char * type);
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
gss_krb5_get_remotekey(const gss_ctx_id_t context_handle,
|
|
||||||
krb5_keyblock **key);
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
gss_krb5_get_localkey(const gss_ctx_id_t context_handle,
|
|
||||||
krb5_keyblock **key);
|
|
||||||
|
|
||||||
krb5_error_code
|
|
||||||
gss_address_to_krb5addr(OM_uint32 gss_addr_type,
|
|
||||||
gss_buffer_desc *gss_addr,
|
|
||||||
int16_t port,
|
|
||||||
krb5_address *address);
|
|
||||||
|
|
||||||
/* sec_context flags */
|
|
||||||
|
|
||||||
#define SC_LOCAL_ADDRESS 0x01
|
|
||||||
#define SC_REMOTE_ADDRESS 0x02
|
|
||||||
#define SC_KEYBLOCK 0x04
|
|
||||||
#define SC_LOCAL_SUBKEY 0x08
|
|
||||||
#define SC_REMOTE_SUBKEY 0x10
|
|
||||||
|
|
||||||
int
|
|
||||||
gss_oid_equal(const gss_OID a, const gss_OID b);
|
|
||||||
|
|
||||||
void
|
|
||||||
gssapi_krb5_set_error_string (void);
|
|
||||||
|
|
||||||
char *
|
|
||||||
gssapi_krb5_get_error_string (void);
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
_gss_DES3_get_mic_compat(OM_uint32 *minor_status, gss_ctx_id_t ctx);
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
gssapi_lifetime_left(OM_uint32 *, OM_uint32, OM_uint32 *);
|
|
||||||
|
|
||||||
/* 8003 */
|
|
||||||
|
|
||||||
krb5_error_code
|
|
||||||
gssapi_encode_om_uint32(OM_uint32, u_char *);
|
|
||||||
|
|
||||||
krb5_error_code
|
|
||||||
gssapi_encode_be_om_uint32(OM_uint32, u_char *);
|
|
||||||
|
|
||||||
krb5_error_code
|
|
||||||
gssapi_decode_om_uint32(u_char *, OM_uint32 *);
|
|
||||||
|
|
||||||
krb5_error_code
|
|
||||||
gssapi_decode_be_om_uint32(u_char *, OM_uint32 *);
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,229 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997 - 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: import_name.c,v 1.13 2003/03/16 17:33:31 lha Exp $");
|
|
||||||
|
|
||||||
static OM_uint32
|
|
||||||
parse_krb5_name (OM_uint32 *minor_status,
|
|
||||||
const char *name,
|
|
||||||
gss_name_t *output_name)
|
|
||||||
{
|
|
||||||
krb5_error_code kerr;
|
|
||||||
|
|
||||||
kerr = krb5_parse_name (gssapi_krb5_context, name, output_name);
|
|
||||||
|
|
||||||
if (kerr == 0)
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
else if (kerr == KRB5_PARSE_ILLCHAR || kerr == KRB5_PARSE_MALFORMED) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
*minor_status = kerr;
|
|
||||||
return GSS_S_BAD_NAME;
|
|
||||||
} else {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
*minor_status = kerr;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static OM_uint32
|
|
||||||
import_krb5_name (OM_uint32 *minor_status,
|
|
||||||
const gss_buffer_t input_name_buffer,
|
|
||||||
gss_name_t *output_name)
|
|
||||||
{
|
|
||||||
OM_uint32 ret;
|
|
||||||
char *tmp;
|
|
||||||
|
|
||||||
tmp = malloc (input_name_buffer->length + 1);
|
|
||||||
if (tmp == NULL) {
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
memcpy (tmp,
|
|
||||||
input_name_buffer->value,
|
|
||||||
input_name_buffer->length);
|
|
||||||
tmp[input_name_buffer->length] = '\0';
|
|
||||||
|
|
||||||
ret = parse_krb5_name(minor_status, tmp, output_name);
|
|
||||||
free(tmp);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static OM_uint32
|
|
||||||
import_hostbased_name (OM_uint32 *minor_status,
|
|
||||||
const gss_buffer_t input_name_buffer,
|
|
||||||
gss_name_t *output_name)
|
|
||||||
{
|
|
||||||
krb5_error_code kerr;
|
|
||||||
char *tmp;
|
|
||||||
char *p;
|
|
||||||
char *host;
|
|
||||||
char local_hostname[MAXHOSTNAMELEN];
|
|
||||||
|
|
||||||
*output_name = NULL;
|
|
||||||
|
|
||||||
tmp = malloc (input_name_buffer->length + 1);
|
|
||||||
if (tmp == NULL) {
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
memcpy (tmp,
|
|
||||||
input_name_buffer->value,
|
|
||||||
input_name_buffer->length);
|
|
||||||
tmp[input_name_buffer->length] = '\0';
|
|
||||||
|
|
||||||
p = strchr (tmp, '@');
|
|
||||||
if (p != NULL) {
|
|
||||||
*p = '\0';
|
|
||||||
host = p + 1;
|
|
||||||
} else {
|
|
||||||
if (gethostname(local_hostname, sizeof(local_hostname)) < 0) {
|
|
||||||
*minor_status = errno;
|
|
||||||
free (tmp);
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
host = local_hostname;
|
|
||||||
}
|
|
||||||
|
|
||||||
kerr = krb5_sname_to_principal (gssapi_krb5_context,
|
|
||||||
host,
|
|
||||||
tmp,
|
|
||||||
KRB5_NT_SRV_HST,
|
|
||||||
output_name);
|
|
||||||
free (tmp);
|
|
||||||
*minor_status = kerr;
|
|
||||||
if (kerr == 0)
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
else if (kerr == KRB5_PARSE_ILLCHAR || kerr == KRB5_PARSE_MALFORMED) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
*minor_status = kerr;
|
|
||||||
return GSS_S_BAD_NAME;
|
|
||||||
} else {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
*minor_status = kerr;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static OM_uint32
|
|
||||||
import_export_name (OM_uint32 *minor_status,
|
|
||||||
const gss_buffer_t input_name_buffer,
|
|
||||||
gss_name_t *output_name)
|
|
||||||
{
|
|
||||||
unsigned char *p;
|
|
||||||
uint32_t length;
|
|
||||||
OM_uint32 ret;
|
|
||||||
char *name;
|
|
||||||
|
|
||||||
if (input_name_buffer->length < 10 + GSS_KRB5_MECHANISM->length)
|
|
||||||
return GSS_S_BAD_NAME;
|
|
||||||
|
|
||||||
/* TOK, MECH_OID_LEN, DER(MECH_OID), NAME_LEN, NAME */
|
|
||||||
|
|
||||||
p = input_name_buffer->value;
|
|
||||||
|
|
||||||
if (memcmp(&p[0], "\x04\x01\x00", 3) != 0 ||
|
|
||||||
p[3] != GSS_KRB5_MECHANISM->length + 2 ||
|
|
||||||
p[4] != 0x06 ||
|
|
||||||
p[5] != GSS_KRB5_MECHANISM->length ||
|
|
||||||
memcmp(&p[6], GSS_KRB5_MECHANISM->elements,
|
|
||||||
GSS_KRB5_MECHANISM->length) != 0)
|
|
||||||
return GSS_S_BAD_NAME;
|
|
||||||
|
|
||||||
p += 6 + GSS_KRB5_MECHANISM->length;
|
|
||||||
|
|
||||||
length = p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
|
|
||||||
p += 4;
|
|
||||||
|
|
||||||
if (length > input_name_buffer->length - 10 - GSS_KRB5_MECHANISM->length)
|
|
||||||
return GSS_S_BAD_NAME;
|
|
||||||
|
|
||||||
name = malloc(length + 1);
|
|
||||||
if (name == NULL) {
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
memcpy(name, p, length);
|
|
||||||
name[length] = '\0';
|
|
||||||
|
|
||||||
ret = parse_krb5_name(minor_status, name, output_name);
|
|
||||||
free(name);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
gss_oid_equal(const gss_OID a, const gss_OID b)
|
|
||||||
{
|
|
||||||
if (a == b)
|
|
||||||
return 1;
|
|
||||||
else if (a == GSS_C_NO_OID || b == GSS_C_NO_OID || a->length != b->length)
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return memcmp(a->elements, b->elements, a->length) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
OM_uint32 gss_import_name
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
const gss_buffer_t input_name_buffer,
|
|
||||||
const gss_OID input_name_type,
|
|
||||||
gss_name_t * output_name
|
|
||||||
)
|
|
||||||
{
|
|
||||||
GSSAPI_KRB5_INIT ();
|
|
||||||
|
|
||||||
*minor_status = 0;
|
|
||||||
*output_name = GSS_C_NO_NAME;
|
|
||||||
|
|
||||||
if (gss_oid_equal(input_name_type, GSS_C_NT_HOSTBASED_SERVICE))
|
|
||||||
return import_hostbased_name (minor_status,
|
|
||||||
input_name_buffer,
|
|
||||||
output_name);
|
|
||||||
else if (gss_oid_equal(input_name_type, GSS_C_NO_OID)
|
|
||||||
|| gss_oid_equal(input_name_type, GSS_C_NT_USER_NAME)
|
|
||||||
|| gss_oid_equal(input_name_type, GSS_KRB5_NT_PRINCIPAL_NAME))
|
|
||||||
/* default printable syntax */
|
|
||||||
return import_krb5_name (minor_status,
|
|
||||||
input_name_buffer,
|
|
||||||
output_name);
|
|
||||||
else if (gss_oid_equal(input_name_type, GSS_C_NT_EXPORT_NAME)) {
|
|
||||||
return import_export_name(minor_status,
|
|
||||||
input_name_buffer,
|
|
||||||
output_name);
|
|
||||||
} else {
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_BAD_NAMETYPE;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,212 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1999 - 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: import_sec_context.c,v 1.7 2003/03/16 18:01:32 lha Exp $");
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
gss_import_sec_context (
|
|
||||||
OM_uint32 * minor_status,
|
|
||||||
const gss_buffer_t interprocess_token,
|
|
||||||
gss_ctx_id_t * context_handle
|
|
||||||
)
|
|
||||||
{
|
|
||||||
OM_uint32 ret = GSS_S_FAILURE;
|
|
||||||
krb5_error_code kret;
|
|
||||||
krb5_storage *sp;
|
|
||||||
krb5_auth_context ac;
|
|
||||||
krb5_address local, remote;
|
|
||||||
krb5_address *localp, *remotep;
|
|
||||||
krb5_data data;
|
|
||||||
gss_buffer_desc buffer;
|
|
||||||
krb5_keyblock keyblock;
|
|
||||||
int32_t tmp;
|
|
||||||
int32_t flags;
|
|
||||||
OM_uint32 minor;
|
|
||||||
|
|
||||||
GSSAPI_KRB5_INIT ();
|
|
||||||
|
|
||||||
localp = remotep = NULL;
|
|
||||||
|
|
||||||
sp = krb5_storage_from_mem (interprocess_token->value,
|
|
||||||
interprocess_token->length);
|
|
||||||
if (sp == NULL) {
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
*context_handle = malloc(sizeof(**context_handle));
|
|
||||||
if (*context_handle == NULL) {
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
krb5_storage_free (sp);
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
memset (*context_handle, 0, sizeof(**context_handle));
|
|
||||||
|
|
||||||
kret = krb5_auth_con_init (gssapi_krb5_context,
|
|
||||||
&(*context_handle)->auth_context);
|
|
||||||
if (kret) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
*minor_status = kret;
|
|
||||||
ret = GSS_S_FAILURE;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* flags */
|
|
||||||
|
|
||||||
*minor_status = 0;
|
|
||||||
|
|
||||||
if (krb5_ret_int32 (sp, &flags) != 0)
|
|
||||||
goto failure;
|
|
||||||
|
|
||||||
/* retrieve the auth context */
|
|
||||||
|
|
||||||
ac = (*context_handle)->auth_context;
|
|
||||||
krb5_ret_int32 (sp, &ac->flags);
|
|
||||||
if (flags & SC_LOCAL_ADDRESS) {
|
|
||||||
if (krb5_ret_address (sp, localp = &local) != 0)
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & SC_REMOTE_ADDRESS) {
|
|
||||||
if (krb5_ret_address (sp, remotep = &remote) != 0)
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
krb5_auth_con_setaddrs (gssapi_krb5_context, ac, localp, remotep);
|
|
||||||
if (localp)
|
|
||||||
krb5_free_address (gssapi_krb5_context, localp);
|
|
||||||
if (remotep)
|
|
||||||
krb5_free_address (gssapi_krb5_context, remotep);
|
|
||||||
localp = remotep = NULL;
|
|
||||||
|
|
||||||
if (krb5_ret_int16 (sp, &ac->local_port) != 0)
|
|
||||||
goto failure;
|
|
||||||
|
|
||||||
if (krb5_ret_int16 (sp, &ac->remote_port) != 0)
|
|
||||||
goto failure;
|
|
||||||
if (flags & SC_KEYBLOCK) {
|
|
||||||
if (krb5_ret_keyblock (sp, &keyblock) != 0)
|
|
||||||
goto failure;
|
|
||||||
krb5_auth_con_setkey (gssapi_krb5_context, ac, &keyblock);
|
|
||||||
krb5_free_keyblock_contents (gssapi_krb5_context, &keyblock);
|
|
||||||
}
|
|
||||||
if (flags & SC_LOCAL_SUBKEY) {
|
|
||||||
if (krb5_ret_keyblock (sp, &keyblock) != 0)
|
|
||||||
goto failure;
|
|
||||||
krb5_auth_con_setlocalsubkey (gssapi_krb5_context, ac, &keyblock);
|
|
||||||
krb5_free_keyblock_contents (gssapi_krb5_context, &keyblock);
|
|
||||||
}
|
|
||||||
if (flags & SC_REMOTE_SUBKEY) {
|
|
||||||
if (krb5_ret_keyblock (sp, &keyblock) != 0)
|
|
||||||
goto failure;
|
|
||||||
krb5_auth_con_setremotesubkey (gssapi_krb5_context, ac, &keyblock);
|
|
||||||
krb5_free_keyblock_contents (gssapi_krb5_context, &keyblock);
|
|
||||||
}
|
|
||||||
if (krb5_ret_int32 (sp, &ac->local_seqnumber))
|
|
||||||
goto failure;
|
|
||||||
if (krb5_ret_int32 (sp, &ac->remote_seqnumber))
|
|
||||||
goto failure;
|
|
||||||
|
|
||||||
if (krb5_ret_int32 (sp, &tmp) != 0)
|
|
||||||
goto failure;
|
|
||||||
ac->keytype = tmp;
|
|
||||||
if (krb5_ret_int32 (sp, &tmp) != 0)
|
|
||||||
goto failure;
|
|
||||||
ac->cksumtype = tmp;
|
|
||||||
|
|
||||||
/* names */
|
|
||||||
|
|
||||||
if (krb5_ret_data (sp, &data))
|
|
||||||
goto failure;
|
|
||||||
buffer.value = data.data;
|
|
||||||
buffer.length = data.length;
|
|
||||||
|
|
||||||
ret = gss_import_name (minor_status, &buffer, GSS_C_NT_EXPORT_NAME,
|
|
||||||
&(*context_handle)->source);
|
|
||||||
if (ret) {
|
|
||||||
ret = gss_import_name (minor_status, &buffer, GSS_C_NO_OID,
|
|
||||||
&(*context_handle)->source);
|
|
||||||
if (ret) {
|
|
||||||
krb5_data_free (&data);
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
krb5_data_free (&data);
|
|
||||||
|
|
||||||
if (krb5_ret_data (sp, &data) != 0)
|
|
||||||
goto failure;
|
|
||||||
buffer.value = data.data;
|
|
||||||
buffer.length = data.length;
|
|
||||||
|
|
||||||
ret = gss_import_name (minor_status, &buffer, GSS_C_NT_EXPORT_NAME,
|
|
||||||
&(*context_handle)->target);
|
|
||||||
if (ret) {
|
|
||||||
ret = gss_import_name (minor_status, &buffer, GSS_C_NO_OID,
|
|
||||||
&(*context_handle)->target);
|
|
||||||
if (ret) {
|
|
||||||
krb5_data_free (&data);
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
krb5_data_free (&data);
|
|
||||||
|
|
||||||
if (krb5_ret_int32 (sp, &tmp))
|
|
||||||
goto failure;
|
|
||||||
(*context_handle)->flags = tmp;
|
|
||||||
if (krb5_ret_int32 (sp, &tmp))
|
|
||||||
goto failure;
|
|
||||||
(*context_handle)->more_flags = tmp;
|
|
||||||
if (krb5_ret_int32 (sp, &tmp) == 0)
|
|
||||||
(*context_handle)->lifetime = tmp;
|
|
||||||
else
|
|
||||||
(*context_handle)->lifetime = GSS_C_INDEFINITE;
|
|
||||||
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
|
|
||||||
failure:
|
|
||||||
krb5_auth_con_free (gssapi_krb5_context,
|
|
||||||
(*context_handle)->auth_context);
|
|
||||||
if ((*context_handle)->source != NULL)
|
|
||||||
gss_release_name(&minor, &(*context_handle)->source);
|
|
||||||
if ((*context_handle)->target != NULL)
|
|
||||||
gss_release_name(&minor, &(*context_handle)->target);
|
|
||||||
if (localp)
|
|
||||||
krb5_free_address (gssapi_krb5_context, localp);
|
|
||||||
if (remotep)
|
|
||||||
krb5_free_address (gssapi_krb5_context, remotep);
|
|
||||||
free (*context_handle);
|
|
||||||
*context_handle = GSS_C_NO_CONTEXT;
|
|
||||||
return ret;
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997 - 2001, 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: indicate_mechs.c,v 1.5 2003/03/16 17:38:20 lha Exp $");
|
|
||||||
|
|
||||||
OM_uint32 gss_indicate_mechs
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
gss_OID_set * mech_set
|
|
||||||
)
|
|
||||||
{
|
|
||||||
OM_uint32 ret;
|
|
||||||
|
|
||||||
ret = gss_create_empty_oid_set(minor_status, mech_set);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
ret = gss_add_oid_set_member(minor_status, GSS_KRB5_MECHANISM, mech_set);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997 - 2000 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: init.c,v 1.6 2001/08/13 13:14:07 joda Exp $");
|
|
||||||
|
|
||||||
krb5_error_code
|
|
||||||
gssapi_krb5_init (void)
|
|
||||||
{
|
|
||||||
if(gssapi_krb5_context == NULL)
|
|
||||||
return krb5_init_context (&gssapi_krb5_context);
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,578 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997 - 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: init_sec_context.c,v 1.36.2.1 2003/08/15 14:21:18 lha Exp $");
|
|
||||||
|
|
||||||
/*
|
|
||||||
* copy the addresses from `input_chan_bindings' (if any) to
|
|
||||||
* the auth context `ac'
|
|
||||||
*/
|
|
||||||
|
|
||||||
static OM_uint32
|
|
||||||
set_addresses (krb5_auth_context ac,
|
|
||||||
const gss_channel_bindings_t input_chan_bindings)
|
|
||||||
{
|
|
||||||
/* Port numbers are expected to be in application_data.value,
|
|
||||||
* initator's port first */
|
|
||||||
|
|
||||||
krb5_address initiator_addr, acceptor_addr;
|
|
||||||
krb5_error_code kret;
|
|
||||||
|
|
||||||
if (input_chan_bindings == GSS_C_NO_CHANNEL_BINDINGS
|
|
||||||
|| input_chan_bindings->application_data.length !=
|
|
||||||
2 * sizeof(ac->local_port))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
memset(&initiator_addr, 0, sizeof(initiator_addr));
|
|
||||||
memset(&acceptor_addr, 0, sizeof(acceptor_addr));
|
|
||||||
|
|
||||||
ac->local_port =
|
|
||||||
*(int16_t *) input_chan_bindings->application_data.value;
|
|
||||||
|
|
||||||
ac->remote_port =
|
|
||||||
*((int16_t *) input_chan_bindings->application_data.value + 1);
|
|
||||||
|
|
||||||
kret = gss_address_to_krb5addr(input_chan_bindings->acceptor_addrtype,
|
|
||||||
&input_chan_bindings->acceptor_address,
|
|
||||||
ac->remote_port,
|
|
||||||
&acceptor_addr);
|
|
||||||
if (kret)
|
|
||||||
return kret;
|
|
||||||
|
|
||||||
kret = gss_address_to_krb5addr(input_chan_bindings->initiator_addrtype,
|
|
||||||
&input_chan_bindings->initiator_address,
|
|
||||||
ac->local_port,
|
|
||||||
&initiator_addr);
|
|
||||||
if (kret) {
|
|
||||||
krb5_free_address (gssapi_krb5_context, &acceptor_addr);
|
|
||||||
return kret;
|
|
||||||
}
|
|
||||||
|
|
||||||
kret = krb5_auth_con_setaddrs(gssapi_krb5_context,
|
|
||||||
ac,
|
|
||||||
&initiator_addr, /* local address */
|
|
||||||
&acceptor_addr); /* remote address */
|
|
||||||
|
|
||||||
krb5_free_address (gssapi_krb5_context, &initiator_addr);
|
|
||||||
krb5_free_address (gssapi_krb5_context, &acceptor_addr);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
free(input_chan_bindings->application_data.value);
|
|
||||||
input_chan_bindings->application_data.value = NULL;
|
|
||||||
input_chan_bindings->application_data.length = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return kret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* handle delegated creds in init-sec-context
|
|
||||||
*/
|
|
||||||
|
|
||||||
static void
|
|
||||||
do_delegation (krb5_auth_context ac,
|
|
||||||
krb5_ccache ccache,
|
|
||||||
krb5_creds *cred,
|
|
||||||
const gss_name_t target_name,
|
|
||||||
krb5_data *fwd_data,
|
|
||||||
int *flags)
|
|
||||||
{
|
|
||||||
krb5_creds creds;
|
|
||||||
krb5_kdc_flags fwd_flags;
|
|
||||||
krb5_error_code kret;
|
|
||||||
|
|
||||||
memset (&creds, 0, sizeof(creds));
|
|
||||||
krb5_data_zero (fwd_data);
|
|
||||||
|
|
||||||
kret = krb5_cc_get_principal(gssapi_krb5_context, ccache, &creds.client);
|
|
||||||
if (kret)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
kret = krb5_build_principal(gssapi_krb5_context,
|
|
||||||
&creds.server,
|
|
||||||
strlen(creds.client->realm),
|
|
||||||
creds.client->realm,
|
|
||||||
KRB5_TGS_NAME,
|
|
||||||
creds.client->realm,
|
|
||||||
NULL);
|
|
||||||
if (kret)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
creds.times.endtime = 0;
|
|
||||||
|
|
||||||
fwd_flags.i = 0;
|
|
||||||
fwd_flags.b.forwarded = 1;
|
|
||||||
fwd_flags.b.forwardable = 1;
|
|
||||||
|
|
||||||
if ( /*target_name->name.name_type != KRB5_NT_SRV_HST ||*/
|
|
||||||
target_name->name.name_string.len < 2)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
kret = krb5_get_forwarded_creds(gssapi_krb5_context,
|
|
||||||
ac,
|
|
||||||
ccache,
|
|
||||||
fwd_flags.i,
|
|
||||||
target_name->name.name_string.val[1],
|
|
||||||
&creds,
|
|
||||||
fwd_data);
|
|
||||||
|
|
||||||
out:
|
|
||||||
if (kret)
|
|
||||||
*flags &= ~GSS_C_DELEG_FLAG;
|
|
||||||
else
|
|
||||||
*flags |= GSS_C_DELEG_FLAG;
|
|
||||||
|
|
||||||
if (creds.client)
|
|
||||||
krb5_free_principal(gssapi_krb5_context, creds.client);
|
|
||||||
if (creds.server)
|
|
||||||
krb5_free_principal(gssapi_krb5_context, creds.server);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* first stage of init-sec-context
|
|
||||||
*/
|
|
||||||
|
|
||||||
static OM_uint32
|
|
||||||
init_auth
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
const gss_cred_id_t initiator_cred_handle,
|
|
||||||
gss_ctx_id_t * context_handle,
|
|
||||||
const gss_name_t target_name,
|
|
||||||
const gss_OID mech_type,
|
|
||||||
OM_uint32 req_flags,
|
|
||||||
OM_uint32 time_req,
|
|
||||||
const gss_channel_bindings_t input_chan_bindings,
|
|
||||||
const gss_buffer_t input_token,
|
|
||||||
gss_OID * actual_mech_type,
|
|
||||||
gss_buffer_t output_token,
|
|
||||||
OM_uint32 * ret_flags,
|
|
||||||
OM_uint32 * time_rec
|
|
||||||
)
|
|
||||||
{
|
|
||||||
OM_uint32 ret = GSS_S_FAILURE;
|
|
||||||
krb5_error_code kret;
|
|
||||||
krb5_flags ap_options;
|
|
||||||
krb5_creds this_cred, *cred;
|
|
||||||
krb5_data outbuf;
|
|
||||||
krb5_ccache ccache;
|
|
||||||
u_int32_t flags;
|
|
||||||
Authenticator *auth;
|
|
||||||
krb5_data authenticator;
|
|
||||||
Checksum cksum;
|
|
||||||
krb5_enctype enctype;
|
|
||||||
krb5_data fwd_data;
|
|
||||||
OM_uint32 lifetime_rec;
|
|
||||||
|
|
||||||
krb5_data_zero(&outbuf);
|
|
||||||
krb5_data_zero(&fwd_data);
|
|
||||||
|
|
||||||
*minor_status = 0;
|
|
||||||
|
|
||||||
*context_handle = malloc(sizeof(**context_handle));
|
|
||||||
if (*context_handle == NULL) {
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
(*context_handle)->auth_context = NULL;
|
|
||||||
(*context_handle)->source = NULL;
|
|
||||||
(*context_handle)->target = NULL;
|
|
||||||
(*context_handle)->flags = 0;
|
|
||||||
(*context_handle)->more_flags = 0;
|
|
||||||
(*context_handle)->ticket = NULL;
|
|
||||||
(*context_handle)->lifetime = GSS_C_INDEFINITE;
|
|
||||||
|
|
||||||
kret = krb5_auth_con_init (gssapi_krb5_context,
|
|
||||||
&(*context_handle)->auth_context);
|
|
||||||
if (kret) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
*minor_status = kret;
|
|
||||||
ret = GSS_S_FAILURE;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
kret = set_addresses ((*context_handle)->auth_context,
|
|
||||||
input_chan_bindings);
|
|
||||||
if (kret) {
|
|
||||||
*minor_status = kret;
|
|
||||||
ret = GSS_S_BAD_BINDINGS;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
int32_t tmp;
|
|
||||||
|
|
||||||
krb5_auth_con_getflags(gssapi_krb5_context,
|
|
||||||
(*context_handle)->auth_context,
|
|
||||||
&tmp);
|
|
||||||
tmp |= KRB5_AUTH_CONTEXT_DO_SEQUENCE;
|
|
||||||
krb5_auth_con_setflags(gssapi_krb5_context,
|
|
||||||
(*context_handle)->auth_context,
|
|
||||||
tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (actual_mech_type)
|
|
||||||
*actual_mech_type = GSS_KRB5_MECHANISM;
|
|
||||||
|
|
||||||
if (initiator_cred_handle == GSS_C_NO_CREDENTIAL) {
|
|
||||||
kret = krb5_cc_default (gssapi_krb5_context, &ccache);
|
|
||||||
if (kret) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
*minor_status = kret;
|
|
||||||
ret = GSS_S_FAILURE;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
ccache = initiator_cred_handle->ccache;
|
|
||||||
|
|
||||||
kret = krb5_cc_get_principal (gssapi_krb5_context,
|
|
||||||
ccache,
|
|
||||||
&(*context_handle)->source);
|
|
||||||
if (kret) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
*minor_status = kret;
|
|
||||||
ret = GSS_S_FAILURE;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
kret = krb5_copy_principal (gssapi_krb5_context,
|
|
||||||
target_name,
|
|
||||||
&(*context_handle)->target);
|
|
||||||
if (kret) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
*minor_status = kret;
|
|
||||||
ret = GSS_S_FAILURE;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = _gss_DES3_get_mic_compat(minor_status, *context_handle);
|
|
||||||
if (ret)
|
|
||||||
goto failure;
|
|
||||||
|
|
||||||
|
|
||||||
memset(&this_cred, 0, sizeof(this_cred));
|
|
||||||
this_cred.client = (*context_handle)->source;
|
|
||||||
this_cred.server = (*context_handle)->target;
|
|
||||||
if (time_req && time_req != GSS_C_INDEFINITE) {
|
|
||||||
krb5_timestamp ts;
|
|
||||||
|
|
||||||
krb5_timeofday (gssapi_krb5_context, &ts);
|
|
||||||
this_cred.times.endtime = ts + time_req;
|
|
||||||
} else
|
|
||||||
this_cred.times.endtime = 0;
|
|
||||||
this_cred.session.keytype = 0;
|
|
||||||
|
|
||||||
kret = krb5_get_credentials (gssapi_krb5_context,
|
|
||||||
KRB5_TC_MATCH_KEYTYPE,
|
|
||||||
ccache,
|
|
||||||
&this_cred,
|
|
||||||
&cred);
|
|
||||||
|
|
||||||
if (kret) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
*minor_status = kret;
|
|
||||||
ret = GSS_S_FAILURE;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
(*context_handle)->lifetime = cred->times.endtime;
|
|
||||||
|
|
||||||
ret = gssapi_lifetime_left(minor_status,
|
|
||||||
(*context_handle)->lifetime,
|
|
||||||
&lifetime_rec);
|
|
||||||
if (ret) {
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lifetime_rec == 0) {
|
|
||||||
*minor_status = 0;
|
|
||||||
ret = GSS_S_CONTEXT_EXPIRED;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
krb5_auth_con_setkey(gssapi_krb5_context,
|
|
||||||
(*context_handle)->auth_context,
|
|
||||||
&cred->session);
|
|
||||||
|
|
||||||
kret = krb5_auth_con_generatelocalsubkey(gssapi_krb5_context,
|
|
||||||
(*context_handle)->auth_context,
|
|
||||||
&cred->session);
|
|
||||||
if(kret) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
*minor_status = kret;
|
|
||||||
ret = GSS_S_FAILURE;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
flags = 0;
|
|
||||||
ap_options = 0;
|
|
||||||
if (req_flags & GSS_C_DELEG_FLAG)
|
|
||||||
do_delegation ((*context_handle)->auth_context,
|
|
||||||
ccache, cred, target_name, &fwd_data, &flags);
|
|
||||||
|
|
||||||
if (req_flags & GSS_C_MUTUAL_FLAG) {
|
|
||||||
flags |= GSS_C_MUTUAL_FLAG;
|
|
||||||
ap_options |= AP_OPTS_MUTUAL_REQUIRED;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (req_flags & GSS_C_REPLAY_FLAG)
|
|
||||||
; /* XXX */
|
|
||||||
if (req_flags & GSS_C_SEQUENCE_FLAG)
|
|
||||||
; /* XXX */
|
|
||||||
if (req_flags & GSS_C_ANON_FLAG)
|
|
||||||
; /* XXX */
|
|
||||||
flags |= GSS_C_CONF_FLAG;
|
|
||||||
flags |= GSS_C_INTEG_FLAG;
|
|
||||||
flags |= GSS_C_SEQUENCE_FLAG;
|
|
||||||
flags |= GSS_C_TRANS_FLAG;
|
|
||||||
|
|
||||||
if (ret_flags)
|
|
||||||
*ret_flags = flags;
|
|
||||||
(*context_handle)->flags = flags;
|
|
||||||
(*context_handle)->more_flags |= LOCAL;
|
|
||||||
|
|
||||||
ret = gssapi_krb5_create_8003_checksum (minor_status,
|
|
||||||
input_chan_bindings,
|
|
||||||
flags,
|
|
||||||
&fwd_data,
|
|
||||||
&cksum);
|
|
||||||
krb5_data_free (&fwd_data);
|
|
||||||
if (ret)
|
|
||||||
goto failure;
|
|
||||||
|
|
||||||
#if 1
|
|
||||||
enctype = (*context_handle)->auth_context->keyblock->keytype;
|
|
||||||
#else
|
|
||||||
if ((*context_handle)->auth_context->enctype)
|
|
||||||
enctype = (*context_handle)->auth_context->enctype;
|
|
||||||
else {
|
|
||||||
kret = krb5_keytype_to_enctype(gssapi_krb5_context,
|
|
||||||
(*context_handle)->auth_context->keyblock->keytype,
|
|
||||||
&enctype);
|
|
||||||
if (kret)
|
|
||||||
return kret;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
kret = krb5_build_authenticator (gssapi_krb5_context,
|
|
||||||
(*context_handle)->auth_context,
|
|
||||||
enctype,
|
|
||||||
cred,
|
|
||||||
&cksum,
|
|
||||||
&auth,
|
|
||||||
&authenticator,
|
|
||||||
KRB5_KU_AP_REQ_AUTH);
|
|
||||||
|
|
||||||
if (kret) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
*minor_status = kret;
|
|
||||||
ret = GSS_S_FAILURE;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
kret = krb5_build_ap_req (gssapi_krb5_context,
|
|
||||||
enctype,
|
|
||||||
cred,
|
|
||||||
ap_options,
|
|
||||||
authenticator,
|
|
||||||
&outbuf);
|
|
||||||
|
|
||||||
if (kret) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
*minor_status = kret;
|
|
||||||
ret = GSS_S_FAILURE;
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = gssapi_krb5_encapsulate (minor_status, &outbuf, output_token,
|
|
||||||
"\x01\x00");
|
|
||||||
if (ret)
|
|
||||||
goto failure;
|
|
||||||
|
|
||||||
krb5_data_free (&outbuf);
|
|
||||||
|
|
||||||
if (flags & GSS_C_MUTUAL_FLAG) {
|
|
||||||
return GSS_S_CONTINUE_NEEDED;
|
|
||||||
} else {
|
|
||||||
if (time_rec)
|
|
||||||
*time_rec = lifetime_rec;
|
|
||||||
|
|
||||||
(*context_handle)->more_flags |= OPEN;
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
||||||
|
|
||||||
failure:
|
|
||||||
krb5_auth_con_free (gssapi_krb5_context,
|
|
||||||
(*context_handle)->auth_context);
|
|
||||||
if((*context_handle)->source)
|
|
||||||
krb5_free_principal (gssapi_krb5_context,
|
|
||||||
(*context_handle)->source);
|
|
||||||
if((*context_handle)->target)
|
|
||||||
krb5_free_principal (gssapi_krb5_context,
|
|
||||||
(*context_handle)->target);
|
|
||||||
free (*context_handle);
|
|
||||||
krb5_data_free (&outbuf);
|
|
||||||
*context_handle = GSS_C_NO_CONTEXT;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static OM_uint32
|
|
||||||
repl_mutual
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
const gss_cred_id_t initiator_cred_handle,
|
|
||||||
gss_ctx_id_t * context_handle,
|
|
||||||
const gss_name_t target_name,
|
|
||||||
const gss_OID mech_type,
|
|
||||||
OM_uint32 req_flags,
|
|
||||||
OM_uint32 time_req,
|
|
||||||
const gss_channel_bindings_t input_chan_bindings,
|
|
||||||
const gss_buffer_t input_token,
|
|
||||||
gss_OID * actual_mech_type,
|
|
||||||
gss_buffer_t output_token,
|
|
||||||
OM_uint32 * ret_flags,
|
|
||||||
OM_uint32 * time_rec
|
|
||||||
)
|
|
||||||
{
|
|
||||||
OM_uint32 ret;
|
|
||||||
krb5_error_code kret;
|
|
||||||
krb5_data indata;
|
|
||||||
krb5_ap_rep_enc_part *repl;
|
|
||||||
|
|
||||||
output_token->length = 0;
|
|
||||||
output_token->value = NULL;
|
|
||||||
|
|
||||||
if (actual_mech_type)
|
|
||||||
*actual_mech_type = GSS_KRB5_MECHANISM;
|
|
||||||
|
|
||||||
ret = gssapi_krb5_decapsulate (minor_status, input_token, &indata,
|
|
||||||
"\x02\x00");
|
|
||||||
if (ret)
|
|
||||||
/* XXX - Handle AP_ERROR */
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
kret = krb5_rd_rep (gssapi_krb5_context,
|
|
||||||
(*context_handle)->auth_context,
|
|
||||||
&indata,
|
|
||||||
&repl);
|
|
||||||
if (kret) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
*minor_status = kret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
krb5_free_ap_rep_enc_part (gssapi_krb5_context,
|
|
||||||
repl);
|
|
||||||
|
|
||||||
(*context_handle)->more_flags |= OPEN;
|
|
||||||
|
|
||||||
*minor_status = 0;
|
|
||||||
if (time_rec) {
|
|
||||||
ret = gssapi_lifetime_left(minor_status,
|
|
||||||
(*context_handle)->lifetime,
|
|
||||||
time_rec);
|
|
||||||
} else {
|
|
||||||
ret = GSS_S_COMPLETE;
|
|
||||||
}
|
|
||||||
if (ret_flags)
|
|
||||||
*ret_flags = (*context_handle)->flags;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* gss_init_sec_context
|
|
||||||
*/
|
|
||||||
|
|
||||||
OM_uint32 gss_init_sec_context
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
const gss_cred_id_t initiator_cred_handle,
|
|
||||||
gss_ctx_id_t * context_handle,
|
|
||||||
const gss_name_t target_name,
|
|
||||||
const gss_OID mech_type,
|
|
||||||
OM_uint32 req_flags,
|
|
||||||
OM_uint32 time_req,
|
|
||||||
const gss_channel_bindings_t input_chan_bindings,
|
|
||||||
const gss_buffer_t input_token,
|
|
||||||
gss_OID * actual_mech_type,
|
|
||||||
gss_buffer_t output_token,
|
|
||||||
OM_uint32 * ret_flags,
|
|
||||||
OM_uint32 * time_rec
|
|
||||||
)
|
|
||||||
{
|
|
||||||
GSSAPI_KRB5_INIT ();
|
|
||||||
|
|
||||||
output_token->length = 0;
|
|
||||||
output_token->value = NULL;
|
|
||||||
|
|
||||||
if (ret_flags)
|
|
||||||
*ret_flags = 0;
|
|
||||||
if (time_rec)
|
|
||||||
*time_rec = 0;
|
|
||||||
|
|
||||||
if (target_name == GSS_C_NO_NAME) {
|
|
||||||
if (actual_mech_type)
|
|
||||||
*actual_mech_type = GSS_C_NO_OID;
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_BAD_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (input_token == GSS_C_NO_BUFFER || input_token->length == 0)
|
|
||||||
return init_auth (minor_status,
|
|
||||||
initiator_cred_handle,
|
|
||||||
context_handle,
|
|
||||||
target_name,
|
|
||||||
mech_type,
|
|
||||||
req_flags,
|
|
||||||
time_req,
|
|
||||||
input_chan_bindings,
|
|
||||||
input_token,
|
|
||||||
actual_mech_type,
|
|
||||||
output_token,
|
|
||||||
ret_flags,
|
|
||||||
time_rec);
|
|
||||||
else
|
|
||||||
return repl_mutual(minor_status,
|
|
||||||
initiator_cred_handle,
|
|
||||||
context_handle,
|
|
||||||
target_name,
|
|
||||||
mech_type,
|
|
||||||
req_flags,
|
|
||||||
time_req,
|
|
||||||
input_chan_bindings,
|
|
||||||
input_token,
|
|
||||||
actual_mech_type,
|
|
||||||
output_token,
|
|
||||||
ret_flags,
|
|
||||||
time_rec);
|
|
||||||
}
|
|
@ -1,85 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997, 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: inquire_context.c,v 1.5 2003/03/16 17:43:30 lha Exp $");
|
|
||||||
|
|
||||||
OM_uint32 gss_inquire_context (
|
|
||||||
OM_uint32 * minor_status,
|
|
||||||
const gss_ctx_id_t context_handle,
|
|
||||||
gss_name_t * src_name,
|
|
||||||
gss_name_t * targ_name,
|
|
||||||
OM_uint32 * lifetime_rec,
|
|
||||||
gss_OID * mech_type,
|
|
||||||
OM_uint32 * ctx_flags,
|
|
||||||
int * locally_initiated,
|
|
||||||
int * open_context
|
|
||||||
)
|
|
||||||
{
|
|
||||||
OM_uint32 ret;
|
|
||||||
|
|
||||||
if (src_name) {
|
|
||||||
ret = gss_duplicate_name (minor_status,
|
|
||||||
context_handle->source,
|
|
||||||
src_name);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (targ_name) {
|
|
||||||
ret = gss_duplicate_name (minor_status,
|
|
||||||
context_handle->target,
|
|
||||||
targ_name);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lifetime_rec)
|
|
||||||
*lifetime_rec = context_handle->lifetime;
|
|
||||||
|
|
||||||
if (mech_type)
|
|
||||||
*mech_type = GSS_KRB5_MECHANISM;
|
|
||||||
|
|
||||||
if (ctx_flags)
|
|
||||||
*ctx_flags = context_handle->flags;
|
|
||||||
|
|
||||||
if (locally_initiated)
|
|
||||||
*locally_initiated = context_handle->more_flags & LOCAL;
|
|
||||||
|
|
||||||
if (open_context)
|
|
||||||
*open_context = context_handle->more_flags & OPEN;
|
|
||||||
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
@ -1,97 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997, 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: inquire_cred.c,v 1.4 2003/03/16 17:42:14 lha Exp $");
|
|
||||||
|
|
||||||
OM_uint32 gss_inquire_cred
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
const gss_cred_id_t cred_handle,
|
|
||||||
gss_name_t * name,
|
|
||||||
OM_uint32 * lifetime,
|
|
||||||
gss_cred_usage_t * cred_usage,
|
|
||||||
gss_OID_set * mechanisms
|
|
||||||
)
|
|
||||||
{
|
|
||||||
OM_uint32 ret;
|
|
||||||
|
|
||||||
*minor_status = 0;
|
|
||||||
|
|
||||||
if (name)
|
|
||||||
*name = NULL;
|
|
||||||
if (mechanisms)
|
|
||||||
*mechanisms = GSS_C_NO_OID_SET;
|
|
||||||
|
|
||||||
if (cred_handle == GSS_C_NO_CREDENTIAL) {
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (name != NULL) {
|
|
||||||
if (cred_handle->principal != NULL) {
|
|
||||||
ret = gss_duplicate_name(minor_status, cred_handle->principal,
|
|
||||||
name);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
} else if (cred_handle->usage == GSS_C_ACCEPT) {
|
|
||||||
*minor_status = krb5_sname_to_principal(gssapi_krb5_context, NULL,
|
|
||||||
NULL, KRB5_NT_SRV_HST, name);
|
|
||||||
if (*minor_status)
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
} else {
|
|
||||||
*minor_status = krb5_get_default_principal(gssapi_krb5_context,
|
|
||||||
name);
|
|
||||||
if (*minor_status)
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (lifetime != NULL) {
|
|
||||||
*lifetime = cred_handle->lifetime;
|
|
||||||
}
|
|
||||||
if (cred_usage != NULL) {
|
|
||||||
*cred_usage = cred_handle->usage;
|
|
||||||
}
|
|
||||||
if (mechanisms != NULL) {
|
|
||||||
ret = gss_create_empty_oid_set(minor_status, mechanisms);
|
|
||||||
if (ret) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
ret = gss_add_oid_set_member(minor_status,
|
|
||||||
&cred_handle->mechanisms->elements[0],
|
|
||||||
mechanisms);
|
|
||||||
if (ret) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
@ -1,80 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: inquire_cred_by_mech.c,v 1.1 2003/03/16 18:11:16 lha Exp $");
|
|
||||||
|
|
||||||
OM_uint32 gss_inquire_cred_by_mech (
|
|
||||||
OM_uint32 * minor_status,
|
|
||||||
const gss_cred_id_t cred_handle,
|
|
||||||
const gss_OID mech_type,
|
|
||||||
gss_name_t * name,
|
|
||||||
OM_uint32 * initiator_lifetime,
|
|
||||||
OM_uint32 * acceptor_lifetime,
|
|
||||||
gss_cred_usage_t * cred_usage
|
|
||||||
)
|
|
||||||
{
|
|
||||||
OM_uint32 ret;
|
|
||||||
OM_uint32 lifetime;
|
|
||||||
|
|
||||||
if (gss_oid_equal(mech_type, GSS_C_NO_OID) == 0 &&
|
|
||||||
gss_oid_equal(mech_type, GSS_KRB5_MECHANISM) == 0) {
|
|
||||||
*minor_status = EINVAL;
|
|
||||||
return GSS_S_BAD_MECH;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = gss_inquire_cred (minor_status,
|
|
||||||
cred_handle,
|
|
||||||
name,
|
|
||||||
&lifetime,
|
|
||||||
cred_usage,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
if (ret == 0 && cred_handle != GSS_C_NO_CREDENTIAL) {
|
|
||||||
gss_cred_usage_t usage;
|
|
||||||
|
|
||||||
usage = cred_handle->usage;
|
|
||||||
|
|
||||||
if (initiator_lifetime) {
|
|
||||||
if (usage == GSS_C_INITIATE || usage == GSS_C_BOTH)
|
|
||||||
*initiator_lifetime = lifetime;
|
|
||||||
}
|
|
||||||
if (acceptor_lifetime) {
|
|
||||||
if (usage == GSS_C_ACCEPT || usage == GSS_C_BOTH)
|
|
||||||
*acceptor_lifetime = lifetime;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: inquire_mechs_for_name.c,v 1.1 2003/03/16 18:12:33 lha Exp $");
|
|
||||||
|
|
||||||
OM_uint32 gss_inquire_mechs_for_name (
|
|
||||||
OM_uint32 * minor_status,
|
|
||||||
const gss_name_t input_name,
|
|
||||||
gss_OID_set * mech_types
|
|
||||||
)
|
|
||||||
{
|
|
||||||
OM_uint32 ret;
|
|
||||||
|
|
||||||
ret = gss_create_empty_oid_set(minor_status, mech_types);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
ret = gss_add_oid_set_member(minor_status,
|
|
||||||
GSS_KRB5_MECHANISM,
|
|
||||||
mech_types);
|
|
||||||
if (ret)
|
|
||||||
gss_release_oid_set(NULL, mech_types);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
@ -1,80 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: inquire_names_for_mech.c,v 1.1 2003/03/16 18:15:29 lha Exp $");
|
|
||||||
|
|
||||||
|
|
||||||
static gss_OID *name_list[] = {
|
|
||||||
&GSS_C_NT_HOSTBASED_SERVICE,
|
|
||||||
&GSS_C_NT_USER_NAME,
|
|
||||||
&GSS_KRB5_NT_PRINCIPAL_NAME,
|
|
||||||
&GSS_C_NT_EXPORT_NAME,
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
OM_uint32 gss_inquire_names_for_mech (
|
|
||||||
OM_uint32 * minor_status,
|
|
||||||
const gss_OID mechanism,
|
|
||||||
gss_OID_set * name_types
|
|
||||||
)
|
|
||||||
{
|
|
||||||
OM_uint32 ret;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
*minor_status = 0;
|
|
||||||
|
|
||||||
if (gss_oid_equal(mechanism, GSS_KRB5_MECHANISM) == 0 &&
|
|
||||||
gss_oid_equal(mechanism, GSS_C_NULL_OID) == 0) {
|
|
||||||
*name_types = GSS_C_NO_OID_SET;
|
|
||||||
return GSS_S_BAD_MECH;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = gss_create_empty_oid_set(minor_status, name_types);
|
|
||||||
if (ret != GSS_S_COMPLETE)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
for (i = 0; name_list[i] != NULL; i++) {
|
|
||||||
ret = gss_add_oid_set_member(minor_status,
|
|
||||||
*(name_list[i]),
|
|
||||||
name_types);
|
|
||||||
if (ret != GSS_S_COMPLETE)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret != GSS_S_COMPLETE)
|
|
||||||
gss_release_oid_set(NULL, name_types);
|
|
||||||
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
@ -1,65 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: process_context_token.c,v 1.1 2003/03/16 18:19:05 lha Exp $");
|
|
||||||
|
|
||||||
OM_uint32 gss_process_context_token (
|
|
||||||
OM_uint32 *minor_status,
|
|
||||||
const gss_ctx_id_t context_handle,
|
|
||||||
const gss_buffer_t token_buffer
|
|
||||||
)
|
|
||||||
{
|
|
||||||
OM_uint32 ret = GSS_S_FAILURE;
|
|
||||||
gss_buffer_desc empty_buffer;
|
|
||||||
gss_qop_t qop_state;
|
|
||||||
|
|
||||||
empty_buffer.length = 0;
|
|
||||||
empty_buffer.value = NULL;
|
|
||||||
|
|
||||||
qop_state = GSS_C_QOP_DEFAULT;
|
|
||||||
|
|
||||||
ret = gss_verify_mic_internal(minor_status, context_handle,
|
|
||||||
token_buffer, &empty_buffer,
|
|
||||||
GSS_C_QOP_DEFAULT, "\x01\x02");
|
|
||||||
|
|
||||||
if (ret == GSS_S_COMPLETE)
|
|
||||||
ret = gss_delete_sec_context(minor_status,
|
|
||||||
(gss_ctx_id_t *)&context_handle,
|
|
||||||
GSS_C_NO_BUFFER);
|
|
||||||
if (ret == GSS_S_COMPLETE)
|
|
||||||
*minor_status = 0;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997 - 2000, 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: release_buffer.c,v 1.5 2003/03/16 17:58:20 lha Exp $");
|
|
||||||
|
|
||||||
OM_uint32 gss_release_buffer
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
gss_buffer_t buffer
|
|
||||||
)
|
|
||||||
{
|
|
||||||
*minor_status = 0;
|
|
||||||
free (buffer->value);
|
|
||||||
buffer->value = NULL;
|
|
||||||
buffer->length = 0;
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997-2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: release_cred.c,v 1.8.2.1 2003/10/07 01:08:21 lha Exp $");
|
|
||||||
|
|
||||||
OM_uint32 gss_release_cred
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
gss_cred_id_t * cred_handle
|
|
||||||
)
|
|
||||||
{
|
|
||||||
*minor_status = 0;
|
|
||||||
|
|
||||||
if (*cred_handle == GSS_C_NO_CREDENTIAL) {
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
||||||
|
|
||||||
GSSAPI_KRB5_INIT ();
|
|
||||||
|
|
||||||
if ((*cred_handle)->principal != NULL)
|
|
||||||
krb5_free_principal(gssapi_krb5_context, (*cred_handle)->principal);
|
|
||||||
if ((*cred_handle)->keytab != NULL)
|
|
||||||
krb5_kt_close(gssapi_krb5_context, (*cred_handle)->keytab);
|
|
||||||
if ((*cred_handle)->ccache != NULL) {
|
|
||||||
const krb5_cc_ops *ops;
|
|
||||||
ops = krb5_cc_get_ops(gssapi_krb5_context, (*cred_handle)->ccache);
|
|
||||||
if (ops == &krb5_mcc_ops)
|
|
||||||
krb5_cc_destroy(gssapi_krb5_context, (*cred_handle)->ccache);
|
|
||||||
else
|
|
||||||
krb5_cc_close(gssapi_krb5_context, (*cred_handle)->ccache);
|
|
||||||
}
|
|
||||||
gss_release_oid_set(NULL, &(*cred_handle)->mechanisms);
|
|
||||||
free(*cred_handle);
|
|
||||||
*cred_handle = GSS_C_NO_CREDENTIAL;
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
||||||
|
|
@ -1,50 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997 - 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: release_name.c,v 1.7 2003/03/16 17:52:48 lha Exp $");
|
|
||||||
|
|
||||||
OM_uint32 gss_release_name
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
gss_name_t * input_name
|
|
||||||
)
|
|
||||||
{
|
|
||||||
GSSAPI_KRB5_INIT ();
|
|
||||||
if (minor_status)
|
|
||||||
*minor_status = 0;
|
|
||||||
krb5_free_principal(gssapi_krb5_context,
|
|
||||||
*input_name);
|
|
||||||
*input_name = GSS_C_NO_NAME;
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997 - 2000, 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: release_oid_set.c,v 1.5 2003/03/16 17:53:25 lha Exp $");
|
|
||||||
|
|
||||||
OM_uint32 gss_release_oid_set
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
gss_OID_set * set
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (minor_status)
|
|
||||||
*minor_status = 0;
|
|
||||||
free ((*set)->elements);
|
|
||||||
free (*set);
|
|
||||||
*set = GSS_C_NO_OID_SET;
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997, 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: test_oid_set_member.c,v 1.5 2003/03/16 17:54:06 lha Exp $");
|
|
||||||
|
|
||||||
OM_uint32 gss_test_oid_set_member (
|
|
||||||
OM_uint32 * minor_status,
|
|
||||||
const gss_OID member,
|
|
||||||
const gss_OID_set set,
|
|
||||||
int * present
|
|
||||||
)
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
*minor_status = 0;
|
|
||||||
*present = 0;
|
|
||||||
for (i = 0; i < set->count; ++i)
|
|
||||||
if (gss_oid_equal(member, &set->elements[i]) != 0) {
|
|
||||||
*present = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
@ -1,422 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997 - 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: unwrap.c,v 1.22.2.1 2003/09/18 22:05:22 lha Exp $");
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
gss_krb5_get_remotekey(const gss_ctx_id_t context_handle,
|
|
||||||
krb5_keyblock **key)
|
|
||||||
{
|
|
||||||
krb5_keyblock *skey;
|
|
||||||
|
|
||||||
krb5_auth_con_getremotesubkey(gssapi_krb5_context,
|
|
||||||
context_handle->auth_context,
|
|
||||||
&skey);
|
|
||||||
if(skey == NULL)
|
|
||||||
krb5_auth_con_getlocalsubkey(gssapi_krb5_context,
|
|
||||||
context_handle->auth_context,
|
|
||||||
&skey);
|
|
||||||
if(skey == NULL)
|
|
||||||
krb5_auth_con_getkey(gssapi_krb5_context,
|
|
||||||
context_handle->auth_context,
|
|
||||||
&skey);
|
|
||||||
if(skey == NULL)
|
|
||||||
return GSS_KRB5_S_KG_NO_SUBKEY; /* XXX */
|
|
||||||
*key = skey;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static OM_uint32
|
|
||||||
unwrap_des
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
const gss_ctx_id_t context_handle,
|
|
||||||
const gss_buffer_t input_message_buffer,
|
|
||||||
gss_buffer_t output_message_buffer,
|
|
||||||
int * conf_state,
|
|
||||||
gss_qop_t * qop_state,
|
|
||||||
krb5_keyblock *key
|
|
||||||
)
|
|
||||||
{
|
|
||||||
u_char *p, *pad;
|
|
||||||
size_t len;
|
|
||||||
MD5_CTX md5;
|
|
||||||
u_char hash[16], seq_data[8];
|
|
||||||
des_key_schedule schedule;
|
|
||||||
des_cblock deskey;
|
|
||||||
des_cblock zero;
|
|
||||||
int i;
|
|
||||||
int32_t seq_number;
|
|
||||||
size_t padlength;
|
|
||||||
OM_uint32 ret;
|
|
||||||
int cstate;
|
|
||||||
|
|
||||||
p = input_message_buffer->value;
|
|
||||||
ret = gssapi_krb5_verify_header (&p,
|
|
||||||
input_message_buffer->length,
|
|
||||||
"\x02\x01");
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
if (memcmp (p, "\x00\x00", 2) != 0)
|
|
||||||
return GSS_S_BAD_SIG;
|
|
||||||
p += 2;
|
|
||||||
if (memcmp (p, "\x00\x00", 2) == 0) {
|
|
||||||
cstate = 1;
|
|
||||||
} else if (memcmp (p, "\xFF\xFF", 2) == 0) {
|
|
||||||
cstate = 0;
|
|
||||||
} else
|
|
||||||
return GSS_S_BAD_MIC;
|
|
||||||
p += 2;
|
|
||||||
if(conf_state != NULL)
|
|
||||||
*conf_state = cstate;
|
|
||||||
if (memcmp (p, "\xff\xff", 2) != 0)
|
|
||||||
return GSS_S_DEFECTIVE_TOKEN;
|
|
||||||
p += 2;
|
|
||||||
p += 16;
|
|
||||||
|
|
||||||
len = p - (u_char *)input_message_buffer->value;
|
|
||||||
|
|
||||||
if(cstate) {
|
|
||||||
/* decrypt data */
|
|
||||||
memcpy (&deskey, key->keyvalue.data, sizeof(deskey));
|
|
||||||
|
|
||||||
for (i = 0; i < sizeof(deskey); ++i)
|
|
||||||
deskey[i] ^= 0xf0;
|
|
||||||
des_set_key (&deskey, schedule);
|
|
||||||
memset (&zero, 0, sizeof(zero));
|
|
||||||
des_cbc_encrypt ((void *)p,
|
|
||||||
(void *)p,
|
|
||||||
input_message_buffer->length - len,
|
|
||||||
schedule,
|
|
||||||
&zero,
|
|
||||||
DES_DECRYPT);
|
|
||||||
|
|
||||||
memset (deskey, 0, sizeof(deskey));
|
|
||||||
memset (schedule, 0, sizeof(schedule));
|
|
||||||
}
|
|
||||||
/* check pad */
|
|
||||||
|
|
||||||
pad = (u_char *)input_message_buffer->value + input_message_buffer->length - 1;
|
|
||||||
padlength = *pad;
|
|
||||||
|
|
||||||
for (i = padlength; i > 0 && *pad == padlength; i--, pad--)
|
|
||||||
;
|
|
||||||
if (i != 0)
|
|
||||||
return GSS_S_BAD_MIC;
|
|
||||||
|
|
||||||
MD5_Init (&md5);
|
|
||||||
MD5_Update (&md5, p - 24, 8);
|
|
||||||
MD5_Update (&md5, p, input_message_buffer->length - len);
|
|
||||||
MD5_Final (hash, &md5);
|
|
||||||
|
|
||||||
memset (&zero, 0, sizeof(zero));
|
|
||||||
memcpy (&deskey, key->keyvalue.data, sizeof(deskey));
|
|
||||||
des_set_key (&deskey, schedule);
|
|
||||||
des_cbc_cksum ((void *)hash, (void *)hash, sizeof(hash),
|
|
||||||
schedule, &zero);
|
|
||||||
if (memcmp (p - 8, hash, 8) != 0)
|
|
||||||
return GSS_S_BAD_MIC;
|
|
||||||
|
|
||||||
/* verify sequence number */
|
|
||||||
|
|
||||||
krb5_auth_getremoteseqnumber (gssapi_krb5_context,
|
|
||||||
context_handle->auth_context,
|
|
||||||
&seq_number);
|
|
||||||
seq_data[0] = (seq_number >> 0) & 0xFF;
|
|
||||||
seq_data[1] = (seq_number >> 8) & 0xFF;
|
|
||||||
seq_data[2] = (seq_number >> 16) & 0xFF;
|
|
||||||
seq_data[3] = (seq_number >> 24) & 0xFF;
|
|
||||||
memset (seq_data + 4,
|
|
||||||
(context_handle->more_flags & LOCAL) ? 0xFF : 0,
|
|
||||||
4);
|
|
||||||
|
|
||||||
p -= 16;
|
|
||||||
des_set_key (&deskey, schedule);
|
|
||||||
des_cbc_encrypt ((void *)p, (void *)p, 8,
|
|
||||||
schedule, (des_cblock *)hash, DES_DECRYPT);
|
|
||||||
|
|
||||||
memset (deskey, 0, sizeof(deskey));
|
|
||||||
memset (schedule, 0, sizeof(schedule));
|
|
||||||
|
|
||||||
if (memcmp (p, seq_data, 8) != 0) {
|
|
||||||
return GSS_S_BAD_MIC;
|
|
||||||
}
|
|
||||||
|
|
||||||
krb5_auth_con_setremoteseqnumber (gssapi_krb5_context,
|
|
||||||
context_handle->auth_context,
|
|
||||||
++seq_number);
|
|
||||||
|
|
||||||
/* copy out data */
|
|
||||||
|
|
||||||
output_message_buffer->length = input_message_buffer->length
|
|
||||||
- len - padlength - 8;
|
|
||||||
output_message_buffer->value = malloc(output_message_buffer->length);
|
|
||||||
if(output_message_buffer->length != 0 && output_message_buffer->value == NULL)
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
memcpy (output_message_buffer->value,
|
|
||||||
p + 24,
|
|
||||||
output_message_buffer->length);
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static OM_uint32
|
|
||||||
unwrap_des3
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
const gss_ctx_id_t context_handle,
|
|
||||||
const gss_buffer_t input_message_buffer,
|
|
||||||
gss_buffer_t output_message_buffer,
|
|
||||||
int * conf_state,
|
|
||||||
gss_qop_t * qop_state,
|
|
||||||
krb5_keyblock *key
|
|
||||||
)
|
|
||||||
{
|
|
||||||
u_char *p, *pad;
|
|
||||||
size_t len;
|
|
||||||
u_char seq[8];
|
|
||||||
krb5_data seq_data;
|
|
||||||
u_char cksum[20];
|
|
||||||
int i;
|
|
||||||
int32_t seq_number;
|
|
||||||
size_t padlength;
|
|
||||||
OM_uint32 ret;
|
|
||||||
int cstate;
|
|
||||||
krb5_crypto crypto;
|
|
||||||
Checksum csum;
|
|
||||||
int cmp;
|
|
||||||
|
|
||||||
p = input_message_buffer->value;
|
|
||||||
ret = gssapi_krb5_verify_header (&p,
|
|
||||||
input_message_buffer->length,
|
|
||||||
"\x02\x01");
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
if (memcmp (p, "\x04\x00", 2) != 0) /* HMAC SHA1 DES3_KD */
|
|
||||||
return GSS_S_BAD_SIG;
|
|
||||||
p += 2;
|
|
||||||
if (memcmp (p, "\x02\x00", 2) == 0) {
|
|
||||||
cstate = 1;
|
|
||||||
} else if (memcmp (p, "\xff\xff", 2) == 0) {
|
|
||||||
cstate = 0;
|
|
||||||
} else
|
|
||||||
return GSS_S_BAD_MIC;
|
|
||||||
p += 2;
|
|
||||||
if(conf_state != NULL)
|
|
||||||
*conf_state = cstate;
|
|
||||||
if (memcmp (p, "\xff\xff", 2) != 0)
|
|
||||||
return GSS_S_DEFECTIVE_TOKEN;
|
|
||||||
p += 2;
|
|
||||||
p += 28;
|
|
||||||
|
|
||||||
len = p - (u_char *)input_message_buffer->value;
|
|
||||||
|
|
||||||
if(cstate) {
|
|
||||||
/* decrypt data */
|
|
||||||
krb5_data tmp;
|
|
||||||
|
|
||||||
ret = krb5_crypto_init(gssapi_krb5_context, key,
|
|
||||||
ETYPE_DES3_CBC_NONE, &crypto);
|
|
||||||
if (ret) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
*minor_status = ret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
ret = krb5_decrypt(gssapi_krb5_context, crypto, KRB5_KU_USAGE_SEAL,
|
|
||||||
p, input_message_buffer->length - len, &tmp);
|
|
||||||
krb5_crypto_destroy(gssapi_krb5_context, crypto);
|
|
||||||
if (ret) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
*minor_status = ret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
assert (tmp.length == input_message_buffer->length - len);
|
|
||||||
|
|
||||||
memcpy (p, tmp.data, tmp.length);
|
|
||||||
krb5_data_free(&tmp);
|
|
||||||
}
|
|
||||||
/* check pad */
|
|
||||||
|
|
||||||
pad = (u_char *)input_message_buffer->value + input_message_buffer->length - 1;
|
|
||||||
padlength = *pad;
|
|
||||||
|
|
||||||
for (i = padlength; i > 0 && *pad == padlength; i--, pad--)
|
|
||||||
;
|
|
||||||
if (i != 0)
|
|
||||||
return GSS_S_BAD_MIC;
|
|
||||||
|
|
||||||
/* verify sequence number */
|
|
||||||
|
|
||||||
krb5_auth_getremoteseqnumber (gssapi_krb5_context,
|
|
||||||
context_handle->auth_context,
|
|
||||||
&seq_number);
|
|
||||||
seq[0] = (seq_number >> 0) & 0xFF;
|
|
||||||
seq[1] = (seq_number >> 8) & 0xFF;
|
|
||||||
seq[2] = (seq_number >> 16) & 0xFF;
|
|
||||||
seq[3] = (seq_number >> 24) & 0xFF;
|
|
||||||
memset (seq + 4,
|
|
||||||
(context_handle->more_flags & LOCAL) ? 0xFF : 0,
|
|
||||||
4);
|
|
||||||
|
|
||||||
p -= 28;
|
|
||||||
|
|
||||||
ret = krb5_crypto_init(gssapi_krb5_context, key,
|
|
||||||
ETYPE_DES3_CBC_NONE, &crypto);
|
|
||||||
if (ret) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
*minor_status = ret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
des_cblock ivec;
|
|
||||||
|
|
||||||
memcpy(&ivec, p + 8, 8);
|
|
||||||
ret = krb5_decrypt_ivec (gssapi_krb5_context,
|
|
||||||
crypto,
|
|
||||||
KRB5_KU_USAGE_SEQ,
|
|
||||||
p, 8, &seq_data,
|
|
||||||
&ivec);
|
|
||||||
}
|
|
||||||
krb5_crypto_destroy (gssapi_krb5_context, crypto);
|
|
||||||
if (ret) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
*minor_status = ret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
if (seq_data.length != 8) {
|
|
||||||
krb5_data_free (&seq_data);
|
|
||||||
return GSS_S_BAD_MIC;
|
|
||||||
}
|
|
||||||
|
|
||||||
cmp = memcmp (seq, seq_data.data, seq_data.length);
|
|
||||||
krb5_data_free (&seq_data);
|
|
||||||
if (cmp != 0) {
|
|
||||||
return GSS_S_BAD_MIC;
|
|
||||||
}
|
|
||||||
|
|
||||||
krb5_auth_con_setremoteseqnumber (gssapi_krb5_context,
|
|
||||||
context_handle->auth_context,
|
|
||||||
++seq_number);
|
|
||||||
|
|
||||||
/* verify checksum */
|
|
||||||
|
|
||||||
memcpy (cksum, p + 8, 20);
|
|
||||||
|
|
||||||
memcpy (p + 20, p - 8, 8);
|
|
||||||
|
|
||||||
csum.cksumtype = CKSUMTYPE_HMAC_SHA1_DES3;
|
|
||||||
csum.checksum.length = 20;
|
|
||||||
csum.checksum.data = cksum;
|
|
||||||
|
|
||||||
ret = krb5_crypto_init(gssapi_krb5_context, key, 0, &crypto);
|
|
||||||
if (ret) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
*minor_status = ret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = krb5_verify_checksum (gssapi_krb5_context, crypto,
|
|
||||||
KRB5_KU_USAGE_SIGN,
|
|
||||||
p + 20,
|
|
||||||
input_message_buffer->length - len + 8,
|
|
||||||
&csum);
|
|
||||||
krb5_crypto_destroy (gssapi_krb5_context, crypto);
|
|
||||||
if (ret) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
*minor_status = ret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* copy out data */
|
|
||||||
|
|
||||||
output_message_buffer->length = input_message_buffer->length
|
|
||||||
- len - padlength - 8;
|
|
||||||
output_message_buffer->value = malloc(output_message_buffer->length);
|
|
||||||
if(output_message_buffer->length != 0 && output_message_buffer->value == NULL)
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
memcpy (output_message_buffer->value,
|
|
||||||
p + 36,
|
|
||||||
output_message_buffer->length);
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
||||||
|
|
||||||
OM_uint32 gss_unwrap
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
const gss_ctx_id_t context_handle,
|
|
||||||
const gss_buffer_t input_message_buffer,
|
|
||||||
gss_buffer_t output_message_buffer,
|
|
||||||
int * conf_state,
|
|
||||||
gss_qop_t * qop_state
|
|
||||||
)
|
|
||||||
{
|
|
||||||
krb5_keyblock *key;
|
|
||||||
OM_uint32 ret;
|
|
||||||
krb5_keytype keytype;
|
|
||||||
|
|
||||||
if (qop_state != NULL)
|
|
||||||
*qop_state = GSS_C_QOP_DEFAULT;
|
|
||||||
ret = gss_krb5_get_remotekey(context_handle, &key);
|
|
||||||
if (ret) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
*minor_status = ret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
krb5_enctype_to_keytype (gssapi_krb5_context, key->keytype, &keytype);
|
|
||||||
|
|
||||||
*minor_status = 0;
|
|
||||||
|
|
||||||
switch (keytype) {
|
|
||||||
case KEYTYPE_DES :
|
|
||||||
ret = unwrap_des (minor_status, context_handle,
|
|
||||||
input_message_buffer, output_message_buffer,
|
|
||||||
conf_state, qop_state, key);
|
|
||||||
break;
|
|
||||||
case KEYTYPE_DES3 :
|
|
||||||
ret = unwrap_des3 (minor_status, context_handle,
|
|
||||||
input_message_buffer, output_message_buffer,
|
|
||||||
conf_state, qop_state, key);
|
|
||||||
break;
|
|
||||||
case KEYTYPE_ARCFOUR:
|
|
||||||
ret = _gssapi_unwrap_arcfour (minor_status, context_handle,
|
|
||||||
input_message_buffer, output_message_buffer,
|
|
||||||
conf_state, qop_state, key);
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
*minor_status = KRB5_PROG_ETYPE_NOSUPP;
|
|
||||||
ret = GSS_S_FAILURE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
krb5_free_keyblock (gssapi_krb5_context, key);
|
|
||||||
return ret;
|
|
||||||
}
|
|
104
lib/gssapi/v1.c
104
lib/gssapi/v1.c
@ -1,104 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: v1.c,v 1.2 1999/12/02 17:05:04 joda Exp $");
|
|
||||||
|
|
||||||
/* These functions are for V1 compatibility */
|
|
||||||
|
|
||||||
OM_uint32 gss_sign
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
gss_ctx_id_t context_handle,
|
|
||||||
int qop_req,
|
|
||||||
gss_buffer_t message_buffer,
|
|
||||||
gss_buffer_t message_token
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return gss_get_mic(minor_status,
|
|
||||||
context_handle,
|
|
||||||
(gss_qop_t)qop_req,
|
|
||||||
message_buffer,
|
|
||||||
message_token);
|
|
||||||
}
|
|
||||||
|
|
||||||
OM_uint32 gss_verify
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
gss_ctx_id_t context_handle,
|
|
||||||
gss_buffer_t message_buffer,
|
|
||||||
gss_buffer_t token_buffer,
|
|
||||||
int * qop_state
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return gss_verify_mic(minor_status,
|
|
||||||
context_handle,
|
|
||||||
message_buffer,
|
|
||||||
token_buffer,
|
|
||||||
(gss_qop_t *)qop_state);
|
|
||||||
}
|
|
||||||
|
|
||||||
OM_uint32 gss_seal
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
gss_ctx_id_t context_handle,
|
|
||||||
int conf_req_flag,
|
|
||||||
int qop_req,
|
|
||||||
gss_buffer_t input_message_buffer,
|
|
||||||
int * conf_state,
|
|
||||||
gss_buffer_t output_message_buffer
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return gss_wrap(minor_status,
|
|
||||||
context_handle,
|
|
||||||
conf_req_flag,
|
|
||||||
(gss_qop_t)qop_req,
|
|
||||||
input_message_buffer,
|
|
||||||
conf_state,
|
|
||||||
output_message_buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
OM_uint32 gss_unseal
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
gss_ctx_id_t context_handle,
|
|
||||||
gss_buffer_t input_message_buffer,
|
|
||||||
gss_buffer_t output_message_buffer,
|
|
||||||
int * conf_state,
|
|
||||||
int * qop_state
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return gss_unwrap(minor_status,
|
|
||||||
context_handle,
|
|
||||||
input_message_buffer,
|
|
||||||
output_message_buffer,
|
|
||||||
conf_state,
|
|
||||||
(gss_qop_t *)qop_state);
|
|
||||||
}
|
|
@ -1,322 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997 - 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: verify_mic.c,v 1.18.2.4 2003/09/18 22:05:34 lha Exp $");
|
|
||||||
|
|
||||||
static OM_uint32
|
|
||||||
verify_mic_des
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
const gss_ctx_id_t context_handle,
|
|
||||||
const gss_buffer_t message_buffer,
|
|
||||||
const gss_buffer_t token_buffer,
|
|
||||||
gss_qop_t * qop_state,
|
|
||||||
krb5_keyblock *key,
|
|
||||||
char *type
|
|
||||||
)
|
|
||||||
{
|
|
||||||
u_char *p;
|
|
||||||
MD5_CTX md5;
|
|
||||||
u_char hash[16], seq_data[8];
|
|
||||||
des_key_schedule schedule;
|
|
||||||
des_cblock zero;
|
|
||||||
des_cblock deskey;
|
|
||||||
int32_t seq_number;
|
|
||||||
OM_uint32 ret;
|
|
||||||
|
|
||||||
p = token_buffer->value;
|
|
||||||
ret = gssapi_krb5_verify_header (&p,
|
|
||||||
token_buffer->length,
|
|
||||||
type);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
if (memcmp(p, "\x00\x00", 2) != 0)
|
|
||||||
return GSS_S_BAD_SIG;
|
|
||||||
p += 2;
|
|
||||||
if (memcmp (p, "\xff\xff\xff\xff", 4) != 0)
|
|
||||||
return GSS_S_BAD_MIC;
|
|
||||||
p += 4;
|
|
||||||
p += 16;
|
|
||||||
|
|
||||||
/* verify checksum */
|
|
||||||
MD5_Init (&md5);
|
|
||||||
MD5_Update (&md5, p - 24, 8);
|
|
||||||
MD5_Update (&md5, message_buffer->value,
|
|
||||||
message_buffer->length);
|
|
||||||
MD5_Final (hash, &md5);
|
|
||||||
|
|
||||||
memset (&zero, 0, sizeof(zero));
|
|
||||||
memcpy (&deskey, key->keyvalue.data, sizeof(deskey));
|
|
||||||
|
|
||||||
des_set_key (&deskey, schedule);
|
|
||||||
des_cbc_cksum ((void *)hash, (void *)hash, sizeof(hash),
|
|
||||||
schedule, &zero);
|
|
||||||
if (memcmp (p - 8, hash, 8) != 0) {
|
|
||||||
memset (deskey, 0, sizeof(deskey));
|
|
||||||
memset (schedule, 0, sizeof(schedule));
|
|
||||||
return GSS_S_BAD_MIC;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* verify sequence number */
|
|
||||||
|
|
||||||
krb5_auth_getremoteseqnumber (gssapi_krb5_context,
|
|
||||||
context_handle->auth_context,
|
|
||||||
&seq_number);
|
|
||||||
seq_data[0] = (seq_number >> 0) & 0xFF;
|
|
||||||
seq_data[1] = (seq_number >> 8) & 0xFF;
|
|
||||||
seq_data[2] = (seq_number >> 16) & 0xFF;
|
|
||||||
seq_data[3] = (seq_number >> 24) & 0xFF;
|
|
||||||
memset (seq_data + 4,
|
|
||||||
(context_handle->more_flags & LOCAL) ? 0xFF : 0,
|
|
||||||
4);
|
|
||||||
|
|
||||||
p -= 16;
|
|
||||||
des_set_key (&deskey, schedule);
|
|
||||||
des_cbc_encrypt ((void *)p, (void *)p, 8,
|
|
||||||
schedule, (des_cblock *)hash, DES_DECRYPT);
|
|
||||||
|
|
||||||
memset (deskey, 0, sizeof(deskey));
|
|
||||||
memset (schedule, 0, sizeof(schedule));
|
|
||||||
|
|
||||||
if (memcmp (p, seq_data, 8) != 0) {
|
|
||||||
return GSS_S_BAD_MIC;
|
|
||||||
}
|
|
||||||
|
|
||||||
krb5_auth_con_setremoteseqnumber (gssapi_krb5_context,
|
|
||||||
context_handle->auth_context,
|
|
||||||
++seq_number);
|
|
||||||
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static OM_uint32
|
|
||||||
verify_mic_des3
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
const gss_ctx_id_t context_handle,
|
|
||||||
const gss_buffer_t message_buffer,
|
|
||||||
const gss_buffer_t token_buffer,
|
|
||||||
gss_qop_t * qop_state,
|
|
||||||
krb5_keyblock *key,
|
|
||||||
char *type
|
|
||||||
)
|
|
||||||
{
|
|
||||||
u_char *p;
|
|
||||||
u_char seq[8];
|
|
||||||
int32_t seq_number;
|
|
||||||
OM_uint32 ret;
|
|
||||||
krb5_crypto crypto;
|
|
||||||
krb5_data seq_data;
|
|
||||||
int cmp, docompat;
|
|
||||||
Checksum csum;
|
|
||||||
char *tmp;
|
|
||||||
char ivec[8];
|
|
||||||
|
|
||||||
p = token_buffer->value;
|
|
||||||
ret = gssapi_krb5_verify_header (&p,
|
|
||||||
token_buffer->length,
|
|
||||||
type);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
if (memcmp(p, "\x04\x00", 2) != 0) /* SGN_ALG = HMAC SHA1 DES3-KD */
|
|
||||||
return GSS_S_BAD_SIG;
|
|
||||||
p += 2;
|
|
||||||
if (memcmp (p, "\xff\xff\xff\xff", 4) != 0)
|
|
||||||
return GSS_S_BAD_MIC;
|
|
||||||
p += 4;
|
|
||||||
|
|
||||||
ret = krb5_crypto_init(gssapi_krb5_context, key,
|
|
||||||
ETYPE_DES3_CBC_NONE, &crypto);
|
|
||||||
if (ret){
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
*minor_status = ret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* verify sequence number */
|
|
||||||
docompat = 0;
|
|
||||||
retry:
|
|
||||||
if (docompat)
|
|
||||||
memset(ivec, 0, 8);
|
|
||||||
else
|
|
||||||
memcpy(ivec, p + 8, 8);
|
|
||||||
|
|
||||||
ret = krb5_decrypt_ivec (gssapi_krb5_context,
|
|
||||||
crypto,
|
|
||||||
KRB5_KU_USAGE_SEQ,
|
|
||||||
p, 8, &seq_data, ivec);
|
|
||||||
if (ret) {
|
|
||||||
if (docompat++) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
krb5_crypto_destroy (gssapi_krb5_context, crypto);
|
|
||||||
*minor_status = ret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
} else
|
|
||||||
goto retry;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (seq_data.length != 8) {
|
|
||||||
krb5_data_free (&seq_data);
|
|
||||||
if (docompat++) {
|
|
||||||
krb5_crypto_destroy (gssapi_krb5_context, crypto);
|
|
||||||
return GSS_S_BAD_MIC;
|
|
||||||
} else
|
|
||||||
goto retry;
|
|
||||||
}
|
|
||||||
|
|
||||||
krb5_auth_getremoteseqnumber (gssapi_krb5_context,
|
|
||||||
context_handle->auth_context,
|
|
||||||
&seq_number);
|
|
||||||
seq[0] = (seq_number >> 0) & 0xFF;
|
|
||||||
seq[1] = (seq_number >> 8) & 0xFF;
|
|
||||||
seq[2] = (seq_number >> 16) & 0xFF;
|
|
||||||
seq[3] = (seq_number >> 24) & 0xFF;
|
|
||||||
memset (seq + 4,
|
|
||||||
(context_handle->more_flags & LOCAL) ? 0xFF : 0,
|
|
||||||
4);
|
|
||||||
cmp = memcmp (seq, seq_data.data, seq_data.length);
|
|
||||||
krb5_data_free (&seq_data);
|
|
||||||
if (cmp != 0) {
|
|
||||||
if (docompat++) {
|
|
||||||
krb5_crypto_destroy (gssapi_krb5_context, crypto);
|
|
||||||
return GSS_S_BAD_MIC;
|
|
||||||
} else
|
|
||||||
goto retry;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* verify checksum */
|
|
||||||
|
|
||||||
tmp = malloc (message_buffer->length + 8);
|
|
||||||
if (tmp == NULL) {
|
|
||||||
krb5_crypto_destroy (gssapi_krb5_context, crypto);
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy (tmp, p - 8, 8);
|
|
||||||
memcpy (tmp + 8, message_buffer->value, message_buffer->length);
|
|
||||||
|
|
||||||
csum.cksumtype = CKSUMTYPE_HMAC_SHA1_DES3;
|
|
||||||
csum.checksum.length = 20;
|
|
||||||
csum.checksum.data = p + 8;
|
|
||||||
|
|
||||||
ret = krb5_verify_checksum (gssapi_krb5_context, crypto,
|
|
||||||
KRB5_KU_USAGE_SIGN,
|
|
||||||
tmp, message_buffer->length + 8,
|
|
||||||
&csum);
|
|
||||||
free (tmp);
|
|
||||||
if (ret) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
krb5_crypto_destroy (gssapi_krb5_context, crypto);
|
|
||||||
*minor_status = ret;
|
|
||||||
return GSS_S_BAD_MIC;
|
|
||||||
}
|
|
||||||
|
|
||||||
krb5_auth_con_setremoteseqnumber (gssapi_krb5_context,
|
|
||||||
context_handle->auth_context,
|
|
||||||
++seq_number);
|
|
||||||
|
|
||||||
krb5_crypto_destroy (gssapi_krb5_context, crypto);
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
gss_verify_mic_internal
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
const gss_ctx_id_t context_handle,
|
|
||||||
const gss_buffer_t message_buffer,
|
|
||||||
const gss_buffer_t token_buffer,
|
|
||||||
gss_qop_t * qop_state,
|
|
||||||
char * type
|
|
||||||
)
|
|
||||||
{
|
|
||||||
krb5_keyblock *key;
|
|
||||||
OM_uint32 ret;
|
|
||||||
krb5_keytype keytype;
|
|
||||||
|
|
||||||
ret = gss_krb5_get_remotekey(context_handle, &key);
|
|
||||||
if (ret) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
*minor_status = ret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
*minor_status = 0;
|
|
||||||
krb5_enctype_to_keytype (gssapi_krb5_context, key->keytype, &keytype);
|
|
||||||
switch (keytype) {
|
|
||||||
case KEYTYPE_DES :
|
|
||||||
ret = verify_mic_des (minor_status, context_handle,
|
|
||||||
message_buffer, token_buffer, qop_state, key,
|
|
||||||
type);
|
|
||||||
break;
|
|
||||||
case KEYTYPE_DES3 :
|
|
||||||
ret = verify_mic_des3 (minor_status, context_handle,
|
|
||||||
message_buffer, token_buffer, qop_state, key,
|
|
||||||
type);
|
|
||||||
break;
|
|
||||||
case KEYTYPE_ARCFOUR :
|
|
||||||
ret = _gssapi_verify_mic_arcfour (minor_status, context_handle,
|
|
||||||
message_buffer, token_buffer,
|
|
||||||
qop_state, key, type);
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
*minor_status = KRB5_PROG_ETYPE_NOSUPP;
|
|
||||||
ret = GSS_S_FAILURE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
krb5_free_keyblock (gssapi_krb5_context, key);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
gss_verify_mic
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
const gss_ctx_id_t context_handle,
|
|
||||||
const gss_buffer_t message_buffer,
|
|
||||||
const gss_buffer_t token_buffer,
|
|
||||||
gss_qop_t * qop_state
|
|
||||||
)
|
|
||||||
{
|
|
||||||
OM_uint32 ret;
|
|
||||||
|
|
||||||
if (qop_state != NULL)
|
|
||||||
*qop_state = GSS_C_QOP_DEFAULT;
|
|
||||||
|
|
||||||
ret = gss_verify_mic_internal(minor_status, context_handle,
|
|
||||||
message_buffer, token_buffer,
|
|
||||||
qop_state, "\x01\x01");
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
@ -1,454 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997 - 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gssapi_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: wrap.c,v 1.21.2.1 2003/09/18 22:05:45 lha Exp $");
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
gss_krb5_get_localkey(const gss_ctx_id_t context_handle,
|
|
||||||
krb5_keyblock **key)
|
|
||||||
{
|
|
||||||
krb5_keyblock *skey;
|
|
||||||
|
|
||||||
krb5_auth_con_getlocalsubkey(gssapi_krb5_context,
|
|
||||||
context_handle->auth_context,
|
|
||||||
&skey);
|
|
||||||
if(skey == NULL)
|
|
||||||
krb5_auth_con_getremotesubkey(gssapi_krb5_context,
|
|
||||||
context_handle->auth_context,
|
|
||||||
&skey);
|
|
||||||
if(skey == NULL)
|
|
||||||
krb5_auth_con_getkey(gssapi_krb5_context,
|
|
||||||
context_handle->auth_context,
|
|
||||||
&skey);
|
|
||||||
if(skey == NULL)
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
*key = skey;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static OM_uint32
|
|
||||||
sub_wrap_size (
|
|
||||||
OM_uint32 req_output_size,
|
|
||||||
OM_uint32 * max_input_size,
|
|
||||||
int blocksize,
|
|
||||||
int extrasize
|
|
||||||
)
|
|
||||||
{
|
|
||||||
size_t len, total_len, padlength;
|
|
||||||
padlength = blocksize - (req_output_size % blocksize);
|
|
||||||
len = req_output_size + 8 + padlength + extrasize;
|
|
||||||
gssapi_krb5_encap_length(len, &len, &total_len);
|
|
||||||
*max_input_size = (OM_uint32)total_len;
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
||||||
|
|
||||||
OM_uint32
|
|
||||||
gss_wrap_size_limit (
|
|
||||||
OM_uint32 * minor_status,
|
|
||||||
const gss_ctx_id_t context_handle,
|
|
||||||
int conf_req_flag,
|
|
||||||
gss_qop_t qop_req,
|
|
||||||
OM_uint32 req_output_size,
|
|
||||||
OM_uint32 * max_input_size
|
|
||||||
)
|
|
||||||
{
|
|
||||||
krb5_keyblock *key;
|
|
||||||
OM_uint32 ret;
|
|
||||||
krb5_keytype keytype;
|
|
||||||
|
|
||||||
ret = gss_krb5_get_localkey(context_handle, &key);
|
|
||||||
if (ret) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
*minor_status = ret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
krb5_enctype_to_keytype (gssapi_krb5_context, key->keytype, &keytype);
|
|
||||||
|
|
||||||
switch (keytype) {
|
|
||||||
case KEYTYPE_DES :
|
|
||||||
case KEYTYPE_ARCFOUR:
|
|
||||||
ret = sub_wrap_size(req_output_size, max_input_size, 8, 22);
|
|
||||||
break;
|
|
||||||
case KEYTYPE_DES3 :
|
|
||||||
ret = sub_wrap_size(req_output_size, max_input_size, 8, 34);
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
*minor_status = KRB5_PROG_ETYPE_NOSUPP;
|
|
||||||
ret = GSS_S_FAILURE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
krb5_free_keyblock (gssapi_krb5_context, key);
|
|
||||||
*minor_status = 0;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static OM_uint32
|
|
||||||
wrap_des
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
const gss_ctx_id_t context_handle,
|
|
||||||
int conf_req_flag,
|
|
||||||
gss_qop_t qop_req,
|
|
||||||
const gss_buffer_t input_message_buffer,
|
|
||||||
int * conf_state,
|
|
||||||
gss_buffer_t output_message_buffer,
|
|
||||||
krb5_keyblock *key
|
|
||||||
)
|
|
||||||
{
|
|
||||||
u_char *p;
|
|
||||||
MD5_CTX md5;
|
|
||||||
u_char hash[16];
|
|
||||||
des_key_schedule schedule;
|
|
||||||
des_cblock deskey;
|
|
||||||
des_cblock zero;
|
|
||||||
int i;
|
|
||||||
int32_t seq_number;
|
|
||||||
size_t len, total_len, padlength, datalen;
|
|
||||||
|
|
||||||
padlength = 8 - (input_message_buffer->length % 8);
|
|
||||||
datalen = input_message_buffer->length + padlength + 8;
|
|
||||||
len = datalen + 22;
|
|
||||||
gssapi_krb5_encap_length (len, &len, &total_len);
|
|
||||||
|
|
||||||
output_message_buffer->length = total_len;
|
|
||||||
output_message_buffer->value = malloc (total_len);
|
|
||||||
if (output_message_buffer->value == NULL) {
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
p = gssapi_krb5_make_header(output_message_buffer->value,
|
|
||||||
len,
|
|
||||||
"\x02\x01"); /* TOK_ID */
|
|
||||||
|
|
||||||
/* SGN_ALG */
|
|
||||||
memcpy (p, "\x00\x00", 2);
|
|
||||||
p += 2;
|
|
||||||
/* SEAL_ALG */
|
|
||||||
if(conf_req_flag)
|
|
||||||
memcpy (p, "\x00\x00", 2);
|
|
||||||
else
|
|
||||||
memcpy (p, "\xff\xff", 2);
|
|
||||||
p += 2;
|
|
||||||
/* Filler */
|
|
||||||
memcpy (p, "\xff\xff", 2);
|
|
||||||
p += 2;
|
|
||||||
|
|
||||||
/* fill in later */
|
|
||||||
memset (p, 0, 16);
|
|
||||||
p += 16;
|
|
||||||
|
|
||||||
/* confounder + data + pad */
|
|
||||||
krb5_generate_random_block(p, 8);
|
|
||||||
memcpy (p + 8, input_message_buffer->value,
|
|
||||||
input_message_buffer->length);
|
|
||||||
memset (p + 8 + input_message_buffer->length, padlength, padlength);
|
|
||||||
|
|
||||||
/* checksum */
|
|
||||||
MD5_Init (&md5);
|
|
||||||
MD5_Update (&md5, p - 24, 8);
|
|
||||||
MD5_Update (&md5, p, datalen);
|
|
||||||
MD5_Final (hash, &md5);
|
|
||||||
|
|
||||||
memset (&zero, 0, sizeof(zero));
|
|
||||||
memcpy (&deskey, key->keyvalue.data, sizeof(deskey));
|
|
||||||
des_set_key (&deskey, schedule);
|
|
||||||
des_cbc_cksum ((void *)hash, (void *)hash, sizeof(hash),
|
|
||||||
schedule, &zero);
|
|
||||||
memcpy (p - 8, hash, 8);
|
|
||||||
|
|
||||||
/* sequence number */
|
|
||||||
krb5_auth_con_getlocalseqnumber (gssapi_krb5_context,
|
|
||||||
context_handle->auth_context,
|
|
||||||
&seq_number);
|
|
||||||
|
|
||||||
p -= 16;
|
|
||||||
p[0] = (seq_number >> 0) & 0xFF;
|
|
||||||
p[1] = (seq_number >> 8) & 0xFF;
|
|
||||||
p[2] = (seq_number >> 16) & 0xFF;
|
|
||||||
p[3] = (seq_number >> 24) & 0xFF;
|
|
||||||
memset (p + 4,
|
|
||||||
(context_handle->more_flags & LOCAL) ? 0 : 0xFF,
|
|
||||||
4);
|
|
||||||
|
|
||||||
des_set_key (&deskey, schedule);
|
|
||||||
des_cbc_encrypt ((void *)p, (void *)p, 8,
|
|
||||||
schedule, (des_cblock *)(p + 8), DES_ENCRYPT);
|
|
||||||
|
|
||||||
krb5_auth_con_setlocalseqnumber (gssapi_krb5_context,
|
|
||||||
context_handle->auth_context,
|
|
||||||
++seq_number);
|
|
||||||
|
|
||||||
/* encrypt the data */
|
|
||||||
p += 16;
|
|
||||||
|
|
||||||
if(conf_req_flag) {
|
|
||||||
memcpy (&deskey, key->keyvalue.data, sizeof(deskey));
|
|
||||||
|
|
||||||
for (i = 0; i < sizeof(deskey); ++i)
|
|
||||||
deskey[i] ^= 0xf0;
|
|
||||||
des_set_key (&deskey, schedule);
|
|
||||||
memset (&zero, 0, sizeof(zero));
|
|
||||||
des_cbc_encrypt ((void *)p,
|
|
||||||
(void *)p,
|
|
||||||
datalen,
|
|
||||||
schedule,
|
|
||||||
&zero,
|
|
||||||
DES_ENCRYPT);
|
|
||||||
|
|
||||||
memset (deskey, 0, sizeof(deskey));
|
|
||||||
memset (schedule, 0, sizeof(schedule));
|
|
||||||
}
|
|
||||||
if(conf_state != NULL)
|
|
||||||
*conf_state = conf_req_flag;
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static OM_uint32
|
|
||||||
wrap_des3
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
const gss_ctx_id_t context_handle,
|
|
||||||
int conf_req_flag,
|
|
||||||
gss_qop_t qop_req,
|
|
||||||
const gss_buffer_t input_message_buffer,
|
|
||||||
int * conf_state,
|
|
||||||
gss_buffer_t output_message_buffer,
|
|
||||||
krb5_keyblock *key
|
|
||||||
)
|
|
||||||
{
|
|
||||||
u_char *p;
|
|
||||||
u_char seq[8];
|
|
||||||
int32_t seq_number;
|
|
||||||
size_t len, total_len, padlength, datalen;
|
|
||||||
u_int32_t ret;
|
|
||||||
krb5_crypto crypto;
|
|
||||||
Checksum cksum;
|
|
||||||
krb5_data encdata;
|
|
||||||
|
|
||||||
padlength = 8 - (input_message_buffer->length % 8);
|
|
||||||
datalen = input_message_buffer->length + padlength + 8;
|
|
||||||
len = datalen + 34;
|
|
||||||
gssapi_krb5_encap_length (len, &len, &total_len);
|
|
||||||
|
|
||||||
output_message_buffer->length = total_len;
|
|
||||||
output_message_buffer->value = malloc (total_len);
|
|
||||||
if (output_message_buffer->value == NULL) {
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
p = gssapi_krb5_make_header(output_message_buffer->value,
|
|
||||||
len,
|
|
||||||
"\x02\x01"); /* TOK_ID */
|
|
||||||
|
|
||||||
/* SGN_ALG */
|
|
||||||
memcpy (p, "\x04\x00", 2); /* HMAC SHA1 DES3-KD */
|
|
||||||
p += 2;
|
|
||||||
/* SEAL_ALG */
|
|
||||||
if(conf_req_flag)
|
|
||||||
memcpy (p, "\x02\x00", 2); /* DES3-KD */
|
|
||||||
else
|
|
||||||
memcpy (p, "\xff\xff", 2);
|
|
||||||
p += 2;
|
|
||||||
/* Filler */
|
|
||||||
memcpy (p, "\xff\xff", 2);
|
|
||||||
p += 2;
|
|
||||||
|
|
||||||
/* calculate checksum (the above + confounder + data + pad) */
|
|
||||||
|
|
||||||
memcpy (p + 20, p - 8, 8);
|
|
||||||
krb5_generate_random_block(p + 28, 8);
|
|
||||||
memcpy (p + 28 + 8, input_message_buffer->value,
|
|
||||||
input_message_buffer->length);
|
|
||||||
memset (p + 28 + 8 + input_message_buffer->length, padlength, padlength);
|
|
||||||
|
|
||||||
ret = krb5_crypto_init(gssapi_krb5_context, key, 0, &crypto);
|
|
||||||
if (ret) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
free (output_message_buffer->value);
|
|
||||||
*minor_status = ret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = krb5_create_checksum (gssapi_krb5_context,
|
|
||||||
crypto,
|
|
||||||
KRB5_KU_USAGE_SIGN,
|
|
||||||
0,
|
|
||||||
p + 20,
|
|
||||||
datalen + 8,
|
|
||||||
&cksum);
|
|
||||||
krb5_crypto_destroy (gssapi_krb5_context, crypto);
|
|
||||||
if (ret) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
free (output_message_buffer->value);
|
|
||||||
*minor_status = ret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* zero out SND_SEQ + SGN_CKSUM in case */
|
|
||||||
memset (p, 0, 28);
|
|
||||||
|
|
||||||
memcpy (p + 8, cksum.checksum.data, cksum.checksum.length);
|
|
||||||
free_Checksum (&cksum);
|
|
||||||
|
|
||||||
/* sequence number */
|
|
||||||
krb5_auth_con_getlocalseqnumber (gssapi_krb5_context,
|
|
||||||
context_handle->auth_context,
|
|
||||||
&seq_number);
|
|
||||||
|
|
||||||
seq[0] = (seq_number >> 0) & 0xFF;
|
|
||||||
seq[1] = (seq_number >> 8) & 0xFF;
|
|
||||||
seq[2] = (seq_number >> 16) & 0xFF;
|
|
||||||
seq[3] = (seq_number >> 24) & 0xFF;
|
|
||||||
memset (seq + 4,
|
|
||||||
(context_handle->more_flags & LOCAL) ? 0 : 0xFF,
|
|
||||||
4);
|
|
||||||
|
|
||||||
|
|
||||||
ret = krb5_crypto_init(gssapi_krb5_context, key, ETYPE_DES3_CBC_NONE,
|
|
||||||
&crypto);
|
|
||||||
if (ret) {
|
|
||||||
free (output_message_buffer->value);
|
|
||||||
*minor_status = ret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
des_cblock ivec;
|
|
||||||
|
|
||||||
memcpy (&ivec, p + 8, 8);
|
|
||||||
ret = krb5_encrypt_ivec (gssapi_krb5_context,
|
|
||||||
crypto,
|
|
||||||
KRB5_KU_USAGE_SEQ,
|
|
||||||
seq, 8, &encdata,
|
|
||||||
&ivec);
|
|
||||||
}
|
|
||||||
krb5_crypto_destroy (gssapi_krb5_context, crypto);
|
|
||||||
if (ret) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
free (output_message_buffer->value);
|
|
||||||
*minor_status = ret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
assert (encdata.length == 8);
|
|
||||||
|
|
||||||
memcpy (p, encdata.data, encdata.length);
|
|
||||||
krb5_data_free (&encdata);
|
|
||||||
|
|
||||||
krb5_auth_con_setlocalseqnumber (gssapi_krb5_context,
|
|
||||||
context_handle->auth_context,
|
|
||||||
++seq_number);
|
|
||||||
|
|
||||||
/* encrypt the data */
|
|
||||||
p += 28;
|
|
||||||
|
|
||||||
if(conf_req_flag) {
|
|
||||||
krb5_data tmp;
|
|
||||||
|
|
||||||
ret = krb5_crypto_init(gssapi_krb5_context, key,
|
|
||||||
ETYPE_DES3_CBC_NONE, &crypto);
|
|
||||||
if (ret) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
free (output_message_buffer->value);
|
|
||||||
*minor_status = ret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
ret = krb5_encrypt(gssapi_krb5_context, crypto, KRB5_KU_USAGE_SEAL,
|
|
||||||
p, datalen, &tmp);
|
|
||||||
krb5_crypto_destroy(gssapi_krb5_context, crypto);
|
|
||||||
if (ret) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
free (output_message_buffer->value);
|
|
||||||
*minor_status = ret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
assert (tmp.length == datalen);
|
|
||||||
|
|
||||||
memcpy (p, tmp.data, datalen);
|
|
||||||
krb5_data_free(&tmp);
|
|
||||||
}
|
|
||||||
if(conf_state != NULL)
|
|
||||||
*conf_state = conf_req_flag;
|
|
||||||
*minor_status = 0;
|
|
||||||
return GSS_S_COMPLETE;
|
|
||||||
}
|
|
||||||
|
|
||||||
OM_uint32 gss_wrap
|
|
||||||
(OM_uint32 * minor_status,
|
|
||||||
const gss_ctx_id_t context_handle,
|
|
||||||
int conf_req_flag,
|
|
||||||
gss_qop_t qop_req,
|
|
||||||
const gss_buffer_t input_message_buffer,
|
|
||||||
int * conf_state,
|
|
||||||
gss_buffer_t output_message_buffer
|
|
||||||
)
|
|
||||||
{
|
|
||||||
krb5_keyblock *key;
|
|
||||||
OM_uint32 ret;
|
|
||||||
krb5_keytype keytype;
|
|
||||||
|
|
||||||
ret = gss_krb5_get_localkey(context_handle, &key);
|
|
||||||
if (ret) {
|
|
||||||
gssapi_krb5_set_error_string ();
|
|
||||||
*minor_status = ret;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
krb5_enctype_to_keytype (gssapi_krb5_context, key->keytype, &keytype);
|
|
||||||
|
|
||||||
switch (keytype) {
|
|
||||||
case KEYTYPE_DES :
|
|
||||||
ret = wrap_des (minor_status, context_handle, conf_req_flag,
|
|
||||||
qop_req, input_message_buffer, conf_state,
|
|
||||||
output_message_buffer, key);
|
|
||||||
break;
|
|
||||||
case KEYTYPE_DES3 :
|
|
||||||
ret = wrap_des3 (minor_status, context_handle, conf_req_flag,
|
|
||||||
qop_req, input_message_buffer, conf_state,
|
|
||||||
output_message_buffer, key);
|
|
||||||
break;
|
|
||||||
case KEYTYPE_ARCFOUR:
|
|
||||||
ret = _gssapi_wrap_arcfour (minor_status, context_handle, conf_req_flag,
|
|
||||||
qop_req, input_message_buffer, conf_state,
|
|
||||||
output_message_buffer, key);
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
*minor_status = KRB5_PROG_ETYPE_NOSUPP;
|
|
||||||
ret = GSS_S_FAILURE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
krb5_free_keyblock (gssapi_krb5_context, key);
|
|
||||||
return ret;
|
|
||||||
}
|
|
@ -1,213 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1999 - 2001 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of KTH nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software without
|
|
||||||
* specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY KTH AND ITS CONTRIBUTORS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KTH OR ITS CONTRIBUTORS BE
|
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
||||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
||||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
|
||||||
|
|
||||||
/* Converts a database from version 0.0* to 0.1. This is done by
|
|
||||||
* making three copies of each DES key (DES-CBC-CRC, DES-CBC-MD4, and
|
|
||||||
* DES-CBC-MD5).
|
|
||||||
*
|
|
||||||
* Use with care.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "hdb_locl.h"
|
|
||||||
#include <getarg.h>
|
|
||||||
#include <err.h>
|
|
||||||
|
|
||||||
RCSID("$Id: convert_db.c,v 1.12 2001/02/20 01:44:53 assar Exp $");
|
|
||||||
|
|
||||||
static krb5_error_code
|
|
||||||
update_keytypes(krb5_context context, HDB *db, hdb_entry *entry, void *data)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int n = 0;
|
|
||||||
Key *k;
|
|
||||||
int save_len;
|
|
||||||
Key *save_val;
|
|
||||||
HDB *new = data;
|
|
||||||
krb5_error_code ret;
|
|
||||||
|
|
||||||
for(i = 0; i < entry->keys.len; i++)
|
|
||||||
if(entry->keys.val[i].key.keytype == KEYTYPE_DES)
|
|
||||||
n += 2;
|
|
||||||
else if(entry->keys.val[i].key.keytype == KEYTYPE_DES3)
|
|
||||||
n += 1;
|
|
||||||
k = malloc(sizeof(*k) * (entry->keys.len + n));
|
|
||||||
n = 0;
|
|
||||||
for(i = 0; i < entry->keys.len; i++) {
|
|
||||||
copy_Key(&entry->keys.val[i], &k[n]);
|
|
||||||
if(entry->keys.val[i].key.keytype == KEYTYPE_DES) {
|
|
||||||
copy_Key(&entry->keys.val[i], &k[n+1]);
|
|
||||||
k[n+1].key.keytype = ETYPE_DES_CBC_MD4;
|
|
||||||
copy_Key(&entry->keys.val[i], &k[n+2]);
|
|
||||||
k[n+2].key.keytype = ETYPE_DES_CBC_MD5;
|
|
||||||
n += 2;
|
|
||||||
}
|
|
||||||
else if(entry->keys.val[i].key.keytype == KEYTYPE_DES3) {
|
|
||||||
copy_Key(&entry->keys.val[i], &k[n+1]);
|
|
||||||
k[n+1].key.keytype = ETYPE_DES3_CBC_MD5;
|
|
||||||
n += 1;
|
|
||||||
}
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
save_len = entry->keys.len;
|
|
||||||
save_val = entry->keys.val;
|
|
||||||
entry->keys.len = n;
|
|
||||||
entry->keys.val = k;
|
|
||||||
ret = new->store(context, new, HDB_F_REPLACE, entry);
|
|
||||||
entry->keys.len = save_len;
|
|
||||||
entry->keys.val = save_val;
|
|
||||||
for(i = 0; i < n; i++)
|
|
||||||
free_Key(&k[i]);
|
|
||||||
free(k);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static krb5_error_code
|
|
||||||
update_version2(krb5_context context, HDB *db, hdb_entry *entry, void *data)
|
|
||||||
{
|
|
||||||
HDB *new = data;
|
|
||||||
if(!db->master_key_set) {
|
|
||||||
int i;
|
|
||||||
for(i = 0; i < entry->keys.len; i++) {
|
|
||||||
free(entry->keys.val[i].mkvno);
|
|
||||||
entry->keys.val[i].mkvno = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
new->store(context, new, HDB_F_REPLACE, entry);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *old_database = HDB_DEFAULT_DB;
|
|
||||||
char *new_database = HDB_DEFAULT_DB ".new";
|
|
||||||
char *mkeyfile;
|
|
||||||
int update_version;
|
|
||||||
int help_flag;
|
|
||||||
int version_flag;
|
|
||||||
|
|
||||||
struct getargs args[] = {
|
|
||||||
{ "old-database", 0, arg_string, &old_database,
|
|
||||||
"name of database to convert", "file" },
|
|
||||||
{ "new-database", 0, arg_string, &new_database,
|
|
||||||
"name of converted database", "file" },
|
|
||||||
{ "master-key", 0, arg_string, &mkeyfile,
|
|
||||||
"v5 master key file", "file" },
|
|
||||||
{ "update-version", 0, arg_flag, &update_version,
|
|
||||||
"update the database to the current version" },
|
|
||||||
{ "help", 'h', arg_flag, &help_flag },
|
|
||||||
{ "version", 0, arg_flag, &version_flag }
|
|
||||||
};
|
|
||||||
|
|
||||||
static int num_args = sizeof(args) / sizeof(args[0]);
|
|
||||||
|
|
||||||
int
|
|
||||||
main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
krb5_error_code ret;
|
|
||||||
krb5_context context;
|
|
||||||
HDB *db, *new;
|
|
||||||
int optind = 0;
|
|
||||||
int master_key_set = 0;
|
|
||||||
|
|
||||||
setprogname(argv[0]);
|
|
||||||
|
|
||||||
if(getarg(args, num_args, argc, argv, &optind))
|
|
||||||
krb5_std_usage(1, args, num_args);
|
|
||||||
|
|
||||||
if(help_flag)
|
|
||||||
krb5_std_usage(0, args, num_args);
|
|
||||||
|
|
||||||
if(version_flag){
|
|
||||||
print_version(NULL);
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = krb5_init_context(&context);
|
|
||||||
if(ret != 0)
|
|
||||||
errx(1, "krb5_init_context failed: %d", ret);
|
|
||||||
|
|
||||||
ret = hdb_create(context, &db, old_database);
|
|
||||||
if(ret != 0)
|
|
||||||
krb5_err(context, 1, ret, "hdb_create");
|
|
||||||
|
|
||||||
ret = hdb_set_master_keyfile(context, db, mkeyfile);
|
|
||||||
if (ret)
|
|
||||||
krb5_err(context, 1, ret, "hdb_set_master_keyfile");
|
|
||||||
master_key_set = 1;
|
|
||||||
ret = hdb_create(context, &new, new_database);
|
|
||||||
if(ret != 0)
|
|
||||||
krb5_err(context, 1, ret, "hdb_create");
|
|
||||||
if (master_key_set) {
|
|
||||||
ret = hdb_set_master_keyfile(context, new, mkeyfile);
|
|
||||||
if (ret)
|
|
||||||
krb5_err(context, 1, ret, "hdb_set_master_keyfile");
|
|
||||||
}
|
|
||||||
ret = db->open(context, db, O_RDONLY, 0);
|
|
||||||
if(ret == HDB_ERR_BADVERSION) {
|
|
||||||
krb5_data tag;
|
|
||||||
krb5_data version;
|
|
||||||
int foo;
|
|
||||||
unsigned ver;
|
|
||||||
tag.data = HDB_DB_FORMAT_ENTRY;
|
|
||||||
tag.length = strlen(tag.data);
|
|
||||||
ret = (*db->_get)(context, db, tag, &version);
|
|
||||||
if(ret)
|
|
||||||
krb5_errx(context, 1, "database is wrong version, "
|
|
||||||
"but couldn't find version key (%s)",
|
|
||||||
HDB_DB_FORMAT_ENTRY);
|
|
||||||
foo = sscanf(version.data, "%u", &ver);
|
|
||||||
krb5_data_free (&version);
|
|
||||||
if(foo != 1)
|
|
||||||
krb5_errx(context, 1, "database version is not a number");
|
|
||||||
if(ver == 1 && HDB_DB_FORMAT == 2) {
|
|
||||||
krb5_warnx(context, "will upgrade database from version %d to %d",
|
|
||||||
ver, HDB_DB_FORMAT);
|
|
||||||
krb5_warnx(context, "rerun to do other conversions");
|
|
||||||
update_version = 1;
|
|
||||||
} else
|
|
||||||
krb5_errx(context, 1,
|
|
||||||
"don't know how to upgrade from version %d to %d",
|
|
||||||
ver, HDB_DB_FORMAT);
|
|
||||||
} else if(ret)
|
|
||||||
krb5_err(context, 1, ret, "%s", old_database);
|
|
||||||
ret = new->open(context, new, O_CREAT|O_EXCL|O_RDWR, 0600);
|
|
||||||
if(ret)
|
|
||||||
krb5_err(context, 1, ret, "%s", new_database);
|
|
||||||
if(update_version)
|
|
||||||
ret = hdb_foreach(context, db, 0, update_version2, new);
|
|
||||||
else
|
|
||||||
ret = hdb_foreach(context, db, 0, update_keytypes, new);
|
|
||||||
if(ret != 0)
|
|
||||||
krb5_err(context, 1, ret, "hdb_foreach");
|
|
||||||
db->close(context, db);
|
|
||||||
new->close(context, new);
|
|
||||||
krb5_warnx(context, "wrote converted database to `%s'", new_database);
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,273 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997 - 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "iprop.h"
|
|
||||||
#include "parse_time.h"
|
|
||||||
|
|
||||||
RCSID("$Id: dump_log.c,v 1.13 2003/04/16 17:56:02 lha Exp $");
|
|
||||||
|
|
||||||
static char *op_names[] = {
|
|
||||||
"get",
|
|
||||||
"delete",
|
|
||||||
"create",
|
|
||||||
"rename",
|
|
||||||
"chpass",
|
|
||||||
"modify",
|
|
||||||
"randkey",
|
|
||||||
"get_privs",
|
|
||||||
"get_princs",
|
|
||||||
"chpass_with_key",
|
|
||||||
"nop"
|
|
||||||
};
|
|
||||||
|
|
||||||
static void
|
|
||||||
print_entry(kadm5_server_context *server_context,
|
|
||||||
u_int32_t ver,
|
|
||||||
time_t timestamp,
|
|
||||||
enum kadm_ops op,
|
|
||||||
u_int32_t len,
|
|
||||||
krb5_storage *sp)
|
|
||||||
{
|
|
||||||
char t[256];
|
|
||||||
int32_t mask;
|
|
||||||
hdb_entry ent;
|
|
||||||
krb5_principal source;
|
|
||||||
char *name1, *name2;
|
|
||||||
krb5_data data;
|
|
||||||
krb5_context context = server_context->context;
|
|
||||||
|
|
||||||
off_t end = krb5_storage_seek(sp, 0, SEEK_CUR) + len;
|
|
||||||
|
|
||||||
krb5_error_code ret;
|
|
||||||
|
|
||||||
strftime(t, sizeof(t), "%Y-%m-%d %H:%M:%S", localtime(×tamp));
|
|
||||||
|
|
||||||
if(op < kadm_get || op > kadm_nop) {
|
|
||||||
printf("unknown op: %d\n", op);
|
|
||||||
krb5_storage_seek(sp, end, SEEK_SET);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf ("%s: ver = %u, timestamp = %s, len = %u\n",
|
|
||||||
op_names[op], ver, t, len);
|
|
||||||
switch(op) {
|
|
||||||
case kadm_delete:
|
|
||||||
krb5_ret_principal(sp, &source);
|
|
||||||
krb5_unparse_name(context, source, &name1);
|
|
||||||
printf(" %s\n", name1);
|
|
||||||
free(name1);
|
|
||||||
krb5_free_principal(context, source);
|
|
||||||
break;
|
|
||||||
case kadm_rename:
|
|
||||||
ret = krb5_data_alloc(&data, len);
|
|
||||||
if (ret)
|
|
||||||
krb5_err (context, 1, ret, "kadm_rename: data alloc: %d", len);
|
|
||||||
krb5_ret_principal(sp, &source);
|
|
||||||
krb5_storage_read(sp, data.data, data.length);
|
|
||||||
hdb_value2entry(context, &data, &ent);
|
|
||||||
krb5_unparse_name(context, source, &name1);
|
|
||||||
krb5_unparse_name(context, ent.principal, &name2);
|
|
||||||
printf(" %s -> %s\n", name1, name2);
|
|
||||||
free(name1);
|
|
||||||
free(name2);
|
|
||||||
krb5_free_principal(context, source);
|
|
||||||
hdb_free_entry(context, &ent);
|
|
||||||
break;
|
|
||||||
case kadm_create:
|
|
||||||
ret = krb5_data_alloc(&data, len);
|
|
||||||
if (ret)
|
|
||||||
krb5_err (context, 1, ret, "kadm_create: data alloc: %d", len);
|
|
||||||
krb5_storage_read(sp, data.data, data.length);
|
|
||||||
ret = hdb_value2entry(context, &data, &ent);
|
|
||||||
if(ret)
|
|
||||||
abort();
|
|
||||||
mask = ~0;
|
|
||||||
goto foo;
|
|
||||||
case kadm_modify:
|
|
||||||
ret = krb5_data_alloc(&data, len);
|
|
||||||
if (ret)
|
|
||||||
krb5_err (context, 1, ret, "kadm_modify: data alloc: %d", len);
|
|
||||||
krb5_ret_int32(sp, &mask);
|
|
||||||
krb5_storage_read(sp, data.data, data.length);
|
|
||||||
ret = hdb_value2entry(context, &data, &ent);
|
|
||||||
if(ret)
|
|
||||||
abort();
|
|
||||||
foo:
|
|
||||||
if(ent.principal /* mask & KADM5_PRINCIPAL */) {
|
|
||||||
krb5_unparse_name(context, ent.principal, &name1);
|
|
||||||
printf(" principal = %s\n", name1);
|
|
||||||
free(name1);
|
|
||||||
}
|
|
||||||
if(mask & KADM5_PRINC_EXPIRE_TIME) {
|
|
||||||
if(ent.valid_end == NULL) {
|
|
||||||
strcpy(t, "never");
|
|
||||||
} else {
|
|
||||||
strftime(t, sizeof(t), "%Y-%m-%d %H:%M:%S",
|
|
||||||
localtime(ent.valid_end));
|
|
||||||
}
|
|
||||||
printf(" expires = %s\n", t);
|
|
||||||
}
|
|
||||||
if(mask & KADM5_PW_EXPIRATION) {
|
|
||||||
if(ent.pw_end == NULL) {
|
|
||||||
strcpy(t, "never");
|
|
||||||
} else {
|
|
||||||
strftime(t, sizeof(t), "%Y-%m-%d %H:%M:%S",
|
|
||||||
localtime(ent.pw_end));
|
|
||||||
}
|
|
||||||
printf(" password exp = %s\n", t);
|
|
||||||
}
|
|
||||||
if(mask & KADM5_LAST_PWD_CHANGE) {
|
|
||||||
}
|
|
||||||
if(mask & KADM5_ATTRIBUTES) {
|
|
||||||
unparse_flags(HDBFlags2int(ent.flags),
|
|
||||||
HDBFlags_units, t, sizeof(t));
|
|
||||||
printf(" attributes = %s\n", t);
|
|
||||||
}
|
|
||||||
if(mask & KADM5_MAX_LIFE) {
|
|
||||||
if(ent.max_life == NULL)
|
|
||||||
strcpy(t, "for ever");
|
|
||||||
else
|
|
||||||
unparse_time(*ent.max_life, t, sizeof(t));
|
|
||||||
printf(" max life = %s\n", t);
|
|
||||||
}
|
|
||||||
if(mask & KADM5_MAX_RLIFE) {
|
|
||||||
if(ent.max_renew == NULL)
|
|
||||||
strcpy(t, "for ever");
|
|
||||||
else
|
|
||||||
unparse_time(*ent.max_renew, t, sizeof(t));
|
|
||||||
printf(" max rlife = %s\n", t);
|
|
||||||
}
|
|
||||||
if(mask & KADM5_MOD_TIME) {
|
|
||||||
printf(" mod time\n");
|
|
||||||
}
|
|
||||||
if(mask & KADM5_MOD_NAME) {
|
|
||||||
printf(" mod name\n");
|
|
||||||
}
|
|
||||||
if(mask & KADM5_KVNO) {
|
|
||||||
printf(" kvno = %d\n", ent.kvno);
|
|
||||||
}
|
|
||||||
if(mask & KADM5_MKVNO) {
|
|
||||||
printf(" mkvno\n");
|
|
||||||
}
|
|
||||||
if(mask & KADM5_AUX_ATTRIBUTES) {
|
|
||||||
printf(" aux attributes\n");
|
|
||||||
}
|
|
||||||
if(mask & KADM5_POLICY) {
|
|
||||||
printf(" policy\n");
|
|
||||||
}
|
|
||||||
if(mask & KADM5_POLICY_CLR) {
|
|
||||||
printf(" mod time\n");
|
|
||||||
}
|
|
||||||
if(mask & KADM5_LAST_SUCCESS) {
|
|
||||||
printf(" last success\n");
|
|
||||||
}
|
|
||||||
if(mask & KADM5_LAST_FAILED) {
|
|
||||||
printf(" last failed\n");
|
|
||||||
}
|
|
||||||
if(mask & KADM5_FAIL_AUTH_COUNT) {
|
|
||||||
printf(" fail auth count\n");
|
|
||||||
}
|
|
||||||
if(mask & KADM5_KEY_DATA) {
|
|
||||||
printf(" key data\n");
|
|
||||||
}
|
|
||||||
if(mask & KADM5_TL_DATA) {
|
|
||||||
printf(" tl data\n");
|
|
||||||
}
|
|
||||||
hdb_free_entry(context, &ent);
|
|
||||||
break;
|
|
||||||
case kadm_nop :
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
krb5_storage_seek(sp, end, SEEK_SET);
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *realm;
|
|
||||||
static int version_flag;
|
|
||||||
static int help_flag;
|
|
||||||
|
|
||||||
static struct getargs args[] = {
|
|
||||||
{ "realm", 'r', arg_string, &realm },
|
|
||||||
{ "version", 0, arg_flag, &version_flag },
|
|
||||||
{ "help", 0, arg_flag, &help_flag }
|
|
||||||
};
|
|
||||||
int num_args = sizeof(args) / sizeof(args[0]);
|
|
||||||
|
|
||||||
int
|
|
||||||
main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
krb5_context context;
|
|
||||||
krb5_error_code ret;
|
|
||||||
void *kadm_handle;
|
|
||||||
kadm5_server_context *server_context;
|
|
||||||
kadm5_config_params conf;
|
|
||||||
|
|
||||||
krb5_program_setup(&context, argc, argv, args, num_args, NULL);
|
|
||||||
|
|
||||||
if(help_flag)
|
|
||||||
krb5_std_usage(0, args, num_args);
|
|
||||||
if(version_flag) {
|
|
||||||
print_version(NULL);
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(&conf, 0, sizeof(conf));
|
|
||||||
if(realm) {
|
|
||||||
conf.mask |= KADM5_CONFIG_REALM;
|
|
||||||
conf.realm = realm;
|
|
||||||
}
|
|
||||||
ret = kadm5_init_with_password_ctx (context,
|
|
||||||
KADM5_ADMIN_SERVICE,
|
|
||||||
NULL,
|
|
||||||
KADM5_ADMIN_SERVICE,
|
|
||||||
&conf, 0, 0,
|
|
||||||
&kadm_handle);
|
|
||||||
if (ret)
|
|
||||||
krb5_err (context, 1, ret, "kadm5_init_with_password_ctx");
|
|
||||||
|
|
||||||
server_context = (kadm5_server_context *)kadm_handle;
|
|
||||||
|
|
||||||
ret = kadm5_log_init (server_context);
|
|
||||||
if (ret)
|
|
||||||
krb5_err (context, 1, ret, "kadm5_log_init");
|
|
||||||
|
|
||||||
ret = kadm5_log_foreach (server_context, print_entry);
|
|
||||||
if(ret)
|
|
||||||
krb5_warn(context, ret, "kadm5_log_foreach");
|
|
||||||
|
|
||||||
ret = kadm5_log_end (server_context);
|
|
||||||
if (ret)
|
|
||||||
krb5_warn(context, ret, "kadm5_log_end");
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,129 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1997-2002 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "iprop.h"
|
|
||||||
|
|
||||||
RCSID("$Id: replay_log.c,v 1.9 2002/05/24 15:19:22 joda Exp $");
|
|
||||||
|
|
||||||
int start_version = -1;
|
|
||||||
int end_version = -1;
|
|
||||||
|
|
||||||
static void
|
|
||||||
apply_entry(kadm5_server_context *server_context,
|
|
||||||
u_int32_t ver,
|
|
||||||
time_t timestamp,
|
|
||||||
enum kadm_ops op,
|
|
||||||
u_int32_t len,
|
|
||||||
krb5_storage *sp)
|
|
||||||
{
|
|
||||||
krb5_error_code ret;
|
|
||||||
|
|
||||||
if((start_version != -1 && ver < start_version) ||
|
|
||||||
(end_version != -1 && ver > end_version)) {
|
|
||||||
/* XXX skip this entry */
|
|
||||||
krb5_storage_seek(sp, len, SEEK_CUR);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
printf ("ver %u... ", ver);
|
|
||||||
fflush (stdout);
|
|
||||||
|
|
||||||
ret = kadm5_log_replay (server_context,
|
|
||||||
op, ver, len, sp);
|
|
||||||
if (ret)
|
|
||||||
krb5_warn (server_context->context, ret, "kadm5_log_replay");
|
|
||||||
|
|
||||||
|
|
||||||
printf ("done\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
int version_flag;
|
|
||||||
int help_flag;
|
|
||||||
struct getargs args[] = {
|
|
||||||
{ "start-version", 0, arg_integer, &start_version, "start replay with this version" },
|
|
||||||
{ "end-version", 0, arg_integer, &end_version, "end replay with this version" },
|
|
||||||
{ "version", 0, arg_flag, &version_flag },
|
|
||||||
{ "help", 0, arg_flag, &help_flag }
|
|
||||||
};
|
|
||||||
int num_args = sizeof(args) / sizeof(args[0]);
|
|
||||||
|
|
||||||
int
|
|
||||||
main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
krb5_context context;
|
|
||||||
krb5_error_code ret;
|
|
||||||
void *kadm_handle;
|
|
||||||
kadm5_config_params conf;
|
|
||||||
kadm5_server_context *server_context;
|
|
||||||
|
|
||||||
krb5_program_setup(&context, argc, argv, args, num_args, NULL);
|
|
||||||
|
|
||||||
if(help_flag)
|
|
||||||
krb5_std_usage(0, args, num_args);
|
|
||||||
if(version_flag) {
|
|
||||||
print_version(NULL);
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(&conf, 0, sizeof(conf));
|
|
||||||
ret = kadm5_init_with_password_ctx (context,
|
|
||||||
KADM5_ADMIN_SERVICE,
|
|
||||||
NULL,
|
|
||||||
KADM5_ADMIN_SERVICE,
|
|
||||||
&conf, 0, 0,
|
|
||||||
&kadm_handle);
|
|
||||||
if (ret)
|
|
||||||
krb5_err (context, 1, ret, "kadm5_init_with_password_ctx");
|
|
||||||
|
|
||||||
server_context = (kadm5_server_context *)kadm_handle;
|
|
||||||
|
|
||||||
ret = server_context->db->open(context,
|
|
||||||
server_context->db,
|
|
||||||
O_RDWR | O_CREAT, 0);
|
|
||||||
if (ret)
|
|
||||||
krb5_err (context, 1, ret, "db->open");
|
|
||||||
|
|
||||||
ret = kadm5_log_init (server_context);
|
|
||||||
if (ret)
|
|
||||||
krb5_err (context, 1, ret, "kadm5_log_init");
|
|
||||||
|
|
||||||
ret = kadm5_log_foreach (server_context, apply_entry);
|
|
||||||
if(ret)
|
|
||||||
krb5_warn(context, ret, "kadm5_log_foreach");
|
|
||||||
ret = kadm5_log_end (server_context);
|
|
||||||
if (ret)
|
|
||||||
krb5_warn(context, ret, "kadm5_log_end");
|
|
||||||
ret = server_context->db->close (context, server_context->db);
|
|
||||||
if (ret)
|
|
||||||
krb5_err (context, 1, ret, "db->close");
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,89 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2000, 2003 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "iprop.h"
|
|
||||||
|
|
||||||
RCSID("$Id: truncate_log.c,v 1.1.8.1 2003/10/14 15:58:46 joda Exp $");
|
|
||||||
|
|
||||||
static char *realm;
|
|
||||||
static int version_flag;
|
|
||||||
static int help_flag;
|
|
||||||
|
|
||||||
static struct getargs args[] = {
|
|
||||||
{ "realm", 'r', arg_string, &realm },
|
|
||||||
{ "version", 0, arg_flag, &version_flag },
|
|
||||||
{ "help", 0, arg_flag, &help_flag }
|
|
||||||
};
|
|
||||||
|
|
||||||
static int num_args = sizeof(args) / sizeof(args[0]);
|
|
||||||
|
|
||||||
int
|
|
||||||
main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
krb5_context context;
|
|
||||||
krb5_error_code ret;
|
|
||||||
void *kadm_handle;
|
|
||||||
kadm5_server_context *server_context;
|
|
||||||
kadm5_config_params conf;
|
|
||||||
|
|
||||||
krb5_program_setup(&context, argc, argv, args, num_args, NULL);
|
|
||||||
|
|
||||||
if(help_flag)
|
|
||||||
krb5_std_usage(0, args, num_args);
|
|
||||||
if(version_flag) {
|
|
||||||
print_version(NULL);
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(&conf, 0, sizeof(conf));
|
|
||||||
if(realm) {
|
|
||||||
conf.mask |= KADM5_CONFIG_REALM;
|
|
||||||
conf.realm = realm;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = kadm5_init_with_password_ctx (context,
|
|
||||||
KADM5_ADMIN_SERVICE,
|
|
||||||
NULL,
|
|
||||||
KADM5_ADMIN_SERVICE,
|
|
||||||
&conf, 0, 0,
|
|
||||||
&kadm_handle);
|
|
||||||
if (ret)
|
|
||||||
krb5_err (context, 1, ret, "kadm5_init_with_password_ctx");
|
|
||||||
|
|
||||||
server_context = (kadm5_server_context *)kadm_handle;
|
|
||||||
|
|
||||||
ret = kadm5_log_truncate (server_context);
|
|
||||||
if(ret)
|
|
||||||
krb5_err (context, 1, ret, "kadm5_log_truncate");
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,71 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1999 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of KTH nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software without
|
|
||||||
* specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY KTH AND ITS CONTRIBUTORS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KTH OR ITS CONTRIBUTORS BE
|
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
||||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
||||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
|
||||||
|
|
||||||
#include "krb5_locl.h"
|
|
||||||
|
|
||||||
RCSID("$Id: dump_config.c,v 1.2 1999/10/28 23:22:41 assar Exp $");
|
|
||||||
|
|
||||||
/* print contents of krb5.conf */
|
|
||||||
|
|
||||||
static void
|
|
||||||
print_tree(struct krb5_config_binding *b, int level)
|
|
||||||
{
|
|
||||||
if (b == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
printf("%*s%s%s%s", level * 4, "",
|
|
||||||
(level == 0) ? "[" : "", b->name, (level == 0) ? "]" : "");
|
|
||||||
if(b->type == krb5_config_list) {
|
|
||||||
if(level > 0)
|
|
||||||
printf(" = {");
|
|
||||||
printf("\n");
|
|
||||||
print_tree(b->u.list, level + 1);
|
|
||||||
if(level > 0)
|
|
||||||
printf("%*s}\n", level * 4, "");
|
|
||||||
} else if(b->type == krb5_config_string) {
|
|
||||||
printf(" = %s\n", b->u.string);
|
|
||||||
}
|
|
||||||
if(b->next)
|
|
||||||
print_tree(b->next, level);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
krb5_context context;
|
|
||||||
krb5_error_code ret = krb5_init_context(&context);
|
|
||||||
if(ret == 0) {
|
|
||||||
print_tree(context->cf, 0);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
@ -1,101 +0,0 @@
|
|||||||
.\" Copyright (c) 1997, 2001 - 2002 Kungliga Tekniska Högskolan
|
|
||||||
.\" (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
.\" All rights reserved.
|
|
||||||
.\"
|
|
||||||
.\" Redistribution and use in source and binary forms, with or without
|
|
||||||
.\" modification, are permitted provided that the following conditions
|
|
||||||
.\" are met:
|
|
||||||
.\"
|
|
||||||
.\" 1. Redistributions of source code must retain the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer.
|
|
||||||
.\"
|
|
||||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer in the
|
|
||||||
.\" documentation and/or other materials provided with the distribution.
|
|
||||||
.\"
|
|
||||||
.\" 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
.\" may be used to endorse or promote products derived from this software
|
|
||||||
.\" without specific prior written permission.
|
|
||||||
.\"
|
|
||||||
.\" THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
.\" SUCH DAMAGE.
|
|
||||||
.\"
|
|
||||||
.\" $Id: krb5_build_principal.3,v 1.7 2003/04/16 13:58:14 lha Exp $
|
|
||||||
.\"
|
|
||||||
.Dd August 8, 1997
|
|
||||||
.Dt KRB5_BUILD_PRINCIPAL 3
|
|
||||||
.Os HEIMDAL
|
|
||||||
.Sh NAME
|
|
||||||
.Nm krb5_build_principal ,
|
|
||||||
.Nm krb5_build_principal_ext ,
|
|
||||||
.Nm krb5_build_principal_va ,
|
|
||||||
.Nm krb5_build_principal_va_ext ,
|
|
||||||
.Nm krb5_make_principal
|
|
||||||
.Nd principal creation functions
|
|
||||||
.Sh LIBRARY
|
|
||||||
Kerberos 5 Library (libkrb5, -lkrb5)
|
|
||||||
.Sh SYNOPSIS
|
|
||||||
.In krb5.h
|
|
||||||
.Ft krb5_error_code
|
|
||||||
.Fn krb5_build_principal "krb5_context context" "krb5_principal *principal" "int realm_len" "krb5_const_realm realm" "..."
|
|
||||||
.Ft krb5_error_code
|
|
||||||
.Fn krb5_build_principal_ext "krb5_context context" "krb5_principal *principal" "int realm_len" "krb5_const_realm realm" "..."
|
|
||||||
.Ft krb5_error_code
|
|
||||||
.Fn krb5_build_principal_va "krb5_context context" "krb5_principal *principal" "int realm_len" "krb5_const_realm realm" "va_list ap"
|
|
||||||
.Ft krb5_error_code
|
|
||||||
.Fn krb5_build_principal_va_ext "krb5_context context" "krb5_principal *principal" "int realm_len" "krb5_const_realm realm" "va_list ap"
|
|
||||||
.Ft krb5_error_code
|
|
||||||
.Fn krb5_make_principal "krb5_context context" "krb5_principal *principal" "krb5_const_realm realm" "..."
|
|
||||||
.Sh DESCRIPTION
|
|
||||||
These functions create a Kerberos 5 principal from a realm and a list
|
|
||||||
of components.
|
|
||||||
All of these functions return an allocated principal in the
|
|
||||||
.Fa principal
|
|
||||||
parameter, this should be freed with
|
|
||||||
.Fn krb5_free_principal
|
|
||||||
after use.
|
|
||||||
.Pp
|
|
||||||
The
|
|
||||||
.Dq build
|
|
||||||
functions take a
|
|
||||||
.Fa realm
|
|
||||||
and the length of the realm. The
|
|
||||||
.Fn krb5_build_principal
|
|
||||||
and
|
|
||||||
.Fn krb5_build_principal_va
|
|
||||||
also takes a list of components (zero-terminated strings), terminated
|
|
||||||
with
|
|
||||||
.Dv NULL .
|
|
||||||
The
|
|
||||||
.Fn krb5_build_principal_ext
|
|
||||||
and
|
|
||||||
.Fn krb5_build_principal_va_ext
|
|
||||||
takes a list of length-value pairs, the list is terminated with a zero
|
|
||||||
length.
|
|
||||||
.Pp
|
|
||||||
The
|
|
||||||
.Fn krb5_make_principal
|
|
||||||
is a wrapper around
|
|
||||||
.Fn krb5_build_principal .
|
|
||||||
If the realm is
|
|
||||||
.Dv NULL ,
|
|
||||||
the default realm will be used.
|
|
||||||
.Sh BUGS
|
|
||||||
You can not have a NUL in a component. Until someone can give a good
|
|
||||||
example of where it would be a good idea to have NUL's in a component,
|
|
||||||
this will not be fixed.
|
|
||||||
.Sh SEE ALSO
|
|
||||||
.Xr krb5_425_conv_principal 3 ,
|
|
||||||
.Xr krb5_free_principal 3 ,
|
|
||||||
.Xr krb5_parse_name 3 ,
|
|
||||||
.Xr krb5_sname_to_principal 3 ,
|
|
||||||
.Xr krb5_unparse_name 3
|
|
@ -1,53 +0,0 @@
|
|||||||
.\" Copyright (c) 2001 Kungliga Tekniska Högskolan
|
|
||||||
.\" (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
.\" All rights reserved.
|
|
||||||
.\"
|
|
||||||
.\" Redistribution and use in source and binary forms, with or without
|
|
||||||
.\" modification, are permitted provided that the following conditions
|
|
||||||
.\" are met:
|
|
||||||
.\"
|
|
||||||
.\" 1. Redistributions of source code must retain the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer.
|
|
||||||
.\"
|
|
||||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer in the
|
|
||||||
.\" documentation and/or other materials provided with the distribution.
|
|
||||||
.\"
|
|
||||||
.\" 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
.\" may be used to endorse or promote products derived from this software
|
|
||||||
.\" without specific prior written permission.
|
|
||||||
.\"
|
|
||||||
.\" THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
.\" SUCH DAMAGE.
|
|
||||||
.\"
|
|
||||||
.\" $Id: krb5_free_addresses.3,v 1.5 2003/04/16 13:58:15 lha Exp $
|
|
||||||
.\"
|
|
||||||
.Dd November 20, 2001
|
|
||||||
.Dt KRB5_FREE_ADDRESSES 3
|
|
||||||
.Os HEIMDAL
|
|
||||||
.Sh NAME
|
|
||||||
.Nm krb5_free_addresses
|
|
||||||
.Nd free list of addresses
|
|
||||||
.Sh LIBRARY
|
|
||||||
Kerberos 5 Library (libkrb5, -lkrb5)
|
|
||||||
.Sh SYNOPSIS
|
|
||||||
.In krb5.h
|
|
||||||
.Ft void
|
|
||||||
.Fn krb5_free_addresses "krb5_context context" "krb5_addresses *addresses"
|
|
||||||
.Sh DESCRIPTION
|
|
||||||
The
|
|
||||||
.Fn krb5_free_addresses
|
|
||||||
will free a list of addresses that has been created with
|
|
||||||
.Fn krb5_get_all_client_addrs
|
|
||||||
or with some other function.
|
|
||||||
.Sh SEE ALSO
|
|
||||||
.Xr krb5_get_all_client_addrs 3
|
|
@ -1,58 +0,0 @@
|
|||||||
.\" Copyright (c) 1997, 2001 - 2002 Kungliga Tekniska Högskolan
|
|
||||||
.\" (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
.\" All rights reserved.
|
|
||||||
.\"
|
|
||||||
.\" Redistribution and use in source and binary forms, with or without
|
|
||||||
.\" modification, are permitted provided that the following conditions
|
|
||||||
.\" are met:
|
|
||||||
.\"
|
|
||||||
.\" 1. Redistributions of source code must retain the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer.
|
|
||||||
.\"
|
|
||||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer in the
|
|
||||||
.\" documentation and/or other materials provided with the distribution.
|
|
||||||
.\"
|
|
||||||
.\" 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
.\" may be used to endorse or promote products derived from this software
|
|
||||||
.\" without specific prior written permission.
|
|
||||||
.\"
|
|
||||||
.\" THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
.\" SUCH DAMAGE.
|
|
||||||
.\"
|
|
||||||
.\" Copyright (c) 1997 Kungliga Tekniska Högskolan
|
|
||||||
.\" $Id: krb5_free_principal.3,v 1.7 2003/04/16 13:58:11 lha Exp $
|
|
||||||
.Dd August 8, 1997
|
|
||||||
.Dt KRB5_FREE_PRINCIPAL 3
|
|
||||||
.Os HEIMDAL
|
|
||||||
.Sh NAME
|
|
||||||
.Nm krb5_free_principal
|
|
||||||
.Nd principal free function
|
|
||||||
.Sh LIBRARY
|
|
||||||
Kerberos 5 Library (libkrb5, -lkrb5)
|
|
||||||
.Sh SYNOPSIS
|
|
||||||
.In krb5.h
|
|
||||||
.Ft void
|
|
||||||
.Fn krb5_free_principal "krb5_context context" "krb5_principal principal"
|
|
||||||
.Sh DESCRIPTION
|
|
||||||
The
|
|
||||||
.Fn krb5_free_principal
|
|
||||||
will free a principal that has been created with
|
|
||||||
.Fn krb5_build_principal ,
|
|
||||||
.Fn krb5_parse_name ,
|
|
||||||
or with some other function.
|
|
||||||
.Sh SEE ALSO
|
|
||||||
.Xr krb5_425_conv_principal 3 ,
|
|
||||||
.Xr krb5_build_principal 3 ,
|
|
||||||
.Xr krb5_parse_name 3 ,
|
|
||||||
.Xr krb5_sname_to_principal 3 ,
|
|
||||||
.Xr krb5_unparse_name 3
|
|
@ -1,81 +0,0 @@
|
|||||||
.\" Copyright (c) 2001 Kungliga Tekniska Högskolan
|
|
||||||
.\" (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
.\" All rights reserved.
|
|
||||||
.\"
|
|
||||||
.\" Redistribution and use in source and binary forms, with or without
|
|
||||||
.\" modification, are permitted provided that the following conditions
|
|
||||||
.\" are met:
|
|
||||||
.\"
|
|
||||||
.\" 1. Redistributions of source code must retain the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer.
|
|
||||||
.\"
|
|
||||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer in the
|
|
||||||
.\" documentation and/or other materials provided with the distribution.
|
|
||||||
.\"
|
|
||||||
.\" 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
.\" may be used to endorse or promote products derived from this software
|
|
||||||
.\" without specific prior written permission.
|
|
||||||
.\"
|
|
||||||
.\" THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
.\" SUCH DAMAGE.
|
|
||||||
.\"
|
|
||||||
.\" $Id: krb5_principal_get_realm.3,v 1.6 2003/04/16 13:58:17 lha Exp $
|
|
||||||
.\"
|
|
||||||
.Dd June 20, 2001
|
|
||||||
.Dt KRB5_PRINCIPAL_GET_REALM 3
|
|
||||||
.Os HEIMDAL
|
|
||||||
.Sh NAME
|
|
||||||
.Nm krb5_principal_get_realm ,
|
|
||||||
.Nm krb5_principal_get_comp_string
|
|
||||||
.Nd decompose a principal
|
|
||||||
.Sh LIBRARY
|
|
||||||
Kerberos 5 Library (libkrb5, -lkrb5)
|
|
||||||
.Sh SYNOPSIS
|
|
||||||
.In krb5.h
|
|
||||||
.Ft "const char *"
|
|
||||||
.Fn krb5_principal_get_realm "krb5_context context" "krb5_principal principal"
|
|
||||||
.Ft "const char *"
|
|
||||||
.Fn krb5_principal_get_comp_string "krb5_context context" "krb5_principal principal" "unsigned int component"
|
|
||||||
.Sh DESCRIPTION
|
|
||||||
These functions return parts of the
|
|
||||||
.Fa principal ,
|
|
||||||
either the realm or a specific component. The returned string points
|
|
||||||
to data inside the principal, so they are valid only as long as the
|
|
||||||
principal exists.
|
|
||||||
.Pp
|
|
||||||
The
|
|
||||||
.Fa component
|
|
||||||
argument to
|
|
||||||
.Fn krb5_principal_get_comp_string
|
|
||||||
is the component number to return, from zero to the total number of
|
|
||||||
components minus one. If a the requested component number is out of range,
|
|
||||||
.Dv NULL
|
|
||||||
is returned.
|
|
||||||
.Pp
|
|
||||||
These functions can be seen as a replacement for the
|
|
||||||
.Fn krb5_princ_realm ,
|
|
||||||
.Fn krb5_princ_component
|
|
||||||
and related macros, described as intermal in the MIT API
|
|
||||||
specification. A difference is that these functions return strings,
|
|
||||||
not
|
|
||||||
.Dv krb5_data .
|
|
||||||
A reason to return
|
|
||||||
.Dv krb5_data
|
|
||||||
was that it was believed that principal components could contain
|
|
||||||
binary data, but this belief was unfounded, and it has been decided
|
|
||||||
that principal components are infact UTF8, so it's safe to use zero
|
|
||||||
terminated strings.
|
|
||||||
.Pp
|
|
||||||
It's generally not necessary to look at the components of a principal.
|
|
||||||
.Sh SEE ALSO
|
|
||||||
.Xr krb5_unparse_name 3
|
|
@ -1,85 +0,0 @@
|
|||||||
.\" Copyright (c) 1997 Kungliga Tekniska Högskolan
|
|
||||||
.\" (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
.\" All rights reserved.
|
|
||||||
.\"
|
|
||||||
.\" Redistribution and use in source and binary forms, with or without
|
|
||||||
.\" modification, are permitted provided that the following conditions
|
|
||||||
.\" are met:
|
|
||||||
.\"
|
|
||||||
.\" 1. Redistributions of source code must retain the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer.
|
|
||||||
.\"
|
|
||||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer in the
|
|
||||||
.\" documentation and/or other materials provided with the distribution.
|
|
||||||
.\"
|
|
||||||
.\" 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
.\" may be used to endorse or promote products derived from this software
|
|
||||||
.\" without specific prior written permission.
|
|
||||||
.\"
|
|
||||||
.\" THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
.\" SUCH DAMAGE.
|
|
||||||
.\"
|
|
||||||
.\" $Id: krb5_sname_to_principal.3,v 1.7 2003/04/16 13:58:17 lha Exp $
|
|
||||||
.\"
|
|
||||||
.Dd August 8, 1997
|
|
||||||
.Dt KRB5_PRINCIPAL 3
|
|
||||||
.Os HEIMDAL
|
|
||||||
.Sh NAME
|
|
||||||
.Nm krb5_sname_to_principal ,
|
|
||||||
.Nm krb5_sock_to_principal
|
|
||||||
.Nd create a service principal
|
|
||||||
.Sh LIBRARY
|
|
||||||
Kerberos 5 Library (libkrb5, -lkrb5)
|
|
||||||
.Sh SYNOPSIS
|
|
||||||
.In krb5.h
|
|
||||||
.Ft krb5_error_code
|
|
||||||
.Fn krb5_sname_to_principal "krb5_context context" "const char *hostname" "const char *sname" "int32_t type" "krb5_principal *principal"
|
|
||||||
.Ft krb5_error_code
|
|
||||||
.Fn krb5_sock_to_principal "krb5_context context" "int socket" "const char *sname" "int32_t type" "krb5_principal *principal"
|
|
||||||
.Sh DESCRIPTION
|
|
||||||
These functions create a
|
|
||||||
.Dq service
|
|
||||||
principal that can, for instance, be used to lookup a key in a keytab. For both these function the
|
|
||||||
.Fa sname
|
|
||||||
parameter will be used for the first component of the created principal. If
|
|
||||||
.Fa sname
|
|
||||||
is
|
|
||||||
.Dv NULL ,
|
|
||||||
.Dq host
|
|
||||||
will be used instead.
|
|
||||||
.Fn krb5_sname_to_principal
|
|
||||||
will use the passed
|
|
||||||
.Fa hostname
|
|
||||||
for the second component. If type
|
|
||||||
.Dv KRB5_NT_SRV_HST
|
|
||||||
this name will be looked up with
|
|
||||||
.Fn gethostbyname .
|
|
||||||
If
|
|
||||||
.Fa hostname is
|
|
||||||
.Dv NULL ,
|
|
||||||
the local hostname will be used.
|
|
||||||
.Pp
|
|
||||||
.Fn krb5_sock_to_principal
|
|
||||||
will use the
|
|
||||||
.Dq sockname
|
|
||||||
of the passed
|
|
||||||
.Fa socket ,
|
|
||||||
which should be a bound
|
|
||||||
.Dv AF_INET
|
|
||||||
socket.
|
|
||||||
.Sh SEE ALSO
|
|
||||||
.Xr krb5_425_conv_principal 3 ,
|
|
||||||
.Xr krb5_build_principal 3 ,
|
|
||||||
.Xr krb5_free_principal 3 ,
|
|
||||||
.Xr krb5_parse_name 3 ,
|
|
||||||
.Xr krb5_unparse_name 3
|
|
@ -1,36 +0,0 @@
|
|||||||
@BOTTOM@
|
|
||||||
|
|
||||||
#ifdef BROKEN_REALLOC
|
|
||||||
#define realloc(X, Y) isoc_realloc((X), (Y))
|
|
||||||
#define isoc_realloc(X, Y) ((X) ? realloc((X), (Y)) : malloc(Y))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef VOID_RETSIGTYPE
|
|
||||||
#define SIGRETURN(x) return
|
|
||||||
#else
|
|
||||||
#define SIGRETURN(x) return (RETSIGTYPE)(x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define RCSID(msg) \
|
|
||||||
static /**/const char *const rcsid[] = { (const char *)rcsid, "\100(#)" msg }
|
|
||||||
|
|
||||||
#undef PROTOTYPES
|
|
||||||
|
|
||||||
/* Maximum values on all known systems */
|
|
||||||
#define MaxHostNameLen (64+4)
|
|
||||||
#define MaxPathLen (1024+4)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Define NDBM if you are using the 4.3 ndbm library (which is part of
|
|
||||||
* libc). If not defined, 4.2 dbm will be assumed.
|
|
||||||
*/
|
|
||||||
#if defined(HAVE_DBM_FIRSTKEY)
|
|
||||||
#define NDBM
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Defining this enables lots of useful (and used) extensions on
|
|
||||||
* glibc-based systems such as Linux
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
|
@ -1,9 +0,0 @@
|
|||||||
dnl $Id$
|
|
||||||
dnl
|
|
||||||
dnl Only put things that for some reason can't live in the `cf'
|
|
||||||
dnl directory in this file.
|
|
||||||
dnl
|
|
||||||
|
|
||||||
dnl $xId: misc.m4,v 1.1 1997/12/14 15:59:04 joda Exp $
|
|
||||||
dnl
|
|
||||||
define(upcase,`echo $1 | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`)dnl
|
|
@ -1,78 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1998 - 2001 Kungliga Tekniska Högskolan
|
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include <config.h>
|
|
||||||
RCSID("$Id: print_version.c,v 1.8 2001/02/20 01:44:55 assar Exp $");
|
|
||||||
#endif
|
|
||||||
#include "roken.h"
|
|
||||||
|
|
||||||
#include "print_version.h"
|
|
||||||
|
|
||||||
void
|
|
||||||
print_version(const char *progname)
|
|
||||||
{
|
|
||||||
const char *arg[] = VERSIONLIST;
|
|
||||||
const int num_args = sizeof(arg) / sizeof(arg[0]);
|
|
||||||
char *msg;
|
|
||||||
size_t len = 0;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if(progname == NULL)
|
|
||||||
progname = getprogname();
|
|
||||||
|
|
||||||
if(num_args == 0)
|
|
||||||
msg = "no version information";
|
|
||||||
else {
|
|
||||||
for(i = 0; i < num_args; i++) {
|
|
||||||
if(i > 0)
|
|
||||||
len += 2;
|
|
||||||
len += strlen(arg[i]);
|
|
||||||
}
|
|
||||||
msg = malloc(len + 1);
|
|
||||||
if(msg == NULL) {
|
|
||||||
fprintf(stderr, "%s: out of memory\n", progname);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
msg[0] = '\0';
|
|
||||||
for(i = 0; i < num_args; i++) {
|
|
||||||
if(i > 0)
|
|
||||||
strcat(msg, ", ");
|
|
||||||
strcat(msg, arg[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fprintf(stderr, "%s (%s)\n", progname, msg);
|
|
||||||
fprintf(stderr, "Copyright (c) 1999 - 2001 Kungliga Tekniska Högskolan\n");
|
|
||||||
if(num_args != 0)
|
|
||||||
free(msg);
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
//{{NO_DEPENDENCIES}}
|
|
||||||
// Microsoft Developer Studio generated include file.
|
|
||||||
// Used by roken.rc
|
|
||||||
//
|
|
||||||
|
|
||||||
// Next default values for new objects
|
|
||||||
//
|
|
||||||
#ifdef APSTUDIO_INVOKED
|
|
||||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
|
||||||
#define _APS_NEXT_RESOURCE_VALUE 101
|
|
||||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
|
||||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
|
||||||
#define _APS_NEXT_SYMED_VALUE 101
|
|
||||||
#endif
|
|
||||||
#endif
|
|
150
mkinstalldirs
150
mkinstalldirs
@ -1,150 +0,0 @@
|
|||||||
#! /bin/sh
|
|
||||||
# mkinstalldirs --- make directory hierarchy
|
|
||||||
|
|
||||||
scriptversion=2004-02-15.20
|
|
||||||
|
|
||||||
# Original author: Noah Friedman <friedman@prep.ai.mit.edu>
|
|
||||||
# Created: 1993-05-16
|
|
||||||
# Public domain.
|
|
||||||
#
|
|
||||||
# This file is maintained in Automake, please report
|
|
||||||
# bugs to <bug-automake@gnu.org> or send patches to
|
|
||||||
# <automake-patches@gnu.org>.
|
|
||||||
|
|
||||||
errstatus=0
|
|
||||||
dirmode=""
|
|
||||||
|
|
||||||
usage="\
|
|
||||||
Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
|
|
||||||
|
|
||||||
Create each directory DIR (with mode MODE, if specified), including all
|
|
||||||
leading file name components.
|
|
||||||
|
|
||||||
Report bugs to <bug-automake@gnu.org>."
|
|
||||||
|
|
||||||
# process command line arguments
|
|
||||||
while test $# -gt 0 ; do
|
|
||||||
case $1 in
|
|
||||||
-h | --help | --h*) # -h for help
|
|
||||||
echo "$usage"
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
-m) # -m PERM arg
|
|
||||||
shift
|
|
||||||
test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
|
|
||||||
dirmode=$1
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
--version)
|
|
||||||
echo "$0 $scriptversion"
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
--) # stop option processing
|
|
||||||
shift
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
-*) # unknown option
|
|
||||||
echo "$usage" 1>&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
*) # first non-opt arg
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
for file
|
|
||||||
do
|
|
||||||
if test -d "$file"; then
|
|
||||||
shift
|
|
||||||
else
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
case $# in
|
|
||||||
0) exit 0 ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and
|
|
||||||
# mkdir -p a/c at the same time, both will detect that a is missing,
|
|
||||||
# one will create a, then the other will try to create a and die with
|
|
||||||
# a "File exists" error. This is a problem when calling mkinstalldirs
|
|
||||||
# from a parallel make. We use --version in the probe to restrict
|
|
||||||
# ourselves to GNU mkdir, which is thread-safe.
|
|
||||||
case $dirmode in
|
|
||||||
'')
|
|
||||||
if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
|
|
||||||
echo "mkdir -p -- $*"
|
|
||||||
exec mkdir -p -- "$@"
|
|
||||||
else
|
|
||||||
# On NextStep and OpenStep, the `mkdir' command does not
|
|
||||||
# recognize any option. It will interpret all options as
|
|
||||||
# directories to create, and then abort because `.' already
|
|
||||||
# exists.
|
|
||||||
test -d ./-p && rmdir ./-p
|
|
||||||
test -d ./--version && rmdir ./--version
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 &&
|
|
||||||
test ! -d ./--version; then
|
|
||||||
echo "mkdir -m $dirmode -p -- $*"
|
|
||||||
exec mkdir -m "$dirmode" -p -- "$@"
|
|
||||||
else
|
|
||||||
# Clean up after NextStep and OpenStep mkdir.
|
|
||||||
for d in ./-m ./-p ./--version "./$dirmode";
|
|
||||||
do
|
|
||||||
test -d $d && rmdir $d
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
for file
|
|
||||||
do
|
|
||||||
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
|
|
||||||
shift
|
|
||||||
|
|
||||||
pathcomp=
|
|
||||||
for d
|
|
||||||
do
|
|
||||||
pathcomp="$pathcomp$d"
|
|
||||||
case $pathcomp in
|
|
||||||
-*) pathcomp=./$pathcomp ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if test ! -d "$pathcomp"; then
|
|
||||||
echo "mkdir $pathcomp"
|
|
||||||
|
|
||||||
mkdir "$pathcomp" || lasterr=$?
|
|
||||||
|
|
||||||
if test ! -d "$pathcomp"; then
|
|
||||||
errstatus=$lasterr
|
|
||||||
else
|
|
||||||
if test ! -z "$dirmode"; then
|
|
||||||
echo "chmod $dirmode $pathcomp"
|
|
||||||
lasterr=""
|
|
||||||
chmod "$dirmode" "$pathcomp" || lasterr=$?
|
|
||||||
|
|
||||||
if test ! -z "$lasterr"; then
|
|
||||||
errstatus=$lasterr
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
pathcomp="$pathcomp/"
|
|
||||||
done
|
|
||||||
done
|
|
||||||
|
|
||||||
exit $errstatus
|
|
||||||
|
|
||||||
# Local Variables:
|
|
||||||
# mode: shell-script
|
|
||||||
# sh-indentation: 2
|
|
||||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
|
||||||
# time-stamp-start: "scriptversion="
|
|
||||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
|
||||||
# time-stamp-end: "$"
|
|
||||||
# End:
|
|
212
tools/build.sh
212
tools/build.sh
@ -1,212 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# Build many combinations of kth-krb/heimdal/openssl
|
|
||||||
#
|
|
||||||
# $Id: build.sh,v 1.8 2003/04/17 12:55:02 lha Exp $
|
|
||||||
|
|
||||||
opt_n= #:
|
|
||||||
make_f= #-j
|
|
||||||
|
|
||||||
heimdal_versions="0.5.2 0.6pre4"
|
|
||||||
krb4_versions="1.2.2"
|
|
||||||
openssl_versions="0.9.6i 0.9.7a 0.9.7b"
|
|
||||||
|
|
||||||
make_check_version=".*heimdal-0.6.*"
|
|
||||||
|
|
||||||
# 0.5 dont eat 0.9.7
|
|
||||||
dont_build="openssl-0.9.7.*heimdal-0.5.*"
|
|
||||||
# 1.2 dont eat 0.9.7
|
|
||||||
dont_build="openssl-0.9.7.*krb4-1.2.* ${dont_build}"
|
|
||||||
#yacc problems
|
|
||||||
dont_build="openssl-0.9.6.*heimdal-0.5.*osf4.* ${dont_build}"
|
|
||||||
#local openssl 09.7 and broken kuser/Makefile.am
|
|
||||||
dont_build="openssl-0.9.6.*heimdal-0.5.*freebsd4.8.* ${dont_build}"
|
|
||||||
failed=
|
|
||||||
|
|
||||||
# Allow override
|
|
||||||
for a in $HOME . /etc ; do
|
|
||||||
[ -f $a/.heimdal-build ] && . $a/.heimdal-build
|
|
||||||
done
|
|
||||||
|
|
||||||
targetdir=${targetdir:-/scratch/heimdal-test}
|
|
||||||
logfile="${targetdir}/buildlog"
|
|
||||||
|
|
||||||
distdirs="${distdirs} /afs/su.se/home/l/h/lha/Public/openssl"
|
|
||||||
distdirs="${distdirs} /afs/pdc.kth.se/public/ftp/pub/heimdal/src"
|
|
||||||
distdirs="${distdirs} /afs/pdc.kth.se/public/ftp/pub/heimdal/src/snapshots"
|
|
||||||
distdirs="${distdirs} /afs/pdc.kth.se/public/ftp/pub/krb/src"
|
|
||||||
|
|
||||||
|
|
||||||
logprint () {
|
|
||||||
d=`date '+%Y-%m-%d %H:%M:%S'`
|
|
||||||
echo "${d}: $*"
|
|
||||||
echo "${d}: --- $*" >> ${logfile}
|
|
||||||
}
|
|
||||||
|
|
||||||
logerror () {
|
|
||||||
echo "$*"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
find_unzip_prog () {
|
|
||||||
unzip_prog=
|
|
||||||
oldIFS="$IFS"
|
|
||||||
IFS=:
|
|
||||||
set -- $PATH
|
|
||||||
IFS="$oldIFS"
|
|
||||||
for a in $* ; do
|
|
||||||
if [ -x $a/gzip ] ; then
|
|
||||||
unzip_prog="$a/gzip -dc"
|
|
||||||
break
|
|
||||||
elif [ -x $a/gunzip ] ; then
|
|
||||||
unzip_prog="$a/gunzip -c"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
[ "$unzip_prog" = "" ] && logerror failed to find unzip program
|
|
||||||
}
|
|
||||||
|
|
||||||
find_canon_name () {
|
|
||||||
canon_name=
|
|
||||||
for a in ${distdirs} ; do
|
|
||||||
if [ -f $a/config.guess ] ; then
|
|
||||||
canon_name=`$a/config.guess`
|
|
||||||
fi
|
|
||||||
if [ "${canon_name}" != "" ] ; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
[ "${canon_name}" = "" ] && logerror "cant find config.guess"
|
|
||||||
}
|
|
||||||
|
|
||||||
do_check_p () {
|
|
||||||
eval check_var=\$"$1"
|
|
||||||
for a in ${check_var} ; do
|
|
||||||
expr "$2${canon_name}" : "${a}" > /dev/null 2>&1 && return 1
|
|
||||||
done
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
unpack_tar () {
|
|
||||||
for a in ${distdirs} ; do
|
|
||||||
if [ -f $a/$1 ] ; then
|
|
||||||
${opt_n} ${unzip_prog} ${a}/$1 | ${opt_n} tar xf -
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
logerror "did not find $1"
|
|
||||||
}
|
|
||||||
|
|
||||||
build () {
|
|
||||||
real_ver=$1
|
|
||||||
prog=$2
|
|
||||||
ver=$3
|
|
||||||
confprog=$4
|
|
||||||
checks=$5
|
|
||||||
pv=${prog}-${ver}
|
|
||||||
mkdir tmp || logerror "failed to build tmpdir"
|
|
||||||
cd tmp || logerror "failed to change dir to tmpdir"
|
|
||||||
do_check_p dont_build ${real_ver} || \
|
|
||||||
{ cd .. ; rmdir tmp ; logprint "not building $1" && return 0 ; }
|
|
||||||
cd .. || logerror "failed to change back from tmpdir"
|
|
||||||
rmdir tmp || logerror "failed to remove tmpdir"
|
|
||||||
logprint "preparing for ${pv}"
|
|
||||||
${opt_n} rm -rf ${targetdir}/${prog}-${ver}
|
|
||||||
${opt_n} rm -rf ${prog}-${ver}
|
|
||||||
unpack_tar ${pv}.tar.gz
|
|
||||||
${opt_n} cd ${pv} || logerror directory ${pv} not there
|
|
||||||
logprint "configure ${prog} ${ver} (${confprog})"
|
|
||||||
${opt_n} ./${confprog} \
|
|
||||||
--prefix=${targetdir}/${pv} >> ${logfile} 2>&1 || \
|
|
||||||
{ logprint failed to configure ${pv} ; return 1 ; }
|
|
||||||
logprint "make ${prog} ${ver}"
|
|
||||||
${opt_n} make ${make_f} >> ${logfile} 2>&1 || \
|
|
||||||
{ logprint failed to make ${pv} ; return 1 ; }
|
|
||||||
${opt_n} make install >> ${logfile} 2>&1 || \
|
|
||||||
{ logprint failed to install ${pv} ; return 1 ; }
|
|
||||||
do_check_p make_check_version ${real_ver} || \
|
|
||||||
{ ${opt_n} make check >> ${logfile} 2>&1 || return 1 ; }
|
|
||||||
${opt_n} cd ..
|
|
||||||
[ "${checks}" != "" ] && ${opt_n} ${checks} >> ${logfile} 2>&1
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
find_canon_name
|
|
||||||
|
|
||||||
logprint using host `hostname`
|
|
||||||
logprint `uname -a`
|
|
||||||
logprint canonical name ${canon_name}
|
|
||||||
|
|
||||||
logprint clearing logfile
|
|
||||||
> ${logfile}
|
|
||||||
|
|
||||||
find_unzip_prog
|
|
||||||
|
|
||||||
logprint using target dir ${targetdir}
|
|
||||||
mkdir -p ${targetdir}/src
|
|
||||||
cd ${targetdir}/src || exit 1
|
|
||||||
rm -rf heimdal* openssl* krb4*
|
|
||||||
|
|
||||||
logprint === building openssl versions
|
|
||||||
for vo in ${openssl_versions} ; do
|
|
||||||
build openssl-${vo} openssl $vo config
|
|
||||||
done
|
|
||||||
|
|
||||||
wssl="--with-openssl=${targetdir}/openssl"
|
|
||||||
wssli="--with-openssl-include=${targetdir}/openssl" #this is a hack for broken heimdal 0.5.x autoconf test
|
|
||||||
wossl="--without-openssl"
|
|
||||||
wk4c="--with-krb4-config=${targetdir}/krb4"
|
|
||||||
bk4c="/bin/krb4-config"
|
|
||||||
wok4="--without-krb4"
|
|
||||||
|
|
||||||
logprint === building heimdal w/o krb4 versions
|
|
||||||
for vo in ${openssl_versions} ; do
|
|
||||||
for vh in ${heimdal_versions} ; do
|
|
||||||
v="openssl-${vo}-heimdal-${vh}"
|
|
||||||
build "${v}" \
|
|
||||||
heimdal ${vh} \
|
|
||||||
"configure ${wok4} ${wssl}-${vo} ${wssli}-${vo}/include" \
|
|
||||||
"${targetdir}/heimdal-${vh}/bin/krb5-config --libs | grep lcrypto" \ || \
|
|
||||||
{ failed="${failed} ${v}" ; logprint ${v} failed ; }
|
|
||||||
done
|
|
||||||
done
|
|
||||||
|
|
||||||
logprint === building krb4
|
|
||||||
for vo in ${openssl_versions} ; do
|
|
||||||
for vk in ${krb4_versions} ; do
|
|
||||||
v="openssl-${vo}-krb4-${vk}"
|
|
||||||
build "${v}" \
|
|
||||||
krb4 ${vk} \
|
|
||||||
"configure ${wssl}-${vo}" \
|
|
||||||
"${targetdir}/krb4-${vk}/bin/krb4-config --libs | grep lcrypto"|| \
|
|
||||||
{ failed="${failed} ${v}" ; logprint ${v} failed ; }
|
|
||||||
done
|
|
||||||
done
|
|
||||||
|
|
||||||
logprint === building heimdal with krb4 versions
|
|
||||||
for vo in ${openssl_versions} ; do
|
|
||||||
for vk in ${krb4_versions} ; do
|
|
||||||
for vh in ${heimdal_versions} ; do
|
|
||||||
v="openssl-${vo}-krb4-${vk}-heimdal-${vh}"
|
|
||||||
build "${v}" \
|
|
||||||
heimdal ${vh} \
|
|
||||||
"configure ${wk4c}-${vk}${bk4c} ${wssl}-${vo} ${wssli}-${vo}/include" \
|
|
||||||
"${targetdir}/heimdal-${vh}/bin/krb5-config --libs | grep lcrypto && ${targetdir}/heimdal-${vh}/bin/krb5-config --libs | grep krb4" \
|
|
||||||
|| \
|
|
||||||
{ failed="${failed} ${v}" ; logprint ${v} failed ; }
|
|
||||||
done
|
|
||||||
done
|
|
||||||
done
|
|
||||||
|
|
||||||
logprint === building heimdal without krb4 and openssl versions
|
|
||||||
for vh in ${heimdal_versions} ; do
|
|
||||||
v="des-heimdal-${vh}"
|
|
||||||
build "${v}" \
|
|
||||||
heimdal ${vh} \
|
|
||||||
"configure ${wok4} ${wossl}" || \
|
|
||||||
{ failed="${failed} ${v}" ; logprint ${v} failed ; }
|
|
||||||
done
|
|
||||||
|
|
||||||
logprint all done
|
|
||||||
[ "${failed}" != "" ] && logprint "failed: ${failed}"
|
|
||||||
exit 0
|
|
Loading…
x
Reference in New Issue
Block a user