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

Header for crypto_pwbox.c. More...

#include "lib/cc/torint.h"

Go to the source code of this file.

Macros

#define UNPWBOX_OKAY   0
 
#define UNPWBOX_BAD_SECRET   -1
 
#define UNPWBOX_CORRUPTED   -2
 

Functions

int crypto_pwbox (uint8_t **out, size_t *outlen_out, const uint8_t *inp, size_t input_len, const char *secret, size_t secret_len, unsigned s2k_flags)
 
int crypto_unpwbox (uint8_t **out, size_t *outlen_out, const uint8_t *inp, size_t input_len, const char *secret, size_t secret_len)
 

Detailed Description

Header for crypto_pwbox.c.

Definition in file crypto_pwbox.h.

Function Documentation

◆ crypto_pwbox()

int crypto_pwbox ( uint8_t **  out,
size_t *  outlen_out,
const uint8_t *  input,
size_t  input_len,
const char *  secret,
size_t  secret_len,
unsigned  s2k_flags 
)

Make an authenticated passphrase-encrypted blob to encode the input_len bytes in input using the passphrase secret of secret_len bytes. Allocate a new chunk of memory to hold the encrypted data, and store a pointer to that memory in *out, and its size in outlen_out. Use s2k_flags as an argument to the passphrase-hashing function.

Definition at line 47 of file crypto_pwbox.c.

◆ crypto_unpwbox()

int crypto_unpwbox ( uint8_t **  out,
size_t *  outlen_out,
const uint8_t *  inp,
size_t  input_len,
const char *  secret,
size_t  secret_len 
)

Try to decrypt the passphrase-encrypted blob of input_len bytes in input using the passphrase secret of secret_len bytes. On success, return 0 and allocate a new chunk of memory to hold the decrypted data, and store a pointer to that memory in *out, and its size in outlen_out. On failure, return UNPWBOX_BAD_SECRET if the passphrase might have been wrong, and UNPWBOX_CORRUPT if the object is definitely corrupt.

Definition at line 153 of file crypto_pwbox.c.