Tor
0.4.7.0-alpha-dev
|
Code for encrypting secrets in a password-protected form and saving them to disk. More...
#include <string.h>
#include "lib/arch/bytes.h"
#include "lib/crypt_ops/crypto_cipher.h"
#include "lib/crypt_ops/crypto_digest.h"
#include "lib/crypt_ops/crypto_pwbox.h"
#include "lib/crypt_ops/crypto_rand.h"
#include "lib/crypt_ops/crypto_s2k.h"
#include "lib/crypt_ops/crypto_util.h"
#include "lib/ctime/di_ops.h"
#include "lib/intmath/muldiv.h"
#include "trunnel/pwbox.h"
#include "lib/log/util_bug.h"
Go to the source code of this file.
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) |
Code for encrypting secrets in a password-protected form and saving them to disk.
Definition in file crypto_pwbox.c.
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.
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.