summaryrefslogtreecommitdiff
path: root/rpmio
diff options
context:
space:
mode:
Diffstat (limited to 'rpmio')
-rw-r--r--rpmio/Makefile.am4
-rw-r--r--rpmio/rpmio.c19
-rw-r--r--rpmio/rpmio_internal.h22
-rw-r--r--rpmio/rpmlog.c8
-rw-r--r--rpmio/rpmmalloc.c4
-rw-r--r--rpmio/tdigest.c76
-rw-r--r--rpmio/url.c2
7 files changed, 99 insertions, 36 deletions
diff --git a/rpmio/Makefile.am b/rpmio/Makefile.am
index 101b30172..e24fc8564 100644
--- a/rpmio/Makefile.am
+++ b/rpmio/Makefile.am
@@ -43,8 +43,10 @@ tkey: librpmio.la tkey.o
$(LINK) -o $@ tkey.o librpmio.la $(top_builddir)/popt/libpopt.la
tdigest.o: tdigest.c
+ $(CC) $(DEFS) -I/usr/include/beecrypt $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -o $@ -c tdigest.c
+
tdigest: librpmio.la tdigest.o
- $(LINK) @LDFLAGS_STATIC@ -o $@ tdigest.o librpmio.la $(top_builddir)/popt/libpopt.la
+ $(LINK) @LDFLAGS_STATIC@ -o $@ tdigest.o librpmio.la $(top_builddir)/popt/libpopt.la -lbeecrypt
tficl.o: tficl.c
$(COMPILE) -I/usr/include/ficl -o $@ -c tficl.c
diff --git a/rpmio/rpmio.c b/rpmio/rpmio.c
index f47b71542..6ad5910e1 100644
--- a/rpmio/rpmio.c
+++ b/rpmio/rpmio.c
@@ -5,15 +5,6 @@
#include "system.h"
#include <stdarg.h>
-#ifdef __LCLINT__
-/*@-incondefs@*/
-typedef unsigned int uint32_t;
-/*@=incondefs@*/
-#define INADDR_ANY ((uint32_t) 0x00000000)
-#define IPPROTO_IP 0
-
-#else /* __LCLINT__ */
-
#if HAVE_MACHINE_TYPES_H
# include <machine/types.h>
#endif
@@ -30,8 +21,6 @@ typedef unsigned int uint32_t;
#define _USE_LIBIO 1
#endif
-#endif /* __LCLINT__ */
-
#if !defined(HAVE_HERRNO) && defined(__hpux) /* XXX HP-UX w/o -D_XOPEN_SOURCE needs */
extern int h_errno;
#endif
@@ -106,7 +95,7 @@ int _rpmio_debug = 0;
* @retval NULL always
*/
/*@unused@*/ static inline /*@null@*/ void *
-_free(/*@only@*/ /*@null@*/ const void * p)
+_free(/*@only@*/ /*@null@*/ /*@out@*/ const void * p)
/*@modifies p@*/
{
if (p != NULL) free((void *)p);
@@ -676,12 +665,15 @@ static int mygethostbyname(const char * host,
}
#endif
+/*@-compdef@*/ /* FIX: address->s_addr undefined. */
static int getHostAddress(const char * host, /*@out@*/ struct in_addr * address)
/*@modifies *address, fileSystem @*/
{
if (xisdigit(host[0])) {
- if (! /*@-unrecog@*/ inet_aton(host, address) /*@=unrecog@*/ )
+ /*@-unrecog@*/
+ if (!inet_aton(host, address))
return FTPERR_BAD_HOST_ADDR;
+ /*@=unrecog@*/
} else {
if (mygethostbyname(host, address)) {
errno = /*@-unrecog@*/ h_errno /*@=unrecog@*/;
@@ -691,6 +683,7 @@ static int getHostAddress(const char * host, /*@out@*/ struct in_addr * address)
return 0;
}
+/*@=compdef@*/
static int tcpConnect(FD_t ctrl, const char * host, int port)
/*@modifies ctrl, fileSystem @*/
diff --git a/rpmio/rpmio_internal.h b/rpmio/rpmio_internal.h
index 3225a607d..a10695e7d 100644
--- a/rpmio/rpmio_internal.h
+++ b/rpmio/rpmio_internal.h
@@ -142,17 +142,29 @@ extern int _rpmio_debug;
extern "C" {
#endif
+/** \ingroup rpmio
+ */
int fdFgets(FD_t fd, char * buf, size_t len)
/*@modifies *buf, fd, fileSystem @*/;
+/** \ingroup rpmio
+ */
/*@null@*/ FD_t ftpOpen(const char *url, /*@unused@*/ int flags,
/*@unused@*/ mode_t mode, /*@out@*/ urlinfo *uret)
/*@modifies *uret, fileSystem @*/;
+
+/** \ingroup rpmio
+ */
int ftpReq(FD_t data, const char * ftpCmd, const char * ftpArg)
/*@modifies data, fileSystem @*/;
+
+/** \ingroup rpmio
+ */
int ftpCmd(const char * cmd, const char * url, const char * arg2)
/*@modifies fileSystem @*/;
+/** \ingroup rpmio
+ */
int ufdClose( /*@only@*/ void * cookie)
/*@modified cookie, fileSystem @*/;
@@ -183,25 +195,23 @@ void fdSetIo(FD_t fd, /*@kept@*/ /*@null@*/ FDIO_t io)
/** \ingroup rpmio
*/
/*@unused@*/ static inline
-/*@dependent@*/ /*@null@*/ FILE * fdGetFILE(FD_t fd)
+/*@exposed@*/ /*@dependent@*/ /*@null@*/ FILE * fdGetFILE(FD_t fd)
/*@*/
{
FDSANE(fd);
- /*@+voidabstract -retexpose@*/
+ /*@+voidabstract@*/
return ((FILE *)fd->fps[fd->nfps].fp);
- /*@=voidabstract =retexpose@*/
+ /*@=voidabstract@*/
}
/** \ingroup rpmio
*/
/*@unused@*/ static inline
-/*@dependent@*/ /*@null@*/ void * fdGetFp(FD_t fd)
+/*@exposed@*/ /*@dependent@*/ /*@null@*/ void * fdGetFp(FD_t fd)
/*@*/
{
FDSANE(fd);
- /*@-retexpose@*/
return fd->fps[fd->nfps].fp;
- /*@=retexpose@*/
}
/** \ingroup rpmio
diff --git a/rpmio/rpmlog.c b/rpmio/rpmlog.c
index 0a866fbc8..24f2964dc 100644
--- a/rpmio/rpmlog.c
+++ b/rpmio/rpmlog.c
@@ -30,7 +30,7 @@ static /*@only@*/ /*@null@*/ rpmlogRec recs = NULL;
* @retval NULL always
*/
/*@unused@*/ static inline /*@null@*/ void *
-_free(/*@only@*/ /*@null@*/ const void * p) /*@modifies p@*/
+_free(/*@only@*/ /*@null@*/ /*@out@*/ const void * p) /*@modifies p@*/
{
if (p != NULL) free((void *)p);
return NULL;
@@ -109,7 +109,7 @@ rpmlogCallback rpmlogSetCallback(rpmlogCallback cb)
return ocb;
}
-/*@-readonlytrans@*/ /* FIX: double indeirection. */
+/*@-readonlytrans@*/ /* FIX: double indirection. */
/*@observer@*/ static char *rpmlogMsgPrefix[] = {
N_("fatal error: "),/*!< RPMLOG_EMERG */
N_("fatal error: "),/*!< RPMLOG_ALERT */
@@ -152,10 +152,10 @@ static void vrpmlog (unsigned code, const char *fmt, va_list ap)
while (1) {
va_list apc;
/*@-sysunrecog -usedef@*/ va_copy(apc, ap); /*@=sysunrecog =usedef@*/
- /*@-unrecog@*/ nb = vsnprintf(msgbuf, msgnb, fmt, apc); /*@=unrecog@*/
+ nb = vsnprintf(msgbuf, msgnb, fmt, apc);
if (nb > -1 && nb < msgnb)
break;
- if (nb > -1) /* glibc 2.1 */
+ if (nb > -1) /* glibc 2.1 (and later) */
msgnb = nb+1;
else /* glibc 2.0 */
msgnb *= 2;
diff --git a/rpmio/rpmmalloc.c b/rpmio/rpmmalloc.c
index d5e467ab5..911d97721 100644
--- a/rpmio/rpmmalloc.c
+++ b/rpmio/rpmmalloc.c
@@ -19,16 +19,14 @@
#if !(HAVE_MCHECK_H && defined(__GNUC__)) && !defined(__LCLINT__)
-/*@only@*/ void * xmalloc (size_t size)
+/*@out@*/ /*@only@*/ void * xmalloc (size_t size)
{
register void *value;
if (size == 0) size++;
value = malloc (size);
if (value == 0)
value = vmefail(size);
- /*@-compdef@*/
return value;
- /*@=compdef@*/
}
/*@only@*/ void * xcalloc (size_t nmemb, size_t size)
diff --git a/rpmio/tdigest.c b/rpmio/tdigest.c
index 411b9c772..92767fe1a 100644
--- a/rpmio/tdigest.c
+++ b/rpmio/tdigest.c
@@ -1,16 +1,27 @@
+#define ENABLE_BEECRYPT 1
+
#include "system.h"
#include "rpmio_internal.h"
#include "popt.h"
+#ifdef ENABLE_BEECRYPT
+#define BEEDLLAPI
+typedef unsigned char byte;
+#include "beecrypt.h"
+#include "md5.h"
+#include "fips180.h"
+#include "sha256.h"
+#endif
#include "debug.h"
+
static rpmDigestFlags flags = RPMDIGEST_MD5;
extern int _rpmio_debug;
static int fips = 0;
-const char * adigest = "a9993e364706816aba3e25717850c26c9cd0d89d";
-const char * bdigest = "84983e441c3bd26ebaae4aa1f95129e5e54670f1";
-const char * cdigest = "34aa973cd4c4daa4f61eeb2bdbad27316534016f";
+const char * FIPSAdigest = "a9993e364706816aba3e25717850c26c9cd0d89d";
+const char * FIPSBdigest = "84983e441c3bd26ebaae4aa1f95129e5e54670f1";
+const char * FIPSCdigest = "34aa973cd4c4daa4f61eeb2bdbad27316534016f";
static struct poptOption optionsTable[] = {
{ "md5", '\0', POPT_BIT_SET, &flags, RPMDIGEST_MD5, NULL, NULL },
@@ -45,6 +56,14 @@ main(int argc, const char *argv[])
int rc;
char appendix;
int i;
+#ifdef ENABLE_BEECRYPT
+ sha1Param sparam;
+ md5Param mparam;
+ uint32 bdigest[5];
+
+ memset(&sparam, 0, sizeof(sparam));
+ memset(&mparam, 0, sizeof(mparam));
+#endif
optCon = poptGetContext(argv[0], argc, argv, optionsTable, 0);
while ((rc = poptGetNextOpt(optCon)) > 0)
@@ -55,6 +74,9 @@ main(int argc, const char *argv[])
if (fips) {
flags &= ~RPMDIGEST_MD5;
flags |= RPMDIGEST_SHA1;
+#ifdef ENABLE_BEECRYPT
+ (void) sha1Reset(&sparam);
+#endif
ctx = rpmDigestInit(flags);
ifn = NULL;
appendix = ' ';
@@ -62,26 +84,39 @@ main(int argc, const char *argv[])
switch (fips) {
case 1:
ifn = "abc";
+#ifdef ENABLE_BEECRYPT
+ (void) sha1Update(&sparam, (const unsigned char*) ifn, strlen(ifn));
+#endif
rpmDigestUpdate(ctx, ifn, strlen(ifn));
- sdigest = adigest;
+ sdigest = FIPSAdigest;
appendix = 'A';
break;
case 2:
ifn = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
+#ifdef ENABLE_BEECRYPT
+ (void) sha1Update(&sparam, (const unsigned char*) ifn, strlen(ifn));
+#endif
rpmDigestUpdate(ctx, ifn, strlen(ifn));
- sdigest = bdigest;
+ sdigest = FIPSBdigest;
appendix = 'B';
break;
case 3:
ifn = "aaaaaaaaaaa ...";
- for (i = 0; i < 1000000; i++)
+ for (i = 0; i < 1000000; i++) {
+#ifdef ENABLE_BEECRYPT
+ (void) sha1Update(&sparam, (const unsigned char*) ifn, 1);
+#endif
rpmDigestUpdate(ctx, ifn, 1);
- sdigest = cdigest;
+ }
+ sdigest = FIPSCdigest;
appendix = 'C';
break;
}
if (ifn == NULL)
return 1;
+#ifdef ENABLE_BEECRYPT
+ (void) sha1Digest(&sparam, bdigest);
+#endif
rpmDigestFinal(ctx, (void **)&digest, &digestlen, asAscii);
if (digest) {
@@ -89,6 +124,11 @@ main(int argc, const char *argv[])
fflush(stdout);
free((void *)digest);
}
+#ifdef ENABLE_BEECRYPT
+ for (i = 0; i < 5; i++)
+ fprintf(stdout, "%08x", bdigest[i]);
+ fprintf(stdout, " BeeCrypt\n");
+#endif
if (sdigest) {
fprintf(stdout, "%s FIPS PUB 180-1 Appendix %c\n", sdigest,
appendix);
@@ -145,9 +185,19 @@ main(int argc, const char *argv[])
odigest = NULL;
(flags & RPMDIGEST_SHA1) ? fdInitSHA1(ofd, reverse) : fdInitMD5(ofd, reverse);
+#ifdef ENABLE_BEECRYPT
+ (flags & RPMDIGEST_SHA1)
+ ? (void) sha1Reset(&sparam)
+ : (void) md5Reset(&mparam);
+#endif
ctx = rpmDigestInit(flags);
while ((nb = Fread(buf, 1, sizeof(buf), ifd)) > 0) {
+#ifdef ENABLE_BEECRYPT
+ (flags & RPMDIGEST_SHA1)
+ ? (void) sha1Update(&sparam, (const unsigned char*) buf, nb)
+ : (void) md5Update(&mparam, (const unsigned char*) buf, nb);
+#endif
rpmDigestUpdate(ctx, buf, nb);
(void) Fwrite(buf, 1, nb, ofd);
}
@@ -163,10 +213,22 @@ main(int argc, const char *argv[])
: fdFiniMD5(ofd, (void **)&odigest, NULL, asAscii);
Fclose(ofd);
+#ifdef ENABLE_BEECRYPT
+ (flags & RPMDIGEST_SHA1)
+ ? (void) sha1Digest(&sparam, bdigest)
+ : (void) md5Digest(&mparam, bdigest);
+#endif
rpmDigestFinal(ctx, (void **)&digest, &digestlen, asAscii);
if (digest) {
fprintf(stdout, "%s %s\n", digest, ifn);
+#ifdef ENABLE_BEECRYPT
+ { int imax = (flags & RPMDIGEST_SHA1) ? 5 : 4;
+ for (i = 0; i < imax; i++)
+ fprintf(stdout, "%08x", bdigest[i]);
+ }
+ fprintf(stdout, " BeeCrypt\n");
+#endif
fflush(stdout);
free((void *)digest);
}
diff --git a/rpmio/url.c b/rpmio/url.c
index 3e6c0aa05..3d21adb8a 100644
--- a/rpmio/url.c
+++ b/rpmio/url.c
@@ -4,9 +4,7 @@
#include "system.h"
-#if !defined(__LCLINT__)
#include <netinet/in.h>
-#endif /* __LCLINT__ */
#include <rpmmacro.h>
#include <rpmmessages.h>