Skip to content

Commit

Permalink
reorg c level files
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Jan 21, 2024
1 parent e6f1f91 commit 6092cae
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 23 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Description: SHA-3 cryptographic hash and SHAKE256 extendable-output functions
(XOF). 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>. Fast and memory-efficient implementation using
the core algorithm from the 'Mbed TLS' library under the Trusted Firmware
Project <https://www.trustedfirmware.org/projects/mbed-tls/>.
the core algorithm from 'Mbed TLS' under the Trusted Firmware Project
<https://www.trustedfirmware.org/projects/mbed-tls/>.
Authors@R:
c(person(given = "Charlie",
family = "Gao",
Expand Down
4 changes: 2 additions & 2 deletions R/base.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#' secretbase: Cryptographic Hash and Extendable-Output Functions
#'
#' SHA-3 cryptographic hash and SHAKE256 extendable-output functions (XOF). Fast
#' and memory-efficient implementation using the core algorithm from the
#' 'Mbed TLS' library under the Trusted Firmware Project
#' and memory-efficient implementation using the core algorithm from 'Mbed
#' TLS' under the Trusted Firmware Project
#' <https://www.trustedfirmware.org/projects/mbed-tls/>. The SHA-3
#' cryptographic hash functions are SHA3-224, SHA3-256, SHA3-384 and
#' SHA3-512, each an instance of the Keccak algorithm. SHAKE256 is one of
Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SHA-3 cryptographic hash and SHAKE256 extendable-output functions (XOF).

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).

Fast and memory-efficient implementation using the core algorithm from the 'Mbed TLS' library under the Trusted Firmware Project <https://www.trustedfirmware.org/projects/mbed-tls/>.
Fast and memory-efficient implementation using the core algorithm from 'Mbed TLS' under the Trusted Firmware Project <https://www.trustedfirmware.org/projects/mbed-tls/>.

### Installation

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ of Standards and Technology (NIST) in 2015 at
[doi:10.6028/NIST.FIPS.202](https://dx.doi.org/10.6028/NIST.FIPS.202).

Fast and memory-efficient implementation using the core algorithm from
the ‘Mbed TLS’ library under the Trusted Firmware Project
‘Mbed TLS’ under the Trusted Firmware Project
<https://www.trustedfirmware.org/projects/mbed-tls/>.

### Installation
Expand Down
4 changes: 2 additions & 2 deletions man/secretbase-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions src/init.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (C) 2024 Hibiki AI Limited <[email protected]>
//
// This file is part of secretbase.
//
// secretbase 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 of the License, or (at your option) any later
// version.
//
// secretbase 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
// secretbase. If not, see <https://www.gnu.org/licenses/>.

// secretbase - package level registrations ------------------------------------

#include "secret.h"

static const R_CallMethodDef callMethods[] = {
{"secretbase_sha3", (DL_FUNC) &secretbase_sha3, 3},
{NULL, NULL, 0}
};

void attribute_visible R_init_secretbase(DllInfo* dll) {
R_registerRoutines(dll, NULL, callMethods, NULL, NULL);
R_useDynamicSymbols(dll, FALSE);
R_forceSymbols(dll, TRUE);
}
17 changes: 2 additions & 15 deletions src/secret.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ static int mbedtls_sha3_finish(mbedtls_sha3_context *ctx,

}

// secretbase - internal R binding functions -----------------------------------
// secretbase - internal auxiliary functions -----------------------------------

static void hash_bytes(R_outpstream_t stream, void *src, int len) {

Expand Down Expand Up @@ -259,7 +259,7 @@ static SEXP nano_hash_char(unsigned char *buf, const size_t sz) {

}

// secretbase - public functions -----------------------------------------------
// secretbase - exported functions ---------------------------------------------

SEXP secretbase_sha3(SEXP x, SEXP size, SEXP convert) {

Expand Down Expand Up @@ -353,16 +353,3 @@ SEXP secretbase_sha3(SEXP x, SEXP size, SEXP convert) {
Rf_error("hashing encountered error");

}

// secretbase - package level registrations ------------------------------------

static const R_CallMethodDef callMethods[] = {
{"secretbase_sha3", (DL_FUNC) &secretbase_sha3, 3},
{NULL, NULL, 0}
};

void attribute_visible R_init_secretbase(DllInfo* dll) {
R_registerRoutines(dll, NULL, callMethods, NULL, NULL);
R_useDynamicSymbols(dll, FALSE);
R_forceSymbols(dll, TRUE);
}
2 changes: 2 additions & 0 deletions src/secret.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,6 @@ typedef struct secretbase_context_s {
int skip;
} secretbase_context;

SEXP secretbase_sha3(SEXP, SEXP, SEXP);

#endif

0 comments on commit 6092cae

Please sign in to comment.