Tor  0.4.7.0-alpha-dev
Macros | Functions
crypto_ope.h File Reference

header for crypto_ope.c More...

#include "orconfig.h"
#include "lib/cc/torint.h"
#include "lib/crypt_ops/crypto_ope.h"
#include "lib/testsupport/testsupport.h"

Go to the source code of this file.

Macros

#define OPE_KEY_LEN   32
 
#define OPE_INPUT_MAX   (1<<18)
 
#define CRYPTO_OPE_ERROR   UINT64_MAX
 
#define crypto_ope_free(ope)    FREE_AND_NULL(crypto_ope_t, crypto_ope_free_, (ope))
 

Functions

crypto_ope_tcrypto_ope_new (const uint8_t *key)
 
void crypto_ope_free_ (crypto_ope_t *ope)
 
uint64_t crypto_ope_encrypt (const crypto_ope_t *ope, int plaintext)
 

Detailed Description

header for crypto_ope.c

Definition in file crypto_ope.h.

Macro Definition Documentation

◆ OPE_INPUT_MAX

#define OPE_INPUT_MAX   (1<<18)

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.

Definition at line 31 of file crypto_ope.h.

◆ OPE_KEY_LEN

#define OPE_KEY_LEN   32

Length of OPE key, in bytes.

Definition at line 18 of file crypto_ope.h.

Function Documentation

◆ crypto_ope_encrypt()

uint64_t crypto_ope_encrypt ( const crypto_ope_t ope,
int  plaintext 
)

Return the encrypted value corresponding to input. The input value must be in range 1..OPE_INPUT_MAX. Returns CRYPTO_OPE_ERROR on an invalid input.

NOTE: this function is not constant-time.

Definition at line 165 of file crypto_ope.c.

◆ crypto_ope_free_()

void crypto_ope_free_ ( crypto_ope_t ope)

Free all storage held in ope.

Definition at line 149 of file crypto_ope.c.

◆ crypto_ope_new()

crypto_ope_t* crypto_ope_new ( const uint8_t *  key)

Return a new crypto_ope_t object, using the provided 256-bit key.

Definition at line 129 of file crypto_ope.c.