[LON-CAPA-cvs] cvs: loncom / lonlocal.pm
foxr
lon-capa-cvs@mail.lon-capa.org
Fri, 28 May 2004 09:39:11 -0000
foxr Fri May 28 05:39:11 2004 EDT
Modified files:
/loncom lonlocal.pm
Log:
Retabinate to match loncapa coding standards.
Index: loncom/lonlocal.pm
diff -u loncom/lonlocal.pm:1.1 loncom/lonlocal.pm:1.2
--- loncom/lonlocal.pm:1.1 Wed May 26 06:21:23 2004
+++ loncom/lonlocal.pm Fri May 28 05:39:11 2004
@@ -0,0 +1,112 @@
+#
+# $Id: lonlocal.pm,v 1.2 2004/05/28 09:39:11 foxr Exp $
+#
+# Copyright Michigan State University Board of Trustees
+#
+# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
+#
+# LON-CAPA is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# LON-CAPA is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with LON-CAPA; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# /home/httpd/html/adm/gpl.txt
+#
+# http://www.lon-capa.org/
+#
+package lonlocal;
+
+#
+# Module that provides support for local connections between secure
+# lonc and secure lond.
+#
+# A local connection exchanges one-time session keys through a
+# file that is written in the certificate directory by lonc and
+# read/deleted by lond. The file is created with permissions
+# rw------- (0600) to prevent it from being snooped unless the system
+# itself has been broken. In addition the file will not be around
+# for very long so it will be hard to find.
+#
+
+use strict;
+
+# CPAN/standard modules
+
+use English;
+use Crypt::IDEA;
+
+# LONCAPA modules
+
+use LONCAPA::Configuration;
+
+# Global variables:
+
+my $perlvar; # Refers to the apache perlsetvar hash.
+
+# Initialization
+
+$perlvar = LONCAPA::Configuration::read_conf('loncapa.conf');
+
+
+#------------------------------------------------------------------------
+#
+# Name BuildKey
+# Description: Create an encryption key.
+# Returns: The key.
+#
+sub CreateCipherKey {
+
+ my $keylength;
+ my $binaryKey;
+ my $cipherkey;
+
+ # we'll use the output of /dev/random to produce our key.
+ # On a system with decent entropy, this ought to be much more
+ # random than all the playing that used to be done to get a key.
+ #
+
+ $keylength = IDEA::keysize();
+ open(RANDOM, "</dev/random");
+ sysread(RANDOM, $binaryKey, $keylength);
+ close RANDOM;
+
+ # The key must be returned in a stringified form in order to be
+ # transmitted to the peer:
+
+ my $hexdigits = $keylength*2; # Assume 8 bits/byte.
+ my $template = "H".$hexdigits;
+ $cipherkey = unpack($template, $binaryKey);
+
+ return $cipherkey;
+}
+
+#------------------------------------------------------------------------
+#
+# Name CreateKeyFile
+# Description Creates a private key file and writes an IDEA key into it.
+#
+# Returns
+# A two element list containing:
+# - The private key that was created
+# - The full path to the file that contains it.
+#
+sub CreateKeyFile {
+
+ # To create the file we need some perlvars to tell us where the
+ # certificate directory. We'll make a file named localkey.$pid
+ # there, and set the mode before writing into it.
+ #
+
+
+}
+
+