aboutsummaryrefslogtreecommitdiff
path: root/crypto.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto.c')
-rw-r--r--crypto.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/crypto.c b/crypto.c
index f819fda..4125f7b 100644
--- a/crypto.c
+++ b/crypto.c
@@ -524,7 +524,7 @@ hash_t u64_to_hash(uint64_t n)
/* simple XOR cipher, so encryption and decryption are symmetric */
hash_t crypt_secret(hash_t encrypted_secret,
- uint64_t file_idx, uint64_t file_counter,
+ uint64_t file_idx, uint64_t file_version,
const void *key, size_t keylen)
{
hash_t pad; /* key = encrypted_secret ^ pad */
@@ -535,7 +535,7 @@ hash_t crypt_secret(hash_t encrypted_secret,
/* potential endianness issue */
HMAC_Update(ctx, (const unsigned char*)&file_idx, sizeof(file_idx));
- HMAC_Update(ctx, (const unsigned char*)&file_counter, sizeof(file_counter));
+ HMAC_Update(ctx, (const unsigned char*)&file_version, sizeof(file_version));
HMAC_Final(ctx, pad.hash, NULL);
HMAC_CTX_free(ctx);
@@ -599,6 +599,19 @@ bool ack_verify(const struct tm_request *req,
return hash_equals(hmac, correct);
}
+void write_to_fd(void *userdata, const void *data, size_t len)
+{
+ int *fdptr = userdata;
+ write(*fdptr, data, len);
+}
+
+
+int read_from_fd(void *userdata, void *buf, size_t len)
+{
+ int *fdptr = userdata;
+ return read(*fdptr, buf, len);
+}
+
void crypto_test(void)
{
#if 1