From 6a631c8b244e148dc261d4d59a10d49b470663ab Mon Sep 17 00:00:00 2001 From: shikokuchuo <53399081+shikokuchuo@users.noreply.github.com> Date: Wed, 24 Apr 2024 19:18:30 +0100 Subject: [PATCH] avoid STDVEC_DATAPTR --- README.Rmd | 4 ++-- README.md | 8 +++++--- src/secret.c | 6 +++--- src/secret2.c | 4 ++-- src/secret3.c | 4 ++-- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/README.Rmd b/README.Rmd index 304476e..df5a052 100644 --- a/README.Rmd +++ b/README.Rmd @@ -27,9 +27,9 @@ Fast and memory-efficient streaming hash functions. Performs direct hashing of s Implementations include the SHA-256, SHA-3 and Keccak cryptographic hash functions, SHAKE256 extendable-output function (XOF), and 'SipHash' pseudo-random function. -The SHA-3 Secure Hash Standard was published by the National Institute of Standards and Technology (NIST) in 2015 at [doi:10.6028/NIST.FIPS.202](https://dx.doi.org/10.6028/NIST.FIPS.202). The SHA-256 Secure Hash Standard was published by NIST in 2002 at . The SipHash family of pseudo-random functions by Jean-Philippe Aumasson and Daniel J. Bernstein was published in 2012 at .[1] +The SHA-3 Secure Hash Standard was published by the National Institute of Standards and Technology (NIST) in 2015 at [doi:10.6028/NIST.FIPS.202](https://dx.doi.org/10.6028/NIST.FIPS.202). SHA-3 is based on the Keccak algorithm, designed by G. Bertoni, J. Daemen, M. Peeters and G. Van Assche. The SHA-256 Secure Hash Standard was published by NIST in 2002 at . The SipHash family of pseudo-random functions by Jean-Philippe Aumasson and Daniel J. Bernstein was published in 2012 at .[1] -The SHA-256 and SHA-3 implementations are based on those by the 'Mbed TLS' Trusted Firmware Project at . The SipHash implementation is based on that of Daniele Nicolodi, David Rheinsberg and Tom Gundersen at , which is in turn based on the reference implementation by Jean-Philippe Aumasson and Daniel J. Bernstein released to the public domain at . +The SHA-256, SHA-3 and Keccak implementations are based on those by the 'Mbed TLS' Trusted Firmware Project at . The SipHash implementation is based on that of Daniele Nicolodi, David Rheinsberg and Tom Gundersen at , which is in turn based on the reference implementation by Jean-Philippe Aumasson and Daniel J. Bernstein released to the public domain at . ### Installation diff --git a/README.md b/README.md index a846dc1..8257875 100644 --- a/README.md +++ b/README.md @@ -26,14 +26,16 @@ pseudo-random function. The SHA-3 Secure Hash Standard was published by the National Institute of Standards and Technology (NIST) in 2015 at [doi:10.6028/NIST.FIPS.202](https://dx.doi.org/10.6028/NIST.FIPS.202). -The SHA-256 Secure Hash Standard was published by NIST in 2002 at +SHA-3 is based on the Keccak algorithm, designed by G. Bertoni, J. +Daemen, M. Peeters and G. Van Assche. The SHA-256 Secure Hash Standard +was published by NIST in 2002 at . The SipHash family of pseudo-random functions by Jean-Philippe Aumasson and Daniel J. Bernstein was published in 2012 at .\[1\] -The SHA-256 and SHA-3 implementations are based on those by the ‘Mbed -TLS’ Trusted Firmware Project at +The SHA-256, SHA-3 and Keccak implementations are based on those by the +‘Mbed TLS’ Trusted Firmware Project at . The SipHash implementation is based on that of Daniele Nicolodi, David Rheinsberg and Tom Gundersen at , which is in diff --git a/src/secret.c b/src/secret.c index 510b7ab..dee088b 100644 --- a/src/secret.c +++ b/src/secret.c @@ -271,7 +271,7 @@ static void hash_object(mbedtls_sha3_context *ctx, const SEXP x) { break; case RAWSXP: if (ATTRIB(x) == R_NilValue) { - mbedtls_sha3_update(ctx, (uint8_t *) STDVEC_DATAPTR(x), (size_t) XLENGTH(x)); + mbedtls_sha3_update(ctx, (uint8_t *) DATAPTR_RO(x), (size_t) XLENGTH(x)); return; } break; @@ -301,7 +301,7 @@ SEXP hash_to_sexp(unsigned char *buf, size_t sz, int conv) { SEXP out; if (conv == 0) { out = Rf_allocVector(RAWSXP, sz); - memcpy(STDVEC_DATAPTR(out), buf, sz); + memcpy(DATAPTR(out), buf, sz); } else if (conv == 1) { char cbuf[sz + sz + 1]; char *cptr = cbuf; @@ -312,7 +312,7 @@ SEXP hash_to_sexp(unsigned char *buf, size_t sz, int conv) { UNPROTECT(1); } else { out = Rf_allocVector(INTSXP, sz / sizeof(int)); - memcpy(STDVEC_DATAPTR(out), buf, sz); + memcpy(DATAPTR(out), buf, sz); } return out; diff --git a/src/secret2.c b/src/secret2.c index 82d4bfd..bdcca3d 100644 --- a/src/secret2.c +++ b/src/secret2.c @@ -422,7 +422,7 @@ static void hash_object(mbedtls_sha256_context *ctx, const SEXP x) { break; case RAWSXP: if (ATTRIB(x) == R_NilValue) { - mbedtls_sha256_update(ctx, (uint8_t *) STDVEC_DATAPTR(x), (size_t) XLENGTH(x)); + mbedtls_sha256_update(ctx, (uint8_t *) DATAPTR_RO(x), (size_t) XLENGTH(x)); return; } break; @@ -476,7 +476,7 @@ static SEXP secretbase_sha256_impl(const SEXP x, SEXP key, const SEXP convert, klen = strlen((char *) data); break; case RAWSXP: - data = (unsigned char *) STDVEC_DATAPTR(key); + data = (unsigned char *) DATAPTR_RO(key); klen = XLENGTH(key); break; default: diff --git a/src/secret3.c b/src/secret3.c index a534102..212a52d 100644 --- a/src/secret3.c +++ b/src/secret3.c @@ -225,7 +225,7 @@ static void hash_object(CSipHash *ctx, const SEXP x) { break; case RAWSXP: if (ATTRIB(x) == R_NilValue) { - c_siphash_append(ctx, (uint8_t *) STDVEC_DATAPTR(x), (size_t) XLENGTH(x)); + c_siphash_append(ctx, (uint8_t *) DATAPTR_RO(x), (size_t) XLENGTH(x)); return; } break; @@ -270,7 +270,7 @@ static SEXP secretbase_siphash_impl(const SEXP x, const SEXP key, const SEXP con klen = strlen((char *) data); break; case RAWSXP: - data = (unsigned char *) STDVEC_DATAPTR(key); + data = (unsigned char *) DATAPTR_RO(key); klen = XLENGTH(key); break; default: