Commit 251c7f43 authored by Milan Broz's avatar Milan Broz

Merge pycryptsetup (Python libcryptsetup bindings).

git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@672 36d66b0a-2a48-0410-832c-cd162a569da5
parent 7835b365
2011-11-05 Milan Broz <mbroz@redhat.com>
* Merge pycryptsetup (Python libcryptsetup bindings).
2011-10-27 Milan Broz <mbroz@redhat.com>
* Fix crypt_get_volume_key_size() for plain device.
* Fix FSF address in license text.
......
......@@ -3,6 +3,7 @@ SUBDIRS = \
lib \
src \
man \
python \
tests \
po
......
AC_PREREQ([2.67])
AC_INIT([cryptsetup],[1.4.0])
AC_INIT([cryptsetup],[1.4.1-cvs])
dnl library version from <major>.<minor>.<release>[-<suffix>]
LIBCRYPTSETUP_VERSION=$(echo $PACKAGE_VERSION | cut -f1 -d-)
......@@ -260,6 +260,25 @@ AC_DEFUN([CS_NUM_WITH], [AC_ARG_WITH([$1],
[CS_DEFINE([$1], [$3], [$2])]
)])
dnl ==========================================================================
dnl Python bindings
AC_ARG_ENABLE([python], AS_HELP_STRING([--enable-python],[enable Python bindings]),
[with_python=$enableval],
[with_python=no])
if test "x$with_python" = "xyes"; then
AM_PATH_PYTHON([2.4])
if ! test -x "$PYTHON-config" ; then
AC_MSG_ERROR([Cannot find python development packages to build bindings])
fi
PYTHON_INCLUDES=$($PYTHON-config --includes)
AC_SUBST(PYTHON_INCLUDES)
fi
AM_CONDITIONAL([PYTHON_CRYPTSETUP], [test "x$with_python" = "xyes"])
dnl ==========================================================================
CS_STR_WITH([plain-hash], [password hashing function for plain mode], [ripemd160])
CS_STR_WITH([plain-cipher], [cipher for plain mode], [aes])
CS_STR_WITH([plain-mode], [cipher mode for plain mode], [cbc-essiv:sha256])
......@@ -288,5 +307,6 @@ src/Makefile
po/Makefile.in
man/Makefile
tests/Makefile
python/Makefile
])
AC_OUTPUT
INCLUDES = -I$(top_srcdir)/lib $(PYTHON_INCLUDES)
EXTRA_DIST = pycryptsetup-test.py
CLEANFILES = *.img
if PYTHON_CRYPTSETUP
TESTS = pycryptsetup-test.py
pyexec_LTLIBRARIES = pycryptsetup.la
pycryptsetup_la_SOURCES = pycryptsetup.c
pycryptsetup_la_CPPFLAGS = $(AM_CPPFLAGS) $(PYTHON_CPPFLAGS)
pycryptsetup_la_LDFLAGS = -avoid-version -module
pycryptsetup_la_LIBADD = $(top_srcdir)/lib/libcryptsetup.la -lpython$(PYTHON_VERSION)
else
all:
endif
#!/usr/bin/python
import sys
import os
sys.path.insert(0, ".libs")
import pycryptsetup
IMG = "test.img"
PASSWORD = "password"
DEVICE = "pycryptsetup_test_dev"
def log(pri, txt):
if pri > 1:
return
print txt,
return
def askyes(txt):
print "Asking about:", txt, "\n"
return 1
def askpassword(txt):
return PASSWORD
os.system("dd if=/dev/zero of=" + IMG + " bs=1M count=32 >/dev/null 2>&1")
c = pycryptsetup.CryptSetup(
device = IMG,
name = DEVICE,
yesDialog = askyes,
logFunc = log,
passwordDialog = askpassword)
r = c.isLuks()
print "isLuks :", r
c.luksFormat()
print "isLuks :", c.isLuks()
print "luksUUID:", c.luksUUID()
print "addKey :", c.addKeyByVolumeKey(PASSWORD)
print "activate:", c.activate(name = DEVICE, passphrase = PASSWORD)
print "status :", c.status()
info = c.info()
print "cipher :", info["cipher"]
print "cmode :", info["cipher_mode"]
print "deact. :", c.deactivate()
del c
os.remove(IMG)
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment