From f021abcae059a4ef22e623fedc6d61cdf3a77279 Mon Sep 17 00:00:00 2001
From: zzz <zzz@mail.i2p>
Date: Thu, 24 Oct 2019 14:32:05 +0000
Subject: [PATCH] Crypto: Add ECIES Engine to context

---
 router/java/src/net/i2p/router/RouterContext.java | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/router/java/src/net/i2p/router/RouterContext.java b/router/java/src/net/i2p/router/RouterContext.java
index 3aa6cbcdbf..2764517ff8 100644
--- a/router/java/src/net/i2p/router/RouterContext.java
+++ b/router/java/src/net/i2p/router/RouterContext.java
@@ -16,6 +16,7 @@ import net.i2p.data.router.RouterKeyGenerator;
 import net.i2p.internal.InternalClientManager;
 import net.i2p.router.client.ClientManagerFacadeImpl;
 import net.i2p.router.crypto.ElGamalAESEngine;
+import net.i2p.router.crypto.ratchet.ECIESAEADEngine;
 import net.i2p.router.crypto.TransientSessionKeyManager;
 import net.i2p.router.dummy.*;
 import net.i2p.router.message.GarlicMessageParser;
@@ -70,6 +71,7 @@ public class RouterContext extends I2PAppContext {
     private RouterKeyGenerator _routingKeyGenerator;
     private GarlicMessageParser _garlicMessageParser;
     private ElGamalAESEngine _elGamalAESEngine;
+    private ECIESAEADEngine _eciesEngine;
     private final Set<Runnable> _finalShutdownTasks;
     // split up big lock on this to avoid deadlocks
     private volatile boolean _initialized;
@@ -224,6 +226,7 @@ public class RouterContext extends I2PAppContext {
             // internal client manager is null
         }
         _elGamalAESEngine = new ElGamalAESEngine(this);
+        _eciesEngine = new ECIESAEADEngine(this);
         _garlicMessageParser = new GarlicMessageParser(this);
         _clientMessagePool = new ClientMessagePool(this);
         _jobQueue = new JobQueue(this);
@@ -692,4 +695,15 @@ public class RouterContext extends I2PAppContext {
     public ElGamalAESEngine elGamalAESEngine() {
         return _elGamalAESEngine;
     }
+
+    /**
+     * Access the ECIES/AEAD engine for this context.  The algorithm
+     * makes use of the sessionKeyManager to coordinate transparent
+     * access to the sessionKeys and sessionTags.
+     *
+     * @since 0.9.44
+     */
+    public ECIESAEADEngine eciesEngine() {
+        return _eciesEngine;
+    }
 }
-- 
GitLab