c-libp2p/include/libp2p/crypto/aes.h

33 lines
1.2 KiB
C
Raw Permalink Normal View History

2017-03-02 21:14:52 +00:00
#pragma once
2017-03-07 00:03:04 +00:00
/**
* Generate a new AES key
* @param key where to store the 32 byte key
* @returns true(1) on success
*/
int libp2p_crypto_aes_key_generate(char* key);
2017-03-02 21:14:52 +00:00
/**
* Encrypt a block of text
2017-03-07 00:03:04 +00:00
* @param key the aes key (32 bytes)
* @param iv the random part of encryption (16 bytes)
* @param input the text to encrypt
* @param input_size the length of the array
* @param output where the output will be placed
* @param output_size the length of the memory allocated for output
* @returns true(1) on success, otherwise false(0)
*/
int libp2p_crypto_aes_encrypt(char* key, char* iv, char* input, size_t input_size, unsigned char** output, size_t* output_size);
/**
* Decrypt a block of text
* @param key the aes key (32 bytes)
* @param iv the random part of encryption (16 bytes)
2017-03-02 21:14:52 +00:00
* @param input the text to encrypt
* @param input_size the length of the array
* @param output where the output will be placed
* @param output_size the length of the memory allocated for output
* @returns true(1) on success, otherwise false(0)
*/
2017-03-07 00:03:04 +00:00
int libp2p_crypto_aes_decrypt(char* key, char* iv, char* input, size_t input_size, unsigned char** output, size_t* output_size);