diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-07-17 16:19:32 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-07-17 16:19:32 -0400 |
commit | e2b744ce38edb8901cff3288634c4ebb5b4568b9 (patch) | |
tree | 9af8bf64a8ed5412ea7b55bd08f3e390867ce770 /src/lib/crypt_ops/crypto_ope.h | |
parent | 12afdcc15a8429bcc50d9287321849b6fa924c2f (diff) | |
parent | 14b507e5207ce7e581c5fc773921f8cf65d08247 (diff) | |
download | tor-e2b744ce38edb8901cff3288634c4ebb5b4568b9.tar.gz tor-e2b744ce38edb8901cff3288634c4ebb5b4568b9.zip |
Merge branch 'bug25552_ope_squashed'
Diffstat (limited to 'src/lib/crypt_ops/crypto_ope.h')
-rw-r--r-- | src/lib/crypt_ops/crypto_ope.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/lib/crypt_ops/crypto_ope.h b/src/lib/crypt_ops/crypto_ope.h new file mode 100644 index 0000000000..c62ed2a942 --- /dev/null +++ b/src/lib/crypt_ops/crypto_ope.h @@ -0,0 +1,46 @@ +/* Copyright (c) 2018, The Tor Project, Inc. */ +/* See LICENSE for licensing information */ + +#ifndef CRYPTO_OPE_H +#define CRYPTO_OPE_H + +#include "orconfig.h" +#include "lib/cc/torint.h" +#include "lib/crypt_ops/crypto_ope.h" +#include "lib/testsupport/testsupport.h" + +/** Length of OPE key, in bytes. */ +#define OPE_KEY_LEN 32 + +/** Largest value that can be passed to crypto_ope_encrypt(). + * + * Expressed as 2^18 because the OPE system prefers powers of two. + * + * The current max value stands for about 70 hours. The rationale here is as + * follows: The rev counter is the time of seconds since the start of an SRV + * period. SRVs are useful for about 48 hours (that's how long they stick + * around on the consensus). Let's also add 12 hours of drift for clock skewed + * services that might be using an old consensus and we arrive to 60 + * hours. The max value should be beyond that. + */ +#define OPE_INPUT_MAX (1<<18) + +#define CRYPTO_OPE_ERROR UINT64_MAX + +typedef struct crypto_ope_t crypto_ope_t; + +crypto_ope_t *crypto_ope_new(const uint8_t *key); +void crypto_ope_free_(crypto_ope_t *ope); +#define crypto_ope_free(ope) \ + FREE_AND_NULL(crypto_ope_t, crypto_ope_free_, (ope)) + +uint64_t crypto_ope_encrypt(const crypto_ope_t *ope, int plaintext); + +#ifdef CRYPTO_OPE_PRIVATE +struct aes_cnt_cipher; +STATIC struct aes_cnt_cipher *ope_get_cipher(const crypto_ope_t *ope, + uint32_t initial_idx); +STATIC uint64_t sum_values_from_cipher(struct aes_cnt_cipher *c, size_t n); +#endif + +#endif |