From 9df41fc2bee63dc6331cb09e9ecd5e5d34b17d2a Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Sat, 1 Mar 2025 17:57:38 +0100 Subject: [PATCH] pcrypto more consistency --- pclsync/pcrypto.c | 4 ++-- pclsync/pcrypto.h | 4 ++-- pclsync/pfscrypto.c | 12 ++++++------ pclsync/ppagecache.c | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pclsync/pcrypto.c b/pclsync/pcrypto.c index 8f45a9c..3529667 100644 --- a/pclsync/pcrypto.c +++ b/pclsync/pcrypto.c @@ -567,7 +567,7 @@ void pcrypto_encode_sec( } } -int pcrypto_decode_sector( +int pcrypto_decode_sec( pcrypto_sector_encdec_t enc, const unsigned char *data, size_t datalen, unsigned char *out, const pcrypto_sector_auth_t auth, uint64_t sectorid) { @@ -649,7 +649,7 @@ int pcrypto_decode_sector( PSYNC_AES256_BLOCK_SIZE); } -void pcrypto_sign_sector( +void pcrypto_sign_sec( pcrypto_sector_encdec_t enc, const unsigned char *data, size_t datalen, pcrypto_sector_auth_t authout) { unsigned char buff[PSYNC_AES256_BLOCK_SIZE * 3 + PSYNC_SHA512_DIGEST_LEN]; diff --git a/pclsync/pcrypto.h b/pclsync/pcrypto.h index 23dbe2f..825cd77 100644 --- a/pclsync/pcrypto.h +++ b/pclsync/pcrypto.h @@ -86,7 +86,7 @@ typedef pcrypto_encdec_iv_t *pcrypto_sector_encdec_t; pcrypto_ctr_encdec_t pcrypto_ctr_encdec_create(psync_symmetric_key_t key); void pcrypto_ctr_encdec_decode(pcrypto_ctr_encdec_t enc, void *data, size_t datalen, uint64_t dataoffset); void pcrypto_ctr_encdec_free(pcrypto_ctr_encdec_t enc); -int pcrypto_decode_sector(pcrypto_sector_encdec_t enc, const unsigned char *data, size_t datalen, unsigned char *out, const pcrypto_sector_auth_t auth, uint64_t sectorid); +int pcrypto_decode_sec(pcrypto_sector_encdec_t enc, const unsigned char *data, size_t datalen, unsigned char *out, const pcrypto_sector_auth_t auth, uint64_t sectorid); unsigned char * pcrypto_decode_text(pcrypto_textdec_t enc, const unsigned char *data, size_t datalen); void pcrypto_encode_sec(pcrypto_sector_encdec_t enc, const unsigned char *data, size_t datalen, unsigned char *out, pcrypto_sector_auth_t authout, uint64_t sectorid); void pcrypto_encode_text(pcrypto_textenc_t enc, const unsigned char *txt, size_t txtlen, unsigned char **out, size_t *outlen); @@ -94,7 +94,7 @@ psync_symmetric_key_t pcrypto_key(); psync_symmetric_key_t pcrypto_key_len(size_t len); pcrypto_sector_encdec_t pcrypto_sec_encdec_create(psync_symmetric_key_t key); void pcrypto_sec_encdec_free(pcrypto_sector_encdec_t enc); -void pcrypto_sign_sector(pcrypto_sector_encdec_t enc, const unsigned char *data, size_t datalen, pcrypto_sector_auth_t authout); +void pcrypto_sign_sec(pcrypto_sector_encdec_t enc, const unsigned char *data, size_t datalen, pcrypto_sector_auth_t authout); pcrypto_textdec_t pcrypto_textdec_create(psync_symmetric_key_t key); void pcrypto_textdec_free(pcrypto_textdec_t enc); pcrypto_textenc_t pcrypto_textenc_create(psync_symmetric_key_t key); diff --git a/pclsync/pfscrypto.c b/pclsync/pfscrypto.c index 161f0c7..f04327c 100644 --- a/pclsync/pfscrypto.c +++ b/pclsync/pfscrypto.c @@ -251,7 +251,7 @@ static int psync_fs_crypto_read_newfile_full_sector_from_log( (unsigned)hdr.length, (int)rd); return -EIO; } - if (unlikely_log(pcrypto_decode_sector( + if (unlikely_log(pcrypto_decode_sec( of->encoder, buff, rd, (unsigned char *)buf, se->auth, se->sectorid))) return -EIO; else @@ -303,7 +303,7 @@ psync_fs_crypto_do_local_tree_check(psync_openfile_t *of, rd = pfile_pread(of->datafile, buff, ssize, off); if (unlikely_log(rd != ssize)) return -1; - pcrypto_sign_sector(of->encoder, buff, ssize, auth); + pcrypto_sign_sec(of->encoder, buff, ssize, auth); level = 0; while (level < offsets->treelevels) { level++; @@ -329,7 +329,7 @@ psync_fs_crypto_do_local_tree_check(psync_openfile_t *of, (unsigned)ssize, (unsigned)authoff); return -1; } - pcrypto_sign_sector(of->encoder, buff, ssize, auth); + pcrypto_sign_sec(of->encoder, buff, ssize, auth); } return 0; } @@ -423,7 +423,7 @@ static int psync_fs_crypto_read_newfile_full_sector_from_datafile( rd = pfile_pread(of->datafile, auth, sizeof(auth), off); if (unlikely_log(rd != sizeof(auth))) return -EIO; - if (unlikely_log(pcrypto_decode_sector( + if (unlikely_log(pcrypto_decode_sec( of->encoder, buff, ssize, (unsigned char *)buf, auth, sectorid))) return -EIO; #if defined(PSYNC_DO_LOCAL_FULL_TREE_CHECK) @@ -615,7 +615,7 @@ static int psync_fs_crypto_switch_sectors(psync_openfile_t *of, // debug(D_NOTICE, "writing level %u signatures to offset %I64u size // %u", level, hdr.offset, sz); hdr.length = sz; - pcrypto_sign_sector(of->encoder, + pcrypto_sign_sec(of->encoder, (unsigned char *)&autharr[level], sz, autharr[level + 1][oldsecn]); wrt = pfile_pwrite(of->logfile, &hdr, sizeof(hdr), of->logoffset); @@ -699,7 +699,7 @@ psync_fs_crypto_write_master_auth(psync_openfile_t *of, assert(offsets->lastauthsectorlen[offsets->treelevels - 1] > 0); assert(offsets->lastauthsectorlen[offsets->treelevels - 1] <= PSYNC_CRYPTO_SECTOR_SIZE); - pcrypto_sign_sector( + pcrypto_sign_sec( of->encoder, (unsigned char *)&autharr[offsets->treelevels - 1], offsets->lastauthsectorlen[offsets->treelevels - 1], data.auth); memset(&data.hdr, 0, sizeof(psync_crypto_log_header)); diff --git a/pclsync/ppagecache.c b/pclsync/ppagecache.c index 3f51636..fa1753f 100644 --- a/pclsync/ppagecache.c +++ b/pclsync/ppagecache.c @@ -2931,7 +2931,7 @@ int psync_pagecache_read_unmodified_encrypted_locked(psync_openfile_t *of, (unsigned long)ap->firstpageid, (unsigned long)ap->firstpageid + ap->size / PSYNC_CRYPTO_AUTH_SIZE, (int)offsets.treelevels); - pcrypto_sign_sector(of->encoder, (unsigned char *)ap->auth, + pcrypto_sign_sec(of->encoder, (unsigned char *)ap->auth, ap->size, sa); p = ap->parent; ap->parent = NULL; @@ -2951,7 +2951,7 @@ int psync_pagecache_read_unmodified_encrypted_locked(psync_openfile_t *of, ret = -EIO; } ap = p; - pcrypto_sign_sector(of->encoder, (unsigned char *)ap->auth, + pcrypto_sign_sec(of->encoder, (unsigned char *)ap->auth, ap->size, sa); p = ap->parent; } while (p); @@ -2975,7 +2975,7 @@ int psync_pagecache_read_unmodified_encrypted_locked(psync_openfile_t *of, if (!ret) { apageid = first_page_id + i - ap->firstpageid; assert(apageid >= 0 && apageid < PSYNC_CRYPTO_HASH_TREE_SECTORS); - if (pcrypto_decode_sector( + if (pcrypto_decode_sec( of->encoder, (unsigned char *)dp[i].buff, dp[i].pagesize, (unsigned char *)dp[i].buff, ap->auth[apageid], first_page_id + i)) {