|
Panu Matilainen |
34fad6 |
diff -r ec9e6c427068 Makefile.am
|
|
Panu Matilainen |
34fad6 |
--- a/Makefile.am Wed Oct 24 16:02:51 2007 +0300
|
|
Panu Matilainen |
34fad6 |
+++ b/Makefile.am Thu Nov 01 10:56:58 2007 +0100
|
|
Panu Matilainen |
34fad6 |
@@ -10,14 +10,14 @@ EXTRA_DIST = CHANGES ChangeLog CREDITS D
|
|
Panu Matilainen |
34fad6 |
po/*.in po/*.po po/rpm.pot \
|
|
Panu Matilainen |
34fad6 |
rpm.magic rpmpopt-$(VERSION) rpmqv.c
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
-SUBDIRS = po misc @WITH_ZLIB_SUBDIR@ @WITH_ELFUTILS_SUBDIR@ @WITH_MAGIC_SUBDIR@ @WITH_DB_SUBDIR@ @WITH_SQLITE3_SUBDIR@ @WITH_POPT_SUBDIR@ @WITH_BEECRYPT_SUBDIR@ @WITH_NEON_SUBDIR@ lua rpmio rpmdb lib build @WITH_PYTHON_SUBDIR@ tools scripts doc .
|
|
Panu Matilainen |
34fad6 |
+SUBDIRS = po misc @WITH_ZLIB_SUBDIR@ @WITH_ELFUTILS_SUBDIR@ @WITH_MAGIC_SUBDIR@ @WITH_DB_SUBDIR@ @WITH_SQLITE3_SUBDIR@ @WITH_POPT_SUBDIR@ @WITH_NEON_SUBDIR@ lua rpmio rpmdb lib build @WITH_PYTHON_SUBDIR@ tools scripts doc .
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
INCLUDES = \
|
|
Panu Matilainen |
34fad6 |
-I$(top_srcdir)/build \
|
|
Panu Matilainen |
34fad6 |
-I$(top_srcdir)/lib \
|
|
Panu Matilainen |
34fad6 |
-I$(top_srcdir)/rpmdb \
|
|
Panu Matilainen |
34fad6 |
-I$(top_srcdir)/rpmio \
|
|
Panu Matilainen |
34fad6 |
- @WITH_BEECRYPT_INCLUDE@ \
|
|
Panu Matilainen |
34fad6 |
+ @WITH_NSS_INCLUDE@ \
|
|
Panu Matilainen |
34fad6 |
@WITH_POPT_INCLUDE@ \
|
|
Panu Matilainen |
34fad6 |
-I$(top_srcdir)/misc \
|
|
Panu Matilainen |
34fad6 |
@WITH_LIBELF_INCLUDE@ \
|
|
Panu Matilainen |
34fad6 |
@@ -25,7 +25,7 @@ INCLUDES = \
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
staticLDFLAGS = @LDFLAGS_STATIC@ @LDFLAGS_NPTL@
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
-myLDFLAGS = @WITH_LIBELF_LIB@ @WITH_BEECRYPT_LIB@
|
|
Panu Matilainen |
34fad6 |
+myLDFLAGS = @WITH_LIBELF_LIB@
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
myLDADD = \
|
|
Panu Matilainen |
34fad6 |
$(top_builddir)/lib/librpm.la \
|
|
Panu Matilainen |
34fad6 |
@@ -33,6 +33,7 @@ myLDADD = \
|
|
Panu Matilainen |
34fad6 |
$(top_builddir)/rpmio/librpmio.la \
|
|
Panu Matilainen |
34fad6 |
@WITH_POPT_LIB@ \
|
|
Panu Matilainen |
34fad6 |
@WITH_ZLIB_LIB@ \
|
|
Panu Matilainen |
34fad6 |
+ @WITH_NSS_LIB@ \
|
|
Panu Matilainen |
34fad6 |
@LIBMISC@
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
rpmbindir = `echo $(bindir) | sed -e s,usr/bin,bin,`
|
|
Panu Matilainen |
34fad6 |
@@ -71,7 +72,7 @@ rpmd.o: $(top_srcdir)/rpmqv.c
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
rpmi_SOURCES =
|
|
Panu Matilainen |
34fad6 |
#rpmi_LDFLAGS = $(myLDFLAGS) $(staticLDFLAGS)
|
|
Panu Matilainen |
34fad6 |
-#rpmi_LDADD = rpmi.o $(myLDADD) @WITH_LIBELF_LIB@ @WITH_BEECRYPT_LIB@
|
|
Panu Matilainen |
34fad6 |
+#rpmi_LDADD = rpmi.o $(myLDADD) @WITH_LIBELF_LIB@
|
|
Panu Matilainen |
34fad6 |
rpmi_LDFLAGS = $(myLDFLAGS)
|
|
Panu Matilainen |
34fad6 |
rpmi_LDADD = rpmi.o $(myLDADD)
|
|
Panu Matilainen |
34fad6 |
rpmi.o: $(top_srcdir)/rpmqv.c
|
|
Panu Matilainen |
34fad6 |
@@ -112,7 +113,6 @@ lint:
|
|
Panu Matilainen |
34fad6 |
`make -s sources -C lib` \
|
|
Panu Matilainen |
34fad6 |
`make -s sources -C rpmdb` \
|
|
Panu Matilainen |
34fad6 |
`make -s sources -C rpmio` \
|
|
Panu Matilainen |
34fad6 |
- `make -s sources -C beecrypt` \
|
|
Panu Matilainen |
34fad6 |
`make -s sources -C file/src` \
|
|
Panu Matilainen |
34fad6 |
`make -s sources -C popt`
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
diff -r ec9e6c427068 autogen.sh
|
|
Panu Matilainen |
34fad6 |
--- a/autogen.sh Wed Oct 24 16:02:51 2007 +0300
|
|
Panu Matilainen |
34fad6 |
+++ b/autogen.sh Thu Nov 01 10:56:58 2007 +0100
|
|
Panu Matilainen |
34fad6 |
@@ -48,9 +48,6 @@ if [ -d zlib ]; then
|
|
Panu Matilainen |
34fad6 |
if [ -d zlib ]; then
|
|
Panu Matilainen |
34fad6 |
(echo "--- zlib"; cd zlib; ./autogen.sh --noconfigure "$@")
|
|
Panu Matilainen |
34fad6 |
fi
|
|
Panu Matilainen |
34fad6 |
-if [ -d beecrypt ]; then
|
|
Panu Matilainen |
34fad6 |
- (echo "--- beecrypt"; cd beecrypt; ./autogen.sh --noconfigure "$@")
|
|
Panu Matilainen |
34fad6 |
-fi
|
|
Panu Matilainen |
34fad6 |
if [ -d elfutils ]; then
|
|
Panu Matilainen |
34fad6 |
(echo "--- elfutils"; cd elfutils; ./autogen.sh --noconfigure "$@")
|
|
Panu Matilainen |
34fad6 |
fi
|
|
Panu Matilainen |
34fad6 |
diff -r ec9e6c427068 build/Makefile.am
|
|
Panu Matilainen |
34fad6 |
--- a/build/Makefile.am Wed Oct 24 16:02:51 2007 +0300
|
|
Panu Matilainen |
34fad6 |
+++ b/build/Makefile.am Thu Nov 01 10:56:58 2007 +0100
|
|
Panu Matilainen |
34fad6 |
@@ -9,7 +9,7 @@ INCLUDES = -I. \
|
|
Panu Matilainen |
34fad6 |
-I$(top_srcdir)/lib \
|
|
Panu Matilainen |
34fad6 |
-I$(top_srcdir)/rpmdb \
|
|
Panu Matilainen |
34fad6 |
-I$(top_srcdir)/rpmio \
|
|
Panu Matilainen |
34fad6 |
- @WITH_BEECRYPT_INCLUDE@ \
|
|
Panu Matilainen |
34fad6 |
+ @WITH_NSS_INCLUDE@ \
|
|
Panu Matilainen |
34fad6 |
@WITH_MAGIC_INCLUDE@ \
|
|
Panu Matilainen |
34fad6 |
@WITH_POPT_INCLUDE@ \
|
|
Panu Matilainen |
34fad6 |
@WITH_LIBELF_INCLUDE@ \
|
|
Panu Matilainen |
34fad6 |
diff -r ec9e6c427068 configure.ac
|
|
Panu Matilainen |
34fad6 |
--- a/configure.ac Wed Oct 24 16:02:51 2007 +0300
|
|
Panu Matilainen |
34fad6 |
+++ b/configure.ac Thu Nov 01 10:56:58 2007 +0100
|
|
Panu Matilainen |
34fad6 |
@@ -463,34 +463,32 @@ AC_SUBST(WITH_LIBDWARF_DEBUGEDIT)
|
|
Panu Matilainen |
34fad6 |
AC_SUBST(WITH_LIBDWARF_DEBUGEDIT)
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
#=================
|
|
Panu Matilainen |
34fad6 |
-# Check for beecrypt library. Prefer external, otherwise internal.
|
|
Panu Matilainen |
34fad6 |
-WITH_BEECRYPT_SUBDIR=
|
|
Panu Matilainen |
34fad6 |
-WITH_BEECRYPT_INCLUDE=
|
|
Panu Matilainen |
34fad6 |
-WITH_BEECRYPT_LIB=
|
|
Panu Matilainen |
34fad6 |
-AC_CHECK_HEADER([beecrypt/beecrypt.h], [
|
|
Panu Matilainen |
34fad6 |
- AC_CHECK_LIB(beecrypt, mpfprintln, [
|
|
Panu Matilainen |
34fad6 |
- AC_DEFINE(HAVE_LIBBEECRYPT, 1, [Define to 1 if you have the 'beecrypt' library (-lbeecrypt).])
|
|
Panu Matilainen |
34fad6 |
- AC_CHECK_HEADER([beecrypt/api.h], [
|
|
Panu Matilainen |
34fad6 |
- AC_DEFINE(HAVE_BEECRYPT_API_H, 1, [Define to 1 if you have the <beecrypt/api.h> header file.])
|
|
Panu Matilainen |
34fad6 |
- ])
|
|
Panu Matilainen |
34fad6 |
- WITH_BEECRYPT_INCLUDE="-I${includedir}/beecrypt"
|
|
Panu Matilainen |
34fad6 |
- WITH_BEECRYPT_LIB="-lbeecrypt"
|
|
Panu Matilainen |
34fad6 |
+# Check for NSS library.
|
|
Panu Matilainen |
34fad6 |
+WITH_NSS_INCLUDE=
|
|
Panu Matilainen |
34fad6 |
+WITH_NSS_LIB=
|
|
Panu Matilainen |
34fad6 |
+check=`pkg-config --version 2>/dev/null`
|
|
Panu Matilainen |
34fad6 |
+if test -n "$check"; then
|
|
Panu Matilainen |
34fad6 |
+ addlib=$(pkg-config --libs nss | sed 's/-lsmime3//;s/-lssl3//')
|
|
Panu Matilainen |
34fad6 |
+ addcppflags=$(pkg-config --cflags nss)
|
|
Panu Matilainen |
34fad6 |
+else
|
|
Panu Matilainen |
34fad6 |
+# Without pkg-config, we'll kludge in some defaults
|
|
Panu Matilainen |
34fad6 |
+ addlib="-lnss3 -lplds4 -lplc4 -lnspr4 -lpthread -ldl"
|
|
Panu Matilainen |
34fad6 |
+ addcppflags="-I/usr/include/nss3 -I/usr/include/nspr4"
|
|
Panu Matilainen |
34fad6 |
+fi
|
|
Panu Matilainen |
34fad6 |
+save_CPPFLAGS="$CPPFLAGS"
|
|
Panu Matilainen |
34fad6 |
+CPPFLAGS="$save_CPPFLAGS $addcppflags"
|
|
Panu Matilainen |
34fad6 |
+AC_CHECK_HEADER([nss3/nss.h], [
|
|
Panu Matilainen |
34fad6 |
+ AC_CHECK_LIB(nss3, NSS_NoDB_Init, [
|
|
Panu Matilainen |
34fad6 |
+ AC_DEFINE(HAVE_LIBNSS, 1, [Define to 1 if you have the 'NSS' library (-lnss3).])
|
|
Panu Matilainen |
34fad6 |
+ WITH_NSS_INCLUDE="$addcppflags"
|
|
Panu Matilainen |
34fad6 |
+ WITH_NSS_LIB="$addlib"
|
|
Panu Matilainen |
34fad6 |
])
|
|
Panu Matilainen |
34fad6 |
],[
|
|
Panu Matilainen |
34fad6 |
- if test -d beecrypt ; then
|
|
Panu Matilainen |
34fad6 |
- AC_DEFINE(HAVE_LIBBEECRYPT, 1, [Define to 1 if you have the 'beecrypt' library (-lbeecrypt).])
|
|
Panu Matilainen |
34fad6 |
- WITH_BEECRYPT_SUBDIR=beecrypt
|
|
Panu Matilainen |
34fad6 |
- WITH_BEECRYPT_INCLUDE="-I\${top_srcdir}/${WITH_BEECRYPT_SUBDIR}"
|
|
Panu Matilainen |
34fad6 |
- WITH_BEECRYPT_LIB="\${top_builddir}/${WITH_BEECRYPT_SUBDIR}/libbeecrypt.la"
|
|
Panu Matilainen |
34fad6 |
- fi
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
- if test -z "${WITH_BEECRYPT_LIB}" ; then
|
|
Panu Matilainen |
34fad6 |
- AC_MSG_ERROR([rpm requires beecrypt])
|
|
Panu Matilainen |
34fad6 |
- fi
|
|
Panu Matilainen |
34fad6 |
-])
|
|
Panu Matilainen |
34fad6 |
-AC_SUBST(WITH_BEECRYPT_SUBDIR)
|
|
Panu Matilainen |
34fad6 |
-AC_SUBST(WITH_BEECRYPT_INCLUDE)
|
|
Panu Matilainen |
34fad6 |
-AC_SUBST(WITH_BEECRYPT_LIB)
|
|
Panu Matilainen |
34fad6 |
+ AC_MSG_ERROR([rpm requires NSS])
|
|
Panu Matilainen |
34fad6 |
+])
|
|
Panu Matilainen |
34fad6 |
+CPPFLAGS="$save_CPPFLAGS"
|
|
Panu Matilainen |
34fad6 |
+AC_SUBST(WITH_NSS_INCLUDE)
|
|
Panu Matilainen |
34fad6 |
+AC_SUBST(WITH_NSS_LIB)
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
#=================
|
|
Panu Matilainen |
34fad6 |
# Check for neon library. Prefer external, otherwise internal.
|
|
Panu Matilainen |
34fad6 |
diff -r ec9e6c427068 lib/Makefile.am
|
|
Panu Matilainen |
34fad6 |
--- a/lib/Makefile.am Wed Oct 24 16:02:51 2007 +0300
|
|
Panu Matilainen |
34fad6 |
+++ b/lib/Makefile.am Thu Nov 01 10:56:58 2007 +0100
|
|
Panu Matilainen |
34fad6 |
@@ -9,7 +9,7 @@ INCLUDES = -I. \
|
|
Panu Matilainen |
34fad6 |
-I$(top_srcdir)/build \
|
|
Panu Matilainen |
34fad6 |
-I$(top_srcdir)/rpmdb \
|
|
Panu Matilainen |
34fad6 |
-I$(top_srcdir)/rpmio \
|
|
Panu Matilainen |
34fad6 |
- @WITH_BEECRYPT_INCLUDE@ \
|
|
Panu Matilainen |
34fad6 |
+ @WITH_NSS_INCLUDE@ \
|
|
Panu Matilainen |
34fad6 |
@WITH_POPT_INCLUDE@ \
|
|
Panu Matilainen |
34fad6 |
-I$(top_srcdir)/misc \
|
|
Panu Matilainen |
34fad6 |
@INCPATH@
|
|
Panu Matilainen |
34fad6 |
diff -r ec9e6c427068 lib/formats.c
|
|
Panu Matilainen |
34fad6 |
--- a/lib/formats.c Wed Oct 24 16:02:51 2007 +0300
|
|
Panu Matilainen |
34fad6 |
+++ b/lib/formats.c Thu Nov 01 10:56:58 2007 +0100
|
|
Panu Matilainen |
34fad6 |
@@ -210,23 +210,17 @@ static /*@only@*/ char * base64Format(in
|
|
Panu Matilainen |
34fad6 |
int lc;
|
|
Panu Matilainen |
34fad6 |
/* XXX HACK ALERT: element field abused as no. bytes of binary data. */
|
|
Panu Matilainen |
34fad6 |
size_t ns = element;
|
|
Panu Matilainen |
34fad6 |
- size_t nt = ((ns + 2) / 3) * 4;
|
|
Panu Matilainen |
34fad6 |
+ size_t nt = 0;
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
/*@-boundswrite@*/
|
|
Panu Matilainen |
34fad6 |
- /*@-globs@*/
|
|
Panu Matilainen |
34fad6 |
- /* Add additional bytes necessary for eol string(s). */
|
|
Panu Matilainen |
34fad6 |
- if (b64encode_chars_per_line > 0 && b64encode_eolstr != NULL) {
|
|
Panu Matilainen |
34fad6 |
- lc = (nt + b64encode_chars_per_line - 1) / b64encode_chars_per_line;
|
|
Panu Matilainen |
34fad6 |
- if (((nt + b64encode_chars_per_line - 1) % b64encode_chars_per_line) != 0)
|
|
Panu Matilainen |
34fad6 |
- ++lc;
|
|
Panu Matilainen |
34fad6 |
- nt += lc * strlen(b64encode_eolstr);
|
|
Panu Matilainen |
34fad6 |
+ if ((enc = b64encode(data, ns, -1)) != NULL) {
|
|
Panu Matilainen |
34fad6 |
+ nt = strlen(enc);
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
- /*@=globs@*/
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
val = t = xmalloc(nt + padding + 1);
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
*t = '\0';
|
|
Panu Matilainen |
34fad6 |
- if ((enc = b64encode(data, ns)) != NULL) {
|
|
Panu Matilainen |
34fad6 |
+ if (enc != NULL) {
|
|
Panu Matilainen |
34fad6 |
t = stpcpy(t, enc);
|
|
Panu Matilainen |
34fad6 |
enc = _free(enc);
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
@@ -310,16 +304,13 @@ static /*@only@*/ char * xmlFormat(int_3
|
|
Panu Matilainen |
34fad6 |
xtag = "string";
|
|
Panu Matilainen |
34fad6 |
break;
|
|
Panu Matilainen |
34fad6 |
case RPM_BIN_TYPE:
|
|
Panu Matilainen |
34fad6 |
- { int cpl = b64encode_chars_per_line;
|
|
Panu Matilainen |
34fad6 |
-/*@-mods@*/
|
|
Panu Matilainen |
34fad6 |
- b64encode_chars_per_line = 0;
|
|
Panu Matilainen |
34fad6 |
-/*@=mods@*/
|
|
Panu Matilainen |
34fad6 |
-/*@-formatconst@*/
|
|
Panu Matilainen |
34fad6 |
- s = base64Format(type, data, formatPrefix, padding, element);
|
|
Panu Matilainen |
34fad6 |
-/*@=formatconst@*/
|
|
Panu Matilainen |
34fad6 |
-/*@-mods@*/
|
|
Panu Matilainen |
34fad6 |
- b64encode_chars_per_line = cpl;
|
|
Panu Matilainen |
34fad6 |
-/*@=mods@*/
|
|
Panu Matilainen |
34fad6 |
+ {
|
|
Panu Matilainen |
34fad6 |
+ /* XXX HACK ALERT: element field abused as no. bytes of binary data. */
|
|
Panu Matilainen |
34fad6 |
+ size_t ns = element;
|
|
Panu Matilainen |
34fad6 |
+ if ((s = b64encode(data, ns, 0)) == NULL) {
|
|
Panu Matilainen |
34fad6 |
+ /* XXX proper error handling would be better. */
|
|
Panu Matilainen |
34fad6 |
+ s = xcalloc(1, padding + (ns / 3) * 4 + 1);
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
xtag = "base64";
|
|
Panu Matilainen |
34fad6 |
} break;
|
|
Panu Matilainen |
34fad6 |
case RPM_CHAR_TYPE:
|
|
Panu Matilainen |
34fad6 |
diff -r ec9e6c427068 lib/package.c
|
|
Panu Matilainen |
34fad6 |
--- a/lib/package.c Wed Oct 24 16:02:51 2007 +0300
|
|
Panu Matilainen |
34fad6 |
+++ b/lib/package.c Thu Nov 01 10:56:58 2007 +0100
|
|
Panu Matilainen |
34fad6 |
@@ -1008,11 +1008,9 @@ rpmRC rpmReadPackageFile(rpmts ts, FD_t
|
|
Panu Matilainen |
34fad6 |
fddig->hashctx = NULL;
|
|
Panu Matilainen |
34fad6 |
/*@switchbreak@*/ break;
|
|
Panu Matilainen |
34fad6 |
case PGPHASHALGO_SHA1:
|
|
Panu Matilainen |
34fad6 |
-#if HAVE_BEECRYPT_API_H
|
|
Panu Matilainen |
34fad6 |
case PGPHASHALGO_SHA256:
|
|
Panu Matilainen |
34fad6 |
case PGPHASHALGO_SHA384:
|
|
Panu Matilainen |
34fad6 |
case PGPHASHALGO_SHA512:
|
|
Panu Matilainen |
34fad6 |
-#endif
|
|
Panu Matilainen |
34fad6 |
dig->sha1ctx = fddig->hashctx;
|
|
Panu Matilainen |
34fad6 |
fddig->hashctx = NULL;
|
|
Panu Matilainen |
34fad6 |
/*@switchbreak@*/ break;
|
|
Panu Matilainen |
34fad6 |
diff -r ec9e6c427068 lib/rpmchecksig.c
|
|
Panu Matilainen |
34fad6 |
--- a/lib/rpmchecksig.c Wed Oct 24 16:02:51 2007 +0300
|
|
Panu Matilainen |
34fad6 |
+++ b/lib/rpmchecksig.c Thu Nov 01 10:56:58 2007 +0100
|
|
Panu Matilainen |
34fad6 |
@@ -447,7 +447,7 @@ rpmRC rpmcliImportPubkey(const rpmts ts,
|
|
Panu Matilainen |
34fad6 |
if (rpmtsOpenDB(ts, (O_RDWR|O_CREAT)))
|
|
Panu Matilainen |
34fad6 |
return RPMRC_FAIL;
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
- if ((enc = b64encode(pkt, pktlen)) == NULL)
|
|
Panu Matilainen |
34fad6 |
+ if ((enc = b64encode(pkt, pktlen, -1)) == NULL)
|
|
Panu Matilainen |
34fad6 |
goto exit;
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
dig = pgpNewDig();
|
|
Panu Matilainen |
34fad6 |
@@ -698,11 +698,9 @@ assert(dig->md5ctx == NULL);
|
|
Panu Matilainen |
34fad6 |
fddig->hashctx = NULL;
|
|
Panu Matilainen |
34fad6 |
/*@switchbreak@*/ break;
|
|
Panu Matilainen |
34fad6 |
case PGPHASHALGO_SHA1:
|
|
Panu Matilainen |
34fad6 |
-#if HAVE_BEECRYPT_API_H
|
|
Panu Matilainen |
34fad6 |
case PGPHASHALGO_SHA256:
|
|
Panu Matilainen |
34fad6 |
case PGPHASHALGO_SHA384:
|
|
Panu Matilainen |
34fad6 |
case PGPHASHALGO_SHA512:
|
|
Panu Matilainen |
34fad6 |
-#endif
|
|
Panu Matilainen |
34fad6 |
assert(dig->sha1ctx == NULL);
|
|
Panu Matilainen |
34fad6 |
dig->sha1ctx = fddig->hashctx;
|
|
Panu Matilainen |
34fad6 |
fddig->hashctx = NULL;
|
|
Panu Matilainen |
34fad6 |
diff -r ec9e6c427068 lib/rpmts.c
|
|
Panu Matilainen |
34fad6 |
--- a/lib/rpmts.c Wed Oct 24 16:02:51 2007 +0300
|
|
Panu Matilainen |
34fad6 |
+++ b/lib/rpmts.c Thu Nov 01 10:56:58 2007 +0100
|
|
Panu Matilainen |
34fad6 |
@@ -4,7 +4,7 @@
|
|
Panu Matilainen |
34fad6 |
*/
|
|
Panu Matilainen |
34fad6 |
#include "system.h"
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
-#include "rpmio_internal.h" /* XXX for pgp and beecrypt */
|
|
Panu Matilainen |
34fad6 |
+#include "rpmio_internal.h" /* XXX for pgp */
|
|
Panu Matilainen |
34fad6 |
#include <rpmlib.h>
|
|
Panu Matilainen |
34fad6 |
#include <rpmmacro.h> /* XXX rpmtsOpenDB() needs rpmGetPath */
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
diff -r ec9e6c427068 lib/signature.c
|
|
Panu Matilainen |
34fad6 |
--- a/lib/signature.c Wed Oct 24 16:02:51 2007 +0300
|
|
Panu Matilainen |
34fad6 |
+++ b/lib/signature.c Thu Nov 01 10:56:58 2007 +0100
|
|
Panu Matilainen |
34fad6 |
@@ -1215,9 +1215,10 @@ verifyRSASignature(rpmts ts, /*@out@*/ c
|
|
Panu Matilainen |
34fad6 |
int_32 sigtag = rpmtsSigtag(ts);
|
|
Panu Matilainen |
34fad6 |
pgpDig dig = rpmtsDig(ts);
|
|
Panu Matilainen |
34fad6 |
pgpDigParams sigp = rpmtsSignature(ts);
|
|
Panu Matilainen |
34fad6 |
- const char * prefix = NULL;
|
|
Panu Matilainen |
34fad6 |
+ SECOidTag sigalg;
|
|
Panu Matilainen |
34fad6 |
rpmRC res = RPMRC_OK;
|
|
Panu Matilainen |
34fad6 |
int xx;
|
|
Panu Matilainen |
34fad6 |
+ SECItem digest;
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
*t = '\0';
|
|
Panu Matilainen |
34fad6 |
if (dig != NULL && dig->hdrmd5ctx == md5ctx)
|
|
Panu Matilainen |
34fad6 |
@@ -1248,43 +1249,40 @@ verifyRSASignature(rpmts ts, /*@out@*/ c
|
|
Panu Matilainen |
34fad6 |
switch (sigp->hash_algo) {
|
|
Panu Matilainen |
34fad6 |
case PGPHASHALGO_MD5:
|
|
Panu Matilainen |
34fad6 |
t = stpcpy(t, " RSA/MD5");
|
|
Panu Matilainen |
34fad6 |
- prefix = "3020300c06082a864886f70d020505000410";
|
|
Panu Matilainen |
34fad6 |
+ sigalg = SEC_OID_PKCS1_MD5_WITH_RSA_ENCRYPTION;
|
|
Panu Matilainen |
34fad6 |
break;
|
|
Panu Matilainen |
34fad6 |
case PGPHASHALGO_SHA1:
|
|
Panu Matilainen |
34fad6 |
t = stpcpy(t, " RSA/SHA1");
|
|
Panu Matilainen |
34fad6 |
- prefix = "3021300906052b0e03021a05000414";
|
|
Panu Matilainen |
34fad6 |
+ sigalg = SEC_OID_PKCS1_SHA1_WITH_RSA_ENCRYPTION;
|
|
Panu Matilainen |
34fad6 |
break;
|
|
Panu Matilainen |
34fad6 |
case PGPHASHALGO_RIPEMD160:
|
|
Panu Matilainen |
34fad6 |
res = RPMRC_NOKEY;
|
|
Panu Matilainen |
34fad6 |
- prefix = NULL;
|
|
Panu Matilainen |
34fad6 |
break;
|
|
Panu Matilainen |
34fad6 |
case PGPHASHALGO_MD2:
|
|
Panu Matilainen |
34fad6 |
t = stpcpy(t, " RSA/MD2");
|
|
Panu Matilainen |
34fad6 |
- prefix = "3020300c06082a864886f70d020205000410";
|
|
Panu Matilainen |
34fad6 |
+ sigalg = SEC_OID_PKCS1_MD2_WITH_RSA_ENCRYPTION;
|
|
Panu Matilainen |
34fad6 |
break;
|
|
Panu Matilainen |
34fad6 |
case PGPHASHALGO_TIGER192:
|
|
Panu Matilainen |
34fad6 |
res = RPMRC_NOKEY;
|
|
Panu Matilainen |
34fad6 |
- prefix = NULL;
|
|
Panu Matilainen |
34fad6 |
break;
|
|
Panu Matilainen |
34fad6 |
case PGPHASHALGO_HAVAL_5_160:
|
|
Panu Matilainen |
34fad6 |
res = RPMRC_NOKEY;
|
|
Panu Matilainen |
34fad6 |
- prefix = NULL;
|
|
Panu Matilainen |
34fad6 |
break;
|
|
Panu Matilainen |
34fad6 |
case PGPHASHALGO_SHA256:
|
|
Panu Matilainen |
34fad6 |
t = stpcpy(t, " RSA/SHA256");
|
|
Panu Matilainen |
34fad6 |
- prefix = "3031300d060960864801650304020105000420";
|
|
Panu Matilainen |
34fad6 |
+ sigalg = SEC_OID_PKCS1_SHA256_WITH_RSA_ENCRYPTION;
|
|
Panu Matilainen |
34fad6 |
break;
|
|
Panu Matilainen |
34fad6 |
case PGPHASHALGO_SHA384:
|
|
Panu Matilainen |
34fad6 |
t = stpcpy(t, " RSA/SHA384");
|
|
Panu Matilainen |
34fad6 |
- prefix = "3041300d060960864801650304020205000430";
|
|
Panu Matilainen |
34fad6 |
+ sigalg = SEC_OID_PKCS1_SHA384_WITH_RSA_ENCRYPTION;
|
|
Panu Matilainen |
34fad6 |
break;
|
|
Panu Matilainen |
34fad6 |
case PGPHASHALGO_SHA512:
|
|
Panu Matilainen |
34fad6 |
t = stpcpy(t, " RSA/SHA512");
|
|
Panu Matilainen |
34fad6 |
- prefix = "3051300d060960864801650304020305000440";
|
|
Panu Matilainen |
34fad6 |
+ sigalg = SEC_OID_PKCS1_SHA512_WITH_RSA_ENCRYPTION;
|
|
Panu Matilainen |
34fad6 |
break;
|
|
Panu Matilainen |
34fad6 |
default:
|
|
Panu Matilainen |
34fad6 |
res = RPMRC_NOKEY;
|
|
Panu Matilainen |
34fad6 |
- prefix = NULL;
|
|
Panu Matilainen |
34fad6 |
+ sigalg = SEC_OID_UNKNOWN;
|
|
Panu Matilainen |
34fad6 |
break;
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
@@ -1295,8 +1293,6 @@ verifyRSASignature(rpmts ts, /*@out@*/ c
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
(void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_DIGEST), 0);
|
|
Panu Matilainen |
34fad6 |
{ DIGEST_CTX ctx = rpmDigestDup(md5ctx);
|
|
Panu Matilainen |
34fad6 |
- byte signhash16[2];
|
|
Panu Matilainen |
34fad6 |
- const char * s;
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
if (sigp->hash != NULL)
|
|
Panu Matilainen |
34fad6 |
xx = rpmDigestUpdate(ctx, sigp->hash, sigp->hashlen);
|
|
Panu Matilainen |
34fad6 |
@@ -1313,40 +1309,18 @@ verifyRSASignature(rpmts ts, /*@out@*/ c
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
#endif
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
- xx = rpmDigestFinal(ctx, (void **)&dig->md5, &dig->md5len, 1);
|
|
Panu Matilainen |
34fad6 |
+ xx = rpmDigestFinal(ctx, (void **)&dig->md5, &dig->md5len, 0);
|
|
Panu Matilainen |
34fad6 |
(void) rpmswExit(rpmtsOp(ts, RPMTS_OP_DIGEST), sigp->hashlen);
|
|
Panu Matilainen |
34fad6 |
rpmtsOp(ts, RPMTS_OP_DIGEST)->count--; /* XXX one too many */
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
/* Compare leading 16 bits of digest for quick check. */
|
|
Panu Matilainen |
34fad6 |
- s = dig->md5;
|
|
Panu Matilainen |
34fad6 |
- signhash16[0] = (nibble(s[0]) << 4) | nibble(s[1]);
|
|
Panu Matilainen |
34fad6 |
- signhash16[1] = (nibble(s[2]) << 4) | nibble(s[3]);
|
|
Panu Matilainen |
34fad6 |
- if (memcmp(signhash16, sigp->signhash16, sizeof(signhash16))) {
|
|
Panu Matilainen |
34fad6 |
+ if (memcmp(dig->md5, sigp->signhash16, 2)) {
|
|
Panu Matilainen |
34fad6 |
res = RPMRC_FAIL;
|
|
Panu Matilainen |
34fad6 |
goto exit;
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
- }
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
- /* Generate RSA modulus parameter. */
|
|
Panu Matilainen |
34fad6 |
- { unsigned int nbits = MP_WORDS_TO_BITS(dig->c.size);
|
|
Panu Matilainen |
34fad6 |
- unsigned int nb = (nbits + 7) >> 3;
|
|
Panu Matilainen |
34fad6 |
- const char * hexstr;
|
|
Panu Matilainen |
34fad6 |
- char * tt;
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
-assert(prefix != NULL);
|
|
Panu Matilainen |
34fad6 |
- hexstr = tt = xmalloc(2 * nb + 1);
|
|
Panu Matilainen |
34fad6 |
- memset(tt, 'f', (2 * nb));
|
|
Panu Matilainen |
34fad6 |
- tt[0] = '0'; tt[1] = '0';
|
|
Panu Matilainen |
34fad6 |
- tt[2] = '0'; tt[3] = '1';
|
|
Panu Matilainen |
34fad6 |
- tt += (2 * nb) - strlen(prefix) - strlen(dig->md5) - 2;
|
|
Panu Matilainen |
34fad6 |
- *tt++ = '0'; *tt++ = '0';
|
|
Panu Matilainen |
34fad6 |
- tt = stpcpy(tt, prefix);
|
|
Panu Matilainen |
34fad6 |
- tt = stpcpy(tt, dig->md5);
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
- mpnzero(&dig->rsahm); (void) mpnsethex(&dig->rsahm, hexstr);
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
- hexstr = _free(hexstr);
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
+ digest.type = siBuffer;
|
|
Panu Matilainen |
34fad6 |
+ digest.data = dig->md5;
|
|
Panu Matilainen |
34fad6 |
+ digest.len = dig->md5len;
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
/* Retrieve the matching public key. */
|
|
Panu Matilainen |
34fad6 |
@@ -1355,12 +1329,7 @@ assert(prefix != NULL);
|
|
Panu Matilainen |
34fad6 |
goto exit;
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
(void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_SIGNATURE), 0);
|
|
Panu Matilainen |
34fad6 |
-#if HAVE_BEECRYPT_API_H
|
|
Panu Matilainen |
34fad6 |
- xx = rsavrfy(&dig->rsa_pk.n, &dig->rsa_pk.e, &dig->c, &dig->rsahm);
|
|
Panu Matilainen |
34fad6 |
-#else
|
|
Panu Matilainen |
34fad6 |
- xx = rsavrfy(&dig->rsa_pk, &dig->rsahm, &dig->c);
|
|
Panu Matilainen |
34fad6 |
-#endif
|
|
Panu Matilainen |
34fad6 |
- if (xx)
|
|
Panu Matilainen |
34fad6 |
+ if (VFY_VerifyDigest(&digest, dig->rsa, dig->rsasig, sigalg, NULL) == SECSuccess)
|
|
Panu Matilainen |
34fad6 |
res = RPMRC_OK;
|
|
Panu Matilainen |
34fad6 |
else
|
|
Panu Matilainen |
34fad6 |
res = RPMRC_FAIL;
|
|
Panu Matilainen |
34fad6 |
@@ -1401,6 +1370,7 @@ verifyDSASignature(rpmts ts, /*@out@*/ c
|
|
Panu Matilainen |
34fad6 |
pgpDigParams sigp = rpmtsSignature(ts);
|
|
Panu Matilainen |
34fad6 |
rpmRC res;
|
|
Panu Matilainen |
34fad6 |
int xx;
|
|
Panu Matilainen |
34fad6 |
+ SECItem digest;
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
*t = '\0';
|
|
Panu Matilainen |
34fad6 |
if (dig != NULL && dig->hdrsha1ctx == sha1ctx)
|
|
Panu Matilainen |
34fad6 |
@@ -1428,7 +1398,6 @@ verifyDSASignature(rpmts ts, /*@out@*/ c
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
(void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_DIGEST), 0);
|
|
Panu Matilainen |
34fad6 |
{ DIGEST_CTX ctx = rpmDigestDup(sha1ctx);
|
|
Panu Matilainen |
34fad6 |
- byte signhash16[2];
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
if (sigp->hash != NULL)
|
|
Panu Matilainen |
34fad6 |
xx = rpmDigestUpdate(ctx, sigp->hash, sigp->hashlen);
|
|
Panu Matilainen |
34fad6 |
@@ -1442,19 +1411,18 @@ verifyDSASignature(rpmts ts, /*@out@*/ c
|
|
Panu Matilainen |
34fad6 |
memcpy(trailer+2, &nb, sizeof(nb));
|
|
Panu Matilainen |
34fad6 |
xx = rpmDigestUpdate(ctx, trailer, sizeof(trailer));
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
- xx = rpmDigestFinal(ctx, (void **)&dig->sha1, &dig->sha1len, 1);
|
|
Panu Matilainen |
34fad6 |
+ xx = rpmDigestFinal(ctx, (void **)&dig->sha1, &dig->sha1len, 0);
|
|
Panu Matilainen |
34fad6 |
(void) rpmswExit(rpmtsOp(ts, RPMTS_OP_DIGEST), sigp->hashlen);
|
|
Panu Matilainen |
34fad6 |
rpmtsOp(ts, RPMTS_OP_DIGEST)->count--; /* XXX one too many */
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
- mpnzero(&dig->hm); (void) mpnsethex(&dig->hm, dig->sha1);
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
/* Compare leading 16 bits of digest for quick check. */
|
|
Panu Matilainen |
34fad6 |
- signhash16[0] = (*dig->hm.data >> 24) & 0xff;
|
|
Panu Matilainen |
34fad6 |
- signhash16[1] = (*dig->hm.data >> 16) & 0xff;
|
|
Panu Matilainen |
34fad6 |
- if (memcmp(signhash16, sigp->signhash16, sizeof(signhash16))) {
|
|
Panu Matilainen |
34fad6 |
+ if (memcmp(dig->sha1, sigp->signhash16, 2)) {
|
|
Panu Matilainen |
34fad6 |
res = RPMRC_FAIL;
|
|
Panu Matilainen |
34fad6 |
goto exit;
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
+ digest.type = siBuffer;
|
|
Panu Matilainen |
34fad6 |
+ digest.data = dig->sha1;
|
|
Panu Matilainen |
34fad6 |
+ digest.len = dig->sha1len;
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
/* Retrieve the matching public key. */
|
|
Panu Matilainen |
34fad6 |
@@ -1463,8 +1431,8 @@ verifyDSASignature(rpmts ts, /*@out@*/ c
|
|
Panu Matilainen |
34fad6 |
goto exit;
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
(void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_SIGNATURE), 0);
|
|
Panu Matilainen |
34fad6 |
- if (dsavrfy(&dig->p, &dig->q, &dig->g,
|
|
Panu Matilainen |
34fad6 |
- &dig->hm, &dig->y, &dig->r, &dig->s))
|
|
Panu Matilainen |
34fad6 |
+ if (VFY_VerifyDigest(&digest, dig->dsa, dig->dsasig,
|
|
Panu Matilainen |
34fad6 |
+ SEC_OID_ANSIX9_DSA_SIGNATURE_WITH_SHA1_DIGEST, NULL) == SECSuccess)
|
|
Panu Matilainen |
34fad6 |
res = RPMRC_OK;
|
|
Panu Matilainen |
34fad6 |
else
|
|
Panu Matilainen |
34fad6 |
res = RPMRC_FAIL;
|
|
Panu Matilainen |
34fad6 |
diff -r ec9e6c427068 python/Makefile.am
|
|
Panu Matilainen |
34fad6 |
--- a/python/Makefile.am Wed Oct 24 16:02:51 2007 +0300
|
|
Panu Matilainen |
34fad6 |
+++ b/python/Makefile.am Thu Nov 01 10:56:58 2007 +0100
|
|
Panu Matilainen |
34fad6 |
@@ -17,7 +17,7 @@ INCLUDES = -I. \
|
|
Panu Matilainen |
34fad6 |
-I$(top_srcdir)/rpmdb \
|
|
Panu Matilainen |
34fad6 |
-I$(top_srcdir)/rpmio \
|
|
Panu Matilainen |
34fad6 |
@WITH_LIBELF_INCLUDE@ \
|
|
Panu Matilainen |
34fad6 |
- @WITH_BEECRYPT_INCLUDE@ \
|
|
Panu Matilainen |
34fad6 |
+ @WITH_NSS_INCLUDE@ \
|
|
Panu Matilainen |
34fad6 |
@WITH_POPT_INCLUDE@ \
|
|
Panu Matilainen |
34fad6 |
-I$(top_srcdir)/misc \
|
|
Panu Matilainen |
34fad6 |
-I$(pyincdir) \
|
|
Panu Matilainen |
34fad6 |
@@ -42,7 +42,7 @@ rpm_LTLIBRARIES = _rpmmodule.la
|
|
Panu Matilainen |
34fad6 |
rpm_LTLIBRARIES = _rpmmodule.la
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
_rpmmodule_la_LDFLAGS = $(mylibs) $(LIBS) -module -avoid-version
|
|
Panu Matilainen |
34fad6 |
-_rpmmodule_la_LIBADD = @WITH_BEECRYPT_LIB@
|
|
Panu Matilainen |
34fad6 |
+_rpmmodule_la_LIBADD = @WITH_NSS_LIB@
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
_rpmmodule_la_SOURCES = rpmmodule.c header-py.c \
|
|
Panu Matilainen |
34fad6 |
rpmal-py.c rpmds-py.c rpmdb-py.c rpmfd-py.c rpmfts-py.c \
|
|
Panu Matilainen |
34fad6 |
diff -r ec9e6c427068 rpmdb/Makefile.am
|
|
Panu Matilainen |
34fad6 |
--- a/rpmdb/Makefile.am Wed Oct 24 16:02:51 2007 +0300
|
|
Panu Matilainen |
34fad6 |
+++ b/rpmdb/Makefile.am Thu Nov 01 10:56:58 2007 +0100
|
|
Panu Matilainen |
34fad6 |
@@ -9,7 +9,7 @@ INCLUDES = -I. \
|
|
Panu Matilainen |
34fad6 |
-I$(top_srcdir)/build \
|
|
Panu Matilainen |
34fad6 |
-I$(top_srcdir)/lib \
|
|
Panu Matilainen |
34fad6 |
-I$(top_srcdir)/rpmio \
|
|
Panu Matilainen |
34fad6 |
- @WITH_BEECRYPT_INCLUDE@ \
|
|
Panu Matilainen |
34fad6 |
+ @WITH_NSS_INCLUDE@ \
|
|
Panu Matilainen |
34fad6 |
@WITH_POPT_INCLUDE@ \
|
|
Panu Matilainen |
34fad6 |
-I$(top_srcdir)/misc \
|
|
Panu Matilainen |
34fad6 |
@WITH_SQLITE3_INCLUDE@ \
|
|
Panu Matilainen |
34fad6 |
diff -r ec9e6c427068 rpmio/Makefile.am
|
|
Panu Matilainen |
34fad6 |
--- a/rpmio/Makefile.am Wed Oct 24 16:02:51 2007 +0300
|
|
Panu Matilainen |
34fad6 |
+++ b/rpmio/Makefile.am Thu Nov 01 10:56:58 2007 +0100
|
|
Panu Matilainen |
34fad6 |
@@ -10,7 +10,7 @@ EXTRA_PROGRAMS = tax tdigest tdir tfts t
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
INCLUDES = -I. \
|
|
Panu Matilainen |
34fad6 |
-I$(top_srcdir) \
|
|
Panu Matilainen |
34fad6 |
- @WITH_BEECRYPT_INCLUDE@ \
|
|
Panu Matilainen |
34fad6 |
+ @WITH_NSS_INCLUDE@ \
|
|
Panu Matilainen |
34fad6 |
@WITH_NEON_INCLUDE@ \
|
|
Panu Matilainen |
34fad6 |
@WITH_LUA_INCLUDE@ \
|
|
Panu Matilainen |
34fad6 |
@WITH_POPT_INCLUDE@ \
|
|
Panu Matilainen |
34fad6 |
@@ -19,23 +19,21 @@ INCLUDES = -I. \
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
pkgincdir = $(pkgincludedir)
|
|
Panu Matilainen |
34fad6 |
pkginc_HEADERS = \
|
|
Panu Matilainen |
34fad6 |
- argv.h fts.h rpmdav.h \
|
|
Panu Matilainen |
34fad6 |
+ argv.h base64.h fts.h rpmdav.h \
|
|
Panu Matilainen |
34fad6 |
rpmio.h rpmurl.h rpmmacro.h rpmlog.h rpmmessages.h rpmerr.h rpmpgp.h \
|
|
Panu Matilainen |
34fad6 |
rpmsq.h rpmsw.h ugid.h
|
|
Panu Matilainen |
34fad6 |
noinst_HEADERS = rpmio_internal.h rpmlua.h rpmhook.h
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
-BEECRYPTLOBJS = $(shell test X"@WITH_BEECRYPT_SUBDIR@" != X && cat $(top_builddir)/@WITH_BEECTYPT_SUBDIR@/listobjs)
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
LDFLAGS = -L$(RPM_BUILD_ROOT)$(usrlibdir) -L$(DESTDIR)$(usrlibdir)
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
usrlibdir = $(libdir)@MARK64@
|
|
Panu Matilainen |
34fad6 |
usrlib_LTLIBRARIES = librpmio.la
|
|
Panu Matilainen |
34fad6 |
librpmio_la_SOURCES = \
|
|
Panu Matilainen |
34fad6 |
- argv.c digest.c fts.c macro.c rpmdav.c \
|
|
Panu Matilainen |
34fad6 |
+ argv.c base64.c digest.c fts.c macro.c rpmdav.c \
|
|
Panu Matilainen |
34fad6 |
rpmhook.c rpmio.c rpmlog.c rpmlua.c rpmmalloc.c \
|
|
Panu Matilainen |
34fad6 |
rpmpgp.c rpmrpc.c rpmsq.c rpmsw.c strcasecmp.c stubs.c url.c ugid.c
|
|
Panu Matilainen |
34fad6 |
librpmio_la_LDFLAGS = -release 4.4 $(LDFLAGS) \
|
|
Panu Matilainen |
34fad6 |
- @WITH_BEECRYPT_LIB@ \
|
|
Panu Matilainen |
34fad6 |
+ @WITH_NSS_LIB@ \
|
|
Panu Matilainen |
34fad6 |
@WITH_NEON_LIB@ \
|
|
Panu Matilainen |
34fad6 |
@WITH_LUA_LIB@ \
|
|
Panu Matilainen |
34fad6 |
@WITH_MAGIC_LIB@ \
|
|
Panu Matilainen |
34fad6 |
@@ -44,22 +42,10 @@ librpmio_la_LIBADD = # $(BEECRYPTLOBJS)
|
|
Panu Matilainen |
34fad6 |
librpmio_la_LIBADD = # $(BEECRYPTLOBJS)
|
|
Panu Matilainen |
34fad6 |
librpmio_la_DEPENDENCIES = # .created
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
-.created:
|
|
Panu Matilainen |
34fad6 |
- if test X"@WITH_BEECRYPT_SUBDIR@" != X; then \
|
|
Panu Matilainen |
34fad6 |
- ${MAKE} -C $(top_builddir)/@WITH_BEECRYPT_SUBDIR@ listobjs ; \
|
|
Panu Matilainen |
34fad6 |
- for lo in $(BEECRYPTLOBJS); do \
|
|
Panu Matilainen |
34fad6 |
- [ -f $$lo ] || $(LN_S) $(top_builddir)/@WITH_BEECRYPT_SUBDIR@/$$lo $$lo ; \
|
|
Panu Matilainen |
34fad6 |
- done \
|
|
Panu Matilainen |
34fad6 |
- fi
|
|
Panu Matilainen |
34fad6 |
- touch $@
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
-clean-local:
|
|
Panu Matilainen |
34fad6 |
- rm -f $(BEECRYPTLOBJS) *.o .created
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
#BUILT_SOURCES = rpmio.lcd
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
rpmio.lcd: Makefile.am ${librpmio_la_SOURCES} ${pkginc_HEADERS} ${noinst_HEADERS}
|
|
Panu Matilainen |
34fad6 |
- -lclint -load ../beecrypt/beecrypt.lcd $(DEFS) $(INCLUDES) $(librpmio_la_SOURCES) -dump $@ 2>/dev/null
|
|
Panu Matilainen |
34fad6 |
+ -lclint -load $(DEFS) $(INCLUDES) $(librpmio_la_SOURCES) -dump $@ 2>/dev/null
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
.PHONY: sources
|
|
Panu Matilainen |
34fad6 |
sources:
|
|
Panu Matilainen |
34fad6 |
@@ -105,7 +91,6 @@ tinv_LDADD = librpmio.la $(top_builddir)
|
|
Panu Matilainen |
34fad6 |
tinv_LDADD = librpmio.la $(top_builddir)/popt/libpopt.la
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
tkey_SOURCES = tkey.c
|
|
Panu Matilainen |
34fad6 |
-tkey_LDFLAGS = @LDFLAGS_STATIC@
|
|
Panu Matilainen |
34fad6 |
tkey_LDADD = librpmio.la $(top_builddir)/popt/libpopt.la
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
tring_SOURCES = tring.c
|
|
Panu Matilainen |
34fad6 |
diff -r ec9e6c427068 rpmio/base64.c
|
|
Panu Matilainen |
34fad6 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
|
Panu Matilainen |
34fad6 |
+++ b/rpmio/base64.c Thu Nov 01 10:56:58 2007 +0100
|
|
Panu Matilainen |
34fad6 |
@@ -0,0 +1,254 @@
|
|
Panu Matilainen |
34fad6 |
+/* base64 encoder/decoder based on public domain implementation
|
|
Panu Matilainen |
34fad6 |
+ * by Chris Venter */
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+#include <arpa/inet.h>
|
|
Panu Matilainen |
34fad6 |
+#include <stdlib.h>
|
|
Panu Matilainen |
34fad6 |
+#include "base64.h"
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+static char base64_encode_value(char value_in)
|
|
Panu Matilainen |
34fad6 |
+{
|
|
Panu Matilainen |
34fad6 |
+ static const char encoding[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
Panu Matilainen |
34fad6 |
+ if (value_in > 63) return '=';
|
|
Panu Matilainen |
34fad6 |
+ return encoding[(int)value_in];
|
|
Panu Matilainen |
34fad6 |
+}
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+static char *base64_encode_block(const char *plaintext_in, int length_in, char *codechar)
|
|
Panu Matilainen |
34fad6 |
+{
|
|
Panu Matilainen |
34fad6 |
+ const char *plainchar = plaintext_in;
|
|
Panu Matilainen |
34fad6 |
+ const char *const plaintextend = plaintext_in + length_in;
|
|
Panu Matilainen |
34fad6 |
+ char result;
|
|
Panu Matilainen |
34fad6 |
+ char fragment;
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ while (1) {
|
|
Panu Matilainen |
34fad6 |
+ if (plainchar == plaintextend) {
|
|
Panu Matilainen |
34fad6 |
+ return codechar;
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+ fragment = *plainchar++;
|
|
Panu Matilainen |
34fad6 |
+ result = (fragment & 0x0fc) >> 2;
|
|
Panu Matilainen |
34fad6 |
+ *codechar++ = base64_encode_value(result);
|
|
Panu Matilainen |
34fad6 |
+ result = (fragment & 0x003) << 4;
|
|
Panu Matilainen |
34fad6 |
+ if (plainchar == plaintextend)
|
|
Panu Matilainen |
34fad6 |
+ {
|
|
Panu Matilainen |
34fad6 |
+ *codechar++ = base64_encode_value(result);
|
|
Panu Matilainen |
34fad6 |
+ *codechar++ = '=';
|
|
Panu Matilainen |
34fad6 |
+ *codechar++ = '=';
|
|
Panu Matilainen |
34fad6 |
+ return codechar;
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+ fragment = *plainchar++;
|
|
Panu Matilainen |
34fad6 |
+ result |= (fragment & 0x0f0) >> 4;
|
|
Panu Matilainen |
34fad6 |
+ *codechar++ = base64_encode_value(result);
|
|
Panu Matilainen |
34fad6 |
+ result = (fragment & 0x00f) << 2;
|
|
Panu Matilainen |
34fad6 |
+ if (plainchar == plaintextend)
|
|
Panu Matilainen |
34fad6 |
+ {
|
|
Panu Matilainen |
34fad6 |
+ *codechar++ = base64_encode_value(result);
|
|
Panu Matilainen |
34fad6 |
+ *codechar++ = '=';
|
|
Panu Matilainen |
34fad6 |
+ return codechar;
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+ fragment = *plainchar++;
|
|
Panu Matilainen |
34fad6 |
+ result |= (fragment & 0x0c0) >> 6;
|
|
Panu Matilainen |
34fad6 |
+ *codechar++ = base64_encode_value(result);
|
|
Panu Matilainen |
34fad6 |
+ result = (fragment & 0x03f) >> 0;
|
|
Panu Matilainen |
34fad6 |
+ *codechar++ = base64_encode_value(result);
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+ /* control should not reach here */
|
|
Panu Matilainen |
34fad6 |
+ return codechar;
|
|
Panu Matilainen |
34fad6 |
+}
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+#define BASE64_DEFAULT_LINE_LENGTH 64
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+char *b64encode(const void *data, size_t len, int linelen)
|
|
Panu Matilainen |
34fad6 |
+{
|
|
Panu Matilainen |
34fad6 |
+ size_t encodedlen;
|
|
Panu Matilainen |
34fad6 |
+ const char *dataptr = data;
|
|
Panu Matilainen |
34fad6 |
+ char *output;
|
|
Panu Matilainen |
34fad6 |
+ char *outptr;
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ if (data == NULL)
|
|
Panu Matilainen |
34fad6 |
+ return NULL;
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ if (linelen < 0)
|
|
Panu Matilainen |
34fad6 |
+ linelen = BASE64_DEFAULT_LINE_LENGTH;
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ linelen /= 4;
|
|
Panu Matilainen |
34fad6 |
+ encodedlen = ((len + 2) / 3) * 4;
|
|
Panu Matilainen |
34fad6 |
+ if (linelen > 0) {
|
|
Panu Matilainen |
34fad6 |
+ encodedlen += encodedlen/(linelen * 4) + 1;
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+ ++encodedlen; /* for zero termination */
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ output = malloc(encodedlen);
|
|
Panu Matilainen |
34fad6 |
+ if (output == NULL)
|
|
Panu Matilainen |
34fad6 |
+ return NULL;
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ outptr = output;
|
|
Panu Matilainen |
34fad6 |
+ while (len > 0) {
|
|
Panu Matilainen |
34fad6 |
+ if (linelen > 0 && len > linelen * 3) {
|
|
Panu Matilainen |
34fad6 |
+ outptr = base64_encode_block(dataptr, linelen * 3, outptr);
|
|
Panu Matilainen |
34fad6 |
+ len -= linelen * 3;
|
|
Panu Matilainen |
34fad6 |
+ dataptr += linelen * 3;
|
|
Panu Matilainen |
34fad6 |
+ } else {
|
|
Panu Matilainen |
34fad6 |
+ outptr = base64_encode_block(dataptr, len, outptr);
|
|
Panu Matilainen |
34fad6 |
+ len = 0;
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+ if (linelen > 0) {
|
|
Panu Matilainen |
34fad6 |
+ *outptr++ = '\n';
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+ *outptr = '\0';
|
|
Panu Matilainen |
34fad6 |
+ return output;
|
|
Panu Matilainen |
34fad6 |
+}
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+static int base64_decode_value(char value_in)
|
|
Panu Matilainen |
34fad6 |
+{
|
|
Panu Matilainen |
34fad6 |
+ static const char decoding[] = {62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-2,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51};
|
|
Panu Matilainen |
34fad6 |
+ static const char decoding_size = sizeof(decoding);
|
|
Panu Matilainen |
34fad6 |
+ value_in -= 43;
|
|
Panu Matilainen |
34fad6 |
+ if (value_in < 0 || value_in > decoding_size)
|
|
Panu Matilainen |
34fad6 |
+ return -1;
|
|
Panu Matilainen |
34fad6 |
+ return decoding[(int)value_in];
|
|
Panu Matilainen |
34fad6 |
+}
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+static size_t base64_decode_block(const char *code_in, const size_t length_in, char *plaintext_out)
|
|
Panu Matilainen |
34fad6 |
+{
|
|
Panu Matilainen |
34fad6 |
+ const char *codechar = code_in;
|
|
Panu Matilainen |
34fad6 |
+ char *plainchar = plaintext_out;
|
|
Panu Matilainen |
34fad6 |
+ char fragment;
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ *plainchar = 0;
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ while (1)
|
|
Panu Matilainen |
34fad6 |
+ {
|
|
Panu Matilainen |
34fad6 |
+ do {
|
|
Panu Matilainen |
34fad6 |
+ if (codechar == code_in+length_in)
|
|
Panu Matilainen |
34fad6 |
+ {
|
|
Panu Matilainen |
34fad6 |
+ return plainchar - plaintext_out;
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+ fragment = (char)base64_decode_value(*codechar++);
|
|
Panu Matilainen |
34fad6 |
+ } while (fragment < 0);
|
|
Panu Matilainen |
34fad6 |
+ *plainchar = (fragment & 0x03f) << 2;
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ do {
|
|
Panu Matilainen |
34fad6 |
+ if (codechar == code_in+length_in)
|
|
Panu Matilainen |
34fad6 |
+ {
|
|
Panu Matilainen |
34fad6 |
+ return plainchar - plaintext_out;
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+ fragment = (char)base64_decode_value(*codechar++);
|
|
Panu Matilainen |
34fad6 |
+ } while (fragment < 0);
|
|
Panu Matilainen |
34fad6 |
+ *plainchar++ |= (fragment & 0x030) >> 4;
|
|
Panu Matilainen |
34fad6 |
+ *plainchar = (fragment & 0x00f) << 4;
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ do {
|
|
Panu Matilainen |
34fad6 |
+ if (codechar == code_in+length_in)
|
|
Panu Matilainen |
34fad6 |
+ {
|
|
Panu Matilainen |
34fad6 |
+ return plainchar - plaintext_out;
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+ fragment = (char)base64_decode_value(*codechar++);
|
|
Panu Matilainen |
34fad6 |
+ } while (fragment < 0);
|
|
Panu Matilainen |
34fad6 |
+ *plainchar++ |= (fragment & 0x03c) >> 2;
|
|
Panu Matilainen |
34fad6 |
+ *plainchar = (fragment & 0x003) << 6;
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ do {
|
|
Panu Matilainen |
34fad6 |
+ if (codechar == code_in+length_in)
|
|
Panu Matilainen |
34fad6 |
+ {
|
|
Panu Matilainen |
34fad6 |
+ return plainchar - plaintext_out;
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+ fragment = (char)base64_decode_value(*codechar++);
|
|
Panu Matilainen |
34fad6 |
+ } while (fragment < 0);
|
|
Panu Matilainen |
34fad6 |
+ *plainchar++ |= (fragment & 0x03f);
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+ /* control should not reach here */
|
|
Panu Matilainen |
34fad6 |
+ return plainchar - plaintext_out;
|
|
Panu Matilainen |
34fad6 |
+}
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+int b64decode(const char *in, void **out, size_t *outlen)
|
|
Panu Matilainen |
34fad6 |
+{
|
|
Panu Matilainen |
34fad6 |
+ size_t outcnt = 0;
|
|
Panu Matilainen |
34fad6 |
+ const char *inptr = in;
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ *out = NULL;
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ if (in == NULL) {
|
|
Panu Matilainen |
34fad6 |
+ return 1;
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ while (*inptr != '\0') {
|
|
Panu Matilainen |
34fad6 |
+ /* assume all ASCII control chars as whitespace */
|
|
Panu Matilainen |
34fad6 |
+ if (*inptr > 32) {
|
|
Panu Matilainen |
34fad6 |
+ if (base64_decode_value(*inptr) != -1) {
|
|
Panu Matilainen |
34fad6 |
+ ++outcnt;
|
|
Panu Matilainen |
34fad6 |
+ } else {
|
|
Panu Matilainen |
34fad6 |
+ return 3;
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+ ++inptr;
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ if (outcnt % 4 != 0)
|
|
Panu Matilainen |
34fad6 |
+ return 2;
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ outcnt = (outcnt / 4) * 3;
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ *out = malloc(outcnt + 1); /* base64_decode_block can write one extra character */
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ if (*out == NULL)
|
|
Panu Matilainen |
34fad6 |
+ return 4;
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ *outlen = base64_decode_block(in, inptr - in, *out);
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ return 0;
|
|
Panu Matilainen |
34fad6 |
+}
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+#define CRC24_INIT 0xb704ce
|
|
Panu Matilainen |
34fad6 |
+#define CRC24_POLY 0x1864cfb
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+char *b64crc(const unsigned char *data, size_t len)
|
|
Panu Matilainen |
34fad6 |
+{
|
|
Panu Matilainen |
34fad6 |
+ uint32_t crc = CRC24_INIT;
|
|
Panu Matilainen |
34fad6 |
+ int i;
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ while (len--) {
|
|
Panu Matilainen |
34fad6 |
+ crc ^= (*data++) << 16;
|
|
Panu Matilainen |
34fad6 |
+ for (i = 0; i < 8; i++) {
|
|
Panu Matilainen |
34fad6 |
+ crc <<= 1;
|
|
Panu Matilainen |
34fad6 |
+ if (crc & 0x1000000)
|
|
Panu Matilainen |
34fad6 |
+ crc ^= CRC24_POLY;
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+ crc = htonl(crc & 0xffffff);
|
|
Panu Matilainen |
34fad6 |
+ data = (unsigned char *)&crc;
|
|
Panu Matilainen |
34fad6 |
+ ++data;
|
|
Panu Matilainen |
34fad6 |
+ return b64encode(data, 3, 0);
|
|
Panu Matilainen |
34fad6 |
+}
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+#ifdef BASE64_TEST
|
|
Panu Matilainen |
34fad6 |
+#include <stdio.h>
|
|
Panu Matilainen |
34fad6 |
+#include <string.h>
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+int main(int argc, char *argv[])
|
|
Panu Matilainen |
34fad6 |
+{
|
|
Panu Matilainen |
34fad6 |
+ static char tst[]="wtrt8122čLýáj\x20s ~ýhž\t4\x02šjjmBvž^%$RTš#á.íěj\x1hčýčŤc+";
|
|
Panu Matilainen |
34fad6 |
+ char *encoded;
|
|
Panu Matilainen |
34fad6 |
+ void *decoded;
|
|
Panu Matilainen |
34fad6 |
+ size_t size;
|
|
Panu Matilainen |
34fad6 |
+ int err;
|
|
Panu Matilainen |
34fad6 |
+ printf("Original: %lu\n%s\n", sizeof(tst)-1, tst);
|
|
Panu Matilainen |
34fad6 |
+ encoded = b64encode(tst, sizeof(tst)-1, 64);
|
|
Panu Matilainen |
34fad6 |
+ printf("Encoded: %lu\n%s\n", strlen(encoded), encoded);
|
|
Panu Matilainen |
34fad6 |
+ if ((err = b64decode(encoded, &decoded, &size)) != 0) {
|
|
Panu Matilainen |
34fad6 |
+ fprintf(stderr, "Error in decode: %d\n", err);
|
|
Panu Matilainen |
34fad6 |
+ return 1;
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+ printf("Decoded:\n%.*s\n", (int)size, (char *)decoded);
|
|
Panu Matilainen |
34fad6 |
+ if (size != sizeof(tst)-1) {
|
|
Panu Matilainen |
34fad6 |
+ fprintf(stderr, "Size differs orig: %lu new: %lu\n", sizeof(tst)-1, size);
|
|
Panu Matilainen |
34fad6 |
+ return 1;
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+ if (memcmp(tst, decoded, size) != 0) {
|
|
Panu Matilainen |
34fad6 |
+ fprintf(stderr, "Decoded data differs.\n");
|
|
Panu Matilainen |
34fad6 |
+ return 1;
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+ fprintf(stderr, "OK\n");
|
|
Panu Matilainen |
34fad6 |
+ return 0;
|
|
Panu Matilainen |
34fad6 |
+}
|
|
Panu Matilainen |
34fad6 |
+#endif
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
diff -r ec9e6c427068 rpmio/base64.h
|
|
Panu Matilainen |
34fad6 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
|
Panu Matilainen |
34fad6 |
+++ b/rpmio/base64.h Thu Nov 01 10:56:58 2007 +0100
|
|
Panu Matilainen |
34fad6 |
@@ -0,0 +1,29 @@
|
|
Panu Matilainen |
34fad6 |
+/* base64 encoder/decoder based on public domain implementation
|
|
Panu Matilainen |
34fad6 |
+ * by Chris Venter */
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+#include <sys/types.h>
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+/* returns malloced base64 encoded string
|
|
Panu Matilainen |
34fad6 |
+ * lines are split with \n characters to be nearest lower multiple of linelen
|
|
Panu Matilainen |
34fad6 |
+ * if linelen/4 == 0 lines are not split
|
|
Panu Matilainen |
34fad6 |
+ * if linelen < 0 default line length (64) is used
|
|
Panu Matilainen |
34fad6 |
+ * the returned string is empty when len == 0
|
|
Panu Matilainen |
34fad6 |
+ * returns NULL on failures
|
|
Panu Matilainen |
34fad6 |
+ */
|
|
Panu Matilainen |
34fad6 |
+char *b64encode(const void *data, size_t len, int linelen);
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+/* decodes from zero terminated base64 encoded string to a newly malloced buffer
|
|
Panu Matilainen |
34fad6 |
+ * ignores whitespace characters in the input string
|
|
Panu Matilainen |
34fad6 |
+ * return values:
|
|
Panu Matilainen |
34fad6 |
+ * 0 - OK
|
|
Panu Matilainen |
34fad6 |
+ * 1 - input is NULL
|
|
Panu Matilainen |
34fad6 |
+ * 2 - invalid length
|
|
Panu Matilainen |
34fad6 |
+ * 3 - invalid characters on input
|
|
Panu Matilainen |
34fad6 |
+ * 4 - malloc failed
|
|
Panu Matilainen |
34fad6 |
+ */
|
|
Panu Matilainen |
34fad6 |
+int b64decode(const char *in, void **out, size_t *outlen);
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+/* counts CRC24 and base64 encodes it in a malloced string
|
|
Panu Matilainen |
34fad6 |
+ * returns NULL on failures
|
|
Panu Matilainen |
34fad6 |
+ */
|
|
Panu Matilainen |
34fad6 |
+char *b64crc(const unsigned char *data, size_t len);
|
|
Panu Matilainen |
34fad6 |
diff -r ec9e6c427068 rpmio/digest.c
|
|
Panu Matilainen |
34fad6 |
--- a/rpmio/digest.c Wed Oct 24 16:02:51 2007 +0300
|
|
Panu Matilainen |
34fad6 |
+++ b/rpmio/digest.c Thu Nov 01 10:56:58 2007 +0100
|
|
Panu Matilainen |
34fad6 |
@@ -19,16 +19,7 @@
|
|
Panu Matilainen |
34fad6 |
*/
|
|
Panu Matilainen |
34fad6 |
struct DIGEST_CTX_s {
|
|
Panu Matilainen |
34fad6 |
rpmDigestFlags flags; /*!< Bit(s) to control digest operation. */
|
|
Panu Matilainen |
34fad6 |
- uint32_t datalen; /*!< No. bytes in block of plaintext data. */
|
|
Panu Matilainen |
34fad6 |
- uint32_t paramlen; /*!< No. bytes of digest parameters. */
|
|
Panu Matilainen |
34fad6 |
- uint32_t digestlen; /*!< No. bytes of digest. */
|
|
Panu Matilainen |
34fad6 |
- void * param; /*!< Digest parameters. */
|
|
Panu Matilainen |
34fad6 |
- int (*Reset) (void * param)
|
|
Panu Matilainen |
34fad6 |
- /*@modifies param @*/; /*!< Digest initialize. */
|
|
Panu Matilainen |
34fad6 |
- int (*Update) (void * param, const byte * data, size_t size)
|
|
Panu Matilainen |
34fad6 |
- /*@modifies param @*/; /*!< Digest transform. */
|
|
Panu Matilainen |
34fad6 |
- int (*Digest) (void * param, /*@out@*/ byte * digest)
|
|
Panu Matilainen |
34fad6 |
- /*@modifies param, digest @*/; /*!< Digest finish. */
|
|
Panu Matilainen |
34fad6 |
+ HASHContext *hashctx; /*!< Internal NSS hash context. */
|
|
Panu Matilainen |
34fad6 |
};
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
/*@-boundsread@*/
|
|
Panu Matilainen |
34fad6 |
@@ -37,115 +28,101 @@ rpmDigestDup(DIGEST_CTX octx)
|
|
Panu Matilainen |
34fad6 |
{
|
|
Panu Matilainen |
34fad6 |
DIGEST_CTX nctx;
|
|
Panu Matilainen |
34fad6 |
nctx = memcpy(xcalloc(1, sizeof(*nctx)), octx, sizeof(*nctx));
|
|
Panu Matilainen |
34fad6 |
- nctx->param = memcpy(xcalloc(1, nctx->paramlen), octx->param, nctx->paramlen);
|
|
Panu Matilainen |
34fad6 |
+ nctx->hashctx = HASH_Clone(octx->hashctx);
|
|
Panu Matilainen |
34fad6 |
+ if (nctx->hashctx == NULL) {
|
|
Panu Matilainen |
34fad6 |
+ fprintf(stderr, "HASH_Clone failed\n");
|
|
Panu Matilainen |
34fad6 |
+ exit(EXIT_FAILURE); /* FIX: callers do not bother checking error return */
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
return nctx;
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
/*@=boundsread@*/
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
-DIGEST_CTX
|
|
Panu Matilainen |
34fad6 |
-rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags)
|
|
Panu Matilainen |
34fad6 |
+static HASH_HashType
|
|
Panu Matilainen |
34fad6 |
+getHashType(pgpHashAlgo hashalgo)
|
|
Panu Matilainen |
34fad6 |
{
|
|
Panu Matilainen |
34fad6 |
- DIGEST_CTX ctx = xcalloc(1, sizeof(*ctx));
|
|
Panu Matilainen |
34fad6 |
- int xx;
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
- ctx->flags = flags;
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
switch (hashalgo) {
|
|
Panu Matilainen |
34fad6 |
case PGPHASHALGO_MD5:
|
|
Panu Matilainen |
34fad6 |
- ctx->digestlen = 16;
|
|
Panu Matilainen |
34fad6 |
- ctx->datalen = 64;
|
|
Panu Matilainen |
34fad6 |
-/*@-sizeoftype@*/ /* FIX: union, not void pointer */
|
|
Panu Matilainen |
34fad6 |
- ctx->paramlen = sizeof(md5Param);
|
|
Panu Matilainen |
34fad6 |
-/*@=sizeoftype@*/
|
|
Panu Matilainen |
34fad6 |
- ctx->param = xcalloc(1, ctx->paramlen);
|
|
Panu Matilainen |
34fad6 |
-/*@-type@*/ /* FIX: cast? */
|
|
Panu Matilainen |
34fad6 |
- ctx->Reset = (void *) md5Reset;
|
|
Panu Matilainen |
34fad6 |
- ctx->Update = (void *) md5Update;
|
|
Panu Matilainen |
34fad6 |
- ctx->Digest = (void *) md5Digest;
|
|
Panu Matilainen |
34fad6 |
-/*@=type@*/
|
|
Panu Matilainen |
34fad6 |
+ return HASH_AlgMD5;
|
|
Panu Matilainen |
34fad6 |
break;
|
|
Panu Matilainen |
34fad6 |
case PGPHASHALGO_SHA1:
|
|
Panu Matilainen |
34fad6 |
- ctx->digestlen = 20;
|
|
Panu Matilainen |
34fad6 |
- ctx->datalen = 64;
|
|
Panu Matilainen |
34fad6 |
-/*@-sizeoftype@*/ /* FIX: union, not void pointer */
|
|
Panu Matilainen |
34fad6 |
- ctx->paramlen = sizeof(sha1Param);
|
|
Panu Matilainen |
34fad6 |
-/*@=sizeoftype@*/
|
|
Panu Matilainen |
34fad6 |
- ctx->param = xcalloc(1, ctx->paramlen);
|
|
Panu Matilainen |
34fad6 |
-/*@-type@*/ /* FIX: cast? */
|
|
Panu Matilainen |
34fad6 |
- ctx->Reset = (void *) sha1Reset;
|
|
Panu Matilainen |
34fad6 |
- ctx->Update = (void *) sha1Update;
|
|
Panu Matilainen |
34fad6 |
- ctx->Digest = (void *) sha1Digest;
|
|
Panu Matilainen |
34fad6 |
-/*@=type@*/
|
|
Panu Matilainen |
34fad6 |
+ return HASH_AlgSHA1;
|
|
Panu Matilainen |
34fad6 |
break;
|
|
Panu Matilainen |
34fad6 |
-#if HAVE_BEECRYPT_API_H
|
|
Panu Matilainen |
34fad6 |
case PGPHASHALGO_SHA256:
|
|
Panu Matilainen |
34fad6 |
- ctx->digestlen = 32;
|
|
Panu Matilainen |
34fad6 |
- ctx->datalen = 64;
|
|
Panu Matilainen |
34fad6 |
-/*@-sizeoftype@*/ /* FIX: union, not void pointer */
|
|
Panu Matilainen |
34fad6 |
- ctx->paramlen = sizeof(sha256Param);
|
|
Panu Matilainen |
34fad6 |
-/*@=sizeoftype@*/
|
|
Panu Matilainen |
34fad6 |
- ctx->param = xcalloc(1, ctx->paramlen);
|
|
Panu Matilainen |
34fad6 |
-/*@-type@*/ /* FIX: cast? */
|
|
Panu Matilainen |
34fad6 |
- ctx->Reset = (void *) sha256Reset;
|
|
Panu Matilainen |
34fad6 |
- ctx->Update = (void *) sha256Update;
|
|
Panu Matilainen |
34fad6 |
- ctx->Digest = (void *) sha256Digest;
|
|
Panu Matilainen |
34fad6 |
-/*@=type@*/
|
|
Panu Matilainen |
34fad6 |
+ return HASH_AlgSHA256;
|
|
Panu Matilainen |
34fad6 |
break;
|
|
Panu Matilainen |
34fad6 |
case PGPHASHALGO_SHA384:
|
|
Panu Matilainen |
34fad6 |
- ctx->digestlen = 48;
|
|
Panu Matilainen |
34fad6 |
- ctx->datalen = 128;
|
|
Panu Matilainen |
34fad6 |
-/*@-sizeoftype@*/ /* FIX: union, not void pointer */
|
|
Panu Matilainen |
34fad6 |
- ctx->paramlen = sizeof(sha384Param);
|
|
Panu Matilainen |
34fad6 |
-/*@=sizeoftype@*/
|
|
Panu Matilainen |
34fad6 |
- ctx->param = xcalloc(1, ctx->paramlen);
|
|
Panu Matilainen |
34fad6 |
-/*@-type@*/ /* FIX: cast? */
|
|
Panu Matilainen |
34fad6 |
- ctx->Reset = (void *) sha384Reset;
|
|
Panu Matilainen |
34fad6 |
- ctx->Update = (void *) sha384Update;
|
|
Panu Matilainen |
34fad6 |
- ctx->Digest = (void *) sha384Digest;
|
|
Panu Matilainen |
34fad6 |
-/*@=type@*/
|
|
Panu Matilainen |
34fad6 |
+ return HASH_AlgSHA384;
|
|
Panu Matilainen |
34fad6 |
break;
|
|
Panu Matilainen |
34fad6 |
case PGPHASHALGO_SHA512:
|
|
Panu Matilainen |
34fad6 |
- ctx->digestlen = 64;
|
|
Panu Matilainen |
34fad6 |
- ctx->datalen = 128;
|
|
Panu Matilainen |
34fad6 |
-/*@-sizeoftype@*/ /* FIX: union, not void pointer */
|
|
Panu Matilainen |
34fad6 |
- ctx->paramlen = sizeof(sha512Param);
|
|
Panu Matilainen |
34fad6 |
-/*@=sizeoftype@*/
|
|
Panu Matilainen |
34fad6 |
- ctx->param = xcalloc(1, ctx->paramlen);
|
|
Panu Matilainen |
34fad6 |
-/*@-type@*/ /* FIX: cast? */
|
|
Panu Matilainen |
34fad6 |
- ctx->Reset = (void *) sha512Reset;
|
|
Panu Matilainen |
34fad6 |
- ctx->Update = (void *) sha512Update;
|
|
Panu Matilainen |
34fad6 |
- ctx->Digest = (void *) sha512Digest;
|
|
Panu Matilainen |
34fad6 |
-/*@=type@*/
|
|
Panu Matilainen |
34fad6 |
+ return HASH_AlgSHA512;
|
|
Panu Matilainen |
34fad6 |
break;
|
|
Panu Matilainen |
34fad6 |
-#endif
|
|
Panu Matilainen |
34fad6 |
case PGPHASHALGO_RIPEMD160:
|
|
Panu Matilainen |
34fad6 |
case PGPHASHALGO_MD2:
|
|
Panu Matilainen |
34fad6 |
case PGPHASHALGO_TIGER192:
|
|
Panu Matilainen |
34fad6 |
case PGPHASHALGO_HAVAL_5_160:
|
|
Panu Matilainen |
34fad6 |
default:
|
|
Panu Matilainen |
34fad6 |
+ return HASH_AlgNULL;
|
|
Panu Matilainen |
34fad6 |
+ /*@notreached@*/ break;
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+}
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+size_t
|
|
Panu Matilainen |
34fad6 |
+rpmDigestLength(pgpHashAlgo hashalgo)
|
|
Panu Matilainen |
34fad6 |
+{
|
|
Panu Matilainen |
34fad6 |
+ return HASH_ResultLen(getHashType(hashalgo));
|
|
Panu Matilainen |
34fad6 |
+}
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+DIGEST_CTX
|
|
Panu Matilainen |
34fad6 |
+rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags)
|
|
Panu Matilainen |
34fad6 |
+{
|
|
Panu Matilainen |
34fad6 |
+ HASH_HashType type;
|
|
Panu Matilainen |
34fad6 |
+ DIGEST_CTX ctx = xcalloc(1, sizeof(*ctx));
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ if (NSS_NoDB_Init(NULL) != SECSuccess)
|
|
Panu Matilainen |
34fad6 |
+ return NULL;
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ ctx->flags = flags;
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ type = getHashType(hashalgo);
|
|
Panu Matilainen |
34fad6 |
+ if (type == HASH_AlgNULL) {
|
|
Panu Matilainen |
34fad6 |
free(ctx);
|
|
Panu Matilainen |
34fad6 |
return NULL;
|
|
Panu Matilainen |
34fad6 |
- /*@notreached@*/ break;
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
-/*@-boundsread@*/
|
|
Panu Matilainen |
34fad6 |
- xx = (*ctx->Reset) (ctx->param);
|
|
Panu Matilainen |
34fad6 |
-/*@=boundsread@*/
|
|
Panu Matilainen |
34fad6 |
+ ctx->hashctx = HASH_Create(type);
|
|
Panu Matilainen |
34fad6 |
+ if (ctx->hashctx == NULL) {
|
|
Panu Matilainen |
34fad6 |
+ free(ctx);
|
|
Panu Matilainen |
34fad6 |
+ return NULL;
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
-DPRINTF((stderr, "*** Init(%x) ctx %p param %p\n", flags, ctx, ctx->param));
|
|
Panu Matilainen |
34fad6 |
+ HASH_Begin(ctx->hashctx);
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+DPRINTF((stderr, "*** Init(%x) ctx %p hashctx %p\n", flags, ctx, ctx->hashctx));
|
|
Panu Matilainen |
34fad6 |
return ctx;
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
-/*@-mustmod@*/ /* LCL: ctx->param may be modified, but ctx is abstract @*/
|
|
Panu Matilainen |
34fad6 |
+/*@-mustmod@*/ /* LCL: ctx->hashctx may be modified, but ctx is abstract @*/
|
|
Panu Matilainen |
34fad6 |
int
|
|
Panu Matilainen |
34fad6 |
rpmDigestUpdate(DIGEST_CTX ctx, const void * data, size_t len)
|
|
Panu Matilainen |
34fad6 |
{
|
|
Panu Matilainen |
34fad6 |
+ unsigned int partlen;
|
|
Panu Matilainen |
34fad6 |
+ const unsigned char *ptr = data;
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
if (ctx == NULL)
|
|
Panu Matilainen |
34fad6 |
return -1;
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
-DPRINTF((stderr, "*** Update(%p,%p,%d) param %p \"%s\"\n", ctx, data, len, ctx->param, ((char *)data)));
|
|
Panu Matilainen |
34fad6 |
+DPRINTF((stderr, "*** Update(%p,%p,%d) hashctx %p \"%s\"\n", ctx, data, len, ctx->hashctx, ((char *)data)));
|
|
Panu Matilainen |
34fad6 |
/*@-boundsread@*/
|
|
Panu Matilainen |
34fad6 |
- return (*ctx->Update) (ctx->param, data, len);
|
|
Panu Matilainen |
34fad6 |
+ partlen = ~(unsigned int)0xFF;
|
|
Panu Matilainen |
34fad6 |
+ while (len > 0) {
|
|
Panu Matilainen |
34fad6 |
+ if (len < partlen) {
|
|
Panu Matilainen |
34fad6 |
+ partlen = (unsigned int)len;
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+ HASH_Update(ctx->hashctx, ptr, partlen);
|
|
Panu Matilainen |
34fad6 |
+ ptr += partlen;
|
|
Panu Matilainen |
34fad6 |
+ len -= partlen;
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+ return 0;
|
|
Panu Matilainen |
34fad6 |
/*@=boundsread@*/
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
/*@=mustmod@*/
|
|
Panu Matilainen |
34fad6 |
@@ -154,35 +131,37 @@ int
|
|
Panu Matilainen |
34fad6 |
int
|
|
Panu Matilainen |
34fad6 |
rpmDigestFinal(DIGEST_CTX ctx, void ** datap, size_t *lenp, int asAscii)
|
|
Panu Matilainen |
34fad6 |
{
|
|
Panu Matilainen |
34fad6 |
- byte * digest;
|
|
Panu Matilainen |
34fad6 |
+ unsigned char * digest;
|
|
Panu Matilainen |
34fad6 |
char * t;
|
|
Panu Matilainen |
34fad6 |
int i;
|
|
Panu Matilainen |
34fad6 |
+ unsigned int digestlen;
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
if (ctx == NULL)
|
|
Panu Matilainen |
34fad6 |
return -1;
|
|
Panu Matilainen |
34fad6 |
- digest = xmalloc(ctx->digestlen);
|
|
Panu Matilainen |
34fad6 |
+ digestlen = HASH_ResultLenContext(ctx->hashctx);
|
|
Panu Matilainen |
34fad6 |
+ digest = xmalloc(digestlen);
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
-DPRINTF((stderr, "*** Final(%p,%p,%p,%d) param %p digest %p\n", ctx, datap, lenp, asAscii, ctx->param, digest));
|
|
Panu Matilainen |
34fad6 |
-/*@-noeffectuncon@*/ /* FIX: check rc */
|
|
Panu Matilainen |
34fad6 |
- (void) (*ctx->Digest) (ctx->param, digest);
|
|
Panu Matilainen |
34fad6 |
+DPRINTF((stderr, "*** Final(%p,%p,%p,%d) hashctx %p digest %p\n", ctx, datap, lenp, asAscii, ctx->hashctx, digest));
|
|
Panu Matilainen |
34fad6 |
+/*@-noeffectuncon@*/
|
|
Panu Matilainen |
34fad6 |
+ HASH_End(ctx->hashctx, digest, &digestlen, digestlen);
|
|
Panu Matilainen |
34fad6 |
/*@=noeffectuncon@*/
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
/* Return final digest. */
|
|
Panu Matilainen |
34fad6 |
/*@-branchstate@*/
|
|
Panu Matilainen |
34fad6 |
if (!asAscii) {
|
|
Panu Matilainen |
34fad6 |
- if (lenp) *lenp = ctx->digestlen;
|
|
Panu Matilainen |
34fad6 |
+ if (lenp) *lenp = digestlen;
|
|
Panu Matilainen |
34fad6 |
if (datap) {
|
|
Panu Matilainen |
34fad6 |
*datap = digest;
|
|
Panu Matilainen |
34fad6 |
digest = NULL;
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
} else {
|
|
Panu Matilainen |
34fad6 |
- if (lenp) *lenp = (2*ctx->digestlen) + 1;
|
|
Panu Matilainen |
34fad6 |
+ if (lenp) *lenp = (2*digestlen) + 1;
|
|
Panu Matilainen |
34fad6 |
if (datap) {
|
|
Panu Matilainen |
34fad6 |
const byte * s = (const byte *) digest;
|
|
Panu Matilainen |
34fad6 |
static const char hex[] = "0123456789abcdef";
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
- *datap = t = xmalloc((2*ctx->digestlen) + 1);
|
|
Panu Matilainen |
34fad6 |
- for (i = 0 ; i < ctx->digestlen; i++) {
|
|
Panu Matilainen |
34fad6 |
+ *datap = t = xmalloc((2*digestlen) + 1);
|
|
Panu Matilainen |
34fad6 |
+ for (i = 0 ; i < digestlen; i++) {
|
|
Panu Matilainen |
34fad6 |
*t++ = hex[ (unsigned)((*s >> 4) & 0x0f) ];
|
|
Panu Matilainen |
34fad6 |
*t++ = hex[ (unsigned)((*s++ ) & 0x0f) ];
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
@@ -191,11 +170,10 @@ DPRINTF((stderr, "*** Final(%p,%p,%p,%d)
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
/*@=branchstate@*/
|
|
Panu Matilainen |
34fad6 |
if (digest) {
|
|
Panu Matilainen |
34fad6 |
- memset(digest, 0, ctx->digestlen); /* In case it's sensitive */
|
|
Panu Matilainen |
34fad6 |
+ memset(digest, 0, digestlen); /* In case it's sensitive */
|
|
Panu Matilainen |
34fad6 |
free(digest);
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
- memset(ctx->param, 0, ctx->paramlen); /* In case it's sensitive */
|
|
Panu Matilainen |
34fad6 |
- free(ctx->param);
|
|
Panu Matilainen |
34fad6 |
+ HASH_Destroy(ctx->hashctx);
|
|
Panu Matilainen |
34fad6 |
memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
|
|
Panu Matilainen |
34fad6 |
free(ctx);
|
|
Panu Matilainen |
34fad6 |
return 0;
|
|
Panu Matilainen |
34fad6 |
diff -r ec9e6c427068 rpmio/rpmio_internal.h
|
|
Panu Matilainen |
34fad6 |
--- a/rpmio/rpmio_internal.h Wed Oct 24 16:02:51 2007 +0300
|
|
Panu Matilainen |
34fad6 |
+++ b/rpmio/rpmio_internal.h Thu Nov 01 10:56:58 2007 +0100
|
|
Panu Matilainen |
34fad6 |
@@ -9,30 +9,14 @@
|
|
Panu Matilainen |
34fad6 |
#include <rpmio.h>
|
|
Panu Matilainen |
34fad6 |
#include <rpmurl.h>
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
-#if HAVE_BEECRYPT_API_H
|
|
Panu Matilainen |
34fad6 |
-#include <api.h>
|
|
Panu Matilainen |
34fad6 |
-#else
|
|
Panu Matilainen |
34fad6 |
-#include <beecrypt.api.h>
|
|
Panu Matilainen |
34fad6 |
-#endif
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
#include <rpmpgp.h>
|
|
Panu Matilainen |
34fad6 |
#include <rpmsw.h>
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
-/* Drag in the beecrypt includes. */
|
|
Panu Matilainen |
34fad6 |
-#include <beecrypt.h>
|
|
Panu Matilainen |
34fad6 |
#include <base64.h>
|
|
Panu Matilainen |
34fad6 |
-#include <dsa.h>
|
|
Panu Matilainen |
34fad6 |
-#include <endianness.h>
|
|
Panu Matilainen |
34fad6 |
-#include <md5.h>
|
|
Panu Matilainen |
34fad6 |
-#include <mp.h>
|
|
Panu Matilainen |
34fad6 |
-#include <rsa.h>
|
|
Panu Matilainen |
34fad6 |
-#include <rsapk.h>
|
|
Panu Matilainen |
34fad6 |
-#include <sha1.h>
|
|
Panu Matilainen |
34fad6 |
-#if HAVE_BEECRYPT_API_H
|
|
Panu Matilainen |
34fad6 |
-#include <sha256.h>
|
|
Panu Matilainen |
34fad6 |
-#include <sha384.h>
|
|
Panu Matilainen |
34fad6 |
-#include <sha512.h>
|
|
Panu Matilainen |
34fad6 |
-#endif
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+#include "nss.h"
|
|
Panu Matilainen |
34fad6 |
+#include "sechash.h"
|
|
Panu Matilainen |
34fad6 |
+#include "keyhi.h"
|
|
Panu Matilainen |
34fad6 |
+#include "cryptohi.h"
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
/** \ingroup rpmio
|
|
Panu Matilainen |
34fad6 |
* Values parsed from OpenPGP signature/pubkey packet(s).
|
|
Panu Matilainen |
34fad6 |
@@ -85,20 +69,13 @@ struct pgpDig_s {
|
|
Panu Matilainen |
34fad6 |
void * md5; /*!< (rsa) V3 signature hash. */
|
|
Panu Matilainen |
34fad6 |
size_t md5len; /*!< (rsa) V3 signature hash length. */
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
- /* DSA parameters. */
|
|
Panu Matilainen |
34fad6 |
- mpbarrett p;
|
|
Panu Matilainen |
34fad6 |
- mpbarrett q;
|
|
Panu Matilainen |
34fad6 |
- mpnumber g;
|
|
Panu Matilainen |
34fad6 |
- mpnumber y;
|
|
Panu Matilainen |
34fad6 |
- mpnumber hm;
|
|
Panu Matilainen |
34fad6 |
- mpnumber r;
|
|
Panu Matilainen |
34fad6 |
- mpnumber s;
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
- /* RSA parameters. */
|
|
Panu Matilainen |
34fad6 |
- rsapk rsa_pk;
|
|
Panu Matilainen |
34fad6 |
- mpnumber m;
|
|
Panu Matilainen |
34fad6 |
- mpnumber c;
|
|
Panu Matilainen |
34fad6 |
- mpnumber rsahm;
|
|
Panu Matilainen |
34fad6 |
+ /* DSA parameters */
|
|
Panu Matilainen |
34fad6 |
+ SECKEYPublicKey *dsa;
|
|
Panu Matilainen |
34fad6 |
+ SECItem *dsasig;
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ /* RSA parameters */
|
|
Panu Matilainen |
34fad6 |
+ SECKEYPublicKey *rsa;
|
|
Panu Matilainen |
34fad6 |
+ SECItem *rsasig;
|
|
Panu Matilainen |
34fad6 |
};
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
/** \ingroup rpmio
|
|
Panu Matilainen |
34fad6 |
diff -r ec9e6c427068 rpmio/rpmpgp.c
|
|
Panu Matilainen |
34fad6 |
--- a/rpmio/rpmpgp.c Wed Oct 24 16:02:51 2007 +0300
|
|
Panu Matilainen |
34fad6 |
+++ b/rpmio/rpmpgp.c Thu Nov 01 10:56:58 2007 +0100
|
|
Panu Matilainen |
34fad6 |
@@ -260,38 +260,100 @@ const char * pgpMpiHex(const byte *p)
|
|
Panu Matilainen |
34fad6 |
/**
|
|
Panu Matilainen |
34fad6 |
* @return 0 on success
|
|
Panu Matilainen |
34fad6 |
*/
|
|
Panu Matilainen |
34fad6 |
-static int pgpHexSet(const char * pre, int lbits,
|
|
Panu Matilainen |
34fad6 |
- /*@out@*/ mpnumber * mpn, const byte * p, const byte * pend)
|
|
Panu Matilainen |
34fad6 |
+static int pgpMpiSet(const char * pre, int lbits,
|
|
Panu Matilainen |
34fad6 |
+ /*@out@*/ void *dest, const byte * p, const byte * pend)
|
|
Panu Matilainen |
34fad6 |
/*@globals fileSystem @*/
|
|
Panu Matilainen |
34fad6 |
- /*@modifies mpn, fileSystem @*/
|
|
Panu Matilainen |
34fad6 |
+ /*@modifies dest, fileSystem @*/
|
|
Panu Matilainen |
34fad6 |
{
|
|
Panu Matilainen |
34fad6 |
unsigned int mbits = pgpMpiBits(p);
|
|
Panu Matilainen |
34fad6 |
unsigned int nbits;
|
|
Panu Matilainen |
34fad6 |
unsigned int nbytes;
|
|
Panu Matilainen |
34fad6 |
- char * t;
|
|
Panu Matilainen |
34fad6 |
+ char *t = dest;
|
|
Panu Matilainen |
34fad6 |
unsigned int ix;
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
if ((p + ((mbits+7) >> 3)) > pend)
|
|
Panu Matilainen |
34fad6 |
return 1;
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
+ if (mbits > lbits)
|
|
Panu Matilainen |
34fad6 |
+ return 1;
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
nbits = (lbits > mbits ? lbits : mbits);
|
|
Panu Matilainen |
34fad6 |
nbytes = ((nbits + 7) >> 3);
|
|
Panu Matilainen |
34fad6 |
- t = xmalloc(2*nbytes+1);
|
|
Panu Matilainen |
34fad6 |
- ix = 2 * ((nbits - mbits) >> 3);
|
|
Panu Matilainen |
34fad6 |
+ ix = (nbits - mbits) >> 3;
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
if (_debug)
|
|
Panu Matilainen |
34fad6 |
-fprintf(stderr, "*** mbits %u nbits %u nbytes %u t %p[%d] ix %u\n", mbits, nbits, nbytes, t, (2*nbytes+1), ix);
|
|
Panu Matilainen |
34fad6 |
- if (ix > 0) memset(t, (int)'0', ix);
|
|
Panu Matilainen |
34fad6 |
- strcpy(t+ix, pgpMpiHex(p));
|
|
Panu Matilainen |
34fad6 |
+fprintf(stderr, "*** mbits %u nbits %u nbytes %u ix %u\n", mbits, nbits, nbytes, ix);
|
|
Panu Matilainen |
34fad6 |
+ if (ix > 0) memset(t, '\0', ix);
|
|
Panu Matilainen |
34fad6 |
+ memcpy(t+ix, p+2, nbytes-ix);
|
|
Panu Matilainen |
34fad6 |
if (_debug)
|
|
Panu Matilainen |
34fad6 |
-fprintf(stderr, "*** %s %s\n", pre, t);
|
|
Panu Matilainen |
34fad6 |
- (void) mpnsethex(mpn, t);
|
|
Panu Matilainen |
34fad6 |
- t = _free(t);
|
|
Panu Matilainen |
34fad6 |
-if (_debug && _print)
|
|
Panu Matilainen |
34fad6 |
-fprintf(stderr, "\t %s ", pre), mpfprintln(stderr, mpn->size, mpn->data);
|
|
Panu Matilainen |
34fad6 |
+fprintf(stderr, "*** %s %s\n", pre, pgpHexStr(dest, nbytes));
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
return 0;
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+/**
|
|
Panu Matilainen |
34fad6 |
+ * @return NULL on error
|
|
Panu Matilainen |
34fad6 |
+ */
|
|
Panu Matilainen |
34fad6 |
+static SECItem *pgpMpiItem(PRArenaPool *arena, /*@out@*/ SECItem *item, const byte *p)
|
|
Panu Matilainen |
34fad6 |
+ /*@globals fileSystem @*/
|
|
Panu Matilainen |
34fad6 |
+ /*@modifies dest, fileSystem @*/
|
|
Panu Matilainen |
34fad6 |
+{
|
|
Panu Matilainen |
34fad6 |
+ unsigned int nbytes = pgpMpiLen(p)-2;
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ if (item == NULL) {
|
|
Panu Matilainen |
34fad6 |
+ if ((item=SECITEM_AllocItem(arena, item, nbytes)) == NULL)
|
|
Panu Matilainen |
34fad6 |
+ return item;
|
|
Panu Matilainen |
34fad6 |
+ } else {
|
|
Panu Matilainen |
34fad6 |
+ if (arena != NULL)
|
|
Panu Matilainen |
34fad6 |
+ item->data = PORT_ArenaGrow(arena, item->data, item->len, nbytes);
|
|
Panu Matilainen |
34fad6 |
+ else
|
|
Panu Matilainen |
34fad6 |
+ item->data = PORT_Realloc(item->data, nbytes);
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ if (item->data == NULL) {
|
|
Panu Matilainen |
34fad6 |
+ if (arena == NULL)
|
|
Panu Matilainen |
34fad6 |
+ SECITEM_FreeItem(item, PR_TRUE);
|
|
Panu Matilainen |
34fad6 |
+ return NULL;
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ memcpy(item->data, p+2, nbytes);
|
|
Panu Matilainen |
34fad6 |
+ item->len = nbytes;
|
|
Panu Matilainen |
34fad6 |
+ return item;
|
|
Panu Matilainen |
34fad6 |
+}
|
|
Panu Matilainen |
34fad6 |
/*@=boundswrite@*/
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+static SECKEYPublicKey *pgpNewPublicKey(KeyType type)
|
|
Panu Matilainen |
34fad6 |
+{
|
|
Panu Matilainen |
34fad6 |
+ PRArenaPool *arena;
|
|
Panu Matilainen |
34fad6 |
+ SECKEYPublicKey *key;
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
|
|
Panu Matilainen |
34fad6 |
+ if (arena == NULL)
|
|
Panu Matilainen |
34fad6 |
+ return NULL;
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ key = PORT_ArenaZAlloc(arena, sizeof(SECKEYPublicKey));
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ if (key == NULL) {
|
|
Panu Matilainen |
34fad6 |
+ PORT_FreeArena(arena, PR_FALSE);
|
|
Panu Matilainen |
34fad6 |
+ return NULL;
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ key->keyType = type;
|
|
Panu Matilainen |
34fad6 |
+ key->pkcs11ID = CK_INVALID_HANDLE;
|
|
Panu Matilainen |
34fad6 |
+ key->pkcs11Slot = NULL;
|
|
Panu Matilainen |
34fad6 |
+ key->arena = arena;
|
|
Panu Matilainen |
34fad6 |
+ return key;
|
|
Panu Matilainen |
34fad6 |
+}
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+static SECKEYPublicKey *pgpNewRSAKey(void)
|
|
Panu Matilainen |
34fad6 |
+{
|
|
Panu Matilainen |
34fad6 |
+ return pgpNewPublicKey(rsaKey);
|
|
Panu Matilainen |
34fad6 |
+}
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+static SECKEYPublicKey *pgpNewDSAKey(void)
|
|
Panu Matilainen |
34fad6 |
+{
|
|
Panu Matilainen |
34fad6 |
+ return pgpNewPublicKey(dsaKey);
|
|
Panu Matilainen |
34fad6 |
+}
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
int pgpPrtSubType(const byte *h, unsigned int hlen, pgpSigType sigtype)
|
|
Panu Matilainen |
34fad6 |
{
|
|
Panu Matilainen |
34fad6 |
@@ -407,6 +469,10 @@ static const char * pgpSigDSA[] = {
|
|
Panu Matilainen |
34fad6 |
};
|
|
Panu Matilainen |
34fad6 |
/*@=varuse =readonlytrans @*/
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
+#ifndef DSA_SUBPRIME_LEN
|
|
Panu Matilainen |
34fad6 |
+#define DSA_SUBPRIME_LEN 20
|
|
Panu Matilainen |
34fad6 |
+#endif
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
static int pgpPrtSigParams(/*@unused@*/ pgpTag tag, byte pubkey_algo, byte sigtype,
|
|
Panu Matilainen |
34fad6 |
const byte *p, const byte *h, unsigned int hlen)
|
|
Panu Matilainen |
34fad6 |
/*@globals fileSystem @*/
|
|
Panu Matilainen |
34fad6 |
@@ -414,7 +480,13 @@ static int pgpPrtSigParams(/*@unused@*/
|
|
Panu Matilainen |
34fad6 |
{
|
|
Panu Matilainen |
34fad6 |
const byte * pend = h + hlen;
|
|
Panu Matilainen |
34fad6 |
int i;
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
+ SECItem dsaraw;
|
|
Panu Matilainen |
34fad6 |
+ unsigned char dsabuf[2*DSA_SUBPRIME_LEN];
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ dsaraw.type = 0;
|
|
Panu Matilainen |
34fad6 |
+ dsaraw.data = dsabuf;
|
|
Panu Matilainen |
34fad6 |
+ dsaraw.len = sizeof(dsabuf);
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
for (i = 0; p < pend; i++, p += pgpMpiLen(p)) {
|
|
Panu Matilainen |
34fad6 |
if (pubkey_algo == PGPPUBKEYALGO_RSA) {
|
|
Panu Matilainen |
34fad6 |
if (i >= 1) break;
|
|
Panu Matilainen |
34fad6 |
@@ -423,9 +495,9 @@ static int pgpPrtSigParams(/*@unused@*/
|
|
Panu Matilainen |
34fad6 |
{
|
|
Panu Matilainen |
34fad6 |
switch (i) {
|
|
Panu Matilainen |
34fad6 |
case 0: /* m**d */
|
|
Panu Matilainen |
34fad6 |
- (void) mpnsethex(&_dig->c, pgpMpiHex(p));
|
|
Panu Matilainen |
34fad6 |
-if (_debug && _print)
|
|
Panu Matilainen |
34fad6 |
-fprintf(stderr, "\t m**d = "), mpfprintln(stderr, _dig->c.size, _dig->c.data);
|
|
Panu Matilainen |
34fad6 |
+ _dig->rsasig = pgpMpiItem(NULL, _dig->rsasig, p);
|
|
Panu Matilainen |
34fad6 |
+ if (_dig->rsasig == NULL)
|
|
Panu Matilainen |
34fad6 |
+ return 1;
|
|
Panu Matilainen |
34fad6 |
/*@switchbreak@*/ break;
|
|
Panu Matilainen |
34fad6 |
default:
|
|
Panu Matilainen |
34fad6 |
/*@switchbreak@*/ break;
|
|
Panu Matilainen |
34fad6 |
@@ -440,11 +512,21 @@ fprintf(stderr, "\t m**d = "), mpfprin
|
|
Panu Matilainen |
34fad6 |
int xx;
|
|
Panu Matilainen |
34fad6 |
xx = 0;
|
|
Panu Matilainen |
34fad6 |
switch (i) {
|
|
Panu Matilainen |
34fad6 |
- case 0: /* r */
|
|
Panu Matilainen |
34fad6 |
- xx = pgpHexSet(pgpSigDSA[i], 160, &_dig->r, p, pend);
|
|
Panu Matilainen |
34fad6 |
+ case 0:
|
|
Panu Matilainen |
34fad6 |
+ memset(dsaraw.data, '\0', 2*DSA_SUBPRIME_LEN);
|
|
Panu Matilainen |
34fad6 |
+ /* r */
|
|
Panu Matilainen |
34fad6 |
+ xx = pgpMpiSet(pgpSigDSA[i], DSA_SUBPRIME_LEN*8, dsaraw.data, p, pend);
|
|
Panu Matilainen |
34fad6 |
/*@switchbreak@*/ break;
|
|
Panu Matilainen |
34fad6 |
case 1: /* s */
|
|
Panu Matilainen |
34fad6 |
- xx = pgpHexSet(pgpSigDSA[i], 160, &_dig->s, p, pend);
|
|
Panu Matilainen |
34fad6 |
+ xx = pgpMpiSet(pgpSigDSA[i], DSA_SUBPRIME_LEN*8, dsaraw.data + DSA_SUBPRIME_LEN, p, pend);
|
|
Panu Matilainen |
34fad6 |
+ if (_dig->dsasig != NULL)
|
|
Panu Matilainen |
34fad6 |
+ SECITEM_FreeItem(_dig->dsasig, PR_FALSE);
|
|
Panu Matilainen |
34fad6 |
+ else if ((_dig->dsasig=SECITEM_AllocItem(NULL, NULL, 0)) == NULL) {
|
|
Panu Matilainen |
34fad6 |
+ xx = 1;
|
|
Panu Matilainen |
34fad6 |
+ /*@switchbreak@*/ break;
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+ if (DSAU_EncodeDerSig(_dig->dsasig, &dsaraw) != SECSuccess)
|
|
Panu Matilainen |
34fad6 |
+ xx = 1;
|
|
Panu Matilainen |
34fad6 |
/*@switchbreak@*/ break;
|
|
Panu Matilainen |
34fad6 |
default:
|
|
Panu Matilainen |
34fad6 |
xx = 1;
|
|
Panu Matilainen |
34fad6 |
@@ -629,16 +711,17 @@ static const byte * pgpPrtPubkeyParams(b
|
|
Panu Matilainen |
34fad6 |
if (pubkey_algo == PGPPUBKEYALGO_RSA) {
|
|
Panu Matilainen |
34fad6 |
if (i >= 2) break;
|
|
Panu Matilainen |
34fad6 |
if (_dig) {
|
|
Panu Matilainen |
34fad6 |
+ if (_dig->rsa == NULL) {
|
|
Panu Matilainen |
34fad6 |
+ _dig->rsa = pgpNewRSAKey();
|
|
Panu Matilainen |
34fad6 |
+ if (_dig->rsa == NULL)
|
|
Panu Matilainen |
34fad6 |
+ break; /* error abort? */
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
switch (i) {
|
|
Panu Matilainen |
34fad6 |
case 0: /* n */
|
|
Panu Matilainen |
34fad6 |
- (void) mpbsethex(&_dig->rsa_pk.n, pgpMpiHex(p));
|
|
Panu Matilainen |
34fad6 |
-if (_debug && _print)
|
|
Panu Matilainen |
34fad6 |
-fprintf(stderr, "\t n = "), mpfprintln(stderr, _dig->rsa_pk.n.size, _dig->rsa_pk.n.modl);
|
|
Panu Matilainen |
34fad6 |
+ pgpMpiItem(_dig->rsa->arena, &_dig->rsa->u.rsa.modulus, p);
|
|
Panu Matilainen |
34fad6 |
/*@switchbreak@*/ break;
|
|
Panu Matilainen |
34fad6 |
case 1: /* e */
|
|
Panu Matilainen |
34fad6 |
- (void) mpnsethex(&_dig->rsa_pk.e, pgpMpiHex(p));
|
|
Panu Matilainen |
34fad6 |
-if (_debug && _print)
|
|
Panu Matilainen |
34fad6 |
-fprintf(stderr, "\t e = "), mpfprintln(stderr, _dig->rsa_pk.e.size, _dig->rsa_pk.e.data);
|
|
Panu Matilainen |
34fad6 |
+ pgpMpiItem(_dig->rsa->arena, &_dig->rsa->u.rsa.publicExponent, p);
|
|
Panu Matilainen |
34fad6 |
/*@switchbreak@*/ break;
|
|
Panu Matilainen |
34fad6 |
default:
|
|
Panu Matilainen |
34fad6 |
/*@switchbreak@*/ break;
|
|
Panu Matilainen |
34fad6 |
@@ -648,26 +731,23 @@ fprintf(stderr, "\t e = "), mpfprin
|
|
Panu Matilainen |
34fad6 |
} else if (pubkey_algo == PGPPUBKEYALGO_DSA) {
|
|
Panu Matilainen |
34fad6 |
if (i >= 4) break;
|
|
Panu Matilainen |
34fad6 |
if (_dig) {
|
|
Panu Matilainen |
34fad6 |
+ if (_dig->dsa == NULL) {
|
|
Panu Matilainen |
34fad6 |
+ _dig->dsa = pgpNewDSAKey();
|
|
Panu Matilainen |
34fad6 |
+ if (_dig->dsa == NULL)
|
|
Panu Matilainen |
34fad6 |
+ break; /* error abort? */
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
switch (i) {
|
|
Panu Matilainen |
34fad6 |
case 0: /* p */
|
|
Panu Matilainen |
34fad6 |
- (void) mpbsethex(&_dig->p, pgpMpiHex(p));
|
|
Panu Matilainen |
34fad6 |
-if (_debug && _print)
|
|
Panu Matilainen |
34fad6 |
-fprintf(stderr, "\t p = "), mpfprintln(stderr, _dig->p.size, _dig->p.modl);
|
|
Panu Matilainen |
34fad6 |
+ pgpMpiItem(_dig->dsa->arena, &_dig->dsa->u.dsa.params.prime, p);
|
|
Panu Matilainen |
34fad6 |
/*@switchbreak@*/ break;
|
|
Panu Matilainen |
34fad6 |
case 1: /* q */
|
|
Panu Matilainen |
34fad6 |
- (void) mpbsethex(&_dig->q, pgpMpiHex(p));
|
|
Panu Matilainen |
34fad6 |
-if (_debug && _print)
|
|
Panu Matilainen |
34fad6 |
-fprintf(stderr, "\t q = "), mpfprintln(stderr, _dig->q.size, _dig->q.modl);
|
|
Panu Matilainen |
34fad6 |
+ pgpMpiItem(_dig->dsa->arena, &_dig->dsa->u.dsa.params.subPrime, p);
|
|
Panu Matilainen |
34fad6 |
/*@switchbreak@*/ break;
|
|
Panu Matilainen |
34fad6 |
case 2: /* g */
|
|
Panu Matilainen |
34fad6 |
- (void) mpnsethex(&_dig->g, pgpMpiHex(p));
|
|
Panu Matilainen |
34fad6 |
-if (_debug && _print)
|
|
Panu Matilainen |
34fad6 |
-fprintf(stderr, "\t g = "), mpfprintln(stderr, _dig->g.size, _dig->g.data);
|
|
Panu Matilainen |
34fad6 |
+ pgpMpiItem(_dig->dsa->arena, &_dig->dsa->u.dsa.params.base, p);
|
|
Panu Matilainen |
34fad6 |
/*@switchbreak@*/ break;
|
|
Panu Matilainen |
34fad6 |
case 3: /* y */
|
|
Panu Matilainen |
34fad6 |
- (void) mpnsethex(&_dig->y, pgpMpiHex(p));
|
|
Panu Matilainen |
34fad6 |
-if (_debug && _print)
|
|
Panu Matilainen |
34fad6 |
-fprintf(stderr, "\t y = "), mpfprintln(stderr, _dig->y.size, _dig->y.data);
|
|
Panu Matilainen |
34fad6 |
+ pgpMpiItem(_dig->dsa->arena, &_dig->dsa->u.dsa.publicValue, p);
|
|
Panu Matilainen |
34fad6 |
/*@switchbreak@*/ break;
|
|
Panu Matilainen |
34fad6 |
default:
|
|
Panu Matilainen |
34fad6 |
/*@switchbreak@*/ break;
|
|
Panu Matilainen |
34fad6 |
@@ -1014,6 +1094,8 @@ pgpDig pgpNewDig(void)
|
|
Panu Matilainen |
34fad6 |
pgpDig pgpNewDig(void)
|
|
Panu Matilainen |
34fad6 |
{
|
|
Panu Matilainen |
34fad6 |
pgpDig dig = xcalloc(1, sizeof(*dig));
|
|
Panu Matilainen |
34fad6 |
+ NSS_NoDB_Init(NULL);
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
return dig;
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
@@ -1038,14 +1120,27 @@ void pgpCleanDig(pgpDig dig)
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
dig->md5 = _free(dig->md5);
|
|
Panu Matilainen |
34fad6 |
dig->sha1 = _free(dig->sha1);
|
|
Panu Matilainen |
34fad6 |
- mpnfree(&dig->hm);
|
|
Panu Matilainen |
34fad6 |
- mpnfree(&dig->r);
|
|
Panu Matilainen |
34fad6 |
- mpnfree(&dig->s);
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
- (void) rsapkFree(&dig->rsa_pk);
|
|
Panu Matilainen |
34fad6 |
- mpnfree(&dig->m);
|
|
Panu Matilainen |
34fad6 |
- mpnfree(&dig->c);
|
|
Panu Matilainen |
34fad6 |
- mpnfree(&dig->rsahm);
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ if (dig->dsa != NULL) {
|
|
Panu Matilainen |
34fad6 |
+ SECKEY_DestroyPublicKey(dig->dsa);
|
|
Panu Matilainen |
34fad6 |
+ dig->dsa = NULL;
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ if (dig->dsasig != NULL) {
|
|
Panu Matilainen |
34fad6 |
+ SECITEM_ZfreeItem(dig->dsasig, PR_TRUE);
|
|
Panu Matilainen |
34fad6 |
+ dig->dsasig = NULL;
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ if (dig->rsa != NULL) {
|
|
Panu Matilainen |
34fad6 |
+ SECKEY_DestroyPublicKey(dig->rsa);
|
|
Panu Matilainen |
34fad6 |
+ dig->rsa = NULL;
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ if (dig->rsasig != NULL) {
|
|
Panu Matilainen |
34fad6 |
+ SECITEM_ZfreeItem(dig->rsasig, PR_TRUE);
|
|
Panu Matilainen |
34fad6 |
+ dig->rsasig = NULL;
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
/*@-nullstate@*/
|
|
Panu Matilainen |
34fad6 |
return;
|
|
Panu Matilainen |
34fad6 |
@@ -1072,14 +1167,6 @@ pgpDig pgpFreeDig(/*@only@*/ /*@null@*/
|
|
Panu Matilainen |
34fad6 |
(void) rpmDigestFinal(dig->sha1ctx, NULL, NULL, 0);
|
|
Panu Matilainen |
34fad6 |
/*@=branchstate@*/
|
|
Panu Matilainen |
34fad6 |
dig->sha1ctx = NULL;
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
- mpbfree(&dig->p);
|
|
Panu Matilainen |
34fad6 |
- mpbfree(&dig->q);
|
|
Panu Matilainen |
34fad6 |
- mpnfree(&dig->g);
|
|
Panu Matilainen |
34fad6 |
- mpnfree(&dig->y);
|
|
Panu Matilainen |
34fad6 |
- mpnfree(&dig->hm);
|
|
Panu Matilainen |
34fad6 |
- mpnfree(&dig->r);
|
|
Panu Matilainen |
34fad6 |
- mpnfree(&dig->s);
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
#ifdef NOTYET
|
|
Panu Matilainen |
34fad6 |
/*@-branchstate@*/
|
|
Panu Matilainen |
34fad6 |
@@ -1094,12 +1181,6 @@ pgpDig pgpFreeDig(/*@only@*/ /*@null@*/
|
|
Panu Matilainen |
34fad6 |
(void) rpmDigestFinal(dig->md5ctx, NULL, NULL, 0);
|
|
Panu Matilainen |
34fad6 |
/*@=branchstate@*/
|
|
Panu Matilainen |
34fad6 |
dig->md5ctx = NULL;
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
- mpbfree(&dig->rsa_pk.n);
|
|
Panu Matilainen |
34fad6 |
- mpnfree(&dig->rsa_pk.e);
|
|
Panu Matilainen |
34fad6 |
- mpnfree(&dig->m);
|
|
Panu Matilainen |
34fad6 |
- mpnfree(&dig->c);
|
|
Panu Matilainen |
34fad6 |
- mpnfree(&dig->hm);
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
dig = _free(dig);
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
@@ -1286,20 +1367,13 @@ char * pgpArmorWrap(int atype, const uns
|
|
Panu Matilainen |
34fad6 |
{
|
|
Panu Matilainen |
34fad6 |
const char * enc;
|
|
Panu Matilainen |
34fad6 |
char * t;
|
|
Panu Matilainen |
34fad6 |
- size_t nt;
|
|
Panu Matilainen |
34fad6 |
+ size_t nt = 0;
|
|
Panu Matilainen |
34fad6 |
char * val;
|
|
Panu Matilainen |
34fad6 |
- int lc;
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
- nt = ((ns + 2) / 3) * 4;
|
|
Panu Matilainen |
34fad6 |
- /*@-globs@*/
|
|
Panu Matilainen |
34fad6 |
- /* Add additional bytes necessary for eol string(s). */
|
|
Panu Matilainen |
34fad6 |
- if (b64encode_chars_per_line > 0 && b64encode_eolstr != NULL) {
|
|
Panu Matilainen |
34fad6 |
- lc = (nt + b64encode_chars_per_line - 1) / b64encode_chars_per_line;
|
|
Panu Matilainen |
34fad6 |
- if (((nt + b64encode_chars_per_line - 1) % b64encode_chars_per_line) != 0)
|
|
Panu Matilainen |
34fad6 |
- ++lc;
|
|
Panu Matilainen |
34fad6 |
- nt += lc * strlen(b64encode_eolstr);
|
|
Panu Matilainen |
34fad6 |
- }
|
|
Panu Matilainen |
34fad6 |
- /*@=globs@*/
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ enc = b64encode(s, ns, -1);
|
|
Panu Matilainen |
34fad6 |
+ if (enc != NULL) {
|
|
Panu Matilainen |
34fad6 |
+ nt = strlen(enc);
|
|
Panu Matilainen |
34fad6 |
+ }
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
nt += 512; /* XXX slop for armor and crc */
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
@@ -1311,9 +1385,9 @@ char * pgpArmorWrap(int atype, const uns
|
|
Panu Matilainen |
34fad6 |
/*@-globs@*/
|
|
Panu Matilainen |
34fad6 |
t = stpcpy( stpcpy(t, "-----\nVersion: rpm-"), VERSION);
|
|
Panu Matilainen |
34fad6 |
/*@=globs@*/
|
|
Panu Matilainen |
34fad6 |
- t = stpcpy(t, " (beecrypt-4.1.2)\n\n");
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
- if ((enc = b64encode(s, ns)) != NULL) {
|
|
Panu Matilainen |
34fad6 |
+ t = stpcpy(t, " (NSS-3)\n\n");
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+ if (enc != NULL) {
|
|
Panu Matilainen |
34fad6 |
t = stpcpy(t, enc);
|
|
Panu Matilainen |
34fad6 |
enc = _free(enc);
|
|
Panu Matilainen |
34fad6 |
if ((enc = b64crc(s, ns)) != NULL) {
|
|
Panu Matilainen |
34fad6 |
diff -r ec9e6c427068 rpmio/rpmpgp.h
|
|
Panu Matilainen |
34fad6 |
--- a/rpmio/rpmpgp.h Wed Oct 24 16:02:51 2007 +0300
|
|
Panu Matilainen |
34fad6 |
+++ b/rpmio/rpmpgp.h Thu Nov 01 10:56:58 2007 +0100
|
|
Panu Matilainen |
34fad6 |
@@ -12,11 +12,7 @@
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
#include <string.h>
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
-#if !defined(_BEECRYPT_API_H)
|
|
Panu Matilainen |
34fad6 |
-/*@-redef@*/
|
|
Panu Matilainen |
34fad6 |
typedef unsigned char byte;
|
|
Panu Matilainen |
34fad6 |
-/*@=redef@*/
|
|
Panu Matilainen |
34fad6 |
-#endif /* _BEECRYPT_API_H */
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
/**
|
|
Panu Matilainen |
34fad6 |
*/
|
|
Panu Matilainen |
34fad6 |
@@ -1393,6 +1389,15 @@ DIGEST_CTX rpmDigestDup(DIGEST_CTX octx)
|
|
Panu Matilainen |
34fad6 |
/*@*/;
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
/** \ingroup rpmio
|
|
Panu Matilainen |
34fad6 |
+ * Obtain digest length in bytes.
|
|
Panu Matilainen |
34fad6 |
+ * @param hashalgo type of digest
|
|
Panu Matilainen |
34fad6 |
+ * @return digest length
|
|
Panu Matilainen |
34fad6 |
+ */
|
|
Panu Matilainen |
34fad6 |
+/*@only@*/ /*@null@*/
|
|
Panu Matilainen |
34fad6 |
+size_t rpmDigestLength(pgpHashAlgo hashalgo)
|
|
Panu Matilainen |
34fad6 |
+ /*@*/;
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
+/** \ingroup rpmio
|
|
Panu Matilainen |
34fad6 |
* Initialize digest.
|
|
Panu Matilainen |
34fad6 |
* Set bit count to 0 and buffer to mysterious initialization constants.
|
|
Panu Matilainen |
34fad6 |
* @param hashalgo type of digest
|
|
Panu Matilainen |
34fad6 |
diff -r ec9e6c427068 rpmio/tkey.c
|
|
Panu Matilainen |
34fad6 |
--- a/rpmio/tkey.c Wed Oct 24 16:02:51 2007 +0300
|
|
Panu Matilainen |
34fad6 |
+++ b/rpmio/tkey.c Thu Nov 01 10:56:58 2007 +0100
|
|
Panu Matilainen |
34fad6 |
@@ -31,7 +31,7 @@ fprintf(stderr, "*** sig is\n%s\n", sig)
|
|
Panu Matilainen |
34fad6 |
return rc;
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
- if ((enc = b64encode(dec, declen)) == NULL) {
|
|
Panu Matilainen |
34fad6 |
+ if ((enc = b64encode(dec, declen, -1)) == NULL) {
|
|
Panu Matilainen |
34fad6 |
fprintf(stderr, "*** b64encode failed\n");
|
|
Panu Matilainen |
34fad6 |
return rc;
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
@@ -51,52 +51,40 @@ fprintf(stderr, "??? %5d %02x != %02x '%
|
|
Panu Matilainen |
34fad6 |
return rc;
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
-/* FIPS-186 test vectors. */
|
|
Panu Matilainen |
34fad6 |
-static const char * fips_p = "8df2a494492276aa3d25759bb06869cbeac0d83afb8d0cf7cbb8324f0d7882e5d0762fc5b7210eafc2e9adac32ab7aac49693dfbf83724c2ec0736ee31c80291";
|
|
Panu Matilainen |
34fad6 |
-static const char * fips_q = "c773218c737ec8ee993b4f2ded30f48edace915f";
|
|
Panu Matilainen |
34fad6 |
-static const char * fips_g = "626d027839ea0a13413163a55b4cb500299d5522956cefcb3bff10f399ce2c2e71cb9de5fa24babf58e5b79521925c9cc42e9f6f464b088cc572af53e6d78802";
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
-static const char * fips_hm = "a9993e364706816aba3e25717850c26c9cd0d89d";
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
-static const char * fips_y = "19131871d75b1612a819f29d78d1b0d7346f7aa77bb62a859bfd6c5675da9d212d3a36ef1672ef660b8c7c255cc0ec74858fba33f44c06699630a76b030ee333";
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
-static const char * fips_r = "8bac1ab66410435cb7181f95b16ab97c92b341c0";
|
|
Panu Matilainen |
34fad6 |
-static const char * fips_s = "41e2345f1f56df2458f426d155b4ba2db6dcd8c8";
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
/* Secret key */
|
|
Panu Matilainen |
34fad6 |
-static const char * jbjSecretDSA = "
|
|
Panu Matilainen |
34fad6 |
-lQFvBDu6XHwRAwCTIHRgKeIlOFUIEZeJVYSrXn0eUrM5S8OF471tTc+IV7AwiXBR
|
|
Panu Matilainen |
34fad6 |
-zCFCan4lO1ipmoAipyN2A6ZX0HWOcWdYlWz2adxA7l8JNiZTzkemA562xwex2wLy
|
|
Panu Matilainen |
34fad6 |
-AQWVTtRN6jv0LccAoN4UWZkIvkT6tV918sEvDEggGARxAv9190RhrDq/GMqd+AHm
|
|
Panu Matilainen |
34fad6 |
-qWrRkrBRHDUBBL2fYEuU3gFekYrW5CDIN6s3Mcq/yUsvwHl7bwmoqbf2qabbyfnv
|
|
Panu Matilainen |
34fad6 |
-Y66ETOPKLcw67ggcptHXHcwlvpfJmHKpjK+ByzgauPXXbRAC+gKDjzXL0kAQxjmT
|
|
Panu Matilainen |
34fad6 |
-2D+16O4vI8Emlx2JVcGLlq/aWhspvQWIzN6PytA3iKZ6uzesrM7yXmqzgodZUsJh
|
|
Panu Matilainen |
34fad6 |
-1wwl/0K5OIJn/oD41UayU8RXNER8SzDYvDYsJymFRwE1s58lL/8DAwJUAllw1pdZ
|
|
Panu Matilainen |
34fad6 |
-WmBIoAvRiv7kE6hWfeCvZzdBVgrHYrp8ceUa3OdulGfYw/0sIzpEU0FfZmFjdG9y
|
|
Panu Matilainen |
34fad6 |
-OgAA30gJ4JMFKVfthnDCHHL+O8lNxykKBmrgVPLClue0KUplZmYgSm9obnNvbiAo
|
|
Panu Matilainen |
34fad6 |
-QVJTIE4zTlBRKSA8amJqQHJlZGhhdC5jb20+iFcEExECABcFAju6XHwFCwcKAwQD
|
|
Panu Matilainen |
34fad6 |
-FQMCAxYCAQIXgAAKCRCB0qVW2I6DmQU6AJ490bVWZuM4yCOh8MWj6qApCr1/gwCf
|
|
Panu Matilainen |
34fad6 |
-f3+QgXFXAeTyPtMmReyWxThABtE=
|
|
Panu Matilainen |
34fad6 |
+static const char * jbjSecretDSA = "\n\
|
|
Panu Matilainen |
34fad6 |
+lQFvBDu6XHwRAwCTIHRgKeIlOFUIEZeJVYSrXn0eUrM5S8OF471tTc+IV7AwiXBR\n\
|
|
Panu Matilainen |
34fad6 |
+zCFCan4lO1ipmoAipyN2A6ZX0HWOcWdYlWz2adxA7l8JNiZTzkemA562xwex2wLy\n\
|
|
Panu Matilainen |
34fad6 |
+AQWVTtRN6jv0LccAoN4UWZkIvkT6tV918sEvDEggGARxAv9190RhrDq/GMqd+AHm\n\
|
|
Panu Matilainen |
34fad6 |
+qWrRkrBRHDUBBL2fYEuU3gFekYrW5CDIN6s3Mcq/yUsvwHl7bwmoqbf2qabbyfnv\n\
|
|
Panu Matilainen |
34fad6 |
+Y66ETOPKLcw67ggcptHXHcwlvpfJmHKpjK+ByzgauPXXbRAC+gKDjzXL0kAQxjmT\n\
|
|
Panu Matilainen |
34fad6 |
+2D+16O4vI8Emlx2JVcGLlq/aWhspvQWIzN6PytA3iKZ6uzesrM7yXmqzgodZUsJh\n\
|
|
Panu Matilainen |
34fad6 |
+1wwl/0K5OIJn/oD41UayU8RXNER8SzDYvDYsJymFRwE1s58lL/8DAwJUAllw1pdZ\n\
|
|
Panu Matilainen |
34fad6 |
+WmBIoAvRiv7kE6hWfeCvZzdBVgrHYrp8ceUa3OdulGfYw/0sIzpEU0FfZmFjdG9y\n\
|
|
Panu Matilainen |
34fad6 |
+OgAA30gJ4JMFKVfthnDCHHL+O8lNxykKBmrgVPLClue0KUplZmYgSm9obnNvbiAo\n\
|
|
Panu Matilainen |
34fad6 |
+QVJTIE4zTlBRKSA8amJqQHJlZGhhdC5jb20+iFcEExECABcFAju6XHwFCwcKAwQD\n\
|
|
Panu Matilainen |
34fad6 |
+FQMCAxYCAQIXgAAKCRCB0qVW2I6DmQU6AJ490bVWZuM4yCOh8MWj6qApCr1/gwCf\n\
|
|
Panu Matilainen |
34fad6 |
+f3+QgXFXAeTyPtMmReyWxThABtE=\n\
|
|
Panu Matilainen |
34fad6 |
";
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
/* Public key */
|
|
Panu Matilainen |
34fad6 |
-static const char * jbjPublicDSA = "
|
|
Panu Matilainen |
34fad6 |
-mQFCBDu6XHwRAwCTIHRgKeIlOFUIEZeJVYSrXn0eUrM5S8OF471tTc+IV7AwiXBR
|
|
Panu Matilainen |
34fad6 |
-zCFCan4lO1ipmoAipyN2A6ZX0HWOcWdYlWz2adxA7l8JNiZTzkemA562xwex2wLy
|
|
Panu Matilainen |
34fad6 |
-AQWVTtRN6jv0LccAoN4UWZkIvkT6tV918sEvDEggGARxAv9190RhrDq/GMqd+AHm
|
|
Panu Matilainen |
34fad6 |
-qWrRkrBRHDUBBL2fYEuU3gFekYrW5CDIN6s3Mcq/yUsvwHl7bwmoqbf2qabbyfnv
|
|
Panu Matilainen |
34fad6 |
-Y66ETOPKLcw67ggcptHXHcwlvpfJmHKpjK+ByzgauPXXbRAC+gKDjzXL0kAQxjmT
|
|
Panu Matilainen |
34fad6 |
-2D+16O4vI8Emlx2JVcGLlq/aWhspvQWIzN6PytA3iKZ6uzesrM7yXmqzgodZUsJh
|
|
Panu Matilainen |
34fad6 |
-1wwl/0K5OIJn/oD41UayU8RXNER8SzDYvDYsJymFRwE1s58lL7QpSmVmZiBKb2hu
|
|
Panu Matilainen |
34fad6 |
-c29uIChBUlMgTjNOUFEpIDxqYmpAcmVkaGF0LmNvbT6IVwQTEQIAFwUCO7pcfAUL
|
|
Panu Matilainen |
34fad6 |
-BwoDBAMVAwIDFgIBAheAAAoJEIHSpVbYjoOZBToAn3TXaAI+bhg51EeyaiFip/6W
|
|
Panu Matilainen |
34fad6 |
-OVwBAJ44rTtNsgZBQxXISjB64CWxl4VaWQ==
|
|
Panu Matilainen |
34fad6 |
+static const char * jbjPublicDSA = "\n\
|
|
Panu Matilainen |
34fad6 |
+mQFCBDu6XHwRAwCTIHRgKeIlOFUIEZeJVYSrXn0eUrM5S8OF471tTc+IV7AwiXBR\n\
|
|
Panu Matilainen |
34fad6 |
+zCFCan4lO1ipmoAipyN2A6ZX0HWOcWdYlWz2adxA7l8JNiZTzkemA562xwex2wLy\n\
|
|
Panu Matilainen |
34fad6 |
+AQWVTtRN6jv0LccAoN4UWZkIvkT6tV918sEvDEggGARxAv9190RhrDq/GMqd+AHm\n\
|
|
Panu Matilainen |
34fad6 |
+qWrRkrBRHDUBBL2fYEuU3gFekYrW5CDIN6s3Mcq/yUsvwHl7bwmoqbf2qabbyfnv\n\
|
|
Panu Matilainen |
34fad6 |
+Y66ETOPKLcw67ggcptHXHcwlvpfJmHKpjK+ByzgauPXXbRAC+gKDjzXL0kAQxjmT\n\
|
|
Panu Matilainen |
34fad6 |
+2D+16O4vI8Emlx2JVcGLlq/aWhspvQWIzN6PytA3iKZ6uzesrM7yXmqzgodZUsJh\n\
|
|
Panu Matilainen |
34fad6 |
+1wwl/0K5OIJn/oD41UayU8RXNER8SzDYvDYsJymFRwE1s58lL7QpSmVmZiBKb2hu\n\
|
|
Panu Matilainen |
34fad6 |
+c29uIChBUlMgTjNOUFEpIDxqYmpAcmVkaGF0LmNvbT6IVwQTEQIAFwUCO7pcfAUL\n\
|
|
Panu Matilainen |
34fad6 |
+BwoDBAMVAwIDFgIBAheAAAoJEIHSpVbYjoOZBToAn3TXaAI+bhg51EeyaiFip/6W\n\
|
|
Panu Matilainen |
34fad6 |
+OVwBAJ44rTtNsgZBQxXISjB64CWxl4VaWQ==\n\
|
|
Panu Matilainen |
34fad6 |
";
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
/* Signature */
|
|
Panu Matilainen |
34fad6 |
-static const char * abcSignatureDSA = "
|
|
Panu Matilainen |
34fad6 |
-iD8DBQA7vII+gdKlVtiOg5kRAvg4AJ0fV3gDBADobAnK2HOkV88bfmFMEgCeNysO
|
|
Panu Matilainen |
34fad6 |
-nP3dWWJnp0Pnbor7pIob4Dk=
|
|
Panu Matilainen |
34fad6 |
+static const char * abcSignatureDSA = "\n\
|
|
Panu Matilainen |
34fad6 |
+iD8DBQA7vII+gdKlVtiOg5kRAvg4AJ0fV3gDBADobAnK2HOkV88bfmFMEgCeNysO\n\
|
|
Panu Matilainen |
34fad6 |
+nP3dWWJnp0Pnbor7pIob4Dk=\n\
|
|
Panu Matilainen |
34fad6 |
";
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
int
|
|
Panu Matilainen |
34fad6 |
@@ -107,28 +95,6 @@ main (int argc, char *argv[])
|
|
Panu Matilainen |
34fad6 |
int rc;
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
dig = pgpNewDig();
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
- mpbzero(&dig->p); mpbsethex(&dig->p, fips_p);
|
|
Panu Matilainen |
34fad6 |
- mpbzero(&dig->q); mpbsethex(&dig->q, fips_q);
|
|
Panu Matilainen |
34fad6 |
- mpnzero(&dig->g); mpnsethex(&dig->g, fips_g);
|
|
Panu Matilainen |
34fad6 |
- mpnzero(&dig->y); mpnsethex(&dig->y, fips_y);
|
|
Panu Matilainen |
34fad6 |
- mpnzero(&dig->r); mpnsethex(&dig->r, fips_r);
|
|
Panu Matilainen |
34fad6 |
- mpnzero(&dig->s); mpnsethex(&dig->s, fips_s);
|
|
Panu Matilainen |
34fad6 |
- mpnzero(&dig->hm); mpnsethex(&dig->hm, fips_hm);
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
- rc = dsavrfy(&dig->p, &dig->q, &dig->g, &dig->hm,
|
|
Panu Matilainen |
34fad6 |
- &dig->y, &dig->r, &dig->s);
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
-fprintf(stderr, "=============================== DSA FIPS-186-1: rc %d\n", rc);
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
- mpbfree(&dig->p);
|
|
Panu Matilainen |
34fad6 |
- mpbfree(&dig->q);
|
|
Panu Matilainen |
34fad6 |
- mpnfree(&dig->g);
|
|
Panu Matilainen |
34fad6 |
- mpnfree(&dig->y);
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
- mpnfree(&dig->hm);
|
|
Panu Matilainen |
34fad6 |
- mpnfree(&dig->r);
|
|
Panu Matilainen |
34fad6 |
- mpnfree(&dig->s);
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
fprintf(stderr, "=============================== GPG Secret Key\n");
|
|
Panu Matilainen |
34fad6 |
if ((rc = doit(jbjSecretDSA, dig, printing)) != 0)
|
|
Panu Matilainen |
34fad6 |
@@ -144,39 +110,33 @@ fprintf(stderr, "=======================
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
{ DIGEST_CTX ctx = rpmDigestInit(PGPHASHALGO_SHA1, RPMDIGEST_NONE);
|
|
Panu Matilainen |
34fad6 |
struct pgpDigParams_s * dsig = &dig->signature;
|
|
Panu Matilainen |
34fad6 |
- const char * digest = NULL;
|
|
Panu Matilainen |
34fad6 |
+ void *digest = NULL;
|
|
Panu Matilainen |
34fad6 |
size_t digestlen = 0;
|
|
Panu Matilainen |
34fad6 |
const char * txt = "abc";
|
|
Panu Matilainen |
34fad6 |
+ SECItem digitem;
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
rpmDigestUpdate(ctx, txt, strlen(txt));
|
|
Panu Matilainen |
34fad6 |
rpmDigestUpdate(ctx, dsig->hash, dsig->hashlen);
|
|
Panu Matilainen |
34fad6 |
- rpmDigestFinal(ctx, (void **)&digest, &digestlen, 1);
|
|
Panu Matilainen |
34fad6 |
+ rpmDigestFinal(ctx, &digest, &digestlen, 0);
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
- mpnzero(&dig->hm); mpnsethex(&dig->hm, digest);
|
|
Panu Matilainen |
34fad6 |
+fprintf(stderr, "\n hm = [ 160]: %s\n\n", pgpHexStr(digest, digestlen));
|
|
Panu Matilainen |
34fad6 |
+ digitem.type = siBuffer;
|
|
Panu Matilainen |
34fad6 |
+ digitem.data = digest;
|
|
Panu Matilainen |
34fad6 |
+ digitem.len = digestlen;
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
-fprintf(stderr, "\n hm = [ 160]: %s\n\n", digest);
|
|
Panu Matilainen |
34fad6 |
+ rc = VFY_VerifyDigest(&digitem, dig->dsa, dig->dsasig, SEC_OID_ANSIX9_DSA_SIGNATURE_WITH_SHA1_DIGEST, NULL);
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
if (digest) {
|
|
Panu Matilainen |
34fad6 |
- free((void *)digest);
|
|
Panu Matilainen |
34fad6 |
+ free(digest);
|
|
Panu Matilainen |
34fad6 |
digest = NULL;
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
- rc = dsavrfy(&dig->p, &dig->q, &dig->g, &dig->hm,
|
|
Panu Matilainen |
34fad6 |
- &dig->y, &dig->r, &dig->s);
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
fprintf(stderr, "=============================== DSA verify: rc %d\n", rc);
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
- mpbfree(&dig->p);
|
|
Panu Matilainen |
34fad6 |
- mpbfree(&dig->q);
|
|
Panu Matilainen |
34fad6 |
- mpnfree(&dig->g);
|
|
Panu Matilainen |
34fad6 |
- mpnfree(&dig->y);
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
- mpnfree(&dig->hm);
|
|
Panu Matilainen |
34fad6 |
- mpnfree(&dig->r);
|
|
Panu Matilainen |
34fad6 |
- mpnfree(&dig->s);
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
dig = pgpFreeDig(dig);
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
return rc;
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
diff -r ec9e6c427068 tools/Makefile.am
|
|
Panu Matilainen |
34fad6 |
--- a/tools/Makefile.am Wed Oct 24 16:02:51 2007 +0300
|
|
Panu Matilainen |
34fad6 |
+++ b/tools/Makefile.am Thu Nov 01 10:56:58 2007 +0100
|
|
Panu Matilainen |
34fad6 |
@@ -8,7 +8,7 @@ INCLUDES = -I. \
|
|
Panu Matilainen |
34fad6 |
-I$(top_srcdir)/lib \
|
|
Panu Matilainen |
34fad6 |
-I$(top_srcdir)/rpmdb \
|
|
Panu Matilainen |
34fad6 |
-I$(top_srcdir)/rpmio \
|
|
Panu Matilainen |
34fad6 |
- @WITH_BEECRYPT_INCLUDE@ \
|
|
Panu Matilainen |
34fad6 |
+ @WITH_NSS_INCLUDE@ \
|
|
Panu Matilainen |
34fad6 |
@WITH_POPT_INCLUDE@ \
|
|
Panu Matilainen |
34fad6 |
@WITH_LIBELF_INCLUDE@ \
|
|
Panu Matilainen |
34fad6 |
@WITH_LIBDWARF_INCLUDE@ \
|
|
Panu Matilainen |
34fad6 |
@@ -36,10 +36,10 @@ convertdb1_SOURCES = convertdb1.c
|
|
Panu Matilainen |
34fad6 |
convertdb1_SOURCES = convertdb1.c
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
debugedit_SOURCES = debugedit.c hashtab.c
|
|
Panu Matilainen |
34fad6 |
-#debugedit_LDADD = @LDFLAGS_STATIC@ \
|
|
Panu Matilainen |
34fad6 |
-debugedit_LDADD = \
|
|
Panu Matilainen |
34fad6 |
+debugedit_CFLAGS = $(INCLUDES)
|
|
Panu Matilainen |
34fad6 |
+#debugedit_LDFLAGS = $(staticLDFLAGS)
|
|
Panu Matilainen |
34fad6 |
+debugedit_LDADD = $(top_builddir)/rpmio/librpmio.la \
|
|
Panu Matilainen |
34fad6 |
@WITH_LIBELF_LIB@ \
|
|
Panu Matilainen |
34fad6 |
- @WITH_BEECRYPT_LIB@ \
|
|
Panu Matilainen |
34fad6 |
@WITH_POPT_LIB@
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
javadeps_SOURCES = javadeps.c
|
|
Panu Matilainen |
34fad6 |
diff -r ec9e6c427068 tools/debugedit.c
|
|
Panu Matilainen |
34fad6 |
--- a/tools/debugedit.c Wed Oct 24 16:02:51 2007 +0300
|
|
Panu Matilainen |
34fad6 |
+++ b/tools/debugedit.c Thu Nov 01 10:56:58 2007 +0100
|
|
Panu Matilainen |
34fad6 |
@@ -36,8 +36,8 @@
|
|
Panu Matilainen |
34fad6 |
#include <gelf.h>
|
|
Panu Matilainen |
34fad6 |
#include <dwarf.h>
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
-#include <beecrypt/beecrypt.h>
|
|
Panu Matilainen |
34fad6 |
-
|
|
Panu Matilainen |
34fad6 |
+#include <rpmio.h>
|
|
Panu Matilainen |
34fad6 |
+#include <rpmpgp.h>
|
|
Panu Matilainen |
34fad6 |
#include "hashtab.h"
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
#define DW_TAG_partial_unit 0x3c
|
|
Panu Matilainen |
34fad6 |
@@ -1304,22 +1304,27 @@ error_out:
|
|
Panu Matilainen |
34fad6 |
return NULL;
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
+static const pgpHashAlgo algorithms[] = { PGPHASHALGO_MD5,
|
|
Panu Matilainen |
34fad6 |
+ PGPHASHALGO_SHA1, PGPHASHALGO_SHA256, PGPHASHALGO_SHA384, PGPHASHALGO_SHA512 };
|
|
Panu Matilainen |
34fad6 |
+
|
|
Panu Matilainen |
34fad6 |
/* Compute a fresh build ID bit-string from the editted file contents. */
|
|
Panu Matilainen |
34fad6 |
static void
|
|
Panu Matilainen |
34fad6 |
handle_build_id (DSO *dso, Elf_Data *build_id,
|
|
Panu Matilainen |
34fad6 |
size_t build_id_offset, size_t build_id_size)
|
|
Panu Matilainen |
34fad6 |
{
|
|
Panu Matilainen |
34fad6 |
- hashFunctionContext ctx;
|
|
Panu Matilainen |
34fad6 |
- const hashFunction *hf = NULL;
|
|
Panu Matilainen |
34fad6 |
- int i = hashFunctionCount ();
|
|
Panu Matilainen |
34fad6 |
+ DIGEST_CTX ctx;
|
|
Panu Matilainen |
34fad6 |
+ pgpHashAlgo algorithm;
|
|
Panu Matilainen |
34fad6 |
+ int i = sizeof(algorithms)/sizeof(algorithms[0]);
|
|
Panu Matilainen |
34fad6 |
+ void *digest = NULL;
|
|
Panu Matilainen |
34fad6 |
+ size_t len;
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
while (i-- > 0)
|
|
Panu Matilainen |
34fad6 |
{
|
|
Panu Matilainen |
34fad6 |
- hf = hashFunctionGet (i);
|
|
Panu Matilainen |
34fad6 |
- if (hf != NULL && hf->digestsize == build_id_size)
|
|
Panu Matilainen |
34fad6 |
+ algorithm = algorithms[i];
|
|
Panu Matilainen |
34fad6 |
+ if (rpmDigestLength(algorithm) == build_id_size)
|
|
Panu Matilainen |
34fad6 |
break;
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
- if (hf == NULL)
|
|
Panu Matilainen |
34fad6 |
+ if (i < 0)
|
|
Panu Matilainen |
34fad6 |
{
|
|
Panu Matilainen |
34fad6 |
fprintf (stderr, "Cannot handle %Zu-byte build ID\n", build_id_size);
|
|
Panu Matilainen |
34fad6 |
exit (1);
|
|
Panu Matilainen |
34fad6 |
@@ -1335,7 +1340,7 @@ handle_build_id (DSO *dso, Elf_Data *bui
|
|
Panu Matilainen |
34fad6 |
/* Clear the old bits so they do not affect the new hash. */
|
|
Panu Matilainen |
34fad6 |
memset ((char *) build_id->d_buf + build_id_offset, 0, build_id_size);
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
- hashFunctionContextInit (&ctx, hf);
|
|
Panu Matilainen |
34fad6 |
+ ctx = rpmDigestInit(algorithm, 0);
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
/* Slurp the relevant header bits and section contents and feed them
|
|
Panu Matilainen |
34fad6 |
into the hash function. The only bits we ignore are the offset
|
|
Panu Matilainen |
34fad6 |
@@ -1349,8 +1354,7 @@ handle_build_id (DSO *dso, Elf_Data *bui
|
|
Panu Matilainen |
34fad6 |
inline void process (const void *data, size_t size);
|
|
Panu Matilainen |
34fad6 |
inline void process (const void *data, size_t size)
|
|
Panu Matilainen |
34fad6 |
{
|
|
Panu Matilainen |
34fad6 |
- memchunk chunk = { .data = (void *) data, .size = size };
|
|
Panu Matilainen |
34fad6 |
- hashFunctionContextUpdateMC (&ctx, &chunk);
|
|
Panu Matilainen |
34fad6 |
+ rpmDigestUpdate(ctx, data, size);
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
union
|
|
Panu Matilainen |
34fad6 |
@@ -1405,22 +1409,17 @@ handle_build_id (DSO *dso, Elf_Data *bui
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
- hashFunctionContextDigest (&ctx, (byte *) build_id->d_buf + build_id_offset);
|
|
Panu Matilainen |
34fad6 |
- hashFunctionContextFree (&ctx;;
|
|
Panu Matilainen |
34fad6 |
+ rpmDigestFinal(ctx, &digest, &len, 0);
|
|
Panu Matilainen |
34fad6 |
+ memcpy((unsigned char *)build_id->d_buf + build_id_offset, digest, build_id_size);
|
|
Panu Matilainen |
34fad6 |
+ free(digest);
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
elf_flagdata (build_id, ELF_C_SET, ELF_F_DIRTY);
|
|
Panu Matilainen |
34fad6 |
|
|
Panu Matilainen |
34fad6 |
/* Now format the build ID bits in hex to print out. */
|
|
Panu Matilainen |
34fad6 |
{
|
|
Panu Matilainen |
34fad6 |
- const unsigned char * id = build_id->d_buf + build_id_offset;
|
|
Panu Matilainen |
34fad6 |
+ const byte * id = (byte *)build_id->d_buf + build_id_offset;
|
|
Panu Matilainen |
34fad6 |
char hex[build_id_size * 2 + 1];
|
|
Panu Matilainen |
34fad6 |
- int n = snprintf (hex, 3, "%02" PRIx8, id[0]);
|
|
Panu Matilainen |
34fad6 |
- assert (n == 2);
|
|
Panu Matilainen |
34fad6 |
- for (i = 1; i < build_id_size; ++i)
|
|
Panu Matilainen |
34fad6 |
- {
|
|
Panu Matilainen |
34fad6 |
- n = snprintf (&hex[i * 2], 3, "%02" PRIx8, id[i]);
|
|
Panu Matilainen |
34fad6 |
- assert (n == 2);
|
|
Panu Matilainen |
34fad6 |
- }
|
|
Panu Matilainen |
34fad6 |
+ pgpHexCvt(hex, id, build_id_size);
|
|
Panu Matilainen |
34fad6 |
puts (hex);
|
|
Panu Matilainen |
34fad6 |
}
|
|
Panu Matilainen |
34fad6 |
}
|