[prev in list] [next in list] [prev in thread] [next in thread]
List: rpm-cvs
Subject: [CVS] RPM: rpm-5_4: rpm/ CHANGES rpm/rpmio/ .cvsignore Makefile.am b2s...
From: "Jeff Johnson" <jbj () rpm5 ! org>
Date: 2013-11-01 14:51:30
Message-ID: 20131101145130.341D52FB35 () rpm5 ! org
[Download RAW message or body]
RPM Package Manager, CVS Repository
http://rpm5.org/cvs/
____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson
Root: /v/rpm/cvs Email: jbj@rpm5.org
Module: rpm Date: 01-Nov-2013 15:51:30
Branch: rpm-5_4 Handle: 2013110114512801
Added files: (Branch: rpm-5_4)
rpm/rpmio b2sum.c
Modified files: (Branch: rpm-5_4)
rpm CHANGES
rpm/rpmio .cvsignore Makefile.am digest.c librpmio.vers
poptIO.c rpmiotypes.h
Log:
- blake2: add b2sum to compare with rpmdigest.
- blake2: wire blake2[b,bp,s,sp] into rpm.
Summary:
Revision Changes Path
1.3501.2.356+2 -0 rpm/CHANGES
1.41.2.8 +1 -0 rpm/rpmio/.cvsignore
1.293.2.25 +4 -1 rpm/rpmio/Makefile.am
1.1.2.1 +315 -0 rpm/rpmio/b2sum.c
2.93.2.4 +53 -0 rpm/rpmio/digest.c
2.199.2.28 +12 -0 rpm/rpmio/librpmio.vers
1.94.2.7 +8 -0 rpm/rpmio/poptIO.c
1.47.2.12 +5 -0 rpm/rpmio/rpmiotypes.h
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: rpm/CHANGES
============================================================================
$ cvs diff -u -r1.3501.2.355 -r1.3501.2.356 CHANGES
--- rpm/CHANGES 31 Oct 2013 20:45:43 -0000 1.3501.2.355
+++ rpm/CHANGES 1 Nov 2013 14:51:28 -0000 1.3501.2.356
@@ -1,4 +1,6 @@
5.4.14 -> 5.4.15:
+ - jbj: blake2: add b2sum to compare with rpmdigest.
+ - jbj: blake2: wire blake2[b,bp,s,sp] into rpm.
- jbj: blake2: compile/run blake2b/blake2bp/blake2s/blake2sp self tests.
- jbj: blake2: add blake2-rpm.c BeeCrypt-like API wrapper.
- jbj: rpmlog: don't clobber errno.
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/.cvsignore
============================================================================
$ cvs diff -u -r1.41.2.7 -r1.41.2.8 .cvsignore
--- rpm/rpmio/.cvsignore 31 Oct 2013 20:45:44 -0000 1.41.2.7
+++ rpm/rpmio/.cvsignore 1 Nov 2013 14:51:29 -0000 1.41.2.8
@@ -12,6 +12,7 @@
*.lo
*.log
*.trs
+b2sum
dumpasn1
gengpg.h
getdate.c
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/Makefile.am
============================================================================
$ cvs diff -u -r1.293.2.24 -r1.293.2.25 Makefile.am
--- rpm/rpmio/Makefile.am 31 Oct 2013 20:45:44 -0000 1.293.2.24
+++ rpm/rpmio/Makefile.am 1 Nov 2013 14:51:29 -0000 1.293.2.25
@@ -26,7 +26,7 @@
tmire todbc toid tperl tpython tput trpmio tsexp tsvn tsw ttcl \
dumpasn1 lookup3
-noinst_PROGRAMS += tset tblake2b tblake2bp tblake2s tblake2sp
+noinst_PROGRAMS += b2sum tset tblake2b tblake2bp tblake2s tblake2sp
if WITH_LIBGIT2
noinst_PROGRAMS += tgit
else
@@ -368,6 +368,9 @@
# testdata/wintestinput3 \
# testdata/wintestoutput3
+b2sum_SOURCES = b2sum.c
+b2sum_LDADD = $(RPMIO_LDADD_COMMON)
+
bsdiff_SOURCES = bsdiff.c
bsdiff_LDADD = $(RPMIO_LDADD_COMMON)
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/b2sum.c
============================================================================
$ cvs diff -u -r0 -r1.1.2.1 b2sum.c
--- /dev/null 2013-11-01 15:45:40.000000000 +0100
+++ b2sum.c 2013-11-01 15:51:29.862072548 +0100
@@ -0,0 +1,315 @@
+/*
+ BLAKE2 reference source code package - b2sum tool
+
+ Written in 2012 by Samuel Neves <sneves@dei.uc.pt>
+
+ To the extent possible under law, the author(s) have dedicated all copyright
+ and related and neighboring rights to this software to the public domain
+ worldwide. This software is distributed without any warranty.
+
+ You should have received a copy of the CC0 Public Domain Dedication along with
+ this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <errno.h>
+
+#include <ctype.h>
+#include <unistd.h>
+#include <getopt.h>
+
+#include "blake2.h"
+
+/* This will help compatibility with coreutils */
+static int blake2s_stream( FILE *stream, void *resstream )
+{
+ int ret = -1;
+ size_t sum, n;
+ blake2s_state S[1];
+ static const size_t buffer_length = 32768;
+ uint8_t *buffer = ( uint8_t * )malloc( buffer_length );
+
+ if( !buffer ) return -1;
+
+ blake2s_init( S, BLAKE2S_OUTBYTES );
+
+ while( 1 )
+ {
+ sum = 0;
+
+ while( 1 )
+ {
+ n = fread( buffer + sum, 1, buffer_length - sum, stream );
+ sum += n;
+
+ if( buffer_length == sum )
+ break;
+
+ if( 0 == n )
+ {
+ if( ferror( stream ) )
+ goto cleanup_buffer;
+
+ goto final_process;
+ }
+
+ if( feof( stream ) )
+ goto final_process;
+ }
+
+ blake2s_update( S, buffer, buffer_length );
+ }
+
+final_process:;
+
+ if( sum > 0 ) blake2s_update( S, buffer, sum );
+
+ blake2s_final( S, resstream, BLAKE2S_OUTBYTES );
+ ret = 0;
+cleanup_buffer:
+ free( buffer );
+ return ret;
+}
+
+int blake2b_stream( FILE *stream, void *resstream )
+{
+ int ret = -1;
+ size_t sum, n;
+ blake2b_state S[1];
+ static const size_t buffer_length = 32768;
+ uint8_t *buffer = ( uint8_t * )malloc( buffer_length );
+
+ if( !buffer ) return -1;
+
+ blake2b_init( S, BLAKE2B_OUTBYTES );
+
+ while( 1 )
+ {
+ sum = 0;
+
+ while( 1 )
+ {
+ n = fread( buffer + sum, 1, buffer_length - sum, stream );
+ sum += n;
+
+ if( buffer_length == sum )
+ break;
+
+ if( 0 == n )
+ {
+ if( ferror( stream ) )
+ goto cleanup_buffer;
+
+ goto final_process;
+ }
+
+ if( feof( stream ) )
+ goto final_process;
+ }
+
+ blake2b_update( S, buffer, buffer_length );
+ }
+
+final_process:;
+
+ if( sum > 0 ) blake2b_update( S, buffer, sum );
+
+ blake2b_final( S, resstream, BLAKE2B_OUTBYTES );
+ ret = 0;
+cleanup_buffer:
+ free( buffer );
+ return ret;
+}
+
+static int blake2sp_stream( FILE *stream, void *resstream )
+{
+ int ret = -1;
+ size_t sum, n;
+ blake2sp_state S[1];
+ static const size_t buffer_length = 16 * ( 1UL << 20 );
+ uint8_t *buffer = ( uint8_t * )malloc( buffer_length );
+
+ if( !buffer ) return -1;
+
+ blake2sp_init( S, BLAKE2S_OUTBYTES );
+
+ while( 1 )
+ {
+ sum = 0;
+
+ while( 1 )
+ {
+ n = fread( buffer + sum, 1, buffer_length - sum, stream );
+ sum += n;
+
+ if( buffer_length == sum )
+ break;
+
+ if( 0 == n )
+ {
+ if( ferror( stream ) )
+ goto cleanup_buffer;
+
+ goto final_process;
+ }
+
+ if( feof( stream ) )
+ goto final_process;
+ }
+
+ blake2sp_update( S, buffer, buffer_length );
+ }
+
+final_process:;
+
+ if( sum > 0 ) blake2sp_update( S, buffer, sum );
+
+ blake2sp_final( S, resstream, BLAKE2S_OUTBYTES );
+ ret = 0;
+cleanup_buffer:
+ free( buffer );
+ return ret;
+}
+
+
+static int blake2bp_stream( FILE *stream, void *resstream )
+{
+ int ret = -1;
+ size_t sum, n;
+ blake2bp_state S[1];
+ static const size_t buffer_length = 16 * ( 1UL << 20 );
+ uint8_t *buffer = ( uint8_t * )malloc( buffer_length );
+
+ if( !buffer ) return -1;
+
+ blake2bp_init( S, BLAKE2B_OUTBYTES );
+
+ while( 1 )
+ {
+ sum = 0;
+
+ while( 1 )
+ {
+ n = fread( buffer + sum, 1, buffer_length - sum, stream );
+ sum += n;
+
+ if( buffer_length == sum )
+ break;
+
+ if( 0 == n )
+ {
+ if( ferror( stream ) )
+ goto cleanup_buffer;
+
+ goto final_process;
+ }
+
+ if( feof( stream ) )
+ goto final_process;
+ }
+
+ blake2bp_update( S, buffer, buffer_length );
+ }
+
+final_process:;
+
+ if( sum > 0 ) blake2bp_update( S, buffer, sum );
+
+ blake2bp_final( S, resstream, BLAKE2B_OUTBYTES );
+ ret = 0;
+cleanup_buffer:
+ free( buffer );
+ return ret;
+}
+
+typedef int ( *blake2fn )( FILE *, void * );
+
+
+static void usage( char **argv )
+{
+ fprintf( stderr, "Usage: %s [-a HASH] [FILE]...\n", argv[0] );
+ fprintf( stderr, "\tHASH in blake2b blake2s blake2bp blake2sp\n" );
+ exit( 111 );
+}
+
+
+int main( int argc, char **argv )
+{
+ blake2fn blake2_stream = blake2b_stream;
+ size_t outlen = BLAKE2B_OUTBYTES;
+ unsigned char hash[BLAKE2B_OUTBYTES] = {0};
+ int c;
+ int i;
+ int j;
+
+ opterr = 1;
+
+ if ( argc == 1 ) usage( argv ); /* show usage upon no-argument */
+
+ while( ( c = getopt( argc, argv, "a:" ) ) != -1 )
+ {
+ switch( c )
+ {
+ case 'a':
+ if( 0 == strcmp( optarg, "blake2b" ) )
+ {
+ blake2_stream = blake2b_stream;
+ outlen = BLAKE2B_OUTBYTES;
+ }
+ else if ( 0 == strcmp( optarg, "blake2s" ) )
+ {
+ blake2_stream = blake2s_stream;
+ outlen = BLAKE2S_OUTBYTES;
+ }
+ else if ( 0 == strcmp( optarg, "blake2bp" ) )
+ {
+ blake2_stream = blake2bp_stream;
+ outlen = BLAKE2B_OUTBYTES;
+ }
+ else if ( 0 == strcmp( optarg, "blake2sp" ) )
+ {
+ blake2_stream = blake2sp_stream;
+ outlen = BLAKE2S_OUTBYTES;
+ }
+ else
+ {
+ printf( "Invalid function name: `%s'\n", optarg );
+ usage( argv );
+ }
+
+ break;
+ }
+ }
+
+ for( i = optind; i < argc; ++i )
+ {
+ FILE *f = NULL;
+ f = fopen( argv[i], "rb" );
+
+ if( !f )
+ {
+ fprintf( stderr, "Could not open `%s': %s\n", argv[i], strerror( errno ) );
+ goto end0;
+ }
+
+ if( blake2_stream( f, hash ) < 0 )
+ {
+ fprintf( stderr, "Failed to hash `%s'\n", argv[i] );
+ goto end1;
+ }
+
+ for( j = 0; j < outlen; ++j )
+ printf( "%02x", hash[j] );
+
+ printf( " %s\n", argv[i] );
+end1:
+ fclose( f );
+end0: ;
+ }
+
+ return 0;
+}
+
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/digest.c
============================================================================
$ cvs diff -u -r2.93.2.3 -r2.93.2.4 digest.c
--- rpm/rpmio/digest.c 16 Apr 2012 20:53:32 -0000 2.93.2.3
+++ rpm/rpmio/digest.c 1 Nov 2013 14:51:29 -0000 2.93.2.4
@@ -13,6 +13,7 @@
#include "arirang.h"
#include "blake.h"
+#include "blake2-rpm.h"
#include "bmw.h"
@@ -609,6 +610,58 @@
ctx->Update = (int (*)(void *, const byte *, size_t)) blakeUpdate;
ctx->Digest = (int (*)(void *, byte *)) blakeDigest;
break;
+ case PGPHASHALGO_BLAKE2B:
+ ctx->name = "BLAKE2B";
+ ctx->blocksize = 8 * BLAKE2B_BLOCKBYTES;
+ ctx->digestsize = BLAKE2B_OUTBYTES;
+/*@-sizeoftype@*/ /* FIX: union, not void pointer */
+ ctx->paramsize = sizeof(blake2bParam);
+/*@=sizeoftype@*/
+ ctx->param = DRD_xcalloc(1, ctx->paramsize);
+ (void) blake2bInit((blake2bParam *)ctx->param, (int)(8 * ctx->digestsize));
+ ctx->Reset = (int (*)(void *)) blake2bReset;
+ ctx->Update = (int (*)(void *, const byte *, size_t)) blake2bUpdate;
+ ctx->Digest = (int (*)(void *, byte *)) blake2bDigest;
+ break;
+ case PGPHASHALGO_BLAKE2BP:
+ ctx->name = "BLAKE2BP";
+ ctx->blocksize = 8 * BLAKE2B_BLOCKBYTES;
+ ctx->digestsize = BLAKE2B_OUTBYTES;
+/*@-sizeoftype@*/ /* FIX: union, not void pointer */
+ ctx->paramsize = sizeof(blake2bpParam);
+/*@=sizeoftype@*/
+ ctx->param = DRD_xcalloc(1, ctx->paramsize);
+ (void) blake2bpInit((blake2bpParam *)ctx->param, (int)(8 * ctx->digestsize));
+ ctx->Reset = (int (*)(void *)) blake2bpReset;
+ ctx->Update = (int (*)(void *, const byte *, size_t)) blake2bpUpdate;
+ ctx->Digest = (int (*)(void *, byte *)) blake2bpDigest;
+ break;
+ case PGPHASHALGO_BLAKE2S:
+ ctx->name = "BLAKE2S";
+ ctx->blocksize = 8 * BLAKE2S_BLOCKBYTES;
+ ctx->digestsize = BLAKE2S_OUTBYTES;
+/*@-sizeoftype@*/ /* FIX: union, not void pointer */
+ ctx->paramsize = sizeof(blake2sParam);
+/*@=sizeoftype@*/
+ ctx->param = DRD_xcalloc(1, ctx->paramsize);
+ (void) blake2sInit((blake2sParam *)ctx->param, (int)(8 * ctx->digestsize));
+ ctx->Reset = (int (*)(void *)) blake2sReset;
+ ctx->Update = (int (*)(void *, const byte *, size_t)) blake2sUpdate;
+ ctx->Digest = (int (*)(void *, byte *)) blake2sDigest;
+ break;
+ case PGPHASHALGO_BLAKE2SP:
+ ctx->name = "BLAKE2SP";
+ ctx->blocksize = 8 * BLAKE2S_BLOCKBYTES;
+ ctx->digestsize = BLAKE2S_OUTBYTES;
+/*@-sizeoftype@*/ /* FIX: union, not void pointer */
+ ctx->paramsize = sizeof(blake2spParam);
+/*@=sizeoftype@*/
+ ctx->param = DRD_xcalloc(1, ctx->paramsize);
+ (void) blake2spInit((blake2spParam *)ctx->param, (int)(8 * ctx->digestsize));
+ ctx->Reset = (int (*)(void *)) blake2spReset;
+ ctx->Update = (int (*)(void *, const byte *, size_t)) blake2spUpdate;
+ ctx->Digest = (int (*)(void *, byte *)) blake2spDigest;
+ break;
case PGPHASHALGO_BMW_224: ctx->digestsize = 224/8; goto bmw;
case PGPHASHALGO_BMW_256: ctx->digestsize = 256/8; goto bmw;
case PGPHASHALGO_BMW_384: ctx->digestsize = 384/8; goto bmw;
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/librpmio.vers
============================================================================
$ cvs diff -u -r2.199.2.27 -r2.199.2.28 librpmio.vers
--- rpm/rpmio/librpmio.vers 5 Sep 2013 16:50:27 -0000 2.199.2.27
+++ rpm/rpmio/librpmio.vers 1 Nov 2013 14:51:29 -0000 2.199.2.28
@@ -36,6 +36,18 @@
avmagicdir;
avOpendir;
avReaddir;
+ blake2b_init;
+ blake2b_update;
+ blake2b_final;
+ blake2bp_init;
+ blake2bp_update;
+ blake2bp_final;
+ blake2s_init;
+ blake2s_update;
+ blake2s_final;
+ blake2sp_init;
+ blake2sp_update;
+ blake2sp_final;
bzio;
bzdio;
Chdir;
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/poptIO.c
============================================================================
$ cvs diff -u -r1.94.2.6 -r1.94.2.7 poptIO.c
--- rpm/rpmio/poptIO.c 16 Apr 2012 20:53:33 -0000 1.94.2.6
+++ rpm/rpmio/poptIO.c 1 Nov 2013 14:51:29 -0000 1.94.2.7
@@ -191,6 +191,14 @@
N_("Blake-384 digest"), NULL },
{ "blake-512",'\0', POPT_ARG_VAL, &rpmioDigestHashAlgo, PGPHASHALGO_BLAKE_512,
N_("Blake-512 digest"), NULL },
+ { "blake2b",'\0', POPT_ARG_VAL, &rpmioDigestHashAlgo, PGPHASHALGO_BLAKE2B,
+ N_("Blake2b digest"), NULL },
+ { "blake2bp",'\0', POPT_ARG_VAL, &rpmioDigestHashAlgo, PGPHASHALGO_BLAKE2BP,
+ N_("Blake2bp digest"), NULL },
+ { "blake2s",'\0', POPT_ARG_VAL, &rpmioDigestHashAlgo, PGPHASHALGO_BLAKE2S,
+ N_("Blake2s digest"), NULL },
+ { "blake2sp",'\0', POPT_ARG_VAL, &rpmioDigestHashAlgo, PGPHASHALGO_BLAKE2SP,
+ N_("Blake2sp digest"), NULL },
{ "bmw-224",'\0', POPT_ARG_VAL, &rpmioDigestHashAlgo, PGPHASHALGO_BMW_224,
N_("BlueMidnightWish-224 digest"), NULL },
{ "bmw-256",'\0', POPT_ARG_VAL, &rpmioDigestHashAlgo, PGPHASHALGO_BMW_256,
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/rpmiotypes.h
============================================================================
$ cvs diff -u -r1.47.2.11 -r1.47.2.12 rpmiotypes.h
--- rpm/rpmio/rpmiotypes.h 13 Jul 2013 20:19:00 -0000 1.47.2.11
+++ rpm/rpmio/rpmiotypes.h 1 Nov 2013 14:51:29 -0000 1.47.2.12
@@ -247,6 +247,11 @@
PGPHASHALGO_BLAKE_384 = 184+2,/*!< (private) BLAKE-384 */
PGPHASHALGO_BLAKE_512 = 184+3,/*!< (private) BLAKE-512 */
+ PGPHASHALGO_BLAKE2B = 188+0,/*!< (private) BLAKE2B */
+ PGPHASHALGO_BLAKE2BP = 188+1,/*!< (private) BLAKE2BP */
+ PGPHASHALGO_BLAKE2S = 188+2,/*!< (private) BLAKE2S */
+ PGPHASHALGO_BLAKE2SP = 188+3,/*!< (private) BLAKE2SP */
+
PGPHASHALGO_TIB3_224 = 192+0,/*!< (private) TIB3-224 */
PGPHASHALGO_TIB3_256 = 192+1,/*!< (private) TIB3-256 */
PGPHASHALGO_TIB3_384 = 192+2,/*!< (private) TIB3-384 */
@@ .
______________________________________________________________________
RPM Package Manager http://rpm5.org
CVS Sources Repository rpm-cvs@rpm5.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic