diff --git a/src/OVAL/probes/crapi/digest.c b/src/OVAL/probes/crapi/digest.c index fdd361813e..96f638d4a5 100644 --- a/src/OVAL/probes/crapi/digest.c +++ b/src/OVAL/probes/crapi/digest.c @@ -30,179 +30,331 @@ #include #include #include +#include +#include #include #include "crapi.h" #include "digest.h" -#include "md5.h" -#include "sha1.h" -#include "sha2.h" -#include "rmd160.h" -int crapi_digest_fd (int fd, crapi_alg_t alg, void *dst, size_t *size) +#if defined(HAVE_NSS3) +#include +#elif defined(HAVE_GCRYPT) +#include +#else +#error "No crypto library available!" +#endif + +#if defined(HAVE_NSS3) +static int crapi_alg_t_to_lib_arg(crapi_alg_t alg) { - if (dst == NULL) { - errno = EFAULT; + switch (alg) { +#ifdef OPENSCAP_ENABLE_MD5 + case CRAPI_DIGEST_MD5: + return HASH_AlgMD5; +#endif +#ifdef OPENSCAP_ENABLE_SHA1 + case CRAPI_DIGEST_SHA1: + return HASH_AlgSHA1; +#endif + case CRAPI_DIGEST_SHA224: + return HASH_AlgSHA224; + case CRAPI_DIGEST_SHA256: + return HASH_AlgSHA256; + case CRAPI_DIGEST_SHA384: + return HASH_AlgSHA384; + case CRAPI_DIGEST_SHA512: + return HASH_AlgSHA512; + default: return -1; } - if (size == NULL) { +} +#elif defined(HAVE_GCRYPT) +static int crapi_alg_t_to_lib_arg(crapi_alg_t alg) +{ + switch (alg) { +#ifdef OPENSCAP_ENABLE_MD5 + case CRAPI_DIGEST_MD5: + return GCRY_MD_MD5; +#endif +#ifdef OPENSCAP_ENABLE_SHA1 + case CRAPI_DIGEST_SHA1: + return GCRY_MD_SHA1; +#endif + case CRAPI_DIGEST_SHA224: + return GCRY_MD_SHA224; + case CRAPI_DIGEST_SHA256: + return GCRY_MD_SHA256; + case CRAPI_DIGEST_SHA384: + return GCRY_MD_SHA384; + case CRAPI_DIGEST_SHA512: + return GCRY_MD_SHA512; + case CRAPI_DIGEST_RMD160: + return GCRY_MD_RMD160; + default: + return -1; + } +} +#endif + +int crapi_digest_fd(int fd, crapi_alg_t alg, void *dst, size_t *size) +{ + struct stat st; + void *buffer; + size_t buflen; + + if (size == NULL || dst == NULL) { errno = EFAULT; return -1; } + int lib_alg = crapi_alg_t_to_lib_arg(alg); +#if defined(HAVE_NSS3) + if (*size < HASH_ResultLen(lib_alg)) { +#elif defined(HAVE_GCRYPT) + if (*size < gcry_md_get_algo_dlen(lib_alg)) { +#endif + errno = ENOBUFS; + return -1; + } - switch (alg) { -#ifdef OPENSCAP_ENABLE_MD5 - case CRAPI_DIGEST_MD5: - return crapi_md5_fd (fd, dst, size); + if (fstat (fd, &st) != 0) + return (-1); + else { +#if _FILE_OFFSET_BITS == 32 + buflen = st.st_size; +# if defined(OS_FREEBSD) + buffer = mmap(NULL, buflen, PROT_READ, MAP_SHARED | MAP_NOCORE, fd, 0); +# else + buffer = mmap(NULL, buflen, PROT_READ, MAP_SHARED, fd, 0); +# endif + if (buffer == NULL) { +#endif /* _FILE_OFFSET_BITS == 32 */ + uint8_t _buffer[CRAPI_IO_BUFSZ]; + ssize_t ret; + + buffer = _buffer; +#if defined(HAVE_NSS3) + HASHContext *ctx = HASH_Create (lib_alg); + + if (ctx == NULL) + return (-1); +#elif defined(HAVE_GCRYPT) + gcry_md_hd_t hd; + gcry_md_open (&hd, lib_alg, 0); #endif -#ifdef OPENSCAP_ENABLE_SHA1 - case CRAPI_DIGEST_SHA1: - return crapi_sha1_fd (fd, dst, size); -#endif - case CRAPI_DIGEST_SHA224: - return crapi_sha224_fd (fd, dst, size); - case CRAPI_DIGEST_SHA256: - return crapi_sha256_fd (fd, dst, size); - case CRAPI_DIGEST_SHA384: - return crapi_sha384_fd (fd, dst, size); - case CRAPI_DIGEST_SHA512: - return crapi_sha512_fd (fd, dst, size); - case CRAPI_DIGEST_RMD160: - return crapi_rmd160_fd (fd, dst, size); - } - - errno = EINVAL; - return (-1); + + while ((ret = read(fd, buffer, sizeof _buffer)) == sizeof _buffer) +#if defined(HAVE_NSS3) + HASH_Update(ctx, (const unsigned char *)buffer, (unsigned int) sizeof _buffer); +#elif defined(HAVE_GCRYPT) + gcry_md_write(hd, (const void *)buffer, sizeof _buffer); +#endif + + switch (ret) { + case 0: + break; + case -1: + return (-1); + default: + if (ret <= 0) { +#if defined(HAVE_NSS3) + HASH_Destroy(ctx); +#elif defined(HAVE_GCRYPT) + gcry_md_close(hd); +#endif + return -1; + } +#if defined(HAVE_NSS3) + HASH_Update(ctx, (const unsigned char *)buffer, (unsigned int) ret); +#elif defined(HAVE_GCRYPT) + gcry_md_write(hd, (const void *)buffer, (size_t)ret); +#endif + } + +#if defined(HAVE_NSS3) + HASH_End(ctx, dst, (unsigned int *)size, *size); + HASH_Destroy(ctx); +#elif defined(HAVE_GCRYPT) + gcry_md_final(hd); + + buffer = (void *)gcry_md_read(hd, lib_alg); + memcpy (dst, buffer, gcry_md_get_algo_dlen(lib_alg)); + gcry_md_close (hd); +#endif + +#if _FILE_OFFSET_BITS == 32 + } else { +#if defined(HAVE_NSS3) + HASH_HashBuf(lib_alg, (unsigned char *)dst, (unsigned char *)buffer, (unsigned int)buflen); +#elif defined(HAVE_GCRYPT) + gcry_md_hash_buffer(lib_alg, dst, (const void *)buffer, buflen); +#endif + munmap(buffer, buflen); + } +#endif /* _FILE_OFFSET_BITS == 32 */ + } + return (0); +} + +struct crapi_digest_ctx { +#if defined(HAVE_NSS3) + HASHContext *ctx; +#elif defined(HAVE_GCRYPT) + gcry_md_hd_t ctx; +#endif + void *dst; + size_t *size; +}; + +struct digest_ctbl_t { + struct crapi_digest_ctx *ctx; + crapi_alg_t alg; +}; + +static void *crapi_digest_init (void *dst, void *size, crapi_alg_t alg) +{ + struct crapi_digest_ctx *ctx = malloc(sizeof(struct crapi_digest_ctx)); + + int lib_alg = crapi_alg_t_to_lib_arg(alg); +#if defined(HAVE_NSS3) + ctx->ctx = HASH_Create(lib_alg); +#elif defined(HAVE_GCRYPT) + if (gcry_md_open(&ctx->ctx, lib_alg, 0) != 0) { + free(ctx); + return NULL; + } +#endif + ctx->dst = dst; + ctx->size = size; + +#if defined(HAVE_NSS3) + if (ctx->ctx != NULL) { + HASH_Begin(ctx->ctx); + } else { + free(ctx); + ctx = NULL; + } +#endif + + return (ctx); +} + +static int crapi_digest_update(struct crapi_digest_ctx *ctx, void *bptr, size_t blen) +{ +#if defined(HAVE_NSS3) + HASH_Update(ctx->ctx, (const unsigned char *)bptr, (unsigned int)blen); +#elif defined(HAVE_GCRYPT) + gcry_md_write(ctx->ctx, (const void *)bptr, blen); +#endif + return (0); +} + +static int crapi_digest_fini(struct crapi_digest_ctx *ctx, crapi_alg_t alg) +{ +#if defined(HAVE_NSS3) + HASH_End (ctx->ctx, ctx->dst, (unsigned int *)ctx->size, *ctx->size); + HASH_Destroy (ctx->ctx); +#elif defined(HAVE_GCRYPT) + void *buffer; + + gcry_md_final(ctx->ctx); + int lib_alg = crapi_alg_t_to_lib_arg(alg); + buffer = (void *)gcry_md_read(ctx->ctx, lib_alg); + memcpy(ctx->dst, buffer, gcry_md_get_algo_dlen(lib_alg)); + gcry_md_close(ctx->ctx); +#endif + free (ctx); + + return (0); +} + +static void crapi_digest_free(struct crapi_digest_ctx *ctx) +{ +#if defined(HAVE_NSS3) + HASH_Destroy(ctx->ctx); + free(ctx); +#endif + return; } int crapi_mdigest_fd (int fd, int num, ... /* crapi_alg_t alg, void *dst, size_t *size, ...*/) { - register int i; - va_list ap; - struct digest_ctbl_t *ctbl = malloc(num * sizeof(struct digest_ctbl_t)); + register int i; + va_list ap; + struct digest_ctbl_t *ctbl = malloc(num * sizeof(struct digest_ctbl_t)); - crapi_alg_t alg; - void *dst; - size_t *size; + crapi_alg_t alg; + void *dst; + size_t *size; - uint8_t fd_buf[CRAPI_IO_BUFSZ]; - ssize_t ret; + uint8_t fd_buf[CRAPI_IO_BUFSZ]; + ssize_t ret; if (num <= 0 || fd <= 0) { errno = EINVAL; free(ctbl); return -1; } - for (i = 0; i < num; ++i) - ctbl[i].ctx = NULL; + for (i = 0; i < num; ++i) + ctbl[i].ctx = NULL; - va_start (ap, num); + va_start(ap, num); - for (i = 0; i < num; ++i) { - alg = va_arg (ap, crapi_alg_t); - dst = va_arg (ap, void *); - size = va_arg (ap, size_t *); + for (i = 0; i < num; ++i) { + alg = va_arg(ap, crapi_alg_t); + dst = va_arg(ap, void *); + size = va_arg(ap, size_t *); - switch (alg) { -#ifdef OPENSCAP_ENABLE_MD5 - case CRAPI_DIGEST_MD5: - ctbl[i].init = &crapi_md5_init; - ctbl[i].update = &crapi_md5_update; - ctbl[i].fini = &crapi_md5_fini; - ctbl[i].free = &crapi_md5_free; - break; -#endif -#ifdef OPENSCAP_ENABLE_SHA1 - case CRAPI_DIGEST_SHA1: - ctbl[i].init = &crapi_sha1_init; - ctbl[i].update = &crapi_sha1_update; - ctbl[i].fini = &crapi_sha1_fini; - ctbl[i].free = &crapi_sha1_free; - break; -#endif - case CRAPI_DIGEST_SHA224: - ctbl[i].init = &crapi_sha224_init; - ctbl[i].update = &crapi_sha224_update; - ctbl[i].fini = &crapi_sha224_fini; - ctbl[i].free = &crapi_sha224_free; - break; - case CRAPI_DIGEST_SHA256: - ctbl[i].init = &crapi_sha256_init; - ctbl[i].update = &crapi_sha256_update; - ctbl[i].fini = &crapi_sha256_fini; - ctbl[i].free = &crapi_sha256_free; - break; - case CRAPI_DIGEST_SHA384: - ctbl[i].init = &crapi_sha384_init; - ctbl[i].update = &crapi_sha384_update; - ctbl[i].fini = &crapi_sha384_fini; - ctbl[i].free = &crapi_sha384_free; - break; - case CRAPI_DIGEST_SHA512: - ctbl[i].init = &crapi_sha512_init; - ctbl[i].update = &crapi_sha512_update; - ctbl[i].fini = &crapi_sha512_fini; - ctbl[i].free = &crapi_sha512_free; - break; - case CRAPI_DIGEST_RMD160: - ctbl[i].init = &crapi_rmd160_init; - ctbl[i].update = &crapi_rmd160_update; - ctbl[i].fini = &crapi_rmd160_fini; - ctbl[i].free = &crapi_rmd160_free; - break; - default: - va_end (ap); - goto fail; - } - - if ((ctbl[i].ctx = ctbl[i].init (dst, size)) == NULL) + ctbl[i].alg = alg; + if ((ctbl[i].ctx = crapi_digest_init(dst, size, alg)) == NULL) *size = 0; - } + } - va_end (ap); + va_end (ap); - while ((ret = read (fd, fd_buf, sizeof fd_buf)) == sizeof fd_buf) { - for (i = 0; i < num; ++i) { + while ((ret = read(fd, fd_buf, sizeof fd_buf)) == sizeof fd_buf) { + for (i = 0; i < num; ++i) { if (ctbl[i].ctx == NULL) continue; - if (ctbl[i].update (ctbl[i].ctx, fd_buf, sizeof fd_buf) != 0) { - goto fail; - } - } - } - - switch (ret) { - case 0: - break; - case -1: - goto fail; - default: + if (crapi_digest_update(ctbl[i].ctx, fd_buf, sizeof fd_buf) != 0) { + goto fail; + } + } + } + + switch (ret) { + case 0: + break; + case -1: + goto fail; + default: if (ret <= 0) { free(ctbl); return -1; } - for (i = 0; i < num; ++i) { + for (i = 0; i < num; ++i) { if (ctbl[i].ctx == NULL) continue; - if (ctbl[i].update (ctbl[i].ctx, fd_buf, (size_t)ret) != 0) { - goto fail; - } - } - } + if (crapi_digest_update(ctbl[i].ctx, fd_buf, (size_t)ret) != 0) { + goto fail; + } + } + } - for (i = 0; i < num; ++i) { + for (i = 0; i < num; ++i) { if (ctbl[i].ctx == NULL) continue; - ctbl[i].fini (ctbl[i].ctx); + crapi_digest_fini(ctbl[i].ctx, ctbl[i].alg); } - free(ctbl); - return (0); + free(ctbl); + return (0); fail: - for (i = 0; i < num; ++i) - if (ctbl[i].ctx != NULL) - ctbl[i].free (ctbl[i].ctx); + for (i = 0; i < num; ++i) { + if (ctbl[i].ctx != NULL) + crapi_digest_free(ctbl[i].ctx); + } - free(ctbl); - return (-1); + free(ctbl); + return (-1); } diff --git a/src/OVAL/probes/crapi/digest.h b/src/OVAL/probes/crapi/digest.h index 0d66db1336..0ef743a49f 100644 --- a/src/OVAL/probes/crapi/digest.h +++ b/src/OVAL/probes/crapi/digest.h @@ -40,21 +40,8 @@ typedef enum { CRAPI_DIGEST_SHA384 = 0x40 } crapi_alg_t; -#include "md5.h" -#include "sha1.h" -#include "sha2.h" -#include "rmd160.h" - int crapi_digest_fd (int fd, crapi_alg_t alg, void *dst, size_t *size); -struct digest_ctbl_t { - void *ctx; - void *(*init) (void *, void *); - int (*update)(void *, void *, size_t); - int (*fini) (void *); - void (*free) (void *); -}; - int crapi_mdigest_fd (int fd, int num, ... /*crapi_alg_t alg, void *dst, size_t *size, ...*/); #endif /* CRAPI_DIGEST_H */ diff --git a/src/OVAL/probes/crapi/md5.c b/src/OVAL/probes/crapi/md5.c deleted file mode 100644 index 8fc32af027..0000000000 --- a/src/OVAL/probes/crapi/md5.c +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright 2010 Red Hat Inc., Durham, North Carolina. - * All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: - * "Daniel Kopecek" - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include "crapi.h" -#include "md5.h" - -#ifdef OPENSCAP_ENABLE_MD5 - -#if defined(HAVE_NSS3) -#include - -#define CRAPI_MD5DST_LEN MD5_LENGTH - -struct crapi_md5_ctx { - HASHContext *ctx; - void *dst; - size_t *size; -}; - -void *crapi_md5_init (void *dst, void *size) -{ - struct crapi_md5_ctx *ctx = malloc(sizeof(struct crapi_md5_ctx)); - - ctx->ctx = HASH_Create (HASH_AlgMD5); - ctx->dst = dst; - ctx->size = size; - - if (ctx->ctx != NULL) { - HASH_Begin (ctx->ctx); - } else { - free (ctx); - ctx = NULL; - } - - return (ctx); -} - -int crapi_md5_update (void *ctxp, void *bptr, size_t blen) -{ - struct crapi_md5_ctx *ctx = (struct crapi_md5_ctx *)ctxp; - - HASH_Update (ctx->ctx, (const unsigned char *)bptr, (unsigned int)blen); - return (0); -} - -int crapi_md5_fini (void *ctxp) -{ - struct crapi_md5_ctx *ctx = (struct crapi_md5_ctx *)ctxp; - - HASH_End (ctx->ctx, ctx->dst, (unsigned int *)ctx->size, *ctx->size); - HASH_Destroy (ctx->ctx); - free (ctx); - - return (0); -} - -void crapi_md5_free (void *ctxp) -{ - struct crapi_md5_ctx *ctx = (struct crapi_md5_ctx *)ctxp; - - HASH_Destroy (ctx->ctx); - free (ctx); - - return; -} -#elif defined(HAVE_GCRYPT) -#include - -#define CRAPI_MD5DST_LEN gcry_md_get_algo_dlen (GCRY_MD_MD5) - -struct crapi_md5_ctx { - gcry_md_hd_t ctx; - void *dst; - void *size; -}; - -void *crapi_md5_init (void *dst, void *size) -{ - struct crapi_md5_ctx *ctx = malloc(sizeof(struct crapi_md5_ctx)); - - if (gcry_md_open (&ctx->ctx, GCRY_MD_MD5, 0) != 0) { - free(ctx); - return NULL; - } - - ctx->dst = dst; - ctx->size = size; - - return (ctx); -} - -int crapi_md5_update (void *ctxp, void *bptr, size_t blen) -{ - struct crapi_md5_ctx *ctx = (struct crapi_md5_ctx *)ctxp; - - gcry_md_write (ctx->ctx, (const void *)bptr, blen); - return (0); -} - -int crapi_md5_fini (void *ctxp) -{ - struct crapi_md5_ctx *ctx = (struct crapi_md5_ctx *)ctxp; - void *buffer; - - gcry_md_final (ctx->ctx); - buffer = (void *)gcry_md_read (ctx->ctx, GCRY_MD_MD5); - memcpy (ctx->dst, buffer, gcry_md_get_algo_dlen (GCRY_MD_MD5)); - gcry_md_close (ctx->ctx); - free(ctx); - - return (0); -} - -void crapi_md5_free (void *ctxp) -{ - struct crapi_md5_ctx *ctx = (struct crapi_md5_ctx *)ctxp; - - gcry_md_close (ctx->ctx); - free(ctx); - - return; -} -#else -# error "No crypto library available!" -#endif - -int crapi_md5_fd (int fd, void *dst, size_t *size) -{ - struct stat st; - void *buffer; - size_t buflen; - - if (size == NULL) { - errno = EFAULT; - return -1; - } - if (*size < CRAPI_MD5DST_LEN) { - errno = ENOBUFS; - return -1; - } - if (dst == NULL) { - errno = EFAULT; - return -1; - } - - if (fstat (fd, &st) != 0) - return (-1); - else { -#if _FILE_OFFSET_BITS == 32 - buflen = st.st_size; -# if defined(OS_FREEBSD) - buffer = mmap (NULL, buflen, PROT_READ, MAP_SHARED | MAP_NOCORE, fd, 0); -# else - buffer = mmap (NULL, buflen, PROT_READ, MAP_SHARED, fd, 0); -# endif - if (buffer == NULL) { -#endif - uint8_t _buffer[CRAPI_IO_BUFSZ]; - void *ctx; - ssize_t ret; - - buffer = _buffer; - ctx = crapi_md5_init (dst, size); - - if (ctx == NULL) - return (-1); - - while ((ret = read (fd, buffer, sizeof _buffer)) == sizeof _buffer) - crapi_md5_update (ctx, buffer, sizeof _buffer); - - switch (ret) { - case 0: - break; - case -1: - return (-1); - default: - if (ret <= 0) { - crapi_md5_free(ctx); - return -1; - } - crapi_md5_update (ctx, buffer, (size_t) ret); - } - - crapi_md5_fini (ctx); -#if _FILE_OFFSET_BITS == 32 -# if defined(HAVE_NSS3) - } else { - SECStatus ret; - - ret = HASH_HashBuf (HASH_AlgMD5, (unsigned char *)dst, (unsigned char *)buffer, (unsigned int)buflen); - munmap (buffer, buflen); - - return (ret == SECSuccess ? 0 : -1); - } -# elif defined(HAVE_GCRYPT) - } else { - /* XXX: FIPS: Note that this function will abort the process if an unavailable algorithm is used. */ - gcry_md_hash_buffer (GCRY_MD_MD5, dst, (const void *)buffer, buflen); - munmap (buffer, buflen); - } -# endif -#endif /* _FILE_OFFSET_BITS == 32 */ - } - return (0); -} - -#endif /* OPENSCAP_ENABLE_MD5 */ diff --git a/src/OVAL/probes/crapi/md5.h b/src/OVAL/probes/crapi/md5.h deleted file mode 100644 index 15e82bb671..0000000000 --- a/src/OVAL/probes/crapi/md5.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2010 Red Hat Inc., Durham, North Carolina. - * All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: - * "Daniel Kopecek" - */ -#pragma once -#ifndef CRAPI_MD5_H -#define CRAPI_MD5_H - -#include - -#ifdef OPENSCAP_ENABLE_MD5 - -void *crapi_md5_init (void *dst, void *size); -int crapi_md5_update (void *ctxp, void *bptr, size_t blen); -int crapi_md5_fini (void *ctxp); -void crapi_md5_free (void *ctxp); - -int crapi_md5_fd (int fd, void *dst, size_t *size); - -#endif /* OPENSCAP_ENABLE_MD5 */ - -#endif /* CRAPI_MD5_H */ diff --git a/src/OVAL/probes/crapi/rmd160.c b/src/OVAL/probes/crapi/rmd160.c deleted file mode 100644 index cc91b28824..0000000000 --- a/src/OVAL/probes/crapi/rmd160.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright 2010 Red Hat Inc., Durham, North Carolina. - * All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: - * "Daniel Kopecek" - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include - -#include "crapi.h" -#include "rmd160.h" - -#if defined(HAVE_NSS3) -#include - -void *crapi_rmd160_init (void *dst, void *size) -{ - return (NULL); -} - -int crapi_rmd160_update (void *ctxp, void *bptr, size_t blen) -{ - return (-1); -} - -int crapi_rmd160_fini (void *ctxp) -{ - return (-1); -} - -void crapi_rmd160_free (void *ctxp) -{ - return; -} - -int crapi_rmd160_fd (int fd, void *dst, size_t *size) -{ - errno = EOPNOTSUPP; - return (-1); -} -#elif defined(HAVE_GCRYPT) -#include - -struct crapi_rmd160_ctx { - gcry_md_hd_t ctx; - void *dst; - void *size; -}; - -#define CRAPI_RMD160DST_LEN gcry_md_get_algo_dlen (GCRY_MD_RMD160) - -void *crapi_rmd160_init (void *dst, void *size) -{ - struct crapi_rmd160_ctx *ctx = malloc(sizeof(struct crapi_rmd160_ctx)); - - if (gcry_md_open (&ctx->ctx, GCRY_MD_RMD160, 0) != 0) { - free(ctx); - return NULL; - } - - ctx->dst = dst; - ctx->size = size; - - return (ctx); -} - -int crapi_rmd160_update (void *ctxp, void *bptr, size_t blen) -{ - struct crapi_rmd160_ctx *ctx = (struct crapi_rmd160_ctx *)ctxp; - - gcry_md_write (ctx->ctx, (const void *)bptr, blen); - return (0); -} - -int crapi_rmd160_fini (void *ctxp) -{ - struct crapi_rmd160_ctx *ctx = (struct crapi_rmd160_ctx *)ctxp; - void *buffer; - - gcry_md_final (ctx->ctx); - buffer = (void *)gcry_md_read (ctx->ctx, GCRY_MD_RMD160); - memcpy (ctx->dst, buffer, gcry_md_get_algo_dlen (GCRY_MD_RMD160)); - gcry_md_close (ctx->ctx); - free(ctx); - - return (0); -} - -void crapi_rmd160_free (void *ctxp) -{ - struct crapi_rmd160_ctx *ctx = (struct crapi_rmd160_ctx *)ctxp; - - gcry_md_close (ctx->ctx); - free(ctx); - - return; -} - -int crapi_rmd160_fd (int fd, void *dst, size_t *size) -{ - struct stat st; - void *buffer; - size_t buflen; - - if (size == NULL || dst == NULL) { - errno = EFAULT; - return -1; - } - if (*size < gcry_md_get_algo_dlen(GCRY_MD_RMD160)) { - errno = ENOBUFS; - return -1; - } - - if (fstat (fd, &st) != 0) - return (-1); - else { -#if _FILE_OFFSET_BITS == 32 - buflen = st.st_size; -# if defined(OS_FREEBSD) - buffer = mmap (NULL, buflen, PROT_READ, MAP_SHARED | MAP_NOCORE, fd, 0); -# else - buffer = mmap (NULL, buflen, PROT_READ, MAP_SHARED, fd, 0); -# endif - if (buffer == NULL) { -#endif /* _FILE_OFFSET_BITS == 32 */ - uint8_t _buffer[CRAPI_IO_BUFSZ]; - gcry_md_hd_t hd; - ssize_t ret; - - buffer = _buffer; - gcry_md_open (&hd, GCRY_MD_RMD160, 0); - - while ((ret = read (fd, buffer, sizeof _buffer)) == sizeof _buffer) - gcry_md_write (hd, (const void *)buffer, sizeof _buffer); - - switch (ret) { - case 0: - break; - case -1: - return (-1); - default: - if (ret <= 0) { - gcry_md_close(hd); - return -1; - } - gcry_md_write (hd, (const void *)buffer, (size_t)ret); - } - - gcry_md_final (hd); - - buffer = (void *)gcry_md_read (hd, GCRY_MD_RMD160); - memcpy (dst, buffer, gcry_md_get_algo_dlen (GCRY_MD_RMD160)); - gcry_md_close (hd); -#if _FILE_OFFSET_BITS == 32 - } else { - gcry_md_hash_buffer (GCRY_MD_RMD160, dst, (const void *)buffer, buflen); - munmap (buffer, buflen); - } -#endif /* _FILE_OFFSET_BITS == 32 */ - } - return (0); -} -#else -# error "No crypto library available!" -#endif diff --git a/src/OVAL/probes/crapi/rmd160.h b/src/OVAL/probes/crapi/rmd160.h deleted file mode 100644 index 33fd277649..0000000000 --- a/src/OVAL/probes/crapi/rmd160.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2010 Red Hat Inc., Durham, North Carolina. - * All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: - * "Daniel Kopecek" - */ -#pragma once -#ifndef CRAPI_RMD160_H -#define CRAPI_RMD160_H - -#include - -void *crapi_rmd160_init (void *dst, void *size); -int crapi_rmd160_update (void *ctxp, void *bptr, size_t blen); -int crapi_rmd160_fini (void *ctxp); -void crapi_rmd160_free (void *ctxp); - -int crapi_rmd160_fd (int fd, void *dst, size_t *size); - -#endif /* CRAPI_RMD160_H */ diff --git a/src/OVAL/probes/crapi/sha1.c b/src/OVAL/probes/crapi/sha1.c deleted file mode 100644 index 9a757d0274..0000000000 --- a/src/OVAL/probes/crapi/sha1.c +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Copyright 2010 Red Hat Inc., Durham, North Carolina. - * All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: - * "Daniel Kopecek" - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include "crapi.h" -#include "sha1.h" - -#ifdef OPENSCAP_ENABLE_SHA1 - -#if defined(HAVE_NSS3) -#include - -#define CRAPI_SHA1DST_LEN SHA1_LENGTH - -struct crapi_sha1_ctx { - HASHContext *ctx; - void *dst; - size_t *size; -}; - -void *crapi_sha1_init (void *dst, void *size) -{ - struct crapi_sha1_ctx *ctx = malloc(sizeof(struct crapi_sha1_ctx)); - - ctx->ctx = HASH_Create (HASH_AlgSHA1); - ctx->dst = dst; - ctx->size = size; - - if (ctx->ctx != NULL) { - HASH_Begin (ctx->ctx); - } else { - free (ctx); - ctx = NULL; - } - - return (ctx); -} - -int crapi_sha1_update (void *ctxp, void *bptr, size_t blen) -{ - struct crapi_sha1_ctx *ctx = (struct crapi_sha1_ctx *)ctxp; - - HASH_Update (ctx->ctx, (const unsigned char *)bptr, (unsigned int)blen); - return (0); -} - -int crapi_sha1_fini (void *ctxp) -{ - struct crapi_sha1_ctx *ctx = (struct crapi_sha1_ctx *)ctxp; - - HASH_End (ctx->ctx, ctx->dst, (unsigned int *)ctx->size, *ctx->size); - HASH_Destroy (ctx->ctx); - free (ctx); - - return (0); -} - -void crapi_sha1_free (void *ctxp) -{ - struct crapi_sha1_ctx *ctx = (struct crapi_sha1_ctx *)ctxp; - - HASH_Destroy (ctx->ctx); - free (ctx); - - return; -} -#elif defined(HAVE_GCRYPT) -#include - -#define CRAPI_SHA1DST_LEN gcry_md_get_algo_dlen (GCRY_MD_SHA1) - -struct crapi_sha1_ctx { - gcry_md_hd_t ctx; - void *dst; - void *size; -}; - -void *crapi_sha1_init (void *dst, void *size) -{ - struct crapi_sha1_ctx *ctx = malloc(sizeof(struct crapi_sha1_ctx)); - - if (gcry_md_open (&ctx->ctx, GCRY_MD_SHA1, 0) != 0) { - free(ctx); - return NULL; - } - - ctx->dst = dst; - ctx->size = size; - - return (ctx); -} - -int crapi_sha1_update (void *ctxp, void *bptr, size_t blen) -{ - struct crapi_sha1_ctx *ctx = (struct crapi_sha1_ctx *)ctxp; - - gcry_md_write (ctx->ctx, (const void *)bptr, blen); - return (0); -} - -int crapi_sha1_fini (void *ctxp) -{ - struct crapi_sha1_ctx *ctx = (struct crapi_sha1_ctx *)ctxp; - void *buffer; - - gcry_md_final (ctx->ctx); - buffer = (void *)gcry_md_read (ctx->ctx, GCRY_MD_SHA1); - memcpy (ctx->dst, buffer, gcry_md_get_algo_dlen (GCRY_MD_SHA1)); - gcry_md_close (ctx->ctx); - free(ctx); - - return (0); -} - -void crapi_sha1_free (void *ctxp) -{ - struct crapi_sha1_ctx *ctx = (struct crapi_sha1_ctx *)ctxp; - - gcry_md_close (ctx->ctx); - free(ctx); - - return; -} -#else -# error "No crypto library available!" -#endif - -int crapi_sha1_fd (int fd, void *dst, size_t *size) -{ - struct stat st; - void *buffer; - size_t buflen; - - if (size == NULL || dst == NULL) { - errno = EFAULT; - return -1; - } - if (*size < CRAPI_SHA1DST_LEN) { - errno = ENOBUFS; - return -1; - } - - if (fstat (fd, &st) != 0) - return (-1); - else { -#if _FILE_OFFSET_BITS == 32 - buflen = st.st_size; -# if defined(OS_FREEBSD) - buffer = mmap (NULL, buflen, PROT_READ, MAP_SHARED | MAP_NOCORE, fd, 0); -# else - buffer = mmap (NULL, buflen, PROT_READ, MAP_SHARED, fd, 0); -# endif - if (buffer == NULL) { -#endif /* _FILE_OFFSET_BITS == 32 */ - uint8_t _buffer[CRAPI_IO_BUFSZ]; - void *ctx; - ssize_t ret; - - buffer = _buffer; - ctx = crapi_sha1_init (dst, size); - - while ((ret = read (fd, buffer, sizeof _buffer)) == sizeof _buffer) - crapi_sha1_update (ctx, buffer, sizeof _buffer); - - switch (ret) { - case 0: - break; - case -1: - return (-1); - default: - if (ret <= 0) { - crapi_sha1_free(ctx); - return -1; - } - crapi_sha1_update (ctx, buffer, (size_t) ret); - } - - crapi_sha1_fini (ctx); -#if _FILE_OFFSET_BITS == 32 -# if defined(HAVE_NSS3) - } else { - SECStatus ret; - - ret = HASH_HashBuf (HASH_AlgSHA1, (unsigned char *)dst, (unsigned char *)buffer, (unsigned int)buflen); - munmap (buffer, buflen); - - return (ret == SECSuccess ? 0 : -1); - } -# elif defined(HAVE_GCRYPT) - } else { - /* XXX: FIPS: Note that this function will abort the process if an unavailable algorithm is used. */ - gcry_md_hash_buffer (GCRY_MD_SHA1, dst, (const void *)buffer, buflen); - - if (munmap (buffer, buflen) != 0) - return (-1); - } -# endif -#endif /* _FILE_OFFSET_BITS == 32 */ - } - - return (0); -} - -#endif /* OPENSCAP_ENABLE_SHA1 */ diff --git a/src/OVAL/probes/crapi/sha1.h b/src/OVAL/probes/crapi/sha1.h deleted file mode 100644 index 282046c6a9..0000000000 --- a/src/OVAL/probes/crapi/sha1.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2010 Red Hat Inc., Durham, North Carolina. - * All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: - * "Daniel Kopecek" - */ -#pragma once -#ifndef CRAPI_SHA1_H -#define CRAPI_SHA1_H - -#include - -#ifdef OPENSCAP_ENABLE_SHA1 - -void *crapi_sha1_init (void *dst, void *size); -int crapi_sha1_update (void *ctxp, void *bptr, size_t blen); -int crapi_sha1_fini (void *ctxp); -void crapi_sha1_free (void *ctxp); - -int crapi_sha1_fd (int fd, void *dst, size_t *size); - -#endif /* OPENSCAP_ENABLE_SHA1 */ - -#endif /* CRAPI_SHA1_H */ diff --git a/src/OVAL/probes/crapi/sha2.c b/src/OVAL/probes/crapi/sha2.c deleted file mode 100644 index 21c22772ba..0000000000 --- a/src/OVAL/probes/crapi/sha2.c +++ /dev/null @@ -1,330 +0,0 @@ -/* - * Copyright 2010 Red Hat Inc., Durham, North Carolina. - * All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: - * "Daniel Kopecek" - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include - -#include "crapi.h" -#include "sha2.h" - -#if defined(HAVE_NSS3) -#include -#define CRAPI_ALGO_SHA224 HASH_AlgSHA224 -#define CRAPI_ALGO_SHA256 HASH_AlgSHA256 -#define CRAPI_ALGO_SHA384 HASH_AlgSHA384 -#define CRAPI_ALGO_SHA512 HASH_AlgSHA512 -#elif defined(HAVE_GCRYPT) -#include -#define CRAPI_ALGO_SHA224 GCRY_MD_SHA224 -#define CRAPI_ALGO_SHA256 GCRY_MD_SHA256 -#define CRAPI_ALGO_SHA384 GCRY_MD_SHA384 -#define CRAPI_ALGO_SHA512 GCRY_MD_SHA512 -#else -#error "No crypto library available!" -#endif - -static int crapi_sha2_fd (int algo, int fd, void *dst, size_t *size) -{ - struct stat st; - void *buffer; - size_t buflen; - - if (size == NULL || dst == NULL) { - errno = EFAULT; - return -1; - } -#if defined(HAVE_NSS3) - if (*size < HASH_ResultLen(algo)) { -#elif defined(HAVE_GCRYPT) - if (*size < gcry_md_get_algo_dlen(algo)) { -#endif - errno = ENOBUFS; - return -1; - } - - if (fstat (fd, &st) != 0) - return (-1); - else { -#if _FILE_OFFSET_BITS == 32 - buflen = st.st_size; -# if defined(OS_FREEBSD) - buffer = mmap (NULL, buflen, PROT_READ, MAP_SHARED | MAP_NOCORE, fd, 0); -# else - buffer = mmap (NULL, buflen, PROT_READ, MAP_SHARED, fd, 0); -# endif - if (buffer == NULL) { -#endif /* _FILE_OFFSET_BITS == 32 */ - uint8_t _buffer[CRAPI_IO_BUFSZ]; - ssize_t ret; - - buffer = _buffer; -#if defined(HAVE_NSS3) - HASHContext *ctx; - ctx = HASH_Create (algo); - - if (ctx == NULL) - return (-1); -#elif defined(HAVE_GCRYPT) - gcry_md_hd_t hd; - gcry_md_open (&hd, algo, 0); -#endif - - while ((ret = read (fd, buffer, sizeof _buffer)) == sizeof _buffer) -#if defined(HAVE_NSS3) - HASH_Update (ctx, (const unsigned char *)buffer, (unsigned int) sizeof _buffer); -#elif defined(HAVE_GCRYPT) - gcry_md_write (hd, (const void *)buffer, sizeof _buffer); -#endif - - switch (ret) { - case 0: - break; - case -1: - return (-1); - default: - if (ret <= 0) { -#if defined(HAVE_NSS3) - HASH_Destroy(ctx); -#elif defined(HAVE_GCRYPT) - gcry_md_close(hd); -#endif - return -1; - } -#if defined(HAVE_NSS3) - HASH_Update (ctx, (const unsigned char *)buffer, (unsigned int) ret); -#elif defined(HAVE_GCRYPT) - gcry_md_write (hd, (const void *)buffer, (size_t)ret); -#endif - } - -#if defined(HAVE_NSS3) - HASH_End (ctx, dst, (unsigned int *)size, *size); - HASH_Destroy (ctx); -#elif defined(HAVE_GCRYPT) - gcry_md_final (hd); - - buffer = (void *)gcry_md_read (hd, algo); - memcpy (dst, buffer, gcry_md_get_algo_dlen (algo)); - gcry_md_close (hd); -#endif -#if _FILE_OFFSET_BITS == 32 - } else { -#if defined(HAVE_NSS3) - HASH_HashBuf (algo, (unsigned char *)dst, (unsigned char *)buffer, (unsigned int)buflen); -#elif defined(HAVE_GCRYPT) - gcry_md_hash_buffer (algo, dst, (const void *)buffer, buflen); -#endif - munmap (buffer, buflen); - } -#endif /* _FILE_OFFSET_BITS == 32 */ - } - return (0); -} - -struct crapi_sha2_ctx { -#if defined(HAVE_NSS3) - HASHContext *ctx; -#elif defined(HAVE_GCRYPT) - gcry_md_hd_t ctx; -#endif - void *dst; - size_t *size; -}; - -static void *crapi_sha2_init (void *dst, void *size, int alg) -{ - struct crapi_sha2_ctx *ctx = malloc(sizeof(struct crapi_sha2_ctx)); - -#if defined(HAVE_NSS3) - ctx->ctx = HASH_Create (alg); -#elif defined(HAVE_GCRYPT) - if (gcry_md_open (&ctx->ctx, alg, 0) != 0) { - free(ctx); - return NULL; - } -#endif - ctx->dst = dst; - ctx->size = size; - -#if defined(HAVE_NSS3) - if (ctx->ctx != NULL) { - HASH_Begin (ctx->ctx); - } else { - free (ctx); - ctx = NULL; - } -#endif - - return (ctx); -} - -static int crapi_sha2_update (void *ctxp, void *bptr, size_t blen) -{ - struct crapi_sha2_ctx *ctx = (struct crapi_sha2_ctx *)ctxp; - -#if defined(HAVE_NSS3) - HASH_Update (ctx->ctx, (const unsigned char *)bptr, (unsigned int)blen); -#elif defined(HAVE_GCRYPT) - gcry_md_write (ctx->ctx, (const void *)bptr, blen); -#endif - return (0); -} - -static int crapi_sha2_fini (void *ctxp, int alg) -{ - struct crapi_sha2_ctx *ctx = (struct crapi_sha2_ctx *)ctxp; - -#if defined(HAVE_NSS3) - HASH_End (ctx->ctx, ctx->dst, (unsigned int *)ctx->size, *ctx->size); - HASH_Destroy (ctx->ctx); -#elif defined(HAVE_GCRYPT) - void *buffer; - - gcry_md_final (ctx->ctx); - buffer = (void *)gcry_md_read (ctx->ctx, alg); - memcpy (ctx->dst, buffer, gcry_md_get_algo_dlen (alg)); - gcry_md_close (ctx->ctx); -#endif - free (ctx); - - return (0); -} - -static void crapi_sha2_free (void *ctxp) -{ -#if defined(HAVE_NSS3) - struct crapi_sha2_ctx *ctx = (struct crapi_sha2_ctx *)ctxp; - - HASH_Destroy (ctx->ctx); - free (ctx); -#endif - - return; -} - -void *crapi_sha224_init (void *dst, void *size) -{ - return crapi_sha2_init(dst, size, CRAPI_ALGO_SHA224); -} - -int crapi_sha224_update (void *ctxp, void *bptr, size_t blen) -{ - return crapi_sha2_update(ctxp, bptr, blen); -} - -int crapi_sha224_fini (void *ctxp) -{ - return crapi_sha2_fini(ctxp, CRAPI_ALGO_SHA224); -} - -void crapi_sha224_free (void *ctxp) -{ - crapi_sha2_free(ctxp); -} - -int crapi_sha224_fd (int fd, void *dst, size_t *size) -{ - return crapi_sha2_fd (CRAPI_ALGO_SHA224, fd, dst, size); -} - -void *crapi_sha256_init (void *dst, void *size) -{ - return crapi_sha2_init(dst, size, CRAPI_ALGO_SHA256); -} - -int crapi_sha256_update (void *ctxp, void *bptr, size_t blen) -{ - return crapi_sha2_update(ctxp, bptr, blen); -} - -int crapi_sha256_fini (void *ctxp) -{ - return crapi_sha2_fini(ctxp, CRAPI_ALGO_SHA256); -} - -void crapi_sha256_free (void *ctxp) -{ - crapi_sha2_free(ctxp); -} - -int crapi_sha256_fd (int fd, void *dst, size_t *size) -{ - return crapi_sha2_fd (CRAPI_ALGO_SHA256, fd, dst, size); -} - -void *crapi_sha384_init (void *dst, void *size) -{ - return crapi_sha2_init(dst, size, CRAPI_ALGO_SHA384); -} - -int crapi_sha384_update (void *ctxp, void *bptr, size_t blen) -{ - return crapi_sha2_update(ctxp, bptr, blen); -} - -int crapi_sha384_fini (void *ctxp) -{ - return crapi_sha2_fini(ctxp, CRAPI_ALGO_SHA384); -} - -void crapi_sha384_free (void *ctxp) -{ - crapi_sha2_free(ctxp); -} - -int crapi_sha384_fd (int fd, void *dst, size_t *size) -{ - return crapi_sha2_fd (CRAPI_ALGO_SHA384, fd, dst, size); -} - -void *crapi_sha512_init (void *dst, void *size) -{ - return crapi_sha2_init(dst, size, CRAPI_ALGO_SHA512); -} - -int crapi_sha512_update (void *ctxp, void *bptr, size_t blen) -{ - return crapi_sha2_update(ctxp, bptr, blen); -} - -int crapi_sha512_fini (void *ctxp) -{ - return crapi_sha2_fini(ctxp, CRAPI_ALGO_SHA512); -} - -void crapi_sha512_free (void *ctxp) -{ - crapi_sha2_free(ctxp); -} - -int crapi_sha512_fd (int fd, void *dst, size_t *size) -{ - return crapi_sha2_fd (CRAPI_ALGO_SHA512, fd, dst, size); -} diff --git a/src/OVAL/probes/crapi/sha2.h b/src/OVAL/probes/crapi/sha2.h deleted file mode 100644 index d47e3e95d7..0000000000 --- a/src/OVAL/probes/crapi/sha2.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2010 Red Hat Inc., Durham, North Carolina. - * All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: - * "Daniel Kopecek" - */ -#pragma once -#ifndef CRAPI_SHA2_H -#define CRAPI_SHA2_H - -#include - -void *crapi_sha224_init (void *dst, void *size); -int crapi_sha224_update (void *ctxp, void *bptr, size_t blen); -int crapi_sha224_fini (void *ctxp); -void crapi_sha224_free (void *ctxp); - -int crapi_sha224_fd (int fd, void *dst, size_t *size); - -void *crapi_sha256_init (void *dst, void *size); -int crapi_sha256_update (void *ctxp, void *bptr, size_t blen); -int crapi_sha256_fini (void *ctxp); -void crapi_sha256_free (void *ctxp); - -int crapi_sha256_fd (int fd, void *dst, size_t *size); - -void *crapi_sha384_init (void *dst, void *size); -int crapi_sha384_update (void *ctxp, void *bptr, size_t blen); -int crapi_sha384_fini (void *ctxp); -void crapi_sha384_free (void *ctxp); - -int crapi_sha384_fd (int fd, void *dst, size_t *size); - -void *crapi_sha512_init (void *dst, void *size); -int crapi_sha512_update (void *ctxp, void *bptr, size_t blen); -int crapi_sha512_fini (void *ctxp); -void crapi_sha512_free (void *ctxp); - -int crapi_sha512_fd (int fd, void *dst, size_t *size); - -#endif /* CRAPI_SHA2_H */