Skip to content
Browse files

copyright changes, minor cleanup

  • Loading branch information...
1 parent f35c5f2 commit 4a231ebc9d0df083953347b80aaa004331835d77 @cconlon committed Feb 16, 2012
View
8 README
@@ -3,9 +3,9 @@ Kerberos Android NDK Sample Application
This is a sample Android NDK application which acts as a simple GUI wrapper
around the MIT Kerberos kinit, klist, kvno, and kdestroy client
-applications as well as provides a Java GSS-API interface. The GSS-API
-interface is a Java wrapper for the existing Kerberos GSS-API C-bindings and
-was created using SWIG.
+applications as well as provides a sample client which uses the Java
+GSS-API interface. The GSS-API interface is a Java wrapper for the existing
+Kerberos GSS-API C-bindings and was created using SWIG.
This package includes cross-compiled versions of the MIT Kerberos
libraries as well as the CyaSSL Embedded SSL Library. It should be
@@ -14,7 +14,7 @@ Kerberos libraries or the GSS-API interface in their own Android NDK
Applications.
By default, this package uses pre-built static Kerberos and CyaSSL
-libraries, which are needed in order to be linked to the KerberosApp
+libraries which are needed in order to be linked to the KerberosApp
application's native library (libkerberosapp.so).
For detailed information on the Java GSS-API interface, please see the
View
60 android-config.sh
@@ -4,26 +4,32 @@
# Program : android-configure.sh
# Author : Chris Conlon, yaSSL (www.yassl.com)
#
-# Date : October 5, 2011
+# Date : February 15, 2012
#
# Description: This script will configure the MIT Kerberos library
# for cross-compilation by the Android NDK stand-
# alone toolchain.
#
# Instructions:
-# 1) Download, install, and set up Android NDK standalone
-# toolchain.
+# 1) Download, install, and set up the Android SDK and Android NDK
+# standalone toolchain.
+# SDK: http://developer.android.com/sdk/index.html
+# NDK: http://developer.android.com/sdk/ndk/index.html
# 2) Place this script in the /src directory of the kerberos
# source directory.
# 3) Run ./autoconf if needed
# 4) Run ./android-configure.sh
-# 5) Remove pkinit plugin:
-# rm -r ./plugins/preauth/pkinit
+# 5) Exclude the following directories by removing or renaming them.
+# NOTE: This script does this automatically.
+# mv ./clients ./clients.exclude [ kerberos clients ]
+# mv ./tests ./tests.exclude [ kerberos tests ]
+# mv ./appl ./appl.exclude [ kerberos applications ]
+# mv ./kadmin ./kadmin.exclude [ kadmin ]
# 6) Run make
# 7) Install in desired location:
-# make DESTDIR=<staging/path/here> install
-# 8) Copy built libraries from staging location
-# to desired Android project.
+# make DESTDIR=<staging/path/here> install
+# 8) Copy built libraries from staging location to desired
+# Android project.
#
## Add Android NDK Cross Compile toolchain to path
@@ -35,22 +41,46 @@ export CCTOOL="$CCBIN/arm-linux-androideabi-"
## Export our ARM/Android NDK Cross-Compile tools
export CC="${CCTOOL}gcc"
-export CXX="${CCTOOL}g++"
-export NM="${CCTOOL}nm"
-export STRIP="${CCTOOL}strip"
export RANLIB="${CCTOOL}ranlib"
export AR="${CCTOOL}ar"
-export LD="${CCTOOL}ld"
-## Set up proper FLAGS
+## Point these to your cross-compiled CyaSSL library location. CyaSSL can be
+## built for Android using the cyassl-android-ndk package or by
+## cross-compiling it for Android using yaSSL's shell script (www.yassl.com)
+## and the Android NDK Standalone toolchain.
export CYASSL_LIB="/Users/chrisc/android/projects/cyassl-android-ndk/obj/local/armeabi"
export CYASSL_INC="/Users/chrisc/android/projects/cyassl-android-ndk/jni/cyassl/include"
export LDFLAGS="-L$CYASSL_LIB -lm"
export CFLAGS="-I$CYASSL_INC -DANDROID"
## Configure the library
-
ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes krb5_cv_attr_constructor_destructor=yes ac_cv_func_regcomp=yes ac_cv_printf_positional=no ./configure --target=arm-linux-androideabi --host=arm-linux-androideabi --enable-static --disable-shared --with-crypto-impl=cyassl --with-prng-alg=os
-sed -i '' 's/#define KRB5_DNS_LOOKUP 1/#undef KRB5_DNS_LOOKUP/g' include/autoconf.h
+## Adjust autoconf.h's KRB5_DNS_LOOKUP definition
+#unamestr = `uname`
+unamestr=$(uname)
+if [[ $unamestr == 'Linux' ]]; then
+ sed -i 's/#define KRB5_DNS_LOOKUP 1/#undef KRB5_DNS_LOOKUP/g' include/autoconf.h
+elif [[ $unamestr == 'Darwin' ]]; then
+ sed -i '' 's/#define KRB5_DNS_LOOKUP 1/#undef KRB5_DNS_LOOKUP/g' include/autoconf.h
+fi
+
+## Skip building the parts we don't need. After running ./configure, if a
+## folder is renamed or deleted, it will be skipped during the build process.
+if [ -d "./appl" ]; then
+ mv ./appl ./appl.exclude
+ echo "Renamed ./appl to ./appl.exclude"
+fi
+if [ -d "./clients" ]; then
+ mv ./clients ./clients.exclude
+ echo "Renamed ./clients to ./clients.exclude"
+fi
+if [ -d "./tests" ]; then
+ mv ./tests ./tests.exclude
+ echo "Renamed ./tests to ./tests.exclude"
+fi
+if [ -d "./kadmin" ]; then
+ mv ./kadmin ./kadmin.exclude
+ echo "Renamed ./kadmin to ./kadmin.exclude"
+fi
View
4 jni/edu_mit_kerberos_KerberosAppActivity.h
@@ -1,8 +1,8 @@
/*
* edu_mit_kerberos_KerberosAppActivity.h
*
- * Copyright 1990, 2008 by the Massachusetts Institute of Technology.
- * All Rights Reserved.
+ * Copyright (C) 2012 by the Massachusetts Institute of Technology.
+ * All rights reserved.
*
* Export of this software from the United States of America may
* require a specific license from the United States Government.
View
6 jni/gsswrapper_wrap.h
@@ -1,8 +1,8 @@
/*
* gsswrapper_wrap.h
*
- * Copyright 1990, 2008 by the Massachusetts Institute of Technology.
- * All Rights Reserved.
+ * Copyright (C) 2012 by the Massachusetts Institute of Technology.
+ * All rights reserved.
*
* Export of this software from the United States of America may
* require a specific license from the United States Government.
@@ -24,6 +24,8 @@
* or implied warranty.
*
* Function prototypes for SWIG-generated functions.
+ *
+ * Original source developed by yaSSL (http://www.yassl.com)
*
*/
View
4 jni/kerberosapp.c
@@ -1,8 +1,8 @@
/*
* kerberosapp.c
*
- * Copyright 1990, 2008 by the Massachusetts Institute of Technology.
- * All Rights Reserved.
+ * Copyright (C) 2012 by the Massachusetts Institute of Technology.
+ * All rights reserved.
*
* Export of this software from the United States of America may
* require a specific license from the United States Government.
View
4 jni/kerberosapp.h
@@ -1,8 +1,8 @@
/*
* kerberosapp.h
*
- * Copyright 1990, 2008 by the Massachusetts Institute of Technology.
- * All Rights Reserved.
+ * Copyright (C) 2012 by the Massachusetts Institute of Technology.
+ * All rights reserved.
*
* Export of this software from the United States of America may
* require a specific license from the United States Government.
View
87 src/edu/mit/kerberos/KerberosAppActivity.java
@@ -3,8 +3,8 @@
/*
* KerberosAppActivity.java
*
- * Copyright 1990, 2008 by the Massachusetts Institute of Technology.
- * All Rights Reserved.
+ * Copyright (C) 2012 by the Massachusetts Institute of Technology.
+ * All rights reserved.
*
* Export of this software from the United States of America may
* require a specific license from the United States Government.
@@ -84,7 +84,6 @@ public void onClick(View v) {
TextView tv = (TextView) findViewById(R.id.textView);
EditText principal = (EditText) findViewById(R.id.editText1);
- //uid = android.os.Process.myUid();
String prinValue = principal.getText().toString();
int ret = 0;
@@ -437,7 +436,7 @@ private int Authenticate(Socket clientSocket,
maj_status = gsswrapper.gss_indicate_mechs(min_status, mech_set);
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "gss_indicate_mechs(mech_set)", min_status,
- maj_status);
+ maj_status);
gsswrapper.gss_release_oid_set(min_status, mech_set);
return -1;
}
@@ -455,7 +454,7 @@ private int Authenticate(Socket clientSocket,
gsswrapper.getGSS_C_NT_USER_NAME(), clientName);
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "gss_import_name(inClientName)",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
}
@@ -466,7 +465,7 @@ private int Authenticate(Socket clientSocket,
null, time_rec);
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "gss_acquire_cred", min_status,
- maj_status);
+ maj_status);
return -1;
}
@@ -478,7 +477,7 @@ private int Authenticate(Socket clientSocket,
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "setting negotiation mechanism",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
} else {
tv.append("Successfully set neg. mechanism\n");
@@ -496,14 +495,14 @@ private int Authenticate(Socket clientSocket,
clientCredentials, name, lifetime, cred_usage, temp_mech_set);
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "gss_inquire_cred(temp_mech_set)",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
}
maj_status = gsswrapper.gss_release_oid_set(min_status,
temp_mech_set);
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "gss_release_oid_set(temp_mech_set)",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
}
@@ -513,7 +512,7 @@ private int Authenticate(Socket clientSocket,
clientName, clientName_dup);
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "duplicating client name",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
}
gsswrapper.gss_release_name(min_status, clientName_dup);
@@ -524,7 +523,7 @@ private int Authenticate(Socket clientSocket,
clientName, gss_mech_krb5, clientCanonicalized);
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "canonicalizing client name",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
}
@@ -553,7 +552,7 @@ private int Authenticate(Socket clientSocket,
gsswrapper.getGSS_C_NT_HOSTBASED_SERVICE(), serverName);
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "gss_import_name(inServiceName)",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
}
@@ -597,7 +596,7 @@ private int Authenticate(Socket clientSocket,
byte[] temp_token = new byte[(int)outputToken.getLength()];
temp_token = gsswrapper.getDescArray(outputToken);
tv.append("Generated Token Length = " +
- temp_token.length + "\n");
+ temp_token.length + "\n");
err = Util.WriteToken(serverOut, temp_token);
/* free the output token */
@@ -621,11 +620,11 @@ private int Authenticate(Socket clientSocket,
gsswrapper.setDescArray(inputToken, inputTokenBuffer);
inputToken.setLength(inputTokenBuffer.length);
tv.append("Received Token Length = " +
- inputToken.getLength() + "\n");
+ inputToken.getLength() + "\n");
}
} else if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "gss_init_sec_context",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
}
}
@@ -671,7 +670,7 @@ private int Communicate(Socket clientSocket,
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "wrapping message, gss_wrap",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
} else if (state[0] == 0) {
tv.append("Warning! Message not encrypted.\n");
@@ -683,7 +682,7 @@ private int Communicate(Socket clientSocket,
err = Util.WriteToken(serverOut, temp_token);
if (err != 0) {
tv.append("Error sending wrapped message to server, " +
- "WriteToken\n");
+ "WriteToken\n");
return -1;
}
@@ -701,7 +700,7 @@ private int Communicate(Socket clientSocket,
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "verifying signature, gss_verify_mic",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
} else {
tv.append("Signature Verified\n");
@@ -735,7 +734,7 @@ private int AltCommunicate(Socket clientSocket,
context, context_token);
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "exporting security context",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
} else {
tv.append("Successfully exported security context\n");
@@ -745,7 +744,7 @@ private int AltCommunicate(Socket clientSocket,
context_token, context);
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "importing security context",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
} else {
tv.append("Successfully imported security context\n");
@@ -759,7 +758,7 @@ private int AltCommunicate(Socket clientSocket,
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "wrapping message, gss_seal",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
} else if (state[0] == 0) {
tv.append("Warning! Message not encrypted.\n");
@@ -771,7 +770,7 @@ private int AltCommunicate(Socket clientSocket,
err = Util.WriteToken(serverOut, temp_token);
if (err != 0) {
tv.append("Error sending wrapped message to server, " +
- "WriteToken\n");
+ "WriteToken\n");
return -1;
}
@@ -789,7 +788,7 @@ private int AltCommunicate(Socket clientSocket,
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "verifying signature, gss_verify",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
} else {
tv.append("Signature Verified\n");
@@ -834,7 +833,7 @@ private int PrintContextInfo()
is_local, is_open);
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "Inquiring context: gss_inquire_context",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
}
@@ -843,7 +842,7 @@ private int PrintContextInfo()
time_rec);
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "checking for valid context",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
}
@@ -852,7 +851,7 @@ private int PrintContextInfo()
src_name, sname, name_type);
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "Displaying source name: gss_display_name",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
}
@@ -861,7 +860,7 @@ private int PrintContextInfo()
targ_name, tname, name_type);
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "Displaying target name: gss_display_name",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
}
@@ -885,7 +884,7 @@ private int PrintContextInfo()
name_type, oid_name);
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "Converting oid->string: gss_oid_to_str",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
}
@@ -897,7 +896,7 @@ private int PrintContextInfo()
mechanism, mech_attrs, known_attrs);
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "Inquiring mechanism attributes",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
}
tv.append(" Mechanism Attributes:\n");
@@ -911,7 +910,7 @@ private int PrintContextInfo()
mech_attrs.getElement(j), name, short_desc, long_desc);
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "Displaying mechanism attributes",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
}
tv.append(" " + name.getValue() + "\n");
@@ -932,7 +931,7 @@ private int PrintContextInfo()
known_attrs.getElement(k), name, short_desc, long_desc);
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "Displaying known attributes",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
}
tv.append(" " + name.getValue() + "\n");
@@ -949,15 +948,15 @@ private int PrintContextInfo()
mechanism, mech_names);
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "Inquiring mech names",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
}
maj_status = gsswrapper.gss_oid_to_str(min_status,
mechanism, oid_name);
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "Converting oid->string",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
}
@@ -969,7 +968,7 @@ private int PrintContextInfo()
mech_names.getElement(i), oid_name);
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "Converting oid->string",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
}
tv.append(" " + i + ": " + oid_name.getValue() + "\n");
@@ -982,7 +981,7 @@ private int PrintContextInfo()
mechanism, sasl_mech_name, mech_name, mech_description);
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "Inquiring SASL name",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
}
tv.append("SASL mech: " + sasl_mech_name.getValue() + "\n");
@@ -995,7 +994,7 @@ private int PrintContextInfo()
sasl_mech_name, oid);
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "Inquiring mechs for SASL name",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
}
@@ -1011,11 +1010,11 @@ private int PrintContextInfo()
100, max_size);
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "determining largest wrapped message size",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
} else {
tv.append("Largest message size able to be wrapped: "
- + max_size[0] + "\n");
+ + max_size[0] + "\n");
}
gsswrapper.gss_release_buffer(min_status, sasl_mech_name);
@@ -1055,15 +1054,15 @@ private int MiscFunctionTests()
accept_lifetime, cred_usage);
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "inquiring credential info from mech",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
} else {
tv.append("Credential Principal Name: "
- + name.getExternal_name().getValue() + "\n");
+ + name.getExternal_name().getValue() + "\n");
tv.append("Credential Valid for Initiating Contexts for "
- + init_lifetime[0] + " seconds\n");
+ + init_lifetime[0] + " seconds\n");
tv.append("Credential Valid for Accepting Contexts for "
- + accept_lifetime[0] + " seconds\n");
+ + accept_lifetime[0] + " seconds\n");
tv.append("Credential Usage: " + cred_usage[0] + "\n");
}
@@ -1075,7 +1074,7 @@ private int MiscFunctionTests()
context, 0, prf_in, 19, prf_out);
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "testing gss_pseudo_random function",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
}
@@ -1092,7 +1091,7 @@ private int MiscFunctionTests()
mechs);
if (maj_status != GSS_S_COMPLETE) {
Util.displayError(tv, "gss_indicate_mechs_by_attrs",
- min_status, maj_status);
+ min_status, maj_status);
return -1;
}
View
20 src/edu/mit/kerberos/Util.java
@@ -24,7 +24,6 @@
*
* Original source developed by yaSSL (http://www.yassl.com)
*
- * Description:
* Java MIT Kerberos GSS-API interface utility functions.
*
*/
@@ -44,10 +43,10 @@ public static void errorExit(TextView tv, String msg, long[] min_stat, long maj_
{
System.out.println("Error: " + msg);
System.out.println("maj_stat = " + maj_stat + ", min_stat = "
- + (int)min_stat[0]);
+ + (int)min_stat[0]);
tv.append("Error: " + msg + "\n");
tv.append("maj_stat = " + maj_stat + ", min_stat = "
- + (int)min_stat[0] + "\n");
+ + (int)min_stat[0] + "\n");
display_status(tv, min_stat, maj_stat);
System.exit(1);
}
@@ -60,10 +59,10 @@ public static void displayError(TextView tv, String msg, long[] min_stat,
{
System.out.println("Error: " + msg);
System.out.println("maj_stat = " + maj_stat + ", min_stat = "
- + (int)min_stat[0]);
+ + (int)min_stat[0]);
tv.append("Error: " + msg + "\n");
tv.append("maj_stat = " + maj_stat + ", min_stat = "
- + (int)min_stat[0] + "\n");
+ + (int)min_stat[0] + "\n");
display_status(tv, min_stat, maj_stat);
}
@@ -87,9 +86,9 @@ public static void display_status(TextView tv, long[] min_stat, long maj_stat)
System.exit(1);
}
System.out.println("Error message (major): "
- + storage_buffer.getValue());
+ + storage_buffer.getValue());
tv.append("Error message (major): "
- + storage_buffer.getValue() + "\n");
+ + storage_buffer.getValue() + "\n");
// Print mechanism minor status code error
ret = gsswrapper.gss_display_status_wrap(maj_stat, min_stat[0],
@@ -101,9 +100,9 @@ public static void display_status(TextView tv, long[] min_stat, long maj_stat)
System.exit(1);
}
System.out.println("Error message (minor): "
- + storage_buffer.getValue());
+ + storage_buffer.getValue());
tv.append("Error message (minor): "
- + storage_buffer.getValue() + "\n");
+ + storage_buffer.getValue() + "\n");
}
/*
@@ -119,13 +118,12 @@ public static int WriteToken(OutputStream outStream, byte[] outputToken)
/* First send the size of our byte array */
byte[] size = Util.intToByteArray(outputToken.length);
System.out.println("... sending byte array size: " +
- Util.byteArrayToInt(size));
+ Util.byteArrayToInt(size));
outStream.write(size);
/* Now send our actual byte array */
System.out.println("... sending byte array: ");
- //printByteArray(outputToken);
System.out.println("... outputToken.length = " + outputToken.length);
outStream.write(outputToken);
return 0;

0 comments on commit 4a231eb

Please sign in to comment.
Something went wrong with that request. Please try again.