mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-17 02:49:34 -04:00
added encryption routine for FT
This commit is contained in:
parent
997154f9c5
commit
3ad0a81d8f
5 changed files with 144 additions and 13 deletions
|
@ -307,18 +307,18 @@ static void print(const chacha20_state& s)
|
|||
|
||||
static void add(chacha20_state& s,const chacha20_state& t) { for(uint32_t i=0;i<16;++i) s.c[i] += t.c[i] ; }
|
||||
|
||||
static uint8_t read16bits(char s)
|
||||
{
|
||||
if(s >= '0' && s <= '9')
|
||||
return s - '0' ;
|
||||
else if(s >= 'a' && s <= 'f')
|
||||
return s - 'a' + 10 ;
|
||||
else if(s >= 'A' && s <= 'F')
|
||||
return s - 'A' + 10 ;
|
||||
else
|
||||
throw std::runtime_error("Not an hex string!") ;
|
||||
}
|
||||
|
||||
// static uint8_t read16bits(char s)
|
||||
// {
|
||||
// if(s >= '0' && s <= '9')
|
||||
// return s - '0' ;
|
||||
// else if(s >= 'a' && s <= 'f')
|
||||
// return s - 'a' + 10 ;
|
||||
// else if(s >= 'A' && s <= 'F')
|
||||
// return s - 'A' + 10 ;
|
||||
// else
|
||||
// throw std::runtime_error("Not an hex string!") ;
|
||||
// }
|
||||
//
|
||||
// static uint256_32 create_256bit_int(const std::string& s)
|
||||
// {
|
||||
// uint256_32 r(0,0,0,0,0,0,0,0) ;
|
||||
|
@ -431,6 +431,12 @@ void poly1305_tag(uint8_t key[32],uint8_t *message,uint32_t size,uint8_t tag[16]
|
|||
tag[12] = (acc.b[3] >> 0) & 0xff ; tag[13] = (acc.b[3] >> 8) & 0xff ; tag[14] = (acc.b[3] >>16) & 0xff ; tag[15] = (acc.b[3] >>24) & 0xff ;
|
||||
}
|
||||
|
||||
void AEAD_chacha20_poly1305(uint8_t key[32], uint8_t nonce[12],uint8_t *data,uint32_t data_size,uint8_t *aad,uint32_t aad_size,uint8_t tag[16])
|
||||
{
|
||||
#warning this part is not implemented yet.
|
||||
memset(tag,0xff,16) ;
|
||||
}
|
||||
|
||||
void perform_tests()
|
||||
{
|
||||
std::cerr << "Testing Chacha20" << std::endl;
|
||||
|
|
|
@ -62,7 +62,18 @@ namespace librs
|
|||
* \param size size of the data
|
||||
* \param tag generated poly1305 tag.
|
||||
*/
|
||||
static void AEAD_chacha20_poly1305(uint8_t key[32], uint8_t nonce[12],uint8_t *data,uint32_t data_size,uint8_t *aad,uint8_t *aad_size,uint8_t tag[16]) ;
|
||||
static void AEAD_chacha20_poly1305(uint8_t key[32], uint8_t nonce[12],uint8_t *data,uint32_t data_size,uint8_t *aad,uint32_t aad_size,uint8_t tag[16]) ;
|
||||
|
||||
/*!
|
||||
* \brief constant_time_memcmp
|
||||
* Provides a constant time comparison of two memory chunks. The implementation comes from the FreeBSD implementation.
|
||||
*
|
||||
* \param m1 memory block 1
|
||||
* \param m2 memory block 2
|
||||
* \param size common size of m1 and m2
|
||||
* \return
|
||||
*/
|
||||
static bool constant_time_memcmp(const uint8_t *m1,const uint8_t *m2,uint32_t size) ;
|
||||
|
||||
/*!
|
||||
* \brief perform_tests
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue