mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-25 14:26:21 +00:00
Run make format on rebase
This commit is contained in:
@@ -41,7 +41,7 @@
|
||||
#include "omemo/omemo.h"
|
||||
#include "omemo/crypto.h"
|
||||
|
||||
#define AES256_GCM_TAG_LENGTH 16
|
||||
#define AES256_GCM_TAG_LENGTH 16
|
||||
#define AES256_GCM_BUFFER_SIZE 1024
|
||||
|
||||
int
|
||||
@@ -377,8 +377,10 @@ out:
|
||||
return res;
|
||||
}
|
||||
|
||||
int aes256gcm_crypt_file(FILE *in, FILE *out, off_t file_size,
|
||||
unsigned char key[], unsigned char nonce[], bool encrypt) {
|
||||
int
|
||||
aes256gcm_crypt_file(FILE* in, FILE* out, off_t file_size,
|
||||
unsigned char key[], unsigned char nonce[], bool encrypt)
|
||||
{
|
||||
|
||||
if (!gcry_control(GCRYCTL_INITIALIZATION_FINISHED_P)) {
|
||||
fputs("libgcrypt has not been initialized\n", stderr);
|
||||
@@ -393,7 +395,7 @@ int aes256gcm_crypt_file(FILE *in, FILE *out, off_t file_size,
|
||||
gcry_cipher_hd_t hd;
|
||||
|
||||
res = gcry_cipher_open(&hd, GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_GCM,
|
||||
GCRY_CIPHER_SECURE);
|
||||
GCRY_CIPHER_SECURE);
|
||||
if (res != GPG_ERR_NO_ERROR) {
|
||||
goto out;
|
||||
}
|
||||
@@ -463,18 +465,20 @@ out:
|
||||
return res;
|
||||
}
|
||||
|
||||
char *aes256gcm_create_secure_fragment(unsigned char *key, unsigned char *nonce) {
|
||||
char*
|
||||
aes256gcm_create_secure_fragment(unsigned char* key, unsigned char* nonce)
|
||||
{
|
||||
int key_size = AES256_GCM_KEY_LENGTH;
|
||||
int nonce_size = AES256_GCM_NONCE_LENGTH;
|
||||
|
||||
char *fragment = gcry_malloc_secure((nonce_size+key_size)*2+1);
|
||||
char* fragment = gcry_malloc_secure((nonce_size + key_size) * 2 + 1);
|
||||
|
||||
for (int i = 0; i < nonce_size; i++) {
|
||||
sprintf(&(fragment[i*2]), "%02x", nonce[i]);
|
||||
sprintf(&(fragment[i * 2]), "%02x", nonce[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < key_size; i++) {
|
||||
sprintf(&(fragment[(i+nonce_size)*2]), "%02x", key[i]);
|
||||
sprintf(&(fragment[(i + nonce_size) * 2]), "%02x", key[i]);
|
||||
}
|
||||
|
||||
return fragment;
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#define AES128_GCM_IV_LENGTH 12
|
||||
#define AES128_GCM_TAG_LENGTH 16
|
||||
|
||||
#define AES256_GCM_KEY_LENGTH 32
|
||||
#define AES256_GCM_KEY_LENGTH 32
|
||||
#define AES256_GCM_NONCE_LENGTH 12
|
||||
|
||||
int omemo_crypto_init(void);
|
||||
@@ -181,13 +181,13 @@ int aes128gcm_encrypt(unsigned char* ciphertext, size_t* ciphertext_len,
|
||||
const unsigned char* const plaintext, size_t plaintext_len,
|
||||
const unsigned char* const iv, const unsigned char* const key);
|
||||
|
||||
int aes128gcm_decrypt(unsigned char *plaintext,
|
||||
size_t *plaintext_len, const unsigned char *const ciphertext,
|
||||
size_t ciphertext_len, const unsigned char *const iv, size_t iv_len,
|
||||
const unsigned char *const key, const unsigned char *const tag);
|
||||
int aes128gcm_decrypt(unsigned char* plaintext,
|
||||
size_t* plaintext_len, const unsigned char* const ciphertext,
|
||||
size_t ciphertext_len, const unsigned char* const iv, size_t iv_len,
|
||||
const unsigned char* const key, const unsigned char* const tag);
|
||||
|
||||
int aes256gcm_crypt_file(FILE *in, FILE *out, off_t file_size,
|
||||
unsigned char key[], unsigned char nonce[], bool encrypt);
|
||||
int aes256gcm_crypt_file(FILE* in, FILE* out, off_t file_size,
|
||||
unsigned char key[], unsigned char nonce[], bool encrypt);
|
||||
|
||||
char *aes256gcm_create_secure_fragment(unsigned char *key,
|
||||
unsigned char *nonce);
|
||||
char* aes256gcm_create_secure_fragment(unsigned char* key,
|
||||
unsigned char* nonce);
|
||||
|
||||
@@ -1654,13 +1654,16 @@ _generate_signed_pre_key(void)
|
||||
SIGNAL_UNREF(signed_pre_key);
|
||||
}
|
||||
|
||||
|
||||
void omemo_free(void *a) {
|
||||
void
|
||||
omemo_free(void* a)
|
||||
{
|
||||
gcry_free(a);
|
||||
}
|
||||
|
||||
char *omemo_encrypt_file(FILE *in, FILE *out, off_t file_size, int *gcry_res) {
|
||||
unsigned char *key = gcry_random_bytes_secure(
|
||||
char*
|
||||
omemo_encrypt_file(FILE* in, FILE* out, off_t file_size, int* gcry_res)
|
||||
{
|
||||
unsigned char* key = gcry_random_bytes_secure(
|
||||
AES256_GCM_KEY_LENGTH,
|
||||
GCRY_VERY_STRONG_RANDOM);
|
||||
|
||||
@@ -1668,7 +1671,7 @@ char *omemo_encrypt_file(FILE *in, FILE *out, off_t file_size, int *gcry_res) {
|
||||
unsigned char nonce[AES256_GCM_NONCE_LENGTH];
|
||||
gcry_create_nonce(nonce, AES256_GCM_NONCE_LENGTH);
|
||||
|
||||
char *fragment = aes256gcm_create_secure_fragment(key, nonce);
|
||||
char* fragment = aes256gcm_create_secure_fragment(key, nonce);
|
||||
*gcry_res = aes256gcm_crypt_file(in, out, file_size, key, nonce, true);
|
||||
|
||||
if (*gcry_res != GPG_ERR_NO_ERROR) {
|
||||
|
||||
@@ -95,8 +95,8 @@ void omemo_start_muc_sessions(const char* const roomjid);
|
||||
void omemo_start_device_session(const char* const jid, uint32_t device_id, GList* prekeys, uint32_t signed_prekey_id, const unsigned char* const signed_prekey, size_t signed_prekey_len, const unsigned char* const signature, size_t signature_len, const unsigned char* const identity_key, size_t identity_key_len);
|
||||
|
||||
gboolean omemo_loaded(void);
|
||||
char * omemo_on_message_send(ProfWin *win, const char *const message, gboolean request_receipt, gboolean muc, const char *const replace_id);
|
||||
char * omemo_on_message_recv(const char *const from, uint32_t sid, const unsigned char *const iv, size_t iv_len, GList *keys, const unsigned char *const payload, size_t payload_len, gboolean muc, gboolean *trusted);
|
||||
char* omemo_on_message_send(ProfWin* win, const char* const message, gboolean request_receipt, gboolean muc, const char* const replace_id);
|
||||
char* omemo_on_message_recv(const char* const from, uint32_t sid, const unsigned char* const iv, size_t iv_len, GList* keys, const unsigned char* const payload, size_t payload_len, gboolean muc, gboolean* trusted);
|
||||
|
||||
char *omemo_encrypt_file(FILE *in, FILE *out, off_t file_size, int *gcry_res);
|
||||
void omemo_free(void *a);
|
||||
char* omemo_encrypt_file(FILE* in, FILE* out, off_t file_size, int* gcry_res);
|
||||
void omemo_free(void* a);
|
||||
|
||||
Reference in New Issue
Block a user