mirror of
				https://github.com/wangyu-/udp2raw.git
				synced 2025-11-04 12:15:35 +08:00 
			
		
		
		
	merge up to 5cc304
This commit is contained in:
		@@ -7,9 +7,8 @@
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//not used
 | 
			
		||||
//void AES_ECB_encrypt(const uint8_t* input, const uint8_t* key, uint8_t *output, const uint32_t length);
 | 
			
		||||
//void AES_ECB_decrypt(const uint8_t* input, const uint8_t* key, uint8_t *output, const uint32_t length);
 | 
			
		||||
void AES_ECB_encrypt_buffer(const uint8_t* input, const uint8_t* key, uint8_t *output);
 | 
			
		||||
void AES_ECB_decrypt_buffer(const uint8_t* input, const uint8_t* key, uint8_t *output);
 | 
			
		||||
 | 
			
		||||
void AES_CBC_encrypt_buffer(uint8_t* output, uint8_t* input, uint32_t length, const uint8_t* key, const uint8_t* iv);
 | 
			
		||||
void AES_CBC_decrypt_buffer(uint8_t* output, uint8_t* input, uint32_t length, const uint8_t* key, const uint8_t* iv);
 | 
			
		||||
 
 | 
			
		||||
@@ -366,32 +366,25 @@ void AES_CBC_decrypt_buffer(uint8_t* output, uint8_t* input, uint32_t length, co
 | 
			
		||||
  decrypt_cbc(rk, length, iv_tmp, input, output);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
void AES_ECB_encrypt(const uint8_t* input, const uint8_t* key, uint8_t* output, const uint32_t length)
 | 
			
		||||
{
 | 
			
		||||
  uint8_t rk[AES_RKSIZE];
 | 
			
		||||
  static uint8_t rk[AES_RKSIZE];
 | 
			
		||||
 | 
			
		||||
  if (key == NULL)
 | 
			
		||||
  {
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
  aeshw_init();
 | 
			
		||||
  if(key!=NULL)
 | 
			
		||||
    setkey_enc(rk, key);
 | 
			
		||||
  encrypt_ecb(AES_NR, rk, input, output);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AES_ECB_decrypt(const uint8_t* input, const uint8_t* key, uint8_t *output, const uint32_t length)
 | 
			
		||||
{
 | 
			
		||||
  uint8_t rk[AES_RKSIZE];
 | 
			
		||||
  static uint8_t rk[AES_RKSIZE];
 | 
			
		||||
 | 
			
		||||
  if (key == NULL)
 | 
			
		||||
  {
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
  aeshw_init();
 | 
			
		||||
  if(key!=NULL)
 | 
			
		||||
    setkey_dec(rk, key);
 | 
			
		||||
  decrypt_ecb(AES_NR, rk, input, output);
 | 
			
		||||
}*/
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void encrypt_cfb( uint8_t* rk,
 | 
			
		||||
                         uint32_t length,size_t *iv_off,
 | 
			
		||||
 
 | 
			
		||||
@@ -14,13 +14,27 @@
 | 
			
		||||
 | 
			
		||||
void AES_ECB_encrypt(const uint8_t* input, const uint8_t* key, uint8_t *output, const uint32_t length)
 | 
			
		||||
{
 | 
			
		||||
	printf("AES_ECB_encrypt not implemented\n");
 | 
			
		||||
	exit(-1);
 | 
			
		||||
	static aes_context ctx;
 | 
			
		||||
	if(key!=0)
 | 
			
		||||
	{
 | 
			
		||||
		aes_init( &ctx);
 | 
			
		||||
		aes_setkey_enc(&ctx,key,AES_KEYSIZE);
 | 
			
		||||
	}
 | 
			
		||||
	int ret=aes_crypt_ecb( &ctx, AES_ENCRYPT, (const unsigned char*)input,(unsigned char*) output );
 | 
			
		||||
	assert(ret==0);
 | 
			
		||||
	return ;
 | 
			
		||||
}
 | 
			
		||||
void AES_ECB_decrypt(const uint8_t* input, const uint8_t* key, uint8_t *output, const uint32_t length)
 | 
			
		||||
{
 | 
			
		||||
	printf("AES_ECB_encrypt not implemented\n");
 | 
			
		||||
	exit(-1);
 | 
			
		||||
	static aes_context ctx;
 | 
			
		||||
	if(key!=0)
 | 
			
		||||
	{
 | 
			
		||||
		aes_init( &ctx);
 | 
			
		||||
		aes_setkey_dec(&ctx,key,AES_KEYSIZE);
 | 
			
		||||
	}
 | 
			
		||||
	int ret=aes_crypt_ecb( &ctx, AES_DECRYPT, (const unsigned char*)input,(unsigned char*) output );
 | 
			
		||||
	assert(ret==0);
 | 
			
		||||
    return ;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AES_CBC_encrypt_buffer(uint8_t* output, uint8_t* input, uint32_t length, const uint8_t* key, const uint8_t* iv)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user