mirror of
				https://github.com/PurpleI2P/i2pd.git
				synced 2025-11-04 08:30:46 +00:00 
			
		
		
		
	rename DatabaseLookupTageSet to SymmetricKeyTagset
This commit is contained in:
		
							parent
							
								
									59b471b9a2
								
							
						
					
					
						commit
						f321eb66c0
					
				
					 3 changed files with 9 additions and 9 deletions
				
			
		| 
						 | 
				
			
			@ -117,14 +117,14 @@ namespace garlic
 | 
			
		|||
		return session->HandleNextMessage (buf, len, shared_from_this (), index);
 | 
			
		||||
	}	
 | 
			
		||||
 | 
			
		||||
	DatabaseLookupTagSet::DatabaseLookupTagSet (GarlicDestination * destination, const uint8_t * key):
 | 
			
		||||
	SymmetricKeyTagSet::SymmetricKeyTagSet (GarlicDestination * destination, const uint8_t * key):
 | 
			
		||||
		ReceiveRatchetTagSet (nullptr), m_Destination (destination) 
 | 
			
		||||
	{ 
 | 
			
		||||
		memcpy (m_Key, key, 32); 
 | 
			
		||||
		Expire ();	
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	bool DatabaseLookupTagSet::HandleNextMessage (uint8_t * buf, size_t len, int index)
 | 
			
		||||
	bool SymmetricKeyTagSet::HandleNextMessage (uint8_t * buf, size_t len, int index)
 | 
			
		||||
	{
 | 
			
		||||
		if (len < 24) return false;
 | 
			
		||||
		uint8_t nonce[12];
 | 
			
		||||
| 
						 | 
				
			
			@ -133,18 +133,18 @@ namespace garlic
 | 
			
		|||
		len -= 16; // poly1305
 | 
			
		||||
		if (!i2p::crypto::AEADChaCha20Poly1305 (buf + offset, len - offset, buf, 8, m_Key, nonce, buf + offset, len - offset, false)) // decrypt
 | 
			
		||||
		{
 | 
			
		||||
			LogPrint (eLogWarning, "Garlic: Lookup reply AEAD decryption failed");
 | 
			
		||||
			LogPrint (eLogWarning, "Garlic: Symmetric key tagset AEAD decryption failed");
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
		// we assume 1 I2NP block with delivery type local
 | 
			
		||||
		if (offset + 3 > len) 
 | 
			
		||||
		{	
 | 
			
		||||
			LogPrint (eLogWarning, "Garlic: Lookup reply is too short ", len);
 | 
			
		||||
			LogPrint (eLogWarning, "Garlic: Symmetric key tagset is too short ", len);
 | 
			
		||||
			return false;
 | 
			
		||||
		}	
 | 
			
		||||
		if (buf[offset] != eECIESx25519BlkGalicClove)
 | 
			
		||||
		{
 | 
			
		||||
			LogPrint (eLogWarning, "Garlic: Lookup reply unexpected block ", (int)buf[offset]);
 | 
			
		||||
			LogPrint (eLogWarning, "Garlic: Symmetric key tagset unexpected block ", (int)buf[offset]);
 | 
			
		||||
			return false;
 | 
			
		||||
		}	
 | 
			
		||||
		offset++;
 | 
			
		||||
| 
						 | 
				
			
			@ -152,7 +152,7 @@ namespace garlic
 | 
			
		|||
		offset += 2;
 | 
			
		||||
		if (offset + size > len) 
 | 
			
		||||
		{
 | 
			
		||||
			LogPrint (eLogWarning, "Garlic: Lookup reply block is too long ", size);
 | 
			
		||||
			LogPrint (eLogWarning, "Garlic: Symmetric key tagset block is too long ", size);
 | 
			
		||||
			return false;
 | 
			
		||||
		}	
 | 
			
		||||
		if (m_Destination)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -104,11 +104,11 @@ namespace garlic
 | 
			
		|||
			uint64_t m_ExpirationTimestamp = 0;
 | 
			
		||||
	};	
 | 
			
		||||
 | 
			
		||||
	class DatabaseLookupTagSet: public ReceiveRatchetTagSet
 | 
			
		||||
	class SymmetricKeyTagSet: public ReceiveRatchetTagSet
 | 
			
		||||
	{
 | 
			
		||||
		public:
 | 
			
		||||
 | 
			
		||||
			DatabaseLookupTagSet (GarlicDestination * destination, const uint8_t * key);
 | 
			
		||||
			SymmetricKeyTagSet (GarlicDestination * destination, const uint8_t * key);
 | 
			
		||||
 | 
			
		||||
			bool IsIndexExpired (int index) const { return false; };
 | 
			
		||||
			bool HandleNextMessage (uint8_t * buf, size_t len, int index);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -471,7 +471,7 @@ namespace garlic
 | 
			
		|||
	{
 | 
			
		||||
		uint64_t t;
 | 
			
		||||
		memcpy (&t, tag, 8);
 | 
			
		||||
		auto tagset = std::make_shared<DatabaseLookupTagSet>(this, key);
 | 
			
		||||
		auto tagset = std::make_shared<SymmetricKeyTagSet>(this, key);
 | 
			
		||||
		m_ECIESx25519Tags.emplace (t, ECIESX25519AEADRatchetIndexTagset{0, tagset});
 | 
			
		||||
	}	
 | 
			
		||||
		
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue