-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a5a217
commit b921b7e
Showing
5 changed files
with
15 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (C) 2024 Hibiki AI Limited <[email protected]> | ||
// Copyright (C) 2024-2025 Hibiki AI Limited <[email protected]> | ||
// | ||
// This file is part of secretbase. | ||
// | ||
|
@@ -338,7 +338,7 @@ static nano_buf sb_any_buf(const SEXP x) { | |
switch (TYPEOF(x)) { | ||
case STRSXP: | ||
if (XLENGTH(x) == 1 && !ANY_ATTRIB(x)) { | ||
const char *s = SB_STRING(x); | ||
const char *s = CHAR(*STRING_PTR_RO(x)); | ||
NANO_INIT(&buf, (unsigned char *) s, strlen(s)); | ||
break; | ||
} | ||
|
@@ -398,7 +398,7 @@ SEXP secretbase_base64dec(SEXP x, SEXP convert) { | |
|
||
switch (TYPEOF(x)) { | ||
case STRSXP: ; | ||
const char *str = SB_STRING(x); | ||
const char *str = CHAR(*STRING_PTR_RO(x)); | ||
inbuf = (unsigned char *) str; | ||
inlen = strlen(str); | ||
break; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (C) 2024 Hibiki AI Limited <[email protected]> | ||
// Copyright (C) 2024-2025 Hibiki AI Limited <[email protected]> | ||
// | ||
// This file is part of secretbase. | ||
// | ||
|
@@ -250,7 +250,7 @@ static inline void hash_bytes(R_outpstream_t stream, void *src, int len) { | |
static void hash_file(mbedtls_sha3_context *ctx, const SEXP x) { | ||
|
||
SB_ASSERT_STR(x); | ||
const char *file = R_ExpandFileName(SB_STRING(x)); | ||
const char *file = R_ExpandFileName(CHAR(*STRING_PTR_RO(x))); | ||
unsigned char buf[SB_BUF_SIZE]; | ||
FILE *f; | ||
size_t cur; | ||
|
@@ -277,7 +277,7 @@ static void hash_object(mbedtls_sha3_context *ctx, const SEXP x) { | |
switch (TYPEOF(x)) { | ||
case STRSXP: | ||
if (XLENGTH(x) == 1 && !ANY_ATTRIB(x)) { | ||
const char *s = SB_STRING(x); | ||
const char *s = CHAR(*STRING_PTR_RO(x)); | ||
mbedtls_sha3_update(ctx, (uint8_t *) s, strlen(s)); | ||
return; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (C) 2024 Hibiki AI Limited <[email protected]> | ||
// Copyright (C) 2024-2025 Hibiki AI Limited <[email protected]> | ||
// | ||
// This file is part of secretbase. | ||
// | ||
|
@@ -104,7 +104,6 @@ typedef struct nano_buf_s { | |
#define ANY_ATTRIB(x) (ATTRIB(x) != R_NilValue) | ||
#endif | ||
#define SB_DATAPTR(x) (void *) DATAPTR_RO(x) | ||
#define SB_STRING(x) CHAR(*((const SEXP *) DATAPTR_RO(x))) | ||
#define SB_LOGICAL(x) *(int *) DATAPTR_RO(x) | ||
#define SB_ASSERT_LOGICAL(x) if (TYPEOF(x) != LGLSXP) \ | ||
Rf_error("'convert' must be a logical value") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (C) 2024 Hibiki AI Limited <[email protected]> | ||
// Copyright (C) 2024-2025 Hibiki AI Limited <[email protected]> | ||
// | ||
// This file is part of secretbase. | ||
// | ||
|
@@ -385,7 +385,7 @@ static inline void hash_bytes(R_outpstream_t stream, void *src, int len) { | |
static void hash_file(mbedtls_sha256_context *ctx, const SEXP x) { | ||
|
||
SB_ASSERT_STR(x); | ||
const char *file = R_ExpandFileName(SB_STRING(x)); | ||
const char *file = R_ExpandFileName(CHAR(*STRING_PTR_RO(x))); | ||
unsigned char buf[SB_BUF_SIZE]; | ||
FILE *f; | ||
size_t cur; | ||
|
@@ -412,7 +412,7 @@ static void hash_object(mbedtls_sha256_context *ctx, const SEXP x) { | |
switch (TYPEOF(x)) { | ||
case STRSXP: | ||
if (XLENGTH(x) == 1 && !ANY_ATTRIB(x)) { | ||
const char *s = SB_STRING(x); | ||
const char *s = CHAR(*STRING_PTR_RO(x)); | ||
mbedtls_sha256_update(ctx, (uint8_t *) s, strlen(s)); | ||
return; | ||
} | ||
|
@@ -470,7 +470,7 @@ static SEXP secretbase_sha256_impl(const SEXP x, const SEXP key, const SEXP conv | |
|
||
switch (TYPEOF(key)) { | ||
case STRSXP: | ||
data = (unsigned char *) (XLENGTH(key) ? SB_STRING(key) : ""); | ||
data = (unsigned char *) (XLENGTH(key) ? CHAR(*STRING_PTR_RO(key)) : ""); | ||
klen = strlen((char *) data); | ||
break; | ||
case RAWSXP: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (C) 2024 Hibiki AI Limited <[email protected]> | ||
// Copyright (C) 2024-2025 Hibiki AI Limited <[email protected]> | ||
// | ||
// This file is part of secretbase. | ||
// | ||
|
@@ -192,7 +192,7 @@ static inline void hash_bytes(R_outpstream_t stream, void *src, int len) { | |
static void hash_file(CSipHash *ctx, const SEXP x) { | ||
|
||
SB_ASSERT_STR(x); | ||
const char *file = R_ExpandFileName(SB_STRING(x)); | ||
const char *file = R_ExpandFileName(CHAR(*STRING_PTR_RO(x))); | ||
unsigned char buf[SB_BUF_SIZE]; | ||
FILE *f; | ||
size_t cur; | ||
|
@@ -217,7 +217,7 @@ static void hash_object(CSipHash *ctx, const SEXP x) { | |
switch (TYPEOF(x)) { | ||
case STRSXP: | ||
if (XLENGTH(x) == 1 && !ANY_ATTRIB(x)) { | ||
const char *s = SB_STRING(x); | ||
const char *s = CHAR(*STRING_PTR_RO(x)); | ||
c_siphash_append(ctx, (uint8_t *) s, strlen(s)); | ||
return; | ||
} | ||
|
@@ -266,7 +266,7 @@ static SEXP secretbase_siphash_impl(const SEXP x, const SEXP key, const SEXP con | |
size_t klen; | ||
switch (TYPEOF(key)) { | ||
case STRSXP: | ||
data = (unsigned char *) (XLENGTH(key) ? SB_STRING(key) : ""); | ||
data = (unsigned char *) (XLENGTH(key) ? CHAR(*STRING_PTR_RO(key)) : ""); | ||
klen = strlen((char *) data); | ||
break; | ||
case RAWSXP: | ||
|