Tor  0.4.7.0-alpha-dev
Functions
crypto_format.h File Reference

Header for crypto_format.c. More...

#include "lib/testsupport/testsupport.h"
#include "lib/cc/torint.h"
#include "lib/defs/x25519_sizes.h"

Go to the source code of this file.

Functions

int crypto_write_tagged_contents_to_file (const char *fname, const char *typestring, const char *tag, const uint8_t *data, size_t datalen)
 
ssize_t crypto_read_tagged_contents_from_file (const char *fname, const char *typestring, char **tag_out, uint8_t *data_out, ssize_t data_out_len)
 
int ed25519_public_from_base64 (struct ed25519_public_key_t *pkey, const char *input)
 
void ed25519_public_to_base64 (char *output, const struct ed25519_public_key_t *pkey)
 
const char * ed25519_fmt (const struct ed25519_public_key_t *pkey)
 
int ed25519_signature_from_base64 (struct ed25519_signature_t *sig, const char *input)
 
void ed25519_signature_to_base64 (char *output, const struct ed25519_signature_t *sig)
 
void digest_to_base64 (char *d64, const char *digest)
 
int digest_from_base64 (char *digest, const char *d64)
 
void digest256_to_base64 (char *d64, const char *digest)
 
int digest256_from_base64 (char *digest, const char *d64)
 

Detailed Description

Header for crypto_format.c.

Definition in file crypto_format.h.

Function Documentation

◆ crypto_read_tagged_contents_from_file()

ssize_t crypto_read_tagged_contents_from_file ( const char *  fname,
const char *  typestring,
char **  tag_out,
uint8_t *  data_out,
ssize_t  data_out_len 
)

Read a tagged-data file from fname into the data_out_len-byte buffer in data_out. Check that the typestring matches typestring; store the tag into a newly allocated string in tag_out. Return -1 on failure, and the number of bytes of data on success. Preserves the errno from reading the file.

Definition at line 77 of file crypto_format.c.

Referenced by curve25519_keypair_read_from_file(), ed25519_pubkey_read_from_file(), and ed25519_seckey_read_from_file().

◆ crypto_write_tagged_contents_to_file()

int crypto_write_tagged_contents_to_file ( const char *  fname,
const char *  typestring,
const char *  tag,
const uint8_t *  data,
size_t  datalen 
)

Write the datalen bytes from data to the file named fname in the tagged-data format. This format contains a 32-byte header, followed by the data itself. The header is the NUL-padded string "== <b>typestring</b>: <b>tag</b> ==". The length of typestring and tag must therefore be no more than 24.

Definition at line 42 of file crypto_format.c.

◆ digest256_from_base64()

int digest256_from_base64 ( char *  digest,
const char *  d64 
)

Given a base64 encoded, nul-terminated digest in d64 (without trailing newline or = characters), decode it and store the result in the first DIGEST256_LEN bytes at digest.

Definition at line 320 of file crypto_format.c.

Referenced by curve25519_public_from_base64(), and ed25519_public_from_base64().

◆ digest256_to_base64()

void digest256_to_base64 ( char *  d64,
const char *  digest 
)

Base64 encode DIGEST256_LINE bytes from digest, remove the trailing = characters, and store the nul-terminated result in the first BASE64_DIGEST256_LEN+1 bytes of d64. Can not fail.

Definition at line 304 of file crypto_format.c.

Referenced by ed25519_public_to_base64(), and keypin_journal_append_entry().

◆ digest_from_base64()

int digest_from_base64 ( char *  digest,
const char *  d64 
)

Given a base64 encoded, nul-terminated digest in d64 (without trailing newline or = characters), decode it and store the result in the first DIGEST_LEN bytes at digest.

Definition at line 291 of file crypto_format.c.

◆ digest_to_base64()

void digest_to_base64 ( char *  d64,
const char *  digest 
)

Base64 encode DIGEST_LEN bytes from digest, remove the trailing = characters, and store the nul-terminated result in the first BASE64_DIGEST_LEN+1 bytes of d64. Can not fail.

Definition at line 275 of file crypto_format.c.

Referenced by keypin_journal_append_entry(), and service_desc_note_upload().

◆ ed25519_public_from_base64()

int ed25519_public_from_base64 ( ed25519_public_key_t pkey,
const char *  input 
)

Try to decode the string input into an ed25519 public key. On success, store the value in pkey and return 0. Otherwise return -1.

Definition at line 212 of file crypto_format.c.

Referenced by cache_lookup_v3_as_dir().

◆ ed25519_signature_from_base64()

int ed25519_signature_from_base64 ( ed25519_signature_t sig,
const char *  input 
)

Try to decode the string input into an ed25519 signature. On success, store the value in sig and return 0. Otherwise return -1.

Definition at line 255 of file crypto_format.c.