diff options
| author | Lennart Poettering <lennart@poettering.net> | 2003-12-04 21:09:48 +0000 |
|---|---|---|
| committer | Lennart Poettering <lennart@poettering.net> | 2003-12-04 21:09:48 +0000 |
| commit | b3023ac69b16bc682bbfb4a38ce63667f6b2cabe (patch) | |
| tree | ed7d6896aea2fa807f28ca503b3e0b44fb88ee77 /utils/seppl-gen-key | |
| parent | 636960fbb999b4b47ee0cb536bba8c17e8dd7d0d (diff) | |
may fixes from dbindner
git-svn-id: file:///home/lennart/svn/public/seppl/trunk@16 91a2fd9b-5dcb-0310-a70a-d71e310228e6
Diffstat (limited to 'utils/seppl-gen-key')
| -rwxr-xr-x | utils/seppl-gen-key | 110 |
1 files changed, 0 insertions, 110 deletions
diff --git a/utils/seppl-gen-key b/utils/seppl-gen-key deleted file mode 100755 index cc5817e..0000000 --- a/utils/seppl-gen-key +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/python - -# $Id: Makefile.am 40 2003-10-27 18:32:45Z lennart $ -# -# This file is part of seppl. -# -# seppl 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. -# -# seppl 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 seppl; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - -from seppl_common import * -import getopt, sys - -def genkey(a, name, f): - - n, b = find_alg_by_number(a) - - if b == 0: - return -1 - - fd = open("/dev/random", "r+") - key = fd.read(b/8) - fd.close() - - if (len(key) != b/8): - sys.stderr("ERROR: Cannot generate randomness.\n") - return - - if f == dump_key_xml: - print "<seppl-keyring>" - - f(a, name, key) - - if f == dump_key_xml: - print "</seppl-keyring>" - - return 0 - -algorithm = "aes" -bits = 128 -name = "def" -func = dump_key_xml - -def usage(): - global algorithm, bits, name, func - x = { dump_key_xml : "disable", dump_key_bin : "enable" } - - print "%s:" % sys.argv[0] - print " -h --help Show this help" - print " -x --no-xml No xml output (%s)" % x[func] - print " -a --algorithm ALGORITHM Specify algorithm (%s)" % algorithm - print " -b --bits BITS Specify key length (%s)" % bits - print " -n --name NAME Specify key name (%s)" % name - - -def main(): - global algorithm, bits, name, func - - try: - opts, args = getopt.getopt(sys.argv[1:], "hxa:b:n:", ["help", "no-xml", "algorithm=", "bits=", "name="]) - except getopt.GetoptError: - usage() - sys.exit(1) - - u = 0; - - for o, a in opts: - if o in ("-h", "--help"): - u = 1 - - if o in ("-x", "--no-xml"): - func = dump_key_bin - - if o in ("-a", "--algorithm"): - algorithm = a - - if o in ("-b", "--bits"): - bits = int(a) - - if o in ("-n", "--name"): - name = a[:7] - - if u: - usage() - sys.exit(0) - - - a = find_alg_by_name(algorithm, bits) - - if a == -1: - sys.stderr.write("ERROR: Cipher not available\n") - sys.exit(2) - - genkey(a, name, func) - -if __name__ == "__main__": - main() - - - |
