tor  master
Macros | Functions
crypto_pwbox.c File Reference

Code for encrypting secrets in a password-protected form and saving them to disk. More...

#include "crypto.h"
#include "crypto_digest.h"
#include "crypto_pwbox.h"
#include "crypto_rand.h"
#include "crypto_s2k.h"
#include "crypto_util.h"
#include "di_ops.h"
#include "util.h"
#include "pwbox.h"
Include dependency graph for crypto_pwbox.c:

Macros

#define MAX_OVERHEAD   (S2K_MAXLEN + 8 + 1 + 32 + CIPHER_IV_LEN)
 

Functions

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)
 
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

Code for encrypting secrets in a password-protected form and saving them to disk.

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.

◆ 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.

Here is the call graph for this function: