From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by sourceware.org (Postfix) with ESMTPS id BFECF3844070 for ; Tue, 30 Jun 2020 23:32:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BFECF3844070 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05UNW2Mo138354 for ; Tue, 30 Jun 2020 23:32:27 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 31ywrbnkwq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 30 Jun 2020 23:32:27 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05UNNlO4068605 for ; Tue, 30 Jun 2020 23:32:26 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 31xg1xgb68-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 30 Jun 2020 23:32:26 +0000 Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 05UNWPmT005927 for ; Tue, 30 Jun 2020 23:32:25 GMT Received: from loom.srvr.nix (/81.187.191.129) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 30 Jun 2020 23:32:25 +0000 From: Nick Alcock To: binutils@sourceware.org Subject: [PATCH 48/59] libctf: add SHA-1 support for libctf Date: Wed, 1 Jul 2020 00:31:35 +0100 Message-Id: <20200630233146.338613-49-nick.alcock@oracle.com> X-Mailer: git-send-email 2.27.0.247.g3dff7de930 In-Reply-To: <20200630233146.338613-1-nick.alcock@oracle.com> References: <20200630233146.338613-1-nick.alcock@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9668 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 adultscore=0 mlxscore=0 suspectscore=43 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006300162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9668 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxlogscore=999 clxscore=1015 cotscore=-2147483648 priorityscore=1501 lowpriorityscore=0 malwarescore=0 mlxscore=0 adultscore=0 suspectscore=43 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006300163 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Jun 2020 23:32:30 -0000 This very thin abstraction layer provides SHA-1ing facilities to all of libctf, almost all inlined wrappers around the libiberty functionality other than ctf_sha1_fini. The deduplicator will use this to recursively hash types to prove their identity. libctf/ * ctf-sha1.h: New, inline wrappers around sha1_init_ctx and sha1_process_bytes. * ctf-impl.h: Include it. (ctf_sha1_init): New. (ctf_sha1_add): Likewise. (ctf_sha1_fini): Likewise. * ctf-sha1.c: New, non-inline wrapper around sha1_finish_ctx producing strings. * Makefile.am: Add file. * Makefile.in: Regenerate. --- libctf/Makefile.am | 2 +- libctf/Makefile.in | 40 +++++++++++++++++++++++++++---------- libctf/ctf-impl.h | 5 +++++ libctf/ctf-sha1.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++ libctf/ctf-sha1.h | 41 +++++++++++++++++++++++++++++++++++++ 5 files changed, 126 insertions(+), 12 deletions(-) create mode 100644 libctf/ctf-sha1.c create mode 100644 libctf/ctf-sha1.h diff --git a/libctf/Makefile.am b/libctf/Makefile.am index de27cf82394..8f5ea6b0247 100644 --- a/libctf/Makefile.am +++ b/libctf/Makefile.am @@ -44,7 +44,7 @@ libctf_nobfd_la_LDFLAGS = -version-info 0:0:0 @SHARED_LDFLAGS@ @VERSION_FLAGS@ libctf_nobfd_la_CPPFLAGS = $(AM_CPPFLAGS) -DNOBFD=1 libctf_nobfd_la_SOURCES = ctf-archive.c ctf-dump.c ctf-create.c ctf-decl.c ctf-error.c \ ctf-hash.c ctf-labels.c ctf-link.c ctf-lookup.c ctf-open.c \ - ctf-string.c ctf-subr.c ctf-types.c ctf-util.c + ctf-sha1.c ctf-string.c ctf-subr.c ctf-types.c ctf-util.c if NEED_CTF_QSORT_R libctf_nobfd_la_SOURCES += ctf-qsort_r.c endif diff --git a/libctf/Makefile.in b/libctf/Makefile.in index 3b7feea02d2..328edcd5511 100644 --- a/libctf/Makefile.in +++ b/libctf/Makefile.in @@ -165,17 +165,18 @@ am__DEPENDENCIES_1 = libctf_nobfd_la_DEPENDENCIES = $(am__DEPENDENCIES_1) am__libctf_nobfd_la_SOURCES_DIST = ctf-archive.c ctf-dump.c \ ctf-create.c ctf-decl.c ctf-error.c ctf-hash.c ctf-labels.c \ - ctf-link.c ctf-lookup.c ctf-open.c ctf-string.c ctf-subr.c \ - ctf-types.c ctf-util.c ctf-qsort_r.c + ctf-link.c ctf-lookup.c ctf-open.c ctf-sha1.c ctf-string.c \ + ctf-subr.c ctf-types.c ctf-util.c ctf-qsort_r.c @NEED_CTF_QSORT_R_TRUE@am__objects_1 = libctf_nobfd_la-ctf-qsort_r.lo am_libctf_nobfd_la_OBJECTS = libctf_nobfd_la-ctf-archive.lo \ libctf_nobfd_la-ctf-dump.lo libctf_nobfd_la-ctf-create.lo \ libctf_nobfd_la-ctf-decl.lo libctf_nobfd_la-ctf-error.lo \ libctf_nobfd_la-ctf-hash.lo libctf_nobfd_la-ctf-labels.lo \ libctf_nobfd_la-ctf-link.lo libctf_nobfd_la-ctf-lookup.lo \ - libctf_nobfd_la-ctf-open.lo libctf_nobfd_la-ctf-string.lo \ - libctf_nobfd_la-ctf-subr.lo libctf_nobfd_la-ctf-types.lo \ - libctf_nobfd_la-ctf-util.lo $(am__objects_1) + libctf_nobfd_la-ctf-open.lo libctf_nobfd_la-ctf-sha1.lo \ + libctf_nobfd_la-ctf-string.lo libctf_nobfd_la-ctf-subr.lo \ + libctf_nobfd_la-ctf-types.lo libctf_nobfd_la-ctf-util.lo \ + $(am__objects_1) libctf_nobfd_la_OBJECTS = $(am_libctf_nobfd_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) @@ -190,16 +191,17 @@ libctf_nobfd_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) am__libctf_la_SOURCES_DIST = ctf-archive.c ctf-dump.c ctf-create.c \ ctf-decl.c ctf-error.c ctf-hash.c ctf-labels.c ctf-link.c \ - ctf-lookup.c ctf-open.c ctf-string.c ctf-subr.c ctf-types.c \ - ctf-util.c ctf-qsort_r.c ctf-open-bfd.c + ctf-lookup.c ctf-open.c ctf-sha1.c ctf-string.c ctf-subr.c \ + ctf-types.c ctf-util.c ctf-qsort_r.c ctf-open-bfd.c @NEED_CTF_QSORT_R_TRUE@am__objects_2 = libctf_la-ctf-qsort_r.lo am__objects_3 = libctf_la-ctf-archive.lo libctf_la-ctf-dump.lo \ libctf_la-ctf-create.lo libctf_la-ctf-decl.lo \ libctf_la-ctf-error.lo libctf_la-ctf-hash.lo \ libctf_la-ctf-labels.lo libctf_la-ctf-link.lo \ libctf_la-ctf-lookup.lo libctf_la-ctf-open.lo \ - libctf_la-ctf-string.lo libctf_la-ctf-subr.lo \ - libctf_la-ctf-types.lo libctf_la-ctf-util.lo $(am__objects_2) + libctf_la-ctf-sha1.lo libctf_la-ctf-string.lo \ + libctf_la-ctf-subr.lo libctf_la-ctf-types.lo \ + libctf_la-ctf-util.lo $(am__objects_2) am_libctf_la_OBJECTS = $(am__objects_3) libctf_la-ctf-open-bfd.lo libctf_la_OBJECTS = $(am_libctf_la_OBJECTS) libctf_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ @@ -455,8 +457,8 @@ libctf_nobfd_la_LDFLAGS = -version-info 0:0:0 @SHARED_LDFLAGS@ @VERSION_FLAGS@ libctf_nobfd_la_CPPFLAGS = $(AM_CPPFLAGS) -DNOBFD=1 libctf_nobfd_la_SOURCES = ctf-archive.c ctf-dump.c ctf-create.c \ ctf-decl.c ctf-error.c ctf-hash.c ctf-labels.c ctf-link.c \ - ctf-lookup.c ctf-open.c ctf-string.c ctf-subr.c ctf-types.c \ - ctf-util.c $(am__append_1) + ctf-lookup.c ctf-open.c ctf-sha1.c ctf-string.c ctf-subr.c \ + ctf-types.c ctf-util.c $(am__append_1) libctf_la_LIBADD = @BFD_LIBADD@ $(libctf_nobfd_la_LIBADD) libctf_la_CPPFLAGS = $(AM_CPPFLAGS) -DNOBFD=0 libctf_la_DEPENDENCIES = @BFD_DEPENDENCIES@ @@ -587,6 +589,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libctf_la-ctf-open-bfd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libctf_la-ctf-open.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libctf_la-ctf-qsort_r.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libctf_la-ctf-sha1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libctf_la-ctf-string.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libctf_la-ctf-subr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libctf_la-ctf-types.Plo@am__quote@ @@ -602,6 +605,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libctf_nobfd_la-ctf-lookup.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libctf_nobfd_la-ctf-open.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libctf_nobfd_la-ctf-qsort_r.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libctf_nobfd_la-ctf-sha1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libctf_nobfd_la-ctf-string.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libctf_nobfd_la-ctf-subr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libctf_nobfd_la-ctf-types.Plo@am__quote@ @@ -698,6 +702,13 @@ libctf_nobfd_la-ctf-open.lo: ctf-open.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libctf_nobfd_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libctf_nobfd_la-ctf-open.lo `test -f 'ctf-open.c' || echo '$(srcdir)/'`ctf-open.c +libctf_nobfd_la-ctf-sha1.lo: ctf-sha1.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libctf_nobfd_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libctf_nobfd_la-ctf-sha1.lo -MD -MP -MF $(DEPDIR)/libctf_nobfd_la-ctf-sha1.Tpo -c -o libctf_nobfd_la-ctf-sha1.lo `test -f 'ctf-sha1.c' || echo '$(srcdir)/'`ctf-sha1.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libctf_nobfd_la-ctf-sha1.Tpo $(DEPDIR)/libctf_nobfd_la-ctf-sha1.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctf-sha1.c' object='libctf_nobfd_la-ctf-sha1.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libctf_nobfd_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libctf_nobfd_la-ctf-sha1.lo `test -f 'ctf-sha1.c' || echo '$(srcdir)/'`ctf-sha1.c + libctf_nobfd_la-ctf-string.lo: ctf-string.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libctf_nobfd_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libctf_nobfd_la-ctf-string.lo -MD -MP -MF $(DEPDIR)/libctf_nobfd_la-ctf-string.Tpo -c -o libctf_nobfd_la-ctf-string.lo `test -f 'ctf-string.c' || echo '$(srcdir)/'`ctf-string.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libctf_nobfd_la-ctf-string.Tpo $(DEPDIR)/libctf_nobfd_la-ctf-string.Plo @@ -803,6 +814,13 @@ libctf_la-ctf-open.lo: ctf-open.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libctf_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libctf_la-ctf-open.lo `test -f 'ctf-open.c' || echo '$(srcdir)/'`ctf-open.c +libctf_la-ctf-sha1.lo: ctf-sha1.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libctf_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libctf_la-ctf-sha1.lo -MD -MP -MF $(DEPDIR)/libctf_la-ctf-sha1.Tpo -c -o libctf_la-ctf-sha1.lo `test -f 'ctf-sha1.c' || echo '$(srcdir)/'`ctf-sha1.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libctf_la-ctf-sha1.Tpo $(DEPDIR)/libctf_la-ctf-sha1.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ctf-sha1.c' object='libctf_la-ctf-sha1.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libctf_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libctf_la-ctf-sha1.lo `test -f 'ctf-sha1.c' || echo '$(srcdir)/'`ctf-sha1.c + libctf_la-ctf-string.lo: ctf-string.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libctf_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libctf_la-ctf-string.lo -MD -MP -MF $(DEPDIR)/libctf_la-ctf-string.Tpo -c -o libctf_la-ctf-string.lo `test -f 'ctf-string.c' || echo '$(srcdir)/'`ctf-string.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libctf_la-ctf-string.Tpo $(DEPDIR)/libctf_la-ctf-string.Plo diff --git a/libctf/ctf-impl.h b/libctf/ctf-impl.h index 7f47c68eccb..9c5f7bac65a 100644 --- a/libctf/ctf-impl.h +++ b/libctf/ctf-impl.h @@ -25,6 +25,7 @@ #include #include "ctf-decls.h" #include +#include "ctf-sha1.h" #include #include #include @@ -499,6 +500,10 @@ extern int ctf_dynset_exists (ctf_dynset_t *, const void *key, extern int ctf_dynset_next (ctf_dynset_t *, ctf_next_t **, void **key); extern void *ctf_dynset_lookup_any (ctf_dynset_t *); +extern void ctf_sha1_init (ctf_sha1_t *); +extern void ctf_sha1_add (ctf_sha1_t *, const void *, size_t); +extern char *ctf_sha1_fini (ctf_sha1_t *, char *); + #define ctf_list_prev(elem) ((void *)(((ctf_list_t *)(elem))->l_prev)) #define ctf_list_next(elem) ((void *)(((ctf_list_t *)(elem))->l_next)) diff --git a/libctf/ctf-sha1.c b/libctf/ctf-sha1.c new file mode 100644 index 00000000000..47e66558a46 --- /dev/null +++ b/libctf/ctf-sha1.c @@ -0,0 +1,50 @@ +/* SHA-1 thunks. + Copyright (C) 2019 Free Software Foundation, Inc. + + This file is part of libctf. + + libctf is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not see + . */ + +#include +#include + +static const char hex[] = "0123456789abcdef"; + +char * +ctf_sha1_fini (ctf_sha1_t *sha1, char *buf) +{ + size_t i; + + /* Alignment suitable for a uint32_t. */ + union + { + uint32_t align; + unsigned char digest[((CTF_SHA1_SIZE - 1) / 2) + 1]; + } align; + + sha1_finish_ctx (sha1, align.digest); + + if (!buf) + return NULL; + + buf[CTF_SHA1_SIZE - 1] = '\0'; + + for (i = 0; i < (CTF_SHA1_SIZE - 1) / 2; i++) + { + buf[2 * i] = hex[align.digest[i] >> 4]; + buf[2 * i + 1] = hex[align.digest[i] & 0xf]; + } + return buf; +} diff --git a/libctf/ctf-sha1.h b/libctf/ctf-sha1.h new file mode 100644 index 00000000000..b9e0c9eedf8 --- /dev/null +++ b/libctf/ctf-sha1.h @@ -0,0 +1,41 @@ +/* SHA-1 thunks. + Copyright (C) 2019 Free Software Foundation, Inc. + + This file is part of libctf. + + libctf is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not see + . */ + +#ifndef _CTF_SHA1_H +#define _CTF_SHA1_H + +#include "config.h" +#include "sha1.h" + +#define CTF_SHA1_SIZE 41 + +typedef struct sha1_ctx ctf_sha1_t; + +static inline void +ctf_sha1_init (ctf_sha1_t *sha1) +{ + sha1_init_ctx (sha1); +} + +static inline void +ctf_sha1_add (ctf_sha1_t *sha1, const void *buf, size_t len) +{ + sha1_process_bytes (buf, len, sha1); +} +#endif -- 2.27.0.247.g3dff7de930